Browse Source

工时管理--工时的修改接口开发

buzhanyi 8 months ago
parent
commit
211090a10e

+ 4 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/ManHourInfoApi.java

@@ -27,4 +27,8 @@ public interface ManHourInfoApi extends ApiMixin<ManHourInfoVo, Integer> {
     ResMsg deleteManHour(List<ManHourInfoVo> manHourInfoVos);
 
     ResMsg findManHourByID(ManHourInfoVo manHourInfoVo);
+
+    ResMsg editManHour(ManHourInfoVo manHourInfoVo);
+
+    ResMsg submitManHourByeEdit(ManHourInfoVo manHourInfoVo);
 }

+ 10 - 1
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/api/ManHourServiceApi.java

@@ -3,7 +3,6 @@ package com.ankaibei.workFlow.webadmin.ankaibei.api;
 import com.ankaibei.workFlow.webadmin.ankaibei.entity.ManHourInfoEntity;
 import com.ankaibei.workFlow.webadmin.ankaibei.service.ManHourService;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ManHourInfoVo;
-import com.ankaibei.workFlow.webadmin.ankaibei.vo.ManHourJobVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
 import org.springframework.stereotype.Service;
 
@@ -53,5 +52,15 @@ public class ManHourServiceApi implements ManHourInfoApi {
         return manHourService.findManHourByID(Integer.valueOf(manHourInfoVo.getManId()));
     }
 
+    @Override
+    public ResMsg editManHour(ManHourInfoVo manHourInfoVo) {
+        return manHourService.editManHour(manHourInfoVo);
+    }
+
+    @Override
+    public ResMsg submitManHourByeEdit(ManHourInfoVo manHourInfoVo) {
+        return manHourService.submitManHourByeEdit(manHourInfoVo);
+    }
+
 
 }

+ 11 - 2
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/ManHourController.java

