Browse Source

[CODE]: 财务添加部门信息、审批撤销先查询是否已经审批

maxianghua 4 years ago
parent
commit
e09152ae56

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/approvalFlow/AuditPathsController.java

@@ -84,7 +84,7 @@ public class AuditPathsController extends BaseController {
      * 审批撤销
      */
     @RepeatSubmit
-        @PostMapping("/revoke")
+    @PostMapping("/revoke")
     public AjaxResult revoke(@RequestBody AuditItems auditItems) {
         if (StringUtils.isNull(auditItems.getActId())) {
             return AjaxResult.error("操作失败 未找到活动号,请确认");

+ 46 - 13
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/service/impl/AuditPathsServiceImpl.java

@@ -13,9 +13,13 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.finance.domain.TFee;
+import com.ruoyi.finance.mapper.TFeeMapper;
 import com.ruoyi.finance.service.impl.TFeeServiceImpl;
 import com.ruoyi.system.mapper.SysUserMapper;
+import com.ruoyi.warehouseBusiness.domain.TWarehouseAgreement;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
+import com.ruoyi.warehouseBusiness.mapper.TWarehouseAgreementMapper;
 import com.ruoyi.warehouseBusiness.mapper.TWarehouseBillsMapper;
 import com.ruoyi.warehouseBusiness.service.impl.TWarehouseAgreementServiceImpl;
 import com.ruoyi.warehouseBusiness.service.impl.TWarehouseBillsServiceImpl;
@@ -62,7 +66,11 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
     @Autowired
     private TWarehouseAgreementServiceImpl tWarehouseAgreementService;
 
+    @Autowired
+    private TFeeMapper tFeeMapper;
 
+    @Autowired
+    private TWarehouseAgreementMapper tWarehouseAgreementMapper;
 
     /**
      * 查询审批流配置主
@@ -307,7 +315,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         }
                         // 仓库模块
                         AjaxResult ajaxResult = tWarehouseBillsService.warehouseFollow(auditItems.getBillId(), fettle);
-                        String code = (String) ajaxResult.get("code");
+                        String code = ajaxResult.get("code").toString();
                         if ("500".equals(code)) {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return ajaxResult;
@@ -316,18 +324,25 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         // 财务模块
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
+                            // 更新费用明细
+                            AjaxResult ajaxResult = tFeeServiceImpl.billsfeesFollow(auditItems.getBillId());
+                            String code = ajaxResult.get("code").toString();
+                            if ("500".equals(code)) {
+                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                return ajaxResult;
+                            }
                         } else if ("F".equals(at.getIffinalItem())) {
                             fettle = 5L;
                         }
                         // 变更财务状态
                         AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
-                        String code = (String) ajaxResult.get("code");
+                        String code = ajaxResult.get("code").toString();
                         if ("500".equals(code)) {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return ajaxResult;
                         }
                     } else if (auditItems.getActId() >= 310 && auditItems.getActId() <= 320) {
-                        // 财务模块
+                        // 协议模块
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
                         } else if ("F".equals(at.getIffinalItem())) {
@@ -335,7 +350,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         }
                         // 变更财务状态
                         AjaxResult ajaxResult = tWarehouseAgreementService.agreementFollow(auditItems.getBillId(), fettle);
-                        String code = (String) ajaxResult.get("code");
+                        String code = ajaxResult.get("code").toString();
                         if ("500".equals(code)) {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return ajaxResult;
@@ -365,7 +380,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             fettle = 3L;
             // 仓库模块
             AjaxResult ajaxResult = tWarehouseBillsService.warehouseFollow(auditItems.getBillId(), fettle);
-            String code = (String) ajaxResult.get("code");
+            String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             }
@@ -374,7 +389,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             fettle = 3L;
             // 财务模块
             AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
-            String code = (String) ajaxResult.get("code");
+            String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             }
@@ -383,7 +398,7 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             fettle = 3L;
             // 协议模块
             AjaxResult ajaxResult = tWarehouseAgreementService.agreementFollow(auditItems.getBillId(), fettle);
-            String code = (String) ajaxResult.get("code");
+            String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             }
@@ -450,31 +465,49 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
         long fettle = 0L;
         if (auditItems.getActId() >= 110 && auditItems.getActId() <= 140) {
             fettle = 2L;
+            // 查询仓库状态
+            TWarehouseBills tWarehouseBills= tWarehouseBillsMapper.selectTWarehousebillsById(auditItems.getBillId());
+            if(tWarehouseBills.getfBillstatus().equals("5") || tWarehouseBills.getfBillstatus().equals("6")){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("审批撤销失败: 已经过审批");
+            }
             // 仓库模块
             AjaxResult ajaxResult = tWarehouseBillsService.warehouseFollow(auditItems.getBillId(), fettle);
-            String code = (String) ajaxResult.get("code");
+            String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("审批撤销失败: 更新审批状态失败");
             }
-            return ajaxResult;
         } else if (auditItems.getActId() >= 210 && auditItems.getActId() <= 230) {
             fettle = 2L;
+            // 查询财务状态
+            TFee tFee= tFeeMapper.selectTFeeById(auditItems.getBillId());
+            if(tFee.getfBillstatus().equals("5") || tFee.getfBillstatus().equals("6")){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("审批撤销失败: 已经过审批");
+            }
             // 财务模块
             AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
-            String code = (String) ajaxResult.get("code");
+            String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("审批撤销失败: 更新审批状态失败");
             }
-            return ajaxResult;
         } else if (auditItems.getActId() >= 310 && auditItems.getActId() <= 320) {
             fettle = 2L;
+            // 查询协议状态
+            TWarehouseAgreement tWarehouseAgreement=tWarehouseAgreementMapper.selectTWarehouseAgreementById(auditItems.getBillId());
+            if(tWarehouseAgreement.getfBillstatus().equals("5") || tWarehouseAgreement.getfBillstatus().equals("6")){
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("审批撤销失败: 已经过审批");
+            }
             // 协议模块
             AjaxResult ajaxResult = tWarehouseAgreementService.agreementFollow(auditItems.getBillId(), fettle);
-            String code = (String) ajaxResult.get("code");
+            String code = ajaxResult.get("code").toString();
             if ("500".equals(code)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("审批撤销失败: 更新审批状态失败");
             }
-            return ajaxResult;
         }
         AuditItems item = new AuditItems();
         item.setBillId(auditItems.getId());

+ 38 - 8
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -198,6 +198,7 @@ public class TFeeServiceImpl implements ITFeeService {
         if (StringUtils.isNull(tFee.getfId())) {
             // 如果是新数据
             tFee.setCreateBy(loginUser.getUser().getUserName());
+            tFee.setfDeptid(loginUser.getUser().getDeptId());
             tFee.setfBilltype(fBilltype);
             // 业务编码
             Date time = new Date();
@@ -293,9 +294,10 @@ public class TFeeServiceImpl implements ITFeeService {
                 BigDecimal result = calculation1(fAmtdr, fAmt);
                 m.put("fAmtdr",result);
                 m.put("fAmt",result);
-                if(result.compareTo(BigDecimal.ZERO) > 0) {
+                maps.add(m);/*if(result.compareTo(BigDecimal.ZERO) > 0) {
                     maps.add(m);
-                }
+                }*/
+
             }
         }
         return maps;
@@ -316,6 +318,7 @@ public class TFeeServiceImpl implements ITFeeService {
         if (StringUtils.isNull(tFee.getfId())) {
             // 如果是新数据
             tFee.setCreateBy(loginUser.getUser().getUserName());
+            tFee.setfDeptid(loginUser.getUser().getDeptId());
             tFee.setfBilltype(fBilltype);
             // 业务编码
             Date time = new Date();
@@ -338,12 +341,6 @@ public class TFeeServiceImpl implements ITFeeService {
                 tFeeDo.setCreateBy(loginUser.getUser().getUserName());
                 tFeeDo.setCreateTime(new Date());
                 tFeeDoMapper.insertTFeeDo(tFeeDo);
-                // 跟新费用明细
-                int m = updateBillsFees(tFee.getfId(),tFeeDo,fBilltype);
-                if (m == 0) {
-                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                    return AjaxResult.error("更新费用明细失败");
-                }
             }
         }
         // 这里加个判断取系统参数来确定是否需要启用审批流
@@ -392,6 +389,18 @@ public class TFeeServiceImpl implements ITFeeService {
             }
             return approvalFlow;
         }else {
+            if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
+                JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
+                List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
+                for (TFeeDo tFeeDo : tFeeDoList) {
+                    // 跟新费用明细
+                    int m = updateBillsFees(tFee.getfId(),tFeeDo,fBilltype);
+                    if (m == 0) {
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        return AjaxResult.error("更新费用明细失败");
+                    }
+                }
+            }
             AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
             Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
             return ajaxResult;
@@ -425,6 +434,27 @@ public class TFeeServiceImpl implements ITFeeService {
         return AjaxResult.success();
     }
 
+    @Transactional
+    public AjaxResult billsfeesFollow(Long fPid) {
+        if (StringUtils.isNull(fPid)) {
+            return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
+        }
+        TFee tFee=tFeeMapper.selectTFeeById(fPid);
+        // 查询从表数据
+        TFeeDo tFeeDo = new TFeeDo();
+        tFeeDo.setfPid(fPid);
+        List<TFeeDo> tFeeDoList=  tFeeDoMapper.selectTFeeDoList(tFeeDo);
+        for (TFeeDo tFeeDo1 : tFeeDoList) {
+            // 跟新费用明细
+            int m = updateBillsFees(fPid,tFeeDo1,tFee.getfBilltype());
+            if (m == 0) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("更新费用明细失败");
+            }
+        }
+        return AjaxResult.success();
+    }
+
     @Override
     @Transactional
     public AjaxResult revoke(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {