Browse Source

不分费用类型的批量提交

buzhanyi 4 months ago
parent
commit
7354a915f2

+ 16 - 1
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/controller/ApplyForCostController.java

@@ -5,6 +5,7 @@ import com.ankaibei.workFlow.webadmin.ankaibei.enums.CodeEnum;
 import com.ankaibei.workFlow.webadmin.ankaibei.service.ApplyForCostService;
 import com.ankaibei.workFlow.webadmin.ankaibei.service.impl.FileUtil;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.CommunicationInfoVo;
+import com.ankaibei.workFlow.webadmin.ankaibei.vo.CostInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.PurchaseInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.RepastExpenseVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
@@ -348,6 +349,9 @@ public class ApplyForCostController {
         return applyForCostService.repastUpdate(RepastExpenseVo);
     }
 
+    /**
+     * 申请餐费--修改并提交
+     */
     @RequestMapping("/repastSubmitByUpdate")
     public ResMsg repastSubmitByUpdate(@RequestBody RepastExpenseVo RepastExpenseVo) {
         RepastExpenseVo.setApplicant(TokenData.takeFromRequest().getUserId());
@@ -410,5 +414,16 @@ public class ApplyForCostController {
         return applyForCostService.travelSubmitByUpdate(travelExpenseVo);
     }
 
-
+    /**
+     * 不分费用类型的批量提交
+     *
+     * @return ResMsg
+     */
+    @RequestMapping("/costSubmitBatch")
+    public ResMsg costSubmitBatch(@RequestBody List<CostInfoVo> CostInfos) {
+        if (ObjectUtils.isEmpty(CostInfos)) {
+            return new ResMsg(CodeEnum.FAIL, "请选择要提交的数据");
+        }
+        return applyForCostService.costSubmitBatch(CostInfos);
+    }
 }

+ 6 - 0
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/ApplyForCostService.java

@@ -2,6 +2,7 @@ package com.ankaibei.workFlow.webadmin.ankaibei.service;
 
 
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.CommunicationInfoVo;
+import com.ankaibei.workFlow.webadmin.ankaibei.vo.CostInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.PurchaseInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.RepastExpenseVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
@@ -190,4 +191,9 @@ public interface ApplyForCostService {
      */
     ResMsg travelSubmitByUpdate(TravelExpenseVo travelExpenseVo);
 
+
+    /**
+     * 不同类型费用--批量提交
+     */
+    ResMsg costSubmitBatch(List<CostInfoVo> CostInfos);
 }

+ 98 - 5
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/ankaibei/service/impl/ApplyForCostServiceImpl.java

@@ -32,6 +32,7 @@ import com.ankaibei.workFlow.webadmin.ankaibei.service.ApplyForCostService;
 import com.ankaibei.workFlow.webadmin.ankaibei.service.CostInfoService;
 import com.ankaibei.workFlow.webadmin.ankaibei.utils.FlowTaskStart;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.CommunicationInfoVo;
+import com.ankaibei.workFlow.webadmin.ankaibei.vo.CostInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.PurchaseInfoVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.RepastExpenseVo;
 import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