@@ -71,12 +71,21 @@ public class ManHourController {
     }
 
     /**
-     * 新建工时
+     * 编辑工时
      */
     @RequestMapping("/editManHour")
     public ResMsg editManHour(@RequestBody ManHourInfoVo manHourInfoVo) {
         manHourInfoVo.setCreateUser(TokenData.takeFromRequest().getUserId());
-        return manHourInfoApi.addManHour(manHourInfoVo);
+        return manHourInfoApi.editManHour(manHourInfoVo);
+    }
+
+    /**
+     * 编辑工时同时提交
+     */
+    @RequestMapping("/submitManHourByeEdit")
+    public ResMsg submitManHourByeEdit(@RequestBody ManHourInfoVo manHourInfoVo) {
+        manHourInfoVo.setCreateUser(TokenData.takeFromRequest().getUserId());
+        return manHourInfoApi.submitManHourByeEdit(manHourInfoVo);
     }
 
     /**

+ 4 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/ManHourService.java

@@ -27,4 +27,8 @@ public interface ManHourService {
     ResMsg deleteManHour(List<ManHourInfoVo> manHourInfoVos);
 
     ResMsg findManHourByID(Integer manId);
+
+    ResMsg editManHour(ManHourInfoVo manHourInfoVo);
+
+    ResMsg submitManHourByeEdit(ManHourInfoVo manHourInfoVo);
 }

+ 63 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ManHourServiceImpl.java

@@ -160,9 +160,72 @@ public class ManHourServiceImpl implements ManHourService {
     public ResMsg findManHourByID(Integer manId) {
         Optional<ManHourInfoEntity> byId = manHourMapper.findById(manId);
         ManHourInfoEntity infoEntity = byId.orElse(null) != null ? byId.orElse(null) : null;
+        Optional<UserInfoEntity> userInfoEntity = userInfoMapper.findById(infoEntity.getCreateUser());
+        infoEntity.setCreateUser(userInfoEntity.get().getShowName());
+        infoEntity.setProjectUser(userInfoEntity.get().getShowName());
+        Optional<ProjectInfoEntity> projectInfoEntity = projectInfoMapper.findById(Integer.valueOf(infoEntity.getProjectId()));
+        infoEntity.setProjectId(projectInfoEntity.get().getProjectName());
+        Optional<TaskInfoEntity> taskInfoEntity = taskInfoMapper.findById(Integer.valueOf(infoEntity.getTaskId()));
+        infoEntity.setTaskId(taskInfoEntity.get().getTargetTask());
         return new ResMsg(CodeEnum.OK, infoEntity);
     }
 
+    @Override
+    public ResMsg editManHour(ManHourInfoVo manHourInfoVo) {
+        ManHourInfoEntity byId = manHourMapper.findById(manHourInfoVo.getManId()).get();
+        String manStatus = byId.getManStatus();
+        //未提交的工时更改
+        if (ManHourStatus.NO_ALLOCATION.getCode().equals(manStatus)) {
+            ManHourInfoEntity infoEntity = new ManHourInfoEntity();
+            BeanUtils.copyProperties(manHourInfoVo, infoEntity);
+            //保留原本信息
+            infoEntity.setProjectUser(byId.getProjectUser());
+            infoEntity.setCreateUser(byId.getCreateUser());
+            infoEntity.setManStatus(ManHourStatus.NO_ALLOCATION.getCode());
+            infoEntity.setCreateTime(new Date());
+            infoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
+            ManHourInfoEntity save = manHourMapper.save(infoEntity);
+            return new ResMsg(CodeEnum.OK, save);
+        } else if (ManHourStatus.REFUSE_ED.getCode().equals(manStatus)) {
+            //拒绝后的工时更改
+            ManHourInfoEntity infoEntity = new ManHourInfoEntity();
+            BeanUtils.copyProperties(manHourInfoVo, infoEntity);
+            //保留
+            infoEntity.setProjectUser(byId.getProjectUser());
+            infoEntity.setCreateUser(byId.getCreateUser());
+            infoEntity.setManStatus(ManHourStatus.NO_ALLOCATION.getCode());
+            infoEntity.setCreateTime(new Date());
+            infoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
+            infoEntity.setManId(new ManHourInfoEntity().getManId());
+            manHourMapper.deleteById(byId.getManId());
+            ManHourInfoEntity save = manHourMapper.save(infoEntity);
+            return new ResMsg(CodeEnum.OK, save);
+        }
+        return new ResMsg(CodeEnum.OK, null);
+    }
+
+    /**
+     * 编辑工时之后提交
+     *
+     * @param manHourInfoVo
+     * @return
+     */
+    @Override
+    public ResMsg submitManHourByeEdit(ManHourInfoVo manHourInfoVo) {
+        //先编辑工时
+        ManHourInfoEntity infoEntity = (ManHourInfoEntity) editManHour(manHourInfoVo).getData();
+        // 提交工时
+        if (!ObjectUtils.isEmpty(infoEntity)) {
+            ResMsg resMsg = manHourFlowStart(infoEntity);
+            if (!"200".equals(resMsg.getCode())) {
+                return resMsg;
+            }
+        } else {
+            return new ResMsg(CodeEnum.DATA_VALIDATED_FAILED);
+        }
+        return new ResMsg(CodeEnum.OK);
+    }
+
     public ResMsg manHourFlowStart(ManHourInfoEntity manHourInfoEntity) {
         //param processDefinitionKey 项目人员工时接口审批流程--流程标识。
         String processDefinitionKey = "manHourCountApply";

+ 3 - 3
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/vo/ManHourInfoVo.java

@@ -47,7 +47,7 @@ public class ManHourInfoVo extends BaseVo {
     /**
      * 工时日期
      */
-    private String manufactureDate;
+    private Date manufactureDate;
 
     /**
      * 总工时(小时)
@@ -142,11 +142,11 @@ public class ManHourInfoVo extends BaseVo {
         this.endDate = endDate;
     }
 
-    public String getManufactureDate() {
+    public Date getManufactureDate() {
         return manufactureDate;
     }
 
-    public void setManufactureDate(String manufactureDate) {
+    public void setManufactureDate(Date manufactureDate) {
         this.manufactureDate = manufactureDate;
     }