Ver código fonte

工时管理--删除逻辑更改

buzhanyi 6 meses atrás
pai
commit
7db4d4fcdf

+ 20 - 3
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ManHourServiceImpl.java

@@ -99,6 +99,7 @@ public class ManHourServiceImpl implements ManHourService {
             manHourInfoEntity.setProjectUser(showName);
             manHourInfoEntity.setCreateUser(byId1.get().getUserId());
             manHourInfoEntity.setManStatus(ManHourStatus.NO_ALLOCATION.getCode());
+            manHourInfoEntity.setFlowTaskStatus(FlowTaskStatus.DRAFT);
             BeanUtils.copyProperties(job, manHourInfoEntity);
             manHourInfoEntity.setCreateTime(new Date());
             manHourInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
@@ -119,6 +120,7 @@ public class ManHourServiceImpl implements ManHourService {
             manHourInfoEntity.setProjectUser(showName);
             manHourInfoEntity.setCreateUser(byId1.get().getUserId());
             manHourInfoEntity.setManStatus(ManHourStatus.NO_ALLOCATION.getCode());
+            manHourInfoEntity.setFlowTaskStatus(FlowTaskStatus.DRAFT);
             BeanUtils.copyProperties(job, manHourInfoEntity);
             manHourInfoEntity.setCreateTime(new Date());
             manHourInfoEntity.setIsDelete(DataIsDeleteEnum.NORMAL.getCode());
@@ -149,11 +151,26 @@ public class ManHourServiceImpl implements ManHourService {
 
     @Override
     public ResMsg deleteManHour(List<ManHourInfoVo> manHourInfoVos) {
-
+        //审批状态   已提交:0; 审批中:1; 被拒绝:2; 已结束:3; 提前停止:4; 已取消:5;保存草稿:6
+        StringBuffer optional = new StringBuffer("工时:[");
+        int count = 0;
         for (ManHourInfoVo info : manHourInfoVos) {
-            manHourMapper.deleteById(Integer.valueOf(info.getManId()));
+            ManHourInfoEntity byId = manHourMapper.getById(info.getManId());
+//            //如果流程状态大于1,便是不在审核中,可删除
+            if (byId.getFlowTaskStatus() > 1) {
+                manHourMapper.deleteById(Integer.valueOf(info.getManId()));
+                count++;
+            } else {
+                optional.append("【" + byId.getJobContent() + "】,");
+            }
+        }
+        optional.replace(optional.length() - 1, optional.length(), "");
+        optional.append("] 审批未结束,不可删除!");
+        if (count == manHourInfoVos.size()) {
+            return new ResMsg(CodeEnum.OK, "");
+        } else {
+            return new ResMsg(CodeEnum.FAIL, optional);
         }
-        return new ResMsg(CodeEnum.OK);
     }
 
     @Override