Browse Source

处理逻辑:1.调整财务:确认对账、收费、付费逻辑--点击确认对账、收费、付费后先扣费,当审核驳回后数据回滚;2.处理业务编号搜索、发票号保存后与业务编号回显逻辑,去掉第二次发起保存更新对账会根据fPid删除t_fee_do从表逻辑

nzf 3 years ago
parent
commit
1d38fa8491

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWarehousebillsitemsSummaryController.java

@@ -55,7 +55,7 @@ public class TWarehousebillsitemsSummaryController extends BaseController {
     /**
      * 查询库存总账列表
      */
-    @DataScope(deptAlias = "d", userAlias = "u")
+    //@DataScope(deptAlias = "d", userAlias = "u")
     @GetMapping("/list")
     public TableDataInfo list(TWarehouseBills tWarehouseBills) {
         startPage();

+ 15 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/service/impl/AuditPathsServiceImpl.java

@@ -392,12 +392,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;
                             // 更新费用明细
-                            AjaxResult ajaxResult = tFeeServiceImpl.billsfeesFollow(auditItems.getBillId());
+                            /*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;
                         }
@@ -730,6 +730,12 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
             }
         } else if (auditItems.getActId() >= 210 && auditItems.getActId() <= 230) {
             fettle = 3L;
+            String fBillType = null;
+            if (auditItems.getActId() == 210) { // 对账
+                fBillType = "DZRevoke";
+            } else if (auditItems.getActId() == 220 || auditItems.getActId() == 230) {
+                fBillType = "DCRevoke";
+            }
             // 财务模块
             AjaxResult ajaxResult = tFeeServiceImpl.tfeeFollow(auditItems.getBillId(), fettle);
             String code = ajaxResult.get("code").toString();
@@ -737,6 +743,13 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return ajaxResult;
             }
+            // 更新费用明细
+            AjaxResult result = tFeeServiceImpl.updateDSFMoney(auditItems.getBillId(),fBillType);
+            String message = result.get("code").toString();
+            if ("500".equals(message)) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return result;
+            }
         } else if (auditItems.getActId() >= 310 && auditItems.getActId() <= 320) {
             fettle = 3L;
             // 协议模块

+ 11 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/domain/TFee.java

@@ -39,6 +39,9 @@ public class TFee extends BaseEntity {
     @Excel(name = "业务编号(唯一格式+YYYY+YY+NNN,编号不能断号,要连续、如果删除该编号,下次新建单据,优先使用删除单据号,每月从001开始。) 对账 DZ 收费 SF 付费 FF 发票 FP")
     private String fBillno;
 
+    // 业务编号,防止出现与上面业务编号取数冲突
+    private String fSrcBillno;
+
     /**
      * 活动号
      */
@@ -263,6 +266,14 @@ public class TFee extends BaseEntity {
      */
     private  String srcBillNo;
 
+    public String getfSrcBillno() {
+        return fSrcBillno;
+    }
+
+    public void setfSrcBillno(String fSrcBillno) {
+        this.fSrcBillno = fSrcBillno;
+    }
+
     public BigDecimal getfTotalamount() {
         return fTotalamount;
     }

+ 62 - 16
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -237,6 +237,10 @@ public class TFeeServiceImpl implements ITFeeService {
                 map1.put("fFeeunitid", sysDictDataList.get(0).getDictLabel());
                 map1.put("fQty", tWarehousebillsfees.getfQty());
                 map1.put("fUnitprice", tWarehousebillsfees.getfUnitprice());
+                System.err.println("业务编号:" + fees.getfSrcBillno());
+                map1.put("fBillno",fees.getfSrcBillno());// 业务编号(单据编号)
+                System.err.println("发票号:" + fees.getfInvoiceNo());
+                map1.put("invoiceNo",fees.getfInvoiceNo());// 发票号
                 if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("KHDD")) {
                     map1.put("fBusinessType", "船运订单");
                 } else if (CollectionUtils.isNotEmpty(sysDictDataListIn)) {
@@ -398,18 +402,25 @@ public class TFeeServiceImpl implements ITFeeService {
             tFee = tFeeMapper.selectTFeeById(fPid);
             tFee.setSrcBillNo(tFee.getfBillno());
             // 删除从表
-            tFeeDoMapper.deleteByFPid(fPid);
+            // tFeeDoMapper.deleteByFPid(fPid);
         }
         //  财务从表
         if (StringUtils.isNotNull(tfeeDo)) {
             JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
             List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
             for (TFeeDo tFeeDo : tFeeDoList) {
-                tFeeDo.setfPid(fPid);
-                tFeeDo.setCreateBy(loginUser.getUser().getUserName());
-                tFeeDo.setCreateTime(new Date());
-                tFeeDo.setfStatus("2");
-                tFeeDoMapper.insertTFeeDo(tFeeDo);
+                if (StringUtils.isNull(tFeeDo.getfId())) {
+                    tFeeDo.setfPid(fPid);
+                    tFeeDo.setCreateBy(loginUser.getUser().getUserName());
+                    tFeeDo.setCreateTime(new Date());
+                    tFeeDo.setfStatus("2");
+                    tFeeDoMapper.insertTFeeDo(tFeeDo);
+                } else {
+                    // 走了修改
+                    tFeeDo.setUpdateBy(loginUser.getUser().getUserName());
+                    tFeeDo.setUpdateTime(new Date());
+                    tFeeDoMapper.updateTFeeDo(tFeeDo);
+                }
             }
         }
         List<FinancialTFeeDoExcel> list = tFeeDoMapper.selectFinancialTFeeDo(fPid);
@@ -798,6 +809,15 @@ public class TFeeServiceImpl implements ITFeeService {
                 tFeeDoMapper.insertTFeeDo(tFeeDo);
             }
         }
+        // 点击对账、收费、付费提交审核时去掉费用
+        if (actId >= 210 && actId <= 230) {
+            AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
+            String code = ajaxResult.get("code").toString();
+            if ("500".equals(code)) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return ajaxResult;
+            }
+        }
         //凯和收费提交审核时去掉钱
         if (actId >= 430 && actId <= 450){
             AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
@@ -819,17 +839,17 @@ public class TFeeServiceImpl implements ITFeeService {
             auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
             auditItems.setRefno2(fBilltype);// 财务类型
             auditItems.setRefno3(tFee.gettMblno());// 提单号
-            auditItems.setSendUserId(loginUser.getUser().getUserId());
-            auditItems.setSendName(loginUser.getUsername());
-            auditItems.setSendTime(new Date());
-            auditItems.setAuditUserId(loginUser.getUser().getUserId());
-            auditItems.setAuditItem(new Date());
-            auditItems.setAuditOpTime(new Date());
-            auditItems.setFidStatus("f_billstatus");
-            auditItems.setTimes(1L);
+            auditItems.setSendUserId(loginUser.getUser().getUserId()); // 请核人 ID
+            auditItems.setSendName(loginUser.getUsername()); // 请核人名称
+            auditItems.setSendTime(new Date()); // 请核时间
+            auditItems.setAuditUserId(loginUser.getUser().getUserId());// 审核人 ID
+            auditItems.setAuditItem(new Date());// 审核通过时间
+            auditItems.setAuditOpTime(new Date());// 审核时间
+            auditItems.setFidStatus("f_billstatus");// 存储对应审批字段
+            auditItems.setTimes(1L);// 第几次提交审批
             auditItems.setAuditMsg("提交");
-            auditItems.setAuditStatus("O");
-            AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
+            auditItems.setAuditStatus("O");// 提交状态
+            AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);// 生成审批流
             Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
             if (code.equals(500L)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -1182,6 +1202,32 @@ public class TFeeServiceImpl implements ITFeeService {
     }
 
     /**
+     * 账单管理撤销对账、收费、付费
+     * @param fPid
+     * @param fBillType
+     * @return
+     */
+    @Transactional
+    public AjaxResult updateDSFMoney(Long fPid,String fBillType){
+        if (StringUtils.isNull(fPid)) {
+            return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
+        }
+        TFee tFee = tFeeMapper.selectTFeeById(fPid);
+        // 获取从表数据
+        TFeeDo tFeeDo = new TFeeDo();
+        tFeeDo.setfPid(fPid);
+        List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
+        for (TFeeDo tFeeDo1 : tFeeDos) {
+            int m = updateBillsFees(fPid, tFeeDo1, fBillType);
+            if (m == 0) {
+                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                return AjaxResult.error("更新费用明细失败");
+            }
+        }
+        return AjaxResult.success();
+    }
+
+    /**
      * 凯和撤销收费 付费 对账
      * @param fPid
      * @param fBillType

+ 0 - 14
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -3946,20 +3946,6 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                 }
                 //校验计费日期是等于库存总帐计费日,如果不相等则报错
                 checkWhgenleg(wbItem, tWhgenle);
-                // 出库减件数数据
-                Long fQty = wbItem.getfQty();
-                if (fQty==0) {
-                    // 出库毛重数据
-                    BigDecimal fGrossweight = wbItem.getfGrossweight();
-                    // 出库净重数据
-                    BigDecimal fNetweight = wbItem.getfNetweight();
-                    // 上期件数减去出库件数
-                    tWhgenle.setfPreqty(tWhgenle.getfPreqty()-fQty);
-                    // 上期毛重减去当前出库毛重数据
-                    tWhgenle.setfPregrossweight(tWhgenle.getfPregrossweight().subtract(fGrossweight));
-                    // 上期净重减去当前出库净重数据
-                    tWhgenle.setfPrenetweight(tWhgenle.getfPrenetweight().subtract(fNetweight));
-                }
                 //  1、  库存 <  调拨件数  提示库存不足
                 judgeItemQty(tWhgenle, wbItem, i);
                 // 更新库存总账

+ 7 - 2
ruoyi-warehouse/src/main/resources/mapper/finance/TFeeMapper.xml

@@ -75,6 +75,7 @@
         <result property="updateTime" column="update_time"/>
         <result property="chargingMethod" column="charging_method"/>
         <result property="fTotalamount" column="f_totalamount"/>
+        <result property="fSrcBillno" column="f_src_billno"/>
         <result property="invoiceNo" column="invoice_no"/>
         <result property="bank" column="bank"/>
         <result property="waterBillNo" column="water_bill_no"/>
@@ -243,6 +244,7 @@
         SELECT
             f.f_id AS fId,
             f.f_billno AS fBillno,
+            fd.f_src_billno AS fSrcBillno,
             f.f_ctrlcorpid AS fCtrlcorpid,
             pro.dict_label AS chargingMethod,
             f.invoice_no AS invoiceNo,
@@ -273,6 +275,7 @@
             f.update_time
         FROM
             t_fee AS f
+            LEFT JOIN t_fee_do AS fd ON fd.f_pid = f.f_id
             LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
             left join sys_user u on f.create_by = u.user_name
             left join sys_dept d on f.f_deptid = d.dept_id
@@ -282,6 +285,7 @@
         <where>
             <if test="fId != null ">and f.f_id = #{fId}</if>
             <if test="fBillno != null  and fBillno != ''">and f.f_billno = #{fBillno}</if>
+            <if test="fSrcBillno != null  and fSrcBillno != ''">and fd.f_src_billno like concat('%', #{fSrcBillno}, '%')</if>
             <if test="fCtrlcorpid != null ">and f.f_ctrlcorpid = #{fCtrlcorpid}</if>
             <if test="fCorpid != null ">and f.f_corpid = #{fCorpid}</if>
             <if test="tMblno != null  and tMblno != ''">and f.t_mblno = #{tMblno}</if>
@@ -1244,6 +1248,7 @@
         t.f_bscorpno AS fBscorpno,
         t.f_billno AS fBillno,
         w.f_mblno AS fMblno,
+        w.f_invnos as invoiceNo,
         w.f_product_name AS fProductName,
         w.f_bsdate AS fBsdate,
         t.f_billtype AS fBilltype,
@@ -1289,8 +1294,8 @@
             <if test="map.tWareHouseFees.fToCorpid != null  and map.tWareHouseFees.fToCorpid != ''">and w.f_corpid =
                 #{map.tWareHouseFees.fToCorpid}
             </if>
-            <if test="map.tWareHouseFees.fBillno != null  and map.tWareHouseFees.fBillno != ''">and t.f_billno =
-                #{map.tWareHouseFees.fBillno}
+            <if test="map.tWareHouseFees.fBillno != null  and map.tWareHouseFees.fBillno != ''">and t.f_billno like
+                concat('%', #{map.tWareHouseFees.fBillno}, '%')
             </if>
             <if test="map.tWareHouseFees.fMblno != null  and map.tWareHouseFees.fMblno != ''">and w.f_mblno like
                 concat('%', #{map.tWareHouseFees.fMblno}, '%')

+ 3 - 2
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -705,7 +705,7 @@
             AND dict.dict_type = 'storage_type'
             AND dict1.dict_type = 'data_trademodes'
             AND leg.f_qtyD != 0
-            AND leg.f_qtyblc != 0
+            AND (leg.f_qtyblc > 0 OR leg.f_grossweightblc > 0 OR leg.f_netweightblc > 0)
             <if test="fOriginalbillno != null  and fOriginalbillno != ''">and leg.f_originalbillno = #{fOriginalbillno}</if>
             <if test="fPreqty != null ">and leg.f_preqty = #{fPreqty}</if>
             <if test="fCorpid != null ">and leg.f_corpid = #{fCorpid}</if>
@@ -1132,7 +1132,8 @@
         FROM
             t_whgenleg tw
                 LEFT JOIN t_warehouse th ON th.f_id = tw.f_warehouseid
-        WHERE tw.f_qtyblc > 0
+        WHERE
+            (tw.f_qtyblc > 0 OR tw.f_grossweightblc > 0 OR f_netweightblc > 0)
           AND f_corpid = #{fCorpid}
           AND f_mblno = #{fMblno}
     </select>