Sfoglia il codice sorgente

新增按主键更新巡检计划

wangbo 4 anni fa
parent
commit
93b6db9ed7

+ 59 - 15
operation_manager/src/main/java/com/huaxu/task/controller/PlanManageController.java

@@ -49,7 +49,7 @@ public class PlanManageController {
      * @param taskAreaName 任务区域名称
      * @return
      */
-    @PostMapping("/plan/add")
+    @GetMapping("/plan/add")
     @ApiOperation(value = "新增巡检计划")
     public AjaxMessage addPlan(@ApiParam(value = "任务名称", required = true) @RequestParam(required = true) String planName,
                                @ApiParam(value = "任务类型", required = true) @RequestParam(required = true) Integer taskType,
@@ -58,7 +58,8 @@ public class PlanManageController {
                                @ApiParam(value = "计划巡检人ID", required = true) @RequestParam(required = true) String userId,
                                @ApiParam(value = "任务内容", required = true) @RequestParam(required = true) String taskContent,
                                @ApiParam(value = "任务区域坐标", required = true) @RequestParam(required = true) String taskAreaShape,
-                               @ApiParam(value = "任务区域名称", required = true) @RequestParam(required = true) String taskAreaName) {
+                               @ApiParam(value = "任务区域名称", required = true) @RequestParam(required = true) String taskAreaName,
+                               @ApiParam(value = "任务签到点", required = false) @RequestParam(required = false) String taskChecked) {
         LoginUser loginUser = UserUtil.getCurrentUser();
         String planId=DatesUtil.formatDate(new Date(),"yyyyMMddHHmmss")+String.valueOf((int) (Math.random()*(9999-1000)+1000));
         PlanManage record = new PlanManage();
@@ -66,16 +67,17 @@ public class PlanManageController {
         record.setPlanId(planId);
         record.setPlanName(planName);
         record.setTaskType(taskType);
+        record.setTaskChecked(taskChecked);
         record.setPlanStartDate(DatesUtil.parseDate(planStartDate,"yyyy-MM-dd HH:mm:ss"));
         record.setPlanEndDate(DatesUtil.parseDate(planEndDate,"yyyy-MM-dd HH:mm:ss"));
-        record.setUserId(userId);
+        record.setPlanStatus(0);
         record.setTaskContent(taskContent);
         record.setTaskAreaShape(taskAreaShape);
         record.setTaskAreaName(taskAreaName);
         record.setDateCreate(DatesUtil.parseDate(DatesUtil.formatNow(),"yyyy-MM-dd HH:mm:ss"));
         if(loginUser.getId() != null) {
-            record.setPlanUserId(loginUser.getId().toString());
-            record.setCreateBy(loginUser.getId().toString());
+            record.setPlanUserId(String.valueOf(loginUser.getId()));
+            record.setCreateBy(String.valueOf(loginUser.getId()));
         }
         if(loginUser.getTenantId() != null) {
             record.setTenantId(loginUser.getTenantId());
@@ -92,9 +94,10 @@ public class PlanManageController {
     public AjaxMessage<Pagination<PlanManageDto>> selectPlan(
             @ApiParam(value = "页数", required = true)@RequestParam Integer pageNum,
             @ApiParam(value = "条数", required = true)@RequestParam Integer pageSize,
-            @ApiParam(value = "计划单号或计划名称", required = true) @RequestParam(required = false) String key,
-            @ApiParam(value = "计划安排起始日期", required = true) @RequestParam(required = false) String startDate,
-            @ApiParam(value = "计划安排截至日期", required = true) @RequestParam(required = false) String endDate){
+            @ApiParam(value = "状态", required = false) @RequestParam(required = false) Integer planStatus,
+            @ApiParam(value = "计划单号或计划名称", required = false) @RequestParam(required = false) String key,
+            @ApiParam(value = "计划安排起始日期", required = false) @RequestParam(required = false) String startDate,
+            @ApiParam(value = "计划安排截至日期", required = false) @RequestParam(required = false) String endDate){
         PlanManageDto planManageDto = new PlanManageDto();
         //根据用户编号,获取用户的权限
         LoginUser loginUser = UserUtil.getCurrentUser();
@@ -103,6 +106,7 @@ public class PlanManageController {
             planManageDto.setStartDate(startDate);
             planManageDto.setEndDate(endDate);
         }
+        planManageDto.setPlanStatus(planStatus);
         planManageDto.setTenantId(loginUser.getTenantId());
         planManageDto.setProgramItems(loginUser.getProgramItemList());
         planManageDto.setUserType(loginUser.getType());
@@ -119,7 +123,7 @@ public class PlanManageController {
     }
 
 
-    @PostMapping("/plan/submit")
+    @GetMapping("/plan/submit")
     @ApiOperation(value = "提交巡检计划")
     public AjaxMessage submitPlan(
             @ApiParam(value = "计划单号", required = true) @RequestParam(required = false) Integer id){
@@ -144,19 +148,59 @@ public class PlanManageController {
         String startProcess = workFlowService.startProcess(processDefinition,vars);
         Task task = workFlowService.getProcessRuntimeTask(startProcess).get(0);
         Set<String> taskParticipator = workFlowService.getTaskParticipator(task.getId(),false,null);
+        String currentUsers = null;
+        for (String str : taskParticipator) {
+            if(currentUsers == null){
+                currentUsers = str;
+            }
+            else {
+                currentUsers +=String.format(",%s",str);
+            }
+        }
         //更新计划表的流程相关字段值。
         planManage.setPlanStatus(1);//已执行
-        planManage.setUpdateBy(loginUser.getId().toString());
+        if(planManage.getId() != null) {
+            planManage.setUpdateBy(String.valueOf(loginUser.getId()));
+        }
         planManage.setDateUpdate(new Date());
-        planManage.setProcessInstanceId("");
-        planManage.setProcessDefId("");
-        planManage.setCurrentTaskId("");
-        planManage.setCurrentUsers("");
-        planManage.setCurrentTaskName("");
+        planManage.setProcessInstanceId(task.getProcessInstanceId());
+        planManage.setProcessDefId(task.getProcessDefinitionId());
+        planManage.setCurrentTaskId(task.getId());
+        planManage.setCurrentUsers(currentUsers);
+        planManage.setCurrentTaskName(task.getName());
         int rows = planManageService.updateByPrimaryKeySelective(planManage);
         if(rows > 0) {
             return new AjaxMessage<>(ResultStatus.OK);
         }
         return new AjaxMessage<>(ResultStatus.ERROR);
     }
+
+    @PostMapping("/plan/update")
+    @ApiOperation(value = "修改巡检计划")
+    public AjaxMessage updatePlan( @ApiParam(value = "修改巡检计划", required = true) @RequestBody PlanManage planManage) {
+        PlanManage record = new PlanManage();
+        record.setId(planManage.getId());
+        record.setUserId(planManage.getUserId());
+        record.setPlanName(planManage.getPlanName());
+        record.setTaskType(planManage.getTaskType());
+        record.setTaskChecked(planManage.getTaskChecked());
+        record.setPlanStartDate(planManage.getPlanStartDate());
+        record.setPlanEndDate(planManage.getPlanDate());
+        record.setTaskContent(planManage.getTaskContent());
+        record.setTaskAreaShape(planManage.getTaskAreaShape());
+        record.setTaskAreaName(planManage.getTaskAreaName());
+        LoginUser loginUser = UserUtil.getCurrentUser();
+        if(loginUser.getId() != null) {
+            record.setUpdateBy(String.valueOf(loginUser.getId()));
+        }
+        record.setDateUpdate(new Date());
+        int rows = planManageService.updateByPrimaryKeySelective(record);
+        if(rows > 0) {
+            return new AjaxMessage(ResultStatus.OK);
+        }
+        return new AjaxMessage(ResultStatus.ERROR);
+    }
+
+
+
 }

+ 2 - 0
operation_manager/src/main/java/com/huaxu/task/dao/PlanManageMapper.java

@@ -20,5 +20,7 @@ public interface PlanManageMapper {
 
     int updateByPrimaryKeySelective(PlanManage record);
 
+    int updateByPrimaryKey(PlanManage record);
+
     Page<PlanManageDto> findPage(IPage<PlanManageDto> page, @Param("plan") PlanManageDto planManageDto);
 }

+ 3 - 0
operation_manager/src/main/java/com/huaxu/task/entity/PlanManage.java

@@ -104,5 +104,8 @@ public class PlanManage implements Serializable {
     @ApiModelProperty(value = "所属部门id")
     private String departmentOrgId;
 
+    @ApiModelProperty(value = "签到坐标点")
+    private String taskChecked;
+
     private static final long serialVersionUID = 1L;
 }

+ 6 - 0
operation_manager/src/main/java/com/huaxu/task/service/PlanManageService.java

@@ -30,4 +30,10 @@ public interface PlanManageService {
      * 按主键查询
      */
     PlanManage selectByPrimaryKey(Integer id);
+
+    /**
+     * 按主键更新
+     */
+
+    int updateByPrimaryKey(PlanManage record);
 }

+ 5 - 0
operation_manager/src/main/java/com/huaxu/task/service/impl/PlanManageServiceImpl.java

@@ -38,4 +38,9 @@ public class PlanManageServiceImpl implements PlanManageService {
     public PlanManage selectByPrimaryKey(Integer id) {
         return planManageMapper.selectByPrimaryKey(id);
     }
+
+    @Override
+    public int updateByPrimaryKey(PlanManage record) {
+        return planManageMapper.updateByPrimaryKey(record);
+    }
 }

+ 43 - 3
operation_manager/src/main/resources/mapper/task/PlanManageMapper.xml

@@ -27,12 +27,14 @@
     <result column="date_update" property="dateUpdate" jdbcType="TIMESTAMP" />
     <result column="company_org_id" property="companyOrgId" jdbcType="VARCHAR" />
     <result column="department_org_id" property="departmentOrgId" jdbcType="VARCHAR" />
+    <result column="task_checked" property="taskChecked" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     id, plan_id, plan_name, plan_user_id, user_id, plan_date, plan_start_date, plan_end_date, 
     task_content, task_area_shape, task_area_name, task_type, plan_status, tenant_id, 
     process_instance_id, process_def_id, current_task_id, current_users, current_task_name, 
-    create_by, date_create, update_by, date_update, company_org_id, department_org_id
+    create_by, date_create, update_by, date_update, company_org_id, department_org_id,
+    task_checked
   </sql>
   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
@@ -128,6 +130,9 @@
       <if test="departmentOrgId != null" >
         department_org_id,
       </if>
+      <if test="taskChecked != null" >
+        task_checked,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="id != null" >
@@ -149,10 +154,10 @@
         #{planDate,jdbcType=TIMESTAMP},
       </if>
       <if test="planStartDate != null" >
-        #{planStartDate,jdbcType=TIMESTAMP},
+        #{planStartDate,jdbcType=DATE},
       </if>
       <if test="planEndDate != null" >
-        #{planEndDate,jdbcType=TIMESTAMP},
+        #{planEndDate,jdbcType=DATE},
       </if>
       <if test="taskContent != null" >
         #{taskContent,jdbcType=VARCHAR},
@@ -205,6 +210,9 @@
       <if test="departmentOrgId != null" >
         #{departmentOrgId,jdbcType=VARCHAR},
       </if>
+      <if test="taskChecked != null" >
+        #{taskChecked,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.huaxu.task.entity.PlanManage" >
@@ -282,9 +290,41 @@
       <if test="departmentOrgId != null" >
         department_org_id = #{departmentOrgId,jdbcType=VARCHAR},
       </if>
+      <if test="taskChecked != null" >
+        task_checked = #{taskChecked,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
+  <update id="updateByPrimaryKey" parameterType="com.huaxu.task.entity.PlanManage2" >
+    update sc_plan_manage
+    set plan_id = #{planId,jdbcType=VARCHAR},
+      plan_name = #{planName,jdbcType=VARCHAR},
+      plan_user_id = #{planUserId,jdbcType=VARCHAR},
+      user_id = #{userId,jdbcType=VARCHAR},
+      plan_date = #{planDate,jdbcType=TIMESTAMP},
+      plan_start_date = #{planStartDate,jdbcType=TIMESTAMP},
+      plan_end_date = #{planEndDate,jdbcType=TIMESTAMP},
+      task_content = #{taskContent,jdbcType=VARCHAR},
+      task_area_shape = #{taskAreaShape,jdbcType=VARCHAR},
+      task_area_name = #{taskAreaName,jdbcType=VARCHAR},
+      task_type = #{taskType,jdbcType=INTEGER},
+      plan_status = #{planStatus,jdbcType=INTEGER},
+      tenant_id = #{tenantId,jdbcType=VARCHAR},
+      process_instance_id = #{processInstanceId,jdbcType=VARCHAR},
+      process_def_id = #{processDefId,jdbcType=VARCHAR},
+      current_task_id = #{currentTaskId,jdbcType=VARCHAR},
+      current_users = #{currentUsers,jdbcType=VARCHAR},
+      current_task_name = #{currentTaskName,jdbcType=VARCHAR},
+      create_by = #{createBy,jdbcType=VARCHAR},
+      date_create = #{dateCreate,jdbcType=TIMESTAMP},
+      update_by = #{updateBy,jdbcType=VARCHAR},
+      date_update = #{dateUpdate,jdbcType=TIMESTAMP},
+      company_org_id = #{companyOrgId,jdbcType=VARCHAR},
+      department_org_id = #{departmentOrgId,jdbcType=VARCHAR},
+      task_checked = #{taskChecked,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
   <select id="findPage" resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List"/>