Commit 503431e2 authored by xixinzhao's avatar xixinzhao

计划新增

parent 6b28e49a
package com.yeejoin.amos.supervision.core.common.request;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import lombok.Data;
import java.util.List;
@Data
public class AddPlanRequest {
private List<Long> ownerId;
private Plan plan;
}
package com.yeejoin.amos.supervision.core.common.response;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import lombok.Data;
import java.util.List;
@Data
public class PlanPointRespone {
private static final long serialVersionUID = 1L;
private List<Long> ownerId;
private Plan plan;
}
......@@ -5,6 +5,7 @@ import java.util.Date;
import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.data.annotation.LastModifiedDate;
......@@ -266,6 +267,56 @@ public class Plan extends BasicEntity {
@Column(name="user_dept")
private String userDept;
/**
* 牵头部门
*/
@Column(name="lead_department_ids")
private String leadDepartmentIds;
/**
* 牵头人名称,多个
*/
@Column(name="lead_people_names")
private String leadPeopleNames;
/**
* 牵头人
*/
@Column(name="lead_people_ids")
private String leadPeopleIds;
/**
* 牵头部门名称
*/
@Column(name="lead_department_names")
private String leadDepartmentNames;
/**
* 参与人
*/
@Column(name="join_person_ids")
private String joinPersonIds;
/**
* 参与人名称
*/
@Column(name="join_person_names")
private String joinPersonNames;
/**
* 检查类型id
*/
@Column(name="check_type_id")
private String checkTypeId;
/**
* 检查类型名称
*/
@Column(name="check_type_name")
private String checkTypeName;
public String getUserDept() {
return userDept;
}
......@@ -616,4 +667,68 @@ public class Plan extends BasicEntity {
public void setIsSingleExecution(boolean isSingleExecution) {
this.isSingleExecution = isSingleExecution;
}
public String getCheckTypeName() {
return checkTypeName;
}
public void setCheckTypeName(String checkTypeName) {
this.checkTypeName = checkTypeName;
}
public String getCheckTypeId() {
return checkTypeId;
}
public void setCheckTypeId(String checkTypeId) {
this.checkTypeId = checkTypeId;
}
public String getLeadDepartmentNames() {
return leadDepartmentNames;
}
public void setLeadDepartmentNames(String leadDepartmentNames) {
this.leadDepartmentNames = leadDepartmentNames;
}
public String getLeadPeopleIds() {
return leadPeopleIds;
}
public void setLeadPeopleIds(String leadPeopleIds) {
this.leadPeopleIds = leadPeopleIds;
}
public String getLeadPeopleNames() {
return leadPeopleNames;
}
public void setLeadPeopleNames(String leadPeopleNames) {
this.leadPeopleNames = leadPeopleNames;
}
public String getLeadDepartmentIds() {
return leadDepartmentIds;
}
public void setLeadDepartmentIds(String leadDepartmentIds) {
this.leadDepartmentIds = leadDepartmentIds;
}
public String getJoinPersonIds() {
return joinPersonIds;
}
public void setJoinPersonIds(String joinPersonIds) {
this.joinPersonIds = joinPersonIds;
}
public String getJoinPersonNames() {
return joinPersonNames;
}
public void setJoinPersonNames(String joinPersonNames) {
this.joinPersonNames = joinPersonNames;
}
}
\ No newline at end of file
......@@ -270,7 +270,7 @@ public class Point extends BasicEntity {
/**
* 所在建筑名称
*/
@Column(name="building_name")
// @Column(name="building_name")
private String buildingName;
public String getBuildingName() {
......@@ -292,7 +292,7 @@ public class Point extends BasicEntity {
/**
* 所在建筑Id
*/
@Column(name="building_id")
// @Column(name="building_id")
private String buildingId;
/**
......
......@@ -3,15 +3,13 @@ package com.yeejoin.amos.supervision.business.controller;
import java.util.HashMap;
import java.util.List;
import com.yeejoin.amos.supervision.core.common.request.AddPlanRequest;
import com.yeejoin.amos.supervision.core.common.response.PlanPointRespone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -86,7 +84,7 @@ public class PlanController extends AbstractBaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "巡检计划新增及编辑", notes = "巡检计划新增及编辑")
@RequestMapping(value = "/addPlan", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse checkPlanAdd(@ApiParam(value = "巡检计划", required = true) @RequestBody Plan param) {
public CommonResponse checkPlanAdd(@ApiParam(value = "巡检计划", required = true) @RequestBody AddPlanRequest param) {
try {
String userId = getUserId();
ReginParams reginParams = getSelectedOrgInfo();
......@@ -188,4 +186,33 @@ public class PlanController extends AbstractBaseController {
return CommonResponseUtil.success(list);
}
/**
* 计划启用停用
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "计划启用停用", notes = "计划启用停用")
@RequestMapping(value = "/setPlanStatus", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse setPlanStatus(
@ApiParam(value = "计划id") @RequestParam(value = "planId", required = false) Long planId,
@ApiParam(value = "计划状态") @RequestParam(value = "status", required = false) byte status ) {
planService.setplanstatus(planId, status);
return CommonResponseUtil.success();
}
/**
* 获取计划详情
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "计划启用停用", notes = "计划启用停用")
@RequestMapping(value = "/getPlanDetails", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getPlanDetails(
@ApiParam(value = "计划id") @RequestParam(value = "planId", required = false) Long planId ) {
PlanPointRespone planRequest = planService.getplandetails(planId);
return CommonResponseUtil.success(planRequest);
}
}
......@@ -11,6 +11,7 @@ import com.yeejoin.amos.supervision.business.param.PointImportQueryParam;
import com.yeejoin.amos.supervision.business.vo.LeavelMovePointVo;
import com.yeejoin.amos.supervision.business.vo.PointInputItemVo;
import com.yeejoin.amos.supervision.business.vo.PointVo;
import com.yeejoin.amos.supervision.dao.entity.PointInputItem;
import org.apache.ibatis.annotations.Param;
import com.yeejoin.amos.supervision.core.common.response.PointResponse;
......@@ -141,4 +142,18 @@ public interface PointMapper extends BaseMapper {
*/
List<Map<String, Object>> getPointRefItem(List<Long> list);
/**
* 根据业主单位查询点
*/
List<Long> getPointRouteList(List<Long> list);
/**
* 根据业主单位查询点
*/
List<PointInputItem> getPointRouteItem(List<Long> list);
/**
* 根据路线id查询所有点
*/
List<Long> getPointoriginalidbyrouteid(@Param(value = "routeId") Long routeId);
}
......@@ -47,6 +47,21 @@ public class PlanInfoPageParam extends CommonPageable {
*/
private String ownerId;
/**
* 业主单位id
*/
private String planStatus;
/**
* 业主单位id
*/
private String checkTypeId;
/**
* 业主单位id
*/
private String leadPerson;
public String getOwnerId() {
return ownerId;
}
......@@ -102,5 +117,28 @@ public class PlanInfoPageParam extends CommonPageable {
public void setUserId(String userId) {
this.userId = userId;
}
public String getPlanStatus() {
return planStatus;
}
public void setPlanStatus(String planStatus) {
this.planStatus = planStatus;
}
public String getCheckTypeId() {
return checkTypeId;
}
public void setCheckTypeId(String checkTypeId) {
this.checkTypeId = checkTypeId;
}
public String getLeadPerson() {
return leadPerson;
}
public void setLeadPerson(String leadPerson) {
this.leadPerson = leadPerson;
}
}
package com.yeejoin.amos.supervision.business.service.impl;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.supervision.business.constants.XJConstant;
import com.yeejoin.amos.supervision.business.dao.mapper.PlanMapper;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanDao;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanTaskDao;
import com.yeejoin.amos.supervision.business.dao.repository.IPlanTaskDetailDao;
import com.yeejoin.amos.supervision.business.dao.repository.IRouteDao;
import com.yeejoin.amos.supervision.business.dao.mapper.PointMapper;
import com.yeejoin.amos.supervision.business.dao.mapper.RouteMapper;
import com.yeejoin.amos.supervision.business.dao.repository.*;
import com.yeejoin.amos.supervision.business.param.PlanInfoPageParam;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanService;
import com.yeejoin.amos.supervision.core.common.request.AddPlanRequest;
import com.yeejoin.amos.supervision.core.common.response.PlanPointRespone;
import com.yeejoin.amos.supervision.core.util.DateUtil;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import com.yeejoin.amos.supervision.dao.entity.Route;
import com.yeejoin.amos.supervision.dao.entity.*;
import com.yeejoin.amos.supervision.feign.RemoteSecurityService;
import org.apache.velocity.util.ArrayListWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,6 +23,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.stream.Collectors;
......@@ -44,6 +47,24 @@ public class PlanServiceImpl implements IPlanService {
@Autowired
IRouteDao iRouteDao;
@Autowired
IPointDao iPointDao;
@Autowired
private PointMapper pointMapper;
@Autowired
private IRoutePointDao iRoutePointDao;
@Autowired
private IRoutePointItemDao iRoutePointItemDao;
@Autowired
private IPointInputItemDao iPointInputItemDao;
@Autowired
private IPlanService planService;
private static final Logger logger = LoggerFactory.getLogger(PlanServiceImpl.class);
@Override
......@@ -80,27 +101,86 @@ public class PlanServiceImpl implements IPlanService {
}
@Override
@Transactional
public void addPlan(HashMap<String, Object> map) {
Plan param = (Plan) map.get("param");
// 新增路线
AddPlanRequest addPlanRequest = (AddPlanRequest) map.get("param");
Plan param = addPlanRequest.getPlan();
String orgCode = map.get("org_code") == null ? "" : map.get("org_code").toString();
String userId = map.get("user_id") == null ? "" : map.get("user_id").toString();
param.setOrgCode(orgCode);
param.setStatus(Byte.parseByte(XJConstant.PLAN_STATUS_START));
param.setStatus(Byte.parseByte(XJConstant.PLAN_STATUS_STOP));
param.setNextGenDate(DateUtil.getIntervalDate(new Date(), 0));
param.setCreateBy(userId);
//编辑计划
if (param.getId() > 0) {
Plan oriPlan = planDao.findById(param.getId()).get();
param.setCreateDate(oriPlan.getCreateDate());
param.setCreateBy(oriPlan.getCreateBy());
param.setLastUpdBy(userId);
param.setFirstFlag(XJConstant.PLAN_FIRST_STATUS_YES);
addPlanRequest.setPlan(param);
Route route = save(addPlanRequest);
if (!ObjectUtils.isEmpty(route)) {
param.setRouteId(route.getId());
//编辑计划
if (param.getId() > 0) {
Plan oriPlan = planDao.findById(param.getId()).get();
param.setCreateDate(oriPlan.getCreateDate());
param.setCreateBy(oriPlan.getCreateBy());
param.setLastUpdBy(userId);
param.setFirstFlag(XJConstant.PLAN_FIRST_STATUS_YES);
}
if (XJConstant.FIX_DATE_NO.equals(param.getIsFixedDate()) && (XJConstant.PLAN_TYPE_MONTH.equals(param.getPlanType()) || XJConstant.PLAN_TYPE_YEAR.equals(param.getPlanType()))) {
param.setDayBegin(DateUtil.formatStrToTime("00:00:00"));
param.setDayEnd(DateUtil.formatStrToTime("23:59:59"));
}
planDao.save(param);
}
if (XJConstant.FIX_DATE_NO.equals(param.getIsFixedDate()) && (XJConstant.PLAN_TYPE_MONTH.equals(param.getPlanType()) || XJConstant.PLAN_TYPE_YEAR.equals(param.getPlanType()))) {
param.setDayBegin(DateUtil.formatStrToTime("00:00:00"));
param.setDayEnd(DateUtil.formatStrToTime("23:59:59"));
}
/**
* 默认新增路线
*/
public Route save (AddPlanRequest addPlanRequest) {
Route saveRoute = new Route();
Plan plan = addPlanRequest.getPlan();
// 判断是新增还是修改
if (plan.getId()>0) {
// 删除相关点项内容
iRoutePointDao.delRoutePointByRouteId(plan.getRouteId());
iRoutePointItemDao.delRoutePointItem(plan.getRouteId());
saveRoute.setId(plan.getRouteId());
}
planDao.save(param);
saveRoute.setName(plan.getName());
saveRoute.setOrgCode(plan.getOrgCode());
saveRoute.setCreatorId(plan.getCreateBy());
Route route = iRouteDao.save(saveRoute);
if (!ObjectUtils.isEmpty(route.getId())) {
// 新增路线与点关系
List<Long> ownerIds = addPlanRequest.getOwnerId();
if (!ObjectUtils.isEmpty(ownerIds)) {
List<Long> pointVos = pointMapper.getPointRouteList(ownerIds);
if (!ObjectUtils.isEmpty(pointVos)) {
if (!ObjectUtils.isEmpty(pointVos)) {
pointVos.forEach(point -> {
RoutePoint routePoint = new RoutePoint();
routePoint.setOrgCode(plan.getOrgCode());
routePoint.setCreatorId(plan.getCreateBy());
routePoint.setRouteId(route.getId());
routePoint.setPointId(point);
iRoutePointDao.save(routePoint);
});
List<PointInputItem> pointInputItems = pointMapper.getPointRouteItem(pointVos);
if (!ObjectUtils.isEmpty(pointInputItems)) {
pointInputItems.forEach(pointInputItem -> {
RoutePointItem routePointItem = new RoutePointItem();
routePointItem.setRoutePointId(route.getId());
routePointItem.setPointInputItemId(pointInputItem.getId());
iRoutePointItemDao.save(routePointItem);
});
}
}
}
}
}
return route;
}
@Override
......@@ -176,5 +256,22 @@ public class PlanServiceImpl implements IPlanService {
return planMapper.queryPlanListByOrgCode(loginOrgCode);
}
@Override
public void setplanstatus (Long id, byte status) {
Plan oriPlan = planDao.findById(id).get();
oriPlan.setStatus(status);
planDao.save(oriPlan);
}
@Override
public PlanPointRespone getplandetails (Long id) {
PlanPointRespone planRequest = new PlanPointRespone();
Plan plan = planService.queryPlanById(id);;
if (!ObjectUtils.isEmpty(plan)) {
List<Long> ids = pointMapper.getPointoriginalidbyrouteid(plan.getRouteId());
planRequest.setPlan(plan);
planRequest.setOwnerId(ids);
}
return planRequest;
}
}
......@@ -3,6 +3,9 @@ package com.yeejoin.amos.supervision.business.service.intfc;
import java.util.HashMap;
import java.util.List;
import com.yeejoin.amos.supervision.core.common.request.AddPlanRequest;
import com.yeejoin.amos.supervision.core.common.response.PlanPointRespone;
import com.yeejoin.amos.supervision.dao.entity.Point;
import org.springframework.data.domain.Page;
import com.yeejoin.amos.supervision.business.param.PlanInfoPageParam;
......@@ -70,5 +73,13 @@ public interface IPlanService {
*/
List<HashMap<String, Object>> queryPlanListByOrgCode(String loginOrgCode);
/**
* 计划启用停用
*/
void setplanstatus(Long id, byte status);
/**
* 获取计划详情
*/
PlanPointRespone getplandetails(Long id);
}
......@@ -24,6 +24,12 @@ public class PlanPageParamUtil {
param.setRemark(toString(queryRequests.get(i).getValue()));
}else if("ownerId".equals(name)){
param.setOwnerId(toString(queryRequests.get(i).getValue()));
}else if("planStatus".equals(name)){
param.setPlanStatus(toString(queryRequests.get(i).getValue()));
}else if("leadPerson".equals(name)){
param.setLeadPerson(toString(queryRequests.get(i).getValue()));
}else if("checkTypeId".equals(name)){
param.setCheckTypeId(toString(queryRequests.get(i).getValue()));
}
}
param.setOrgCode(perMap.get("orgCode") == null ? null:perMap.get("orgCode").toString());
......
......@@ -147,6 +147,15 @@
b.owner_name AS ownerName,
b.boss_name as bossName,
a.user_name as userName,
a.check_type_id as checkTypeId,
a.check_type_name as checkTypeName,
a.lead_department_ids as leadDepartmentIds,
a.lead_department_names as leadDepartmentNames,
a.lead_people_ids as leadPersonIds,
a.lead_people_names as leadPersonNames,
a.join_person_ids as joinPersonIds,
a.join_person_names as joinPersonNames,
(select count(1) from p_route_point ppo where ppo.route_id = b.id) as totalPoint,
(select count(1) from p_plan_task t where t.plan_id = a.id) as totalPlanTask,
(select count(1) from p_plan_task t where t.plan_id = a.id and t.finish_status <![CDATA[<=]]> 1 ) as waitFinishPlanTask
FROM
......@@ -155,7 +164,8 @@
WHERE
a.route_Id = b.id and a.is_delete = 0
<if test="planName!=null"> and a.name like concat(concat("%",#{planName}),"%")</if>
<if test="planType!=null"> and a.plan_Type = #{planType}</if>
<if test="checkTypeId!=null and checkTypeId != '' "> and a.check_type_id = #{checkTypeId}</if>
<if test="leadPerson!=null and leadPerson != '' "> and a.lead_people_ids = #{leadPerson}</if>
<if test="routeId!=null"> and a.route_Id = #{routeId}</if>
<if test="remark!=null"> and a.remark1 like concat(concat("%",#{remark}),"%")</if>
<if test="userId!=null"> and FIND_IN_SET(#{userId},a.user_id)</if>
......
......@@ -1100,4 +1100,43 @@
#{pointId}
</foreach>
</select>
<select id="getPointRouteList" parameterType="list" resultType="Long">
SELECT
ppi.id
FROM
p_point ppi
WHERE
ppi.original_id IN
<foreach collection="list" open="(" close=")" separator="," item="routeId">
#{routeId}
</foreach>
</select>
<select id="getPointRouteItem" parameterType="list" resultType="com.yeejoin.amos.supervision.dao.entity.PointInputItem">
SELECT
ppi.id
, ppi.input_item_id itemId
, ppi.point_id pointId
, ppi.classify_ids classifyId
FROM
p_point_inputitem ppi
WHERE
ppi.point_id IN
<foreach collection="list" open="(" close=")" separator="," item="pointId">
#{pointId}
</foreach>
</select>
<select id="getPointoriginalidbyrouteid" parameterType="long" resultType="Long">
SELECT
original_id
FROM
p_point as ppo
LEFT JOIN p_route_point as prp ON
ppo.id = prp.point_id
WHERE
prp.route_id = #{routeId}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment