Prechádzať zdrojové kódy

[CODE]: 费用确认

maxianghua 4 rokov pred
rodič
commit
d985d968e8

+ 14 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/fleet/finance/FTmsaccbillsController.java

@@ -98,5 +98,19 @@ public class FTmsaccbillsController extends BaseController {
         return fTmsaccbillsService.queryRemove(fId);
     }
 
+    /**
+     *   确认对账
+     */
+    @PreAuthorize("@ss.hasPermi('finances:contrast:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/confirm")
+    @RepeatSubmit
+    public AjaxResult confirm(@RequestParam("tFee") String tFee,
+                              @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "DZ";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return fTmsaccbillsService.confirm(tFee,tFeeDo,loginUser,billsType);
+    }
 
 }

+ 14 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/fleet/finance/TChargesController.java

@@ -100,5 +100,19 @@ public class TChargesController extends BaseController {
         return fTmsaccbillsService.queryRemove(fId);
     }
 
+    /**
+     *   确认收费
+     */
+    @PreAuthorize("@ss.hasPermi('finances:charge:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/confirm")
+    @RepeatSubmit
+    public AjaxResult confirm(@RequestParam("tFee") String tFee,
+                              @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "JSSF";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return fTmsaccbillsService.confirm(tFee,tFeeDo,loginUser,billsType);
+    }
 
 }

+ 14 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/fleet/finance/TPaymentsController.java

@@ -100,5 +100,18 @@ public class TPaymentsController extends BaseController {
         return fTmsaccbillsService.queryRemove(fId);
     }
 
-
+    /**
+     *   确认收费
+     */
+    @PreAuthorize("@ss.hasPermi('finances:payment:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/confirm")
+    @RepeatSubmit
+    public AjaxResult confirm(@RequestParam("tFee") String tFee,
+                              @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "JSFF";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return fTmsaccbillsService.confirm(tFee,tFeeDo,loginUser,billsType);
+    }
 }

+ 3 - 0
ruoyi-fleet/src/main/java/com/ruoyi/orderManagement/finance/mapper/FTmsaccbillsitemsMapper.java

@@ -1,6 +1,7 @@
 package com.ruoyi.orderManagement.finance.mapper;
 
 import com.ruoyi.orderManagement.finance.domain.FTmsaccbillsitems;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -62,4 +63,6 @@ public interface FTmsaccbillsitemsMapper
     public int deleteFTmsaccbillsitemsByIds(Long[] ids);
 
     int deleteByFPid(Long fId);
+
+    int tfeeDoFollowUpdate(@Param("fPid") Long fPid, @Param("fettle") Long fettle);
 }

+ 2 - 0
ruoyi-fleet/src/main/java/com/ruoyi/orderManagement/finance/service/IFTmsaccbillsService.java

@@ -74,4 +74,6 @@ public interface IFTmsaccbillsService
     public AjaxResult insertTFeeTFeeDo(String tfee, String tfeeDo , LoginUser loginUser, String fBilltype);
 
     public AjaxResult queryRemove(Long fId);
+
+    public AjaxResult confirm(String tfee, String tfeeDo ,LoginUser loginUser,String fBilltype);
 }

+ 96 - 2
ruoyi-fleet/src/main/java/com/ruoyi/orderManagement/finance/service/impl/FTmsaccbillsServiceImpl.java

@@ -26,6 +26,8 @@ import com.ruoyi.system.service.ISysDictDataService;
 import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.util.*;
 
@@ -98,7 +100,10 @@ public class FTmsaccbillsServiceImpl implements IFTmsaccbillsService
                 // 主表数
                 Ftmsorderbills ftmsorderbills = ftmsorderbillsMapper.selectftmsorderbillsById(fees.getfSrcpid());
                 Ftmsorderbillsfees ftmsorderbillsfees = ftmsorderbillsfeesMapper.selectFTmsorderbillsfeesById(fees.getfSrcid());
-                TFees tFees= tFeesMapper.selectTFeesById(ftmsorderbillsfees.getfFeeid());
+                TFees tFees = new TFees();
+                if(null!=ftmsorderbillsfees.getfFeeid()){
+                     tFees= tFeesMapper.selectTFeesById(ftmsorderbillsfees.getfFeeid());
+                }
                 // 字典宝
                 SysDictData sysDictData =new SysDictData();
                 sysDictData.setDictType("data_unitfees");
@@ -117,7 +122,11 @@ public class FTmsaccbillsServiceImpl implements IFTmsaccbillsService
                 map1.put("createTime",ftmsorderbillsfees.getCreateTime()); //业务日期
                 map1.put("actId",ftmsorderbillsfees.getActId()); // 业务类型
                 map1.put("billType",ftmsorderbills.getBillType()); // 作业类型
-                map1.put("fFeeName",tFees.getfName()); // 作业类型
+                if(null!=tFees.getfName()){
+                    map1.put("fFeeName",tFees.getfName()); // 作业类型
+                }else {
+                    map1.put("fFeeName",null); // 作业类型
+                }
                 feesId.add(ftmsorderbillsfees.getfFeeunitid());
                 map1.put("fSrcdc",fees.getDc()); // 收付
                 map1.put("fAmt",fees.getAmtOrg()); // 数量
@@ -284,4 +293,89 @@ public class FTmsaccbillsServiceImpl implements IFTmsaccbillsService
             return AjaxResult.success("2");
         }
     }
+
+    @Override
+    public AjaxResult confirm(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
+        FTmsaccbills fTmsaccbills = JSONArray.parseObject(tfee, FTmsaccbills.class);
+        fTmsaccbills.setBillStatus(4L);
+        if (StringUtils.isNull(fTmsaccbills.getId())) {
+            // 如果是新数据
+            fTmsaccbills.setCreateBy(loginUser.getUser().getUserName());
+            fTmsaccbills.setCreateTime(new Date());
+            // 业务编码
+            Date time = new Date();
+            String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
+            fTmsaccbills.setfBillno(billNo);
+            fTmsaccbills.setfBilltype(fBilltype);
+            fTmsaccbillsMapper.insertFTmsaccbills(fTmsaccbills);
+        } else {
+            fTmsaccbills.setUpdateBy(loginUser.getUser().getUserName());
+            fTmsaccbills.setUpdateTime(new Date());
+            fTmsaccbillsMapper.updateFTmsaccbills(fTmsaccbills);
+            // 删除从表
+            fTmsaccbillsitemsMapper.deleteByFPid(fTmsaccbills.getId());
+        }
+        //  财务从表
+        if (StringUtils.isNotNull(tfeeDo)) {
+            JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
+            List<FTmsaccbillsitems> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), FTmsaccbillsitems.class);
+            for (FTmsaccbillsitems tFeeDo : tFeeDoList) {
+                tFeeDo.setSrcId(fTmsaccbills.getId());
+                tFeeDo.setCreateBy(loginUser.getUser().getUserName());
+                tFeeDo.setCreateTime(new Date());
+                fTmsaccbillsitemsMapper.insertFTmsaccbillsitems(tFeeDo);
+            }
+        }
+
+        if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
+            JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
+            List<FTmsaccbillsitems> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), FTmsaccbillsitems.class);
+            for (FTmsaccbillsitems tFeeDo  : tFeeDoList) {
+                // 跟新费用明细
+                int m = updateBillsFees(fTmsaccbills.getId(),tFeeDo,fBilltype);
+                if (m == 0) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("更新费用明细失败");
+                }
+            }
+        }
+        AjaxResult ajaxResult = tfeeFollow(fTmsaccbills.getId(), 6L);
+        Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
+        return ajaxResult;
+    }
+
+    @Transactional
+    public  int  updateBillsFees(Long fid,FTmsaccbillsitems tFeeDo,String billsType){
+        // 查询从表数据
+        FTmsaccbills tFee = fTmsaccbillsMapper.selectFTmsaccbillsById(fid);
+        if(billsType.equals("JSSF") || billsType.equals("JSFF")){
+            billsType="DC";
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("tFee", tFee);
+        map.put("billType", billsType);
+        map.put("tFeeDo", tFeeDo);
+        return ftmsorderbillsfeesMapper.updateFTmsorderbillsfee(map);
+    }
+
+    @Transactional
+    public AjaxResult tfeeFollow(Long fPid, long fettle) {
+        if (StringUtils.isNull(fPid)) {
+            return AjaxResult.error("财务更新状态未找到主表信息,请与管理员联系");
+        }
+        FTmsaccbills tFee = new FTmsaccbills();
+        tFee.setId(fPid);
+        tFee.setBillStatus(fettle);
+        int tFeeUpdateResult = fTmsaccbillsMapper.updateFTmsaccbills(tFee);
+        if (tFeeUpdateResult <= 0) {
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return AjaxResult.error("更新财务明细状态失败,请联系管理员");
+        }
+        try{
+            int itemUpdateResult = fTmsaccbillsitemsMapper.tfeeDoFollowUpdate(fPid,fettle);
+        } catch (Exception exception){
+            return AjaxResult.error("更新财务明细状态失败,请联系管理员");
+        }
+        return AjaxResult.success();
+    }
 }

+ 4 - 0
ruoyi-fleet/src/main/java/com/ruoyi/statusTracking/mapper/FtmsorderbillsfeesMapper.java

@@ -1,8 +1,10 @@
 package com.ruoyi.statusTracking.mapper;
 
 import com.ruoyi.statusTracking.domain.Ftmsorderbillsfees;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 订单费用Mapper接口
@@ -81,4 +83,6 @@ public interface FtmsorderbillsfeesMapper {
      * @return  结果
      */
     public int deleteFTmsorderbillsfees(Ftmsorderbillsfees ftmsorderbillsfees);
+
+    public int updateFTmsorderbillsfee(@Param("map") Map<String, Object> map);
 }

+ 7 - 0
ruoyi-fleet/src/main/resources/mapper/finance/FTmsaccbillsitemsMapper.xml

@@ -132,4 +132,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <delete id="deleteByFPid" parameterType="Long">
         delete from F_TMSACCBILLSITEMS where src_id = #{fId}
     </delete>
+    <update id="tfeeDoFollowUpdate" parameterType="Long">
+        update
+            F_TMSACCBILLSITEMS
+        set bill_status = #{fettle}
+        where
+            src_id = #{fPid}
+    </update>
 </mapper>

+ 30 - 1
ruoyi-fleet/src/main/resources/mapper/statusTracking/ftmsorderbillsfeesMapper.xml

@@ -311,5 +311,34 @@
     <delete id="deleteFTmsorderbillsfeesByPIdAndActId" parameterType="Long">
         delete from F_TMSORDERBILLSFEES where f_pid = #{fId} and act_id = 1090
     </delete>
-
+    <update id="updateFTmsorderbillsfee" parameterType="Map">
+        update F_TMSORDERBILLSFEES
+        <trim prefix="SET" suffixOverrides=",">
+            /*判断确认对账*/
+            <if test="map.billType == 'DZ'">
+                f_statement_no = #{map.tFee.fBillno},
+                f_accamount = f_accamount + #{map.tFeeDo.fAmt},
+                f_accamount_date =  #{map.tFee.fAccbilldate}
+            </if>
+            /*判断撤销对账*/
+            <if test="map.billType == 'DZRevoke'">
+                f_statement_no =  #{map.tFee.fBillno},
+                f_accamount = f_accamount - #{map.tFeeDo.fAmt},
+                f_accamount_date = #{map.tFee.fAccbilldate}
+            </if>
+            /*判断收付款*/
+            <if test="map.billType == 'DC'">
+                f_stlamount_no = #{map.tFee.fBillno},
+                f_stlamount = f_stlamount +  #{map.tFeeDo.fAmt},
+                f_stlamount_date =#{map.tFee.fAccbilldate}
+            </if>
+            /*判断撤销收付款*/
+            <if test="map.billType == 'DCRevoke'">
+                f_stlamount_no = #{map.tFee.fBillno},
+                f_stlamount = f_stlamount -  #{map.tFeeDo.fAmt},
+                f_stlamount_date =#{map.tFee.fAccbilldate}
+            </if>
+        </trim>
+        where f_id = #{map.tFeeDo.fSrcid}
+    </update>
 </mapper>