Browse Source

[CODE]: 审批通过、审批驳回 变更主表从表状态

maxianghua 4 years ago
parent
commit
f12171d722

+ 52 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/service/impl/AuditPathsServiceImpl.java

@@ -13,9 +13,11 @@ 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.service.impl.TFeeServiceImpl;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
 import com.ruoyi.warehouseBusiness.mapper.TWarehouseBillsMapper;
+import com.ruoyi.warehouseBusiness.service.impl.TWarehouseAgreementServiceImpl;
 import com.ruoyi.warehouseBusiness.service.impl.TWarehouseBillsServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -54,6 +56,14 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
     @Autowired
     private TWarehouseBillsServiceImpl tWarehouseBillsService;
 
+    @Autowired
+    private TFeeServiceImpl tFeeServiceImpl;
+
+    @Autowired
+    private TWarehouseAgreementServiceImpl tWarehouseAgreementService;
+
+
+
     /**
      * 查询审批流配置主
      *
@@ -304,6 +314,32 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         }
                     } else if (auditItems.getActId() >= 210 && auditItems.getActId() <= 230) {
                         // 财务模块
+                        if ("T".equals(at.getIffinalItem())) {
+                            fettle = 6L;
+                        } else if ("F".equals(at.getIffinalItem())) {
+                            fettle = 5L;
+                        }
+                        // 变更财务状态
+                        AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
+                        String code = (String) ajaxResult.get("code");
+                        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())) {
+                            fettle = 5L;
+                        }
+                        // 变更财务状态
+                        AjaxResult ajaxResult = tWarehouseAgreementService.agreementFollow(auditItems.getBillId(), fettle);
+                        String code = (String) ajaxResult.get("code");
+                        if ("500".equals(code)) {
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return ajaxResult;
+                        }
                     }
                     break;
                 }
@@ -334,7 +370,23 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             }
             return ajaxResult;
         } else if (auditItems.getActId() >= 210 && auditItems.getActId() <= 230) {
+            fettle = 3L;
             // 财务模块
+            AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
+            String code = (String) ajaxResult.get("code");
+            if ("500".equals(code)) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            }
+            return ajaxResult;
+        } else if (auditItems.getActId() >= 310 && auditItems.getActId() <= 320) {
+            fettle = 3L;
+            // 协议模块
+            AjaxResult ajaxResult = tWarehouseAgreementService.agreementFollow(auditItems.getBillId(), fettle);
+            String code = (String) ajaxResult.get("code");
+            if ("500".equals(code)) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            }
+            return ajaxResult;
         }
         AuditItems item = new AuditItems();
         item.setBillId(auditItems.getId());

+ 34 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -376,8 +376,41 @@ public class TFeeServiceImpl implements ITFeeService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             }
             return approvalFlow;
+        }else {
+            AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
+            Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
+            return ajaxResult;
         }
-        return null;
+    }
+
+    /**
+     * 根据财务主表id 更新对应明细表状态
+     *
+     * @param fPid 财务主表id
+     * @return 结果
+     */
+    @Transactional
+    public AjaxResult tfeeFollow(Long fPid, long fettle) {
+        if (StringUtils.isNull(fPid)) {
+            return AjaxResult.error("财务更新状态未找到主表信息,请与管理员联系");
+        }
+        TFee tFee = new TFee();
+        tFee.setfId(fPid);
+        tFee.setfBillstatus(String.valueOf(fettle));
+        int tFeeUpdateResult = tFeeMapper.updateTFee(tFee);
+        if (tFeeUpdateResult <= 0) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return AjaxResult.error("更新财务明细状态失败,请联系管理员");
+        }
+        TFeeDo tFeeDo =new TFeeDo();
+        tFeeDo.setfId(fPid);
+        tFeeDo.setfStatus(String.valueOf(fettle));
+        int itemUpdateResult = tFeeDoMapper.updateTFeeDo(tFeeDo);
+        if (itemUpdateResult <= 0) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return AjaxResult.error("更新财务明细状态失败,请联系管理员");
+        }
+        return AjaxResult.success();
     }
 
     @Override

+ 34 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseAgreementServiceImpl.java

@@ -299,8 +299,41 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             }
             return approvalFlow;
+        }else {
+            AjaxResult ajaxResult = agreementFollow(fPid, 6L);
+            Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
+            return ajaxResult;
         }
-        return null;
+    }
+
+    /**
+     * 根据协议主表id 更新对应明细表状态
+     *
+     * @param fPid 协议主表id
+     * @return 结果
+     */
+    @Transactional
+    public AjaxResult agreementFollow(Long fPid, long fettle) {
+        if (StringUtils.isNull(fPid)) {
+            return AjaxResult.error("协议更新状态未找到主表信息,请与管理员联系");
+        }
+        TWarehouseAgreement tWarehouseAgreement = new TWarehouseAgreement();
+        tWarehouseAgreement.setfId(fPid);
+        tWarehouseAgreement.setfBillstatus(String.valueOf(fettle));
+        int tFeeUpdateResult = tWarehouseAgreementMapper.updateTWarehouseAgreement(tWarehouseAgreement);
+        if (tFeeUpdateResult <= 0) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return AjaxResult.error("更新协议明细状态失败,请联系管理员");
+        }
+        TWarehouseAgreementitems tWarehouseAgreementitems = new TWarehouseAgreementitems();
+        tWarehouseAgreementitems.setfId(fPid);
+        tWarehouseAgreementitems.setfStatus(String.valueOf(fettle));
+        int itemUpdateResult = tWarehouseAgreementitemsMapper.updateTWarehouseAgreementitems(tWarehouseAgreementitems);
+        if (itemUpdateResult <= 0) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return AjaxResult.error("更新协议明细状态失败,请联系管理员");
+        }
+        return AjaxResult.success();
     }
 
     /**