Browse Source

[CODE]: 财务模块查询数据、存储主表、从表数据、生成流水号

maxianghua 4 years ago
parent
commit
1e113a7593

+ 29 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/finance/TChargeController.java

@@ -1,18 +1,25 @@
 package com.ruoyi.web.controller.warehouse.finance;
 
 import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.RepeatSubmit;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.finance.domain.TFee;
+import com.ruoyi.finance.domain.TWareHouseFees;
 import com.ruoyi.finance.service.ITFeeService;
+import com.ruoyi.framework.web.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 财务收费数据主Controller
@@ -32,6 +39,7 @@ public class TChargeController extends BaseController {
     @PreAuthorize("@ss.hasPermi('finance:charge:list')")
     @GetMapping("/list")
     public TableDataInfo list(TFee tFee) {
+        tFee.setfBilltype("SF");
         startPage();
         List<TFee> list = tFeeService.selectTFeeList(tFee);
         return getDataTable(list);
@@ -63,9 +71,14 @@ public class TChargeController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('finance:charge:add')")
     @Log(title = "财务数据主", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody TFee tFee) {
-        return toAjax(tFeeService.insertTFee(tFee));
+    @PostMapping(value = "/add")
+    @RepeatSubmit
+    public AjaxResult add(@RequestParam("tFee") String tFee,
+                          @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "SF";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.insertTFeeTFeeDo(tFee,tFeeDo,loginUser,billsType);
     }
 
     /**
@@ -87,4 +100,17 @@ public class TChargeController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] fIds) {
         return toAjax(tFeeService.deleteTFeeByIds(fIds));
     }
+
+    /**
+     *  收费查询
+     */
+    @PreAuthorize("@ss.hasPermi('finance:charge:list')")
+    @GetMapping("/chargeList")
+    public TableDataInfo chargeList(TWareHouseFees tWareHouseFees) {
+        startPage();
+        List<Map<String, Object>> list = tFeeService.warehouseBillsFeesList(tWareHouseFees);
+        return getDataTable(list);
+    }
+
+
 }

+ 13 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/finance/TContrastController.java

@@ -1,13 +1,18 @@
 package com.ruoyi.web.controller.warehouse.finance;
 
 import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.RepeatSubmit;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.finance.domain.TFee;
 import com.ruoyi.finance.service.ITFeeService;
+import com.ruoyi.framework.web.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -64,9 +69,14 @@ public class TContrastController extends BaseController {
      */
     @PreAuthorize("@ss.hasPermi('finance:contrast:add')")
     @Log(title = "财务数据主", businessType = BusinessType.INSERT)
-    @PostMapping
-    public AjaxResult add(@RequestBody TFee tFee) {
-        return toAjax(tFeeService.insertTFee(tFee));
+    @PostMapping(value = "/add")
+    @RepeatSubmit
+    public AjaxResult add(@RequestParam("tFee") String tFee,
+                          @RequestParam("tFeeDo") String tFeeDo ) {
+        String billsType = "DZ";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.insertTFeeTFeeDo(tFee,tFeeDo,loginUser,billsType);
     }
 
     /**

+ 2 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/mapper/TFeeDoMapper.java

@@ -58,4 +58,6 @@ public interface TFeeDoMapper {
      * @return 结果
      */
     public int deleteTFeeDoByIds(Long[] fIds);
+
+    int deleteByFPid(Long fId);
 }

+ 8 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/mapper/TFeeMapper.java

@@ -1,8 +1,10 @@
 package com.ruoyi.warehouse.mapper;
 
 import com.ruoyi.finance.domain.TFee;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 财务数据主Mapper接口
@@ -58,4 +60,10 @@ public interface TFeeMapper {
      * @return 结果
      */
     public int deleteTFeeByIds(Long[] fIds);
+
+    /**
+     *  查询 对账、 收费 数据
+     * @return
+     */
+    public List<Map<String, Object>> warehouseBillsFeesList(@Param("map") Map<String, Object> map);
 }

+ 22 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/ITFeeService.java

@@ -1,8 +1,12 @@
 package com.ruoyi.finance.service;
 
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.finance.domain.TFee;
+import com.ruoyi.finance.domain.TWareHouseFees;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 财务数据主Service接口
@@ -35,6 +39,17 @@ public interface ITFeeService {
      */
     public int insertTFee(TFee tFee);
 
+
+    /**
+     *  保存对账、收款
+     * @param tfee
+     * @param tfeeDo
+     * @param loginUser
+     * @param fBilltype
+     * @return
+     */
+    public AjaxResult insertTFeeTFeeDo(String tfee, String tfeeDo ,LoginUser loginUser,String fBilltype);
+
     /**
      * 修改财务数据主
      *
@@ -58,4 +73,11 @@ public interface ITFeeService {
      * @return 结果
      */
     public int deleteTFeeById(Long fId);
+
+    /**
+     *   对账、收费
+     * @param tWareHouseFees
+     * @return
+     */
+    public List<Map<String, Object>> warehouseBillsFeesList(TWareHouseFees tWareHouseFees);
 }

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

@@ -1,13 +1,25 @@
 package com.ruoyi.finance.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.finance.domain.TFee;
+import com.ruoyi.finance.domain.TFeeDo;
+import com.ruoyi.finance.domain.TWareHouseFees;
 import com.ruoyi.finance.service.ITFeeService;
 import com.ruoyi.warehouse.mapper.TFeeMapper;
+import com.ruoyi.warehouseBusiness.domain.TEnclosure;
+import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
+import com.ruoyi.warehouseBusiness.domain.TWarehousebillsfees;
+import com.ruoyi.warehouseBusiness.domain.TWarehousebillsitems;
+import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.util.*;
 
 /**
  * 财务数据主Service业务层处理
@@ -20,6 +32,12 @@ public class TFeeServiceImpl implements ITFeeService {
     @Autowired
     private TFeeMapper tFeeMapper;
 
+    @Autowired
+    private com.ruoyi.warehouse.mapper.TFeeDoMapper tFeeDoMapper;
+
+    @Autowired
+    private BillnoSerialServiceImpl billnoSerialServiceImpl;
+
     /**
      * 查询财务数据主
      *
@@ -55,6 +73,50 @@ public class TFeeServiceImpl implements ITFeeService {
     }
 
     /**
+     *    新增对账 、收费、
+     * @param tfee
+     * @param tfeeDo
+     * @param loginUser
+     * @param fBilltype
+     * @return
+     */
+    @Override
+    public AjaxResult insertTFeeTFeeDo(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
+        Long fPid = null;
+        TFee tFee = JSONArray.parseObject(tfee, TFee.class);
+        if (StringUtils.isNull(tFee.getfId())) {
+            // 如果是新数据
+            tFee.setCreateBy(loginUser.getUser().getUserName());
+            tFee.setfBilltype(fBilltype);
+            // 业务编码
+            Date time = new Date();
+            String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
+            tFee.setfBillno(billNo);
+            tFeeMapper.insertTFee(tFee);
+            fPid = tFee.getfId();
+        } else {
+            fPid = tFee.getfId();
+            tFee.setUpdateBy(loginUser.getUser().getUserName());
+            tFee.setUpdateTime(new Date());
+            tFeeMapper.updateTFee(tFee);
+            // 删除从表
+            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());
+                tFeeDoMapper.insertTFeeDo(tFeeDo);
+            }
+        }
+        return AjaxResult.success();
+    }
+
+    /**
      * 修改财务数据主
      *
      * @param tFee 财务数据主
@@ -87,4 +149,20 @@ public class TFeeServiceImpl implements ITFeeService {
     public int deleteTFeeById(Long fId) {
         return tFeeMapper.deleteTFeeById(fId);
     }
+
+    @Override
+    public List<Map<String, Object>> warehouseBillsFeesList(TWareHouseFees tWareHouseFees) {
+        // 获取费用list
+        List<Long> feeIdList =new ArrayList<Long>();
+        if(tWareHouseFees.getfFeeid() != null ){
+            List<String> lis = Arrays.asList(tWareHouseFees.getfFeeid().split(","));
+            for (String string : lis) {
+                feeIdList.add(Long.parseLong(string));
+            }
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put("feeIdList", feeIdList);
+        map.put("tWareHouseFees", tWareHouseFees);
+        return tFeeMapper.warehouseBillsFeesList(map);
+    }
 }

+ 4 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/BillnoSerialServiceImpl.java

@@ -80,6 +80,10 @@ public class BillnoSerialServiceImpl implements IBillnoSerialService {
             billNo = "HZ" + billNo;
         } else if ("WA".equals(billType)){
             billNo = "WA" + billNo;
+        } else if ("DZ".equals(billType)){
+            billNo = "DZ" + billNo;
+        } else if ("SF".equals(billType)){
+            billNo = "SF" + billNo;
         }
         return billNo;
     }

+ 4 - 0
ruoyi-warehouse/src/main/resources/mapper/finance/TFeeDoMapper.xml

@@ -116,4 +116,8 @@
         </foreach>
     </delete>
 
+    <delete id="deleteByFPid" parameterType="Long">
+        delete from t_fee_do where f_pid = #{fId}
+    </delete>
+
 </mapper>

+ 82 - 3
ruoyi-warehouse/src/main/resources/mapper/finance/TFeeMapper.xml

@@ -50,10 +50,9 @@
         where f_id = #{fId}
     </select>
 
-    <insert id="insertTFee" parameterType="TFee">
+    <insert id="insertTFee" parameterType="TFee" useGeneratedKeys="true" keyProperty="fId">
         insert into t_fee
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="fId != null">f_id,</if>
             <if test="fBillno != null">f_billno,</if>
             <if test="fCtrlcorpid != null">f_ctrlcorpid,</if>
             <if test="fCorpid != null">f_corpid,</if>
@@ -72,7 +71,6 @@
             <if test="updateTime != null">update_time,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="fId != null">#{fId},</if>
             <if test="fBillno != null">#{fBillno},</if>
             <if test="fCtrlcorpid != null">#{fCtrlcorpid},</if>
             <if test="fCorpid != null">#{fCorpid},</if>
@@ -126,4 +124,85 @@
         </foreach>
     </delete>
 
+    <select id="warehouseBillsFeesList" resultType="java.util.Map">
+        SELECT
+        t.f_corpid AS fCorpid,
+        c.f_name AS fName,
+        w.fId AS fId,
+        w.fName AS fFeesName,
+        t.f_bscorpno AS fBscorpno,
+        t.f_mblno AS fMblno,
+        t.f_product_name AS fProductName,
+        t.f_bsdate AS fBsdate,
+        t.f_billtype AS fBilltype,
+        t.f_review_date AS fReviewDate,
+        w.f_amount AS fOldAmount,
+        w.f_feeid AS fFeeid,
+        f.f_name AS fFeeName,
+        w.f_dc AS fDc,
+        w.f_amount AS fNewAmount
+        FROM
+        t_warehousebills t
+        LEFT JOIN t_corps c ON c.f_id = t.f_corpid
+        LEFT JOIN (
+        SELECT
+        f.f_id AS f_id,
+        f.f_pid AS f_pid,
+        f.f_lineno AS f_lineno,
+        f.f_corpid,
+        f.f_feeid,
+        f.f_feeUnitid,
+        f.f_qty,
+        f.f_unitprice,
+        f.f_amount,
+        f.f_currency,
+        f.f_exrate,
+        f.f_taxrate,
+        f.f_dc,
+        f.f_billstatus,
+        f.f_statement_no,
+        f.f_accamount,
+        f.f_accamount_date,
+        f.f_stlamount_no,
+        f.f_stlamount,
+        f.f_stlamount_date,
+        f.f_invnos,
+        f.f_invamount,
+        f.f_askamount,
+        f.f_status,
+        f.remark,
+        c.f_id AS fId,
+        c.f_name AS fName
+        FROM
+        t_warehousebillsfees AS f
+        LEFT JOIN t_corps AS c ON f.f_corpid = c.f_id
+        ) w ON w.f_pid = t.f_id
+        LEFT JOIN t_fees f ON w.f_feeid = f.f_id
+        <where>
+            <if test="map.tWareHouseFees.fCorpid != null  and map.tWareHouseFees.fCorpid != ''">and t.f_corpid = #{map.tWareHouseFees.fCorpid} </if>
+            <if test="map.tWareHouseFees.fToCorpid != null  and map.tWareHouseFees.fToCorpid != ''">and w.f_corpid = #{map.tWareHouseFees.fToCorpid} </if>
+            <if test="map.tWareHouseFees.fMblno != null  and map.tWareHouseFees.fMblno != ''">and t.f_mblno  like concat('%', #{map.tWareHouseFees.fMblno}, '%') </if>
+            <if test="map.tWareHouseFees.fStatementNo != null and map.tWareHouseFees.fStatementNo != ''">and w.f_statement_no  like concat('%', #{map.tWareHouseFees.fStatementNo}, '%') </if>
+            <!--<if test="map.feeIdList != null  and  map.feeIdList != '' ">
+                and  w.f_feeid in
+                <foreach collection="feeIdList" item="id" index="index" open="(" close=")" separator=",">
+                    #{id}
+                </foreach>
+            </if>-->
+            <if test='map.tWareHouseFees.timeExamine != null and map.tWareHouseFees.timeExamine[0] != null and map.tWareHouseFees.timeExamine[0]!= ""'>
+                and t.f_review_date &gt;= #{map.tWareHouseFees.timeExamine[0]}
+            </if>
+            <if test='map.tWareHouseFees.timeExamine != null and map.tWareHouseFees.timeExamine[1] != null and map.tWareHouseFees.timeExamine[1]!= ""'>
+                and t.f_review_date &lt;= #{map.tWareHouseFees.timeExamine[1]}
+            </if>
+            <if test='map.tWareHouseFees.timeInterval != null and map.tWareHouseFees.timeInterval[0] != null and map.tWareHouseFees.timeInterval[0]!= ""'>
+                and t.f_bsdate &gt;= #{map.tWareHouseFees.timeInterval[0]}
+            </if>
+            <if test='map.tWareHouseFees.timeInterval != null and map.tWareHouseFees.timeInterval[1] != null and map.tWareHouseFees.timeInterval[1]!= ""'>
+                and t.f_bsdate &lt;= #{map.tWareHouseFees.timeInterval[1]}
+            </if>
+            and  t.f_review_date IS NOT NULL
+        </where>
+    </select>
+
 </mapper>