@@ -286,7 +287,7 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
     public ResMsg purchaseSubmitBatch(List<PurchaseInfoVo> purchaseInfoVos) {
         for (PurchaseInfoVo purchaseInfoVo : purchaseInfoVos) {
             CostInfoEntity costInfoEntity = new CostInfoEntity();
-            costInfoEntity.setApplyCostId(purchaseInfoVo.getPurchaseId());
+            costInfoEntity.setCostId(purchaseInfoVo.getPurchaseId());
             costInfoEntity.setCostType("采购费");
             //查询采购费用详情
             ResMsg infoDetails = costInfoService.findCostInfoDetails(costInfoEntity);
@@ -442,7 +443,7 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
     public ResMsg restSubmitBatch(List<RestsInfoVo> restsInfoVos) {
         for (RestsInfoVo restsInfoVo : restsInfoVos) {
             CostInfoEntity costInfoEntity = new CostInfoEntity();
-            costInfoEntity.setApplyCostId(restsInfoVo.getRestsId());
+            costInfoEntity.setCostId(restsInfoVo.getRestsId());
             costInfoEntity.setCostType("其他费用");
             //查询其他费用详情
             ResMsg infoDetails = costInfoService.findCostInfoDetails(costInfoEntity);
@@ -595,7 +596,7 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
     public ResMsg trafficSubmitBatch(List<TrafficExpenseVo> trafficExpenseVos) {
         for (TrafficExpenseVo trafficExpenseVo : trafficExpenseVos) {
             CostInfoEntity costInfoEntity = new CostInfoEntity();
-            costInfoEntity.setApplyCostId(trafficExpenseVo.getId());
+            costInfoEntity.setCostId(trafficExpenseVo.getId());
             costInfoEntity.setCostType("交通费");
             //查询交通费用详情
             ResMsg infoDetails = costInfoService.findCostInfoDetails(costInfoEntity);
@@ -747,7 +748,7 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
     public ResMsg repastSubmitBatch(List<RepastExpenseVo> repastExpenseVos) {
         for (RepastExpenseVo repastExpenseVo : repastExpenseVos) {
             CostInfoEntity costInfoEntity = new CostInfoEntity();
-            costInfoEntity.setApplyCostId(repastExpenseVo.getId());
+            costInfoEntity.setCostId(repastExpenseVo.getId());
             costInfoEntity.setCostType("餐饮费");
             //查询餐饮费用详情
             ResMsg infoDetails = costInfoService.findCostInfoDetails(costInfoEntity);
@@ -899,7 +900,7 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
     public ResMsg travelSubmitBatch(List<TravelExpenseVo> travelExpenseVos) {
         for (TravelExpenseVo travelExpenseVo : travelExpenseVos) {
             CostInfoEntity costInfoEntity = new CostInfoEntity();
-            costInfoEntity.setApplyCostId(travelExpenseVo.getId());
+            costInfoEntity.setCostId(travelExpenseVo.getId());
             costInfoEntity.setCostType("差旅费");
             //查询差旅费用详情
             ResMsg infoDetails = costInfoService.findCostInfoDetails(costInfoEntity);
@@ -1018,6 +1019,97 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
         return new ResMsg(CodeEnum.OK);
     }
 
+    /**
+     * 不分费用类型的批量提交
+     */
+    @Override
+    public ResMsg costSubmitBatch(List<CostInfoVo> CostInfos) {
+        for (CostInfoVo costVo : CostInfos) {
+            CostInfoEntity costNew = new CostInfoEntity();
+            BeanUtils.copyProperties(costVo, costNew);
+            //查询差旅费用详情
+            ResMsg infoDetails = costInfoService.findCostInfoDetails(costNew);
+            if (!"200".equals(infoDetails.getCode())) {
+                return infoDetails;
+            }
+            //根据不同的费用类型调用不同的流程启动
+
+            switch (costVo.getCostType()) {
+                case "通讯费":
+                    //通讯费用申请流程的启动
+                    CommunicationInfoEntity save = (CommunicationInfoEntity) infoDetails.getData();
+                    ResMsg resMsg = communicationFlowStart(save);
+                    if (!"200".equals(resMsg.getCode())) {
+                        return resMsg;
+                    }
+                    save.setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    communicationMapper.save(save);
+                    break;
+                case "采购费":
+                    //采购费用申请流程的启动
+                    PurchaseInfoVo infoVo = (PurchaseInfoVo) infoDetails.getData();
+                    Optional<PurchaseInfoEntity> byId = purchaseInfoMapper.findById(infoVo.getPurchaseId());
+                    ResMsg resMsgTwo = purchaseFlowStart(infoVo);
+                    if (!"200".equals(resMsgTwo.getCode())) {
+                        return resMsgTwo;
+                    }
+                    byId.get().setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    purchaseInfoMapper.save(byId.get());
+                    break;
+                case "其他费用":
+                    //其他费用申请流程的启动
+                    RestsInfoVo saveA = (RestsInfoVo) infoDetails.getData();
+                    Optional<RestsInfoEntity> byIdA = restInfoMapper.findById(saveA.getRestsId());
+                    ResMsg resMsgThree = restFlowStart(byIdA.get());
+                    if (!"200".equals(resMsgThree.getCode())) {
+                        return resMsgThree;
+                    }
+                    //                    byId.get().setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    byIdA.get().setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    restInfoMapper.save(byIdA.get());
+                    break;
+                case "交通费":
+                    //采购费用申请流程的启动
+                    TrafficExpenseVo trafficExpenseVo = (TrafficExpenseVo) infoDetails.getData();
+                    Optional<TrafficExpenseEntity> byIdB = trafficExpenseMapper.findById(trafficExpenseVo.getId());
+                    ResMsg resMsgFore = trafficExpenseFlowStart(byIdB.get());
+                    if (!"200".equals(resMsgFore.getCode())) {
+                        return resMsgFore;
+                    }
+                    byIdB.get().setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    trafficExpenseMapper.save(byIdB.get());
+                    break;
+                case "餐饮费":
+                    //餐饮费用申请流程的启动
+                    RepastExpenseVo saveC = (RepastExpenseVo) infoDetails.getData();
+                    Optional<RepastExpenseEntity> byIdC = repastExpenseMapper.findById(saveC.getId());
+                    ResMsg resMsgFive = repastExpenseFlowStart(byIdC.get());
+                    if (!"200".equals(resMsgFive.getCode())) {
+                        return resMsgFive;
+                    }
+                    byIdC.get().setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    repastExpenseMapper.save(byIdC.get());
+                    break;
+                case "差旅费":
+                    //餐饮费用申请流程的启动
+                    TravelExpenseVo travelExpenseVo = (TravelExpenseVo) infoDetails.getData();
+                    Optional<TravelExpenseEntity> byIdD = travelExpenseMapper.findById(travelExpenseVo.getId());
+                    ResMsg resMsgSix = travelExpenseFlowStart(byIdD.get());
+                    if (!"200".equals(resMsgSix.getCode())) {
+                        return resMsgSix;
+                    }
+                    byIdD.get().setFlowTaskStatus(FlowTaskStatus.SUBMITTED);
+                    travelExpenseMapper.save(byIdD.get());
+                    break;
+                default:
+                    // 处理其他情况
+                    break;
+            }
+        }
+        return new ResMsg(CodeEnum.OK);
+    }
+
+
     /**
      * 查询用户信息
      */
@@ -1025,4 +1117,5 @@ public class ApplyForCostServiceImpl implements ApplyForCostService {
         Optional<UserInfoEntity> byId = userInfoMapper.findById(userId);
         return byId.orElse(null);
     }
+
 }