Explorar o código

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

changhaoning hai 1 ano
pai
achega
dc3c64aa64
Modificáronse 22 ficheiros con 506 adicións e 274 borrados
  1. 5 0
      pom.xml
  2. 0 60
      src/main/java/com/dk/mdm/config/XxlJobConfig.java
  3. 1 50
      src/main/java/com/dk/mdm/controller/mst/CusFollowController.java
  4. 11 0
      src/main/java/com/dk/mdm/controller/mst/StaffController.java
  5. 10 5
      src/main/java/com/dk/mdm/controller/report/ReportController.java
  6. 2 0
      src/main/java/com/dk/mdm/mapper/mac/RecPayMapper.xml
  7. 7 0
      src/main/java/com/dk/mdm/mapper/mst/StaffMapper.java
  8. 5 0
      src/main/java/com/dk/mdm/mapper/mst/StaffMapper.xml
  9. 7 0
      src/main/java/com/dk/mdm/mapper/report/ReportMapper.java
  10. 7 1
      src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml
  11. 1 1
      src/main/java/com/dk/mdm/model/pojo/ivt/InboundItem.java
  12. 6 1
      src/main/java/com/dk/mdm/model/response/mac/RecPayResponse.java
  13. 1 0
      src/main/java/com/dk/mdm/service/common/CommonService.java
  14. 5 4
      src/main/java/com/dk/mdm/service/ivt/inbound/InboundOtherService.java
  15. 2 0
      src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseReturnService.java
  16. 45 45
      src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java
  17. 135 58
      src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java
  18. 12 0
      src/main/java/com/dk/mdm/service/mac/ReceiptService.java
  19. 170 12
      src/main/java/com/dk/mdm/service/mst/CusFollowService.java
  20. 1 0
      src/main/java/com/dk/mdm/service/mst/GoodsSkuService.java
  21. 12 0
      src/main/java/com/dk/mdm/service/mst/StaffService.java
  22. 61 37
      src/main/java/com/dk/mdm/service/report/ReportService.java

+ 5 - 0
pom.xml

@@ -116,6 +116,11 @@
             <artifactId>weixin-java-miniapp</artifactId>
             <version>4.4.0</version>
         </dependency>
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.4.3</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 0 - 60
src/main/java/com/dk/mdm/config/XxlJobConfig.java

@@ -1,60 +0,0 @@
-package com.dk.mdm.config;
-
-import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @desc   : xxl-job config
- * @author : 洪旭东
- * @date   : 2022-05-13 15:44
- */
-@Configuration
-public class XxlJobConfig {
-    private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
-
-    @Value("${xxl.job.admin.addresses}")
-    private String adminAddresses;
-
-    @Value("${xxl.job.accessToken}")
-    private String accessToken;
-
-    @Value("${xxl.job.executor.appname}")
-    private String appname;
-
-    @Value("${xxl.job.executor.address}")
-    private String address;
-
-    @Value("${xxl.job.executor.ip}")
-    private String ip;
-
-    @Value("${xxl.job.executor.port}")
-    private int port;
-
-    @Value("${xxl.job.executor.logpath}")
-    private String logPath;
-
-    @Value("${xxl.job.executor.logretentiondays}")
-    private int logRetentionDays;
-
-
-    @Bean
-    public XxlJobSpringExecutor xxlJobExecutor() {
-        logger.info(">>>>>>>>>>> xxl-job config init.");
-        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
-        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
-        xxlJobSpringExecutor.setAppname(appname);
-        xxlJobSpringExecutor.setAddress(address);
-        xxlJobSpringExecutor.setIp(ip);
-        xxlJobSpringExecutor.setPort(port);
-        xxlJobSpringExecutor.setAccessToken(accessToken);
-        xxlJobSpringExecutor.setLogPath(logPath);
-        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
-
-        return xxlJobSpringExecutor;
-    }
-
-}

+ 1 - 50
src/main/java/com/dk/mdm/controller/mst/CusFollowController.java

@@ -144,56 +144,7 @@ public class CusFollowController{
     @GetMapping("wx_message_test")
     @ResponseBody
     public void wxMessageTest(HttpServletRequest request, HttpServletResponse response){
-        String signature = request.getParameter("signature");
-        String timestamp = request.getParameter("timestamp");
-
-        String nonce = request.getParameter("nonce");
-
-        String echostr = request.getParameter("echostr");
-        // 和小程序后台配置的token保持一致
-        String token = "dPM4EILWQqeEsEmft9pKMIll4VGZ6pJK";
-        // 将下面三个参数拼接成字符串
-        StringBuffer content = new StringBuffer();
-        content.append(timestamp);
-        content.append(nonce);
-        content.append(token);
-        PrintWriter out = null;
-        try {
-            out = response.getWriter();
-            MessageDigest md = MessageDigest.getInstance("SHA-1");
-            // 对拼接好的字符串进行sha1加密
-            byte[] digest = md.digest(content.toString().getBytes());
-            String tmpStr = byteToStr(digest);
-            //获得加密后的字符串与signature对比
-            if (tmpStr != null && tmpStr.equals(signature.toUpperCase())){
-                out.print(echostr);
-                out.flush();
-            }
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            out.close();
-        }
-    }
-
-    private static String byteToStr(byte[] byteArray) {
-        String strDigest = "";
-        for (int i = 0; i < byteArray.length; i++) {
-            strDigest += byteToHexStr(byteArray[i]);
-        }
-        return strDigest;
-    }
-
-    private static String byteToHexStr(byte mByte) {
-        char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
-                'B', 'C', 'D', 'E', 'F' };
-        char[] tempArr = new char[2];
-        tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
-        tempArr[1] = Digit[mByte & 0X0F];
-        String s = new String(tempArr);
-        return s;
+        cusFollowService.wxMessageTest(request, response);
     }
 
 }

+ 11 - 0
src/main/java/com/dk/mdm/controller/mst/StaffController.java

@@ -121,6 +121,17 @@ public class StaffController {
     }
 
     /**
+     * @desc : 更新员工的登录标识
+     * @author : 姜永辉
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "更新员工的登录标识", notes = "更新员工的登录标识")
+    @PostMapping({"update_feign_staff_flg_can_login"})
+    public ResponseResultVO<?> updateFeignStaffFlgCanLogin(@RequestBody List<String> list) {
+        return staffService.updateFeignStaffFlgCanLogin(list);
+    }
+
+    /**
      * @desc : 注册商户时候插入  角色 基础资料(仓库 渠道 收入 支出 入库 出库 账户 来源 盈亏原因) 计量单位 种类  打印票据  等等。
      *         返回角色的数据
      * @author : 姜永辉

+ 10 - 5
src/main/java/com/dk/mdm/controller/report/ReportController.java

@@ -1,15 +1,10 @@
 package com.dk.mdm.controller.report;
 
-import com.alibaba.fastjson.JSONObject;
-import com.dk.common.controller.BaseController;
 import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
-import com.dk.common.service.BaseService;
 import com.dk.common.util.RedisUtil;
-import com.dk.mdm.service.common.CommonService;
 import com.dk.mdm.service.report.ReportService;
-import com.google.gson.JsonObject;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -388,6 +383,16 @@ public class ReportController  {
         return reportService.getBusinessOverview(param);
     }
 
+    /**
+     * @desc   : 资金日记账(web)
+     * @author : 姜宁
+     * @date   : 2024/7/19 15:05
+     */
+    @PostMapping("get_fund_report_web")
+    public ResponseResultVO<PageList<Map<String, Object>>> getFundReportWeb(@RequestBody  Map<String, Object> param) {
+        return reportService.getFundReportWeb(param);
+    }
+
 }
 
 

+ 2 - 0
src/main/java/com/dk/mdm/mapper/mac/RecPayMapper.xml

@@ -81,6 +81,7 @@
         <result column="contact_name" property="contactName"/>
         <result column="contact_phone" property="contactPhone"/>
         <result column="return_address" property="returnAddress"/>
+        <result column="address_no" property="addressNo"/>
 
     </resultMap>
 
@@ -527,6 +528,7 @@
                tmc.cus_name         as "cusName",
                tmc.cus_phone        as "cusPhone",
                tmc.address_full     as "addressFull",
+               tmc.address_no   ,
                tmsp.sup_id,
                tmsp.sup_code,
                tmsp.sup_name,

+ 7 - 0
src/main/java/com/dk/mdm/mapper/mst/StaffMapper.java

@@ -75,6 +75,13 @@ public interface StaffMapper extends BaseMapper<Staff>{
     boolean updateFlgInit(Map<String, Object> params);
 
     /**
+     * @desc : 更新员工的登录标识
+     * @author : 姜永辉
+     * @date : 2024/6/21 10:21
+     */
+    int updateFeignStaffFlgCanLogin(List<String> list);
+
+    /**
      * @desc : 通过用户id更新负责人
      * @author : 刘尧
      * @date : 2024/6/21 10:43

+ 5 - 0
src/main/java/com/dk/mdm/mapper/mst/StaffMapper.xml

@@ -263,6 +263,11 @@
         UPDATE dkic_b.t_mst_staff SET flg_init = false
         WHERE cp_id = #{cpId}
     </update>
+    <!--更新员工的登录标识 '登录系统(1:PC端,2:移动端,3:PC+移动端, 4:无) -->
+    <update id="updateFeignStaffFlgCanLogin">
+        UPDATE dkic_b.t_mst_staff SET flg_can_login = false ,login_type = 4
+        WHERE staff_id = any(#{list,typeHandler= UuidListTypeHandler})
+    </update>
     <!--通过用户id更新负责人-->
     <update id="updateFlgInitById">
         UPDATE dkic_b.t_mst_staff SET flg_init = true

+ 7 - 0
src/main/java/com/dk/mdm/mapper/report/ReportMapper.java

@@ -362,6 +362,13 @@ public interface ReportMapper extends BaseMapper<JSONObject> {
      */
     Map<String, Object> getOrderSummaryItem(Map param);
 
+    /**
+     * @desc   : 资金日记账
+     * @author : 姜宁
+     * @date   : 2024/7/19 15:50
+     */
+    List<Map<String, Object>> getFundReportWeb(Map param);
+
     List<Map<String, Object>> getOutboundAmtByUser(Map<String, Object> params);
 
     Map<String, Object> getStartAmt(Map<String, Object> params);

+ 7 - 1
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -2678,7 +2678,7 @@
     <!-- 资金日记账-->
     <select id="getFundReport" resultType="java.util.Map">
         SELECT *
-        FROM dkic_b.f_get_fund_report(#{accDateStart}::date,#{accDateEnd}::date,#{cpId},#{currentPage},#{pageSize},#{macId}::uuid)
+        FROM dkic_b.f_get_fund_report(#{accDateStart}::date,#{accDateEnd}::date,#{cpId},#{currentPage},#{pageSize},#{macIds, typeHandler=UuidListTypeHandler}::uuid[])
     </select>
 
     <!-- 销售简报-->
@@ -3372,5 +3372,11 @@
         select dkic_b.f_get_order_summary_item(#{cpId}, #{querys, typeHandler=JsonTypeHandler}, #{lang})
     </select>
 
+    <!-- 资金日记账-->
+    <select id="getFundReportWeb" resultType="java.util.Map">
+        SELECT *
+        FROM
+            dkic_b.f_get_fund_report_web(#{accDateStart}::date,#{accDateEnd}::date,#{cpId},#{currentPage},#{pageSize},#{macIds, typeHandler=UuidListTypeHandler}::uuid[])
+    </select>
     <!--endregion-->
 </mapper>

+ 1 - 1
src/main/java/com/dk/mdm/model/pojo/ivt/InboundItem.java

@@ -230,7 +230,7 @@ public class InboundItem extends PageInfo<InboundItem> implements Serializable {
 
 
     /**
-     * 库存数量 (库存数量=商品数量-出库数量)
+     * 库存数量 (库存数量=商品数量-出库数量) (不要了,2024-8-19 周兴)
      */
     @Excel(name = "库存数量 (库存数量=商品数量-出库数量)")
     @ApiModelProperty(value = "库存数量 (库存数量=商品数量-出库数量)")

+ 6 - 1
src/main/java/com/dk/mdm/model/response/mac/RecPayResponse.java

@@ -318,7 +318,12 @@ public class RecPayResponse extends PageInfo<RecPayResponse> implements Serializ
 
     @ApiModelProperty(value = "退货地址")
     private String returnAddress;
-
+    /**
+     * 门牌号
+     */
+    @Excel(name = "门牌号")
+    @ApiModelProperty(value = "门牌号")
+    private String addressNo;
     /**
      * 资金账户编码
      */

+ 1 - 0
src/main/java/com/dk/mdm/service/common/CommonService.java

@@ -746,6 +746,7 @@ public class CommonService extends BaseService<Map<String, Object>> {
         }
         //部门
         if (dataSourceCode.equals("org")) {
+            map.put("flgBusiness", param.get("flgBusiness"));
             list = commonMapper.getOrg(map);
         }
         //品牌

+ 5 - 4
src/main/java/com/dk/mdm/service/ivt/inbound/InboundOtherService.java

@@ -305,8 +305,8 @@ public class InboundOtherService extends BaseService<Inbound> {
                         inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
                         inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.OTHER_INBOUND.getValue());
                         //编辑之前的数
-                        inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty());
-                        inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt());
+                        inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty().subtract(inboundItemResponse.getReturnQty()));
+                        inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt().subtract(inboundItemResponse.getReturnAmt()));
                         //编辑之后的数
                         inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty());
                         inboundItemVO.setIntoAmt(inboundItemVO.getIntoingAmt());
@@ -624,9 +624,10 @@ public class InboundOtherService extends BaseService<Inbound> {
                 inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.OTHER_INBOUND.getValue());
                 //编辑之前的数
                 if (inboundItemResponse.getIntoQty().compareTo(BigDecimal.ZERO) > 0) {
-                    inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty());
-                    inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt());
+                    inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty().subtract(inboundItemResponse.getReturnQty()));
+                    inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt().subtract(inboundItemResponse.getReturnAmt()));
                 }
+
                 inboundItemVO.setAddOrEditFlag(true);
                 //endregion
             }

+ 2 - 0
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseReturnService.java

@@ -188,6 +188,7 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                     ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
         }
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
+
             //region 将库存需要的参数赋值
             inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
             inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_RETURN.getValue());
@@ -351,6 +352,7 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                 if (inboundVO.getDeleteItemList() != null && inboundVO.getDeleteItemList().size() > 0) {
                     for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
                         if (inboundItemVO.getItemId() != null) {
+
                             //region 将库存需要的参数赋值
                             inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
                             inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_RETURN.getValue());

+ 45 - 45
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java

@@ -235,7 +235,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         //endregion
 
         //region 采购总单
-        this.insertOrderMessageByEdit(inboundVO,inboundVO.getItemList());
+        this.insertOrderMessageByEdit(inboundVO, inboundVO.getItemList());
         //endregion
 
         //region 明细
@@ -344,12 +344,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 新建采购入库修改采购订单信息
-     * @date   : 2024/7/6 15:15
+     * @desc : 新建采购入库修改采购订单信息
+     * @date : 2024/7/6 15:15
      * @author : 寇珊珊
      */
     @Transactional(rollbackFor = {Exception.class})
-    public  void insertOrderMessageByEdit(InboundVO inboundVO , List<InboundItemVO> itemList){
+    public void insertOrderMessageByEdit(InboundVO inboundVO, List<InboundItemVO> itemList) {
         //入库明细汇总
         Map<String, List<InboundItemVO>> purchaseIntoItemVOListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
         //入库明细汇总循环
@@ -472,8 +472,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                         inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
                         inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
                         //编辑之前的数
-                        inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty());
-                        inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt());
+                        inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty().subtract(inboundItemResponse.getReturnQty()));
+                        inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt().subtract(inboundItemResponse.getReturnAmt()));
                         //编辑之后的数
                         inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty());
                         inboundItemVO.setIntoAmt(inboundItemVO.getIntoingAmt());
@@ -759,12 +759,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 采购入库编辑修改订单信息
-     * @date   : 2024/7/8 9:12
+     * @desc : 采购入库编辑修改订单信息
+     * @date : 2024/7/8 9:12
      * @author : 寇珊珊
      */
     @Transactional(rollbackFor = {Exception.class})
-        public void updateOrderMessageByEdit(InboundResponse inboundResponse, List<InboundItemVO> itemList, List<InboundItemVO> deleteItemList) {
+    public void updateOrderMessageByEdit(InboundResponse inboundResponse, List<InboundItemVO> itemList, List<InboundItemVO> deleteItemList) {
         //入库明细汇总
         Map<String, List<InboundItemVO>> purchaseIntoItemVOListMap = itemList.stream().collect(Collectors.groupingBy(InboundItemVO::getFromId));
         //入库明细删除汇总
@@ -772,8 +772,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         //人库明细汇总循环
         for (String fromId : purchaseIntoItemVOListMap.keySet()) {
             //有需要删除的修改数据
-            if(delPurchaseIntoItemVOListMap!=null  && delPurchaseIntoItemVOListMap.keySet().size()>0){
-                //库明细删除汇总循环
+            if (delPurchaseIntoItemVOListMap != null && delPurchaseIntoItemVOListMap.keySet().size() > 0) {
+                //库明细删除汇总循环
                 for (String delFromId : delPurchaseIntoItemVOListMap.keySet()) {
                     //新建入库明细来源Id = 删除入库明细来源Id
                     if (fromId.equals(delFromId)) {
@@ -792,13 +792,13 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                         BigDecimal updatePurchaseIntoingAmt = BigDecimal.ZERO;
                         //已入库
                         if (Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())) {
-                            updatePurchaseIntoQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-                            updatePurchaseIntoAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                            updatePurchaseIntoQty = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoQty() != null).map(InboundItemVO::getUpdatePurchaseIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                            updatePurchaseIntoAmt = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoAmt() != null).map(InboundItemVO::getUpdatePurchaseIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                         }
                         //入库中
                         else {
-                            updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-                            updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                            updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingQty() != null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                            updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingAmt() != null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                         }
                         //endregion
 
@@ -856,7 +856,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 }
             }
             //没有需要删除的修改数据
-            else{
+            else {
 
                 //region  提取新建分组后的明细
                 List<InboundItemVO> purchaseIntoItemVOListGroup = purchaseIntoItemVOListMap.get(fromId);
@@ -875,8 +875,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 }
                 //入库中
                 else {
-                    updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-                    updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingQty() != null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                    updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingAmt() != null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                 }
                 //endregion
 
@@ -1073,8 +1073,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 采购入库作废修改采购订单信息
-     * @date   : 2024/7/6 15:27
+     * @desc : 采购入库作废修改采购订单信息
+     * @date : 2024/7/6 15:27
      * @author : 寇珊珊
      */
     @Transactional(rollbackFor = {Exception.class})
@@ -1137,10 +1137,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-         * @desc : 采购入库办理
-         * @date : 2024/3/7 15:47
-         * @author : 寇珊珊
-         */
+     * @desc : 采购入库办理
+     * @date : 2024/3/7 15:47
+     * @author : 寇珊珊
+     */
     @Transactional(rollbackFor = {Exception.class})
     public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
 
@@ -1201,8 +1201,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
                 //编辑之前的数
                 if (inboundItemResponse.getIntoQty().compareTo(BigDecimal.ZERO) > 0) {
-                    inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty());
-                    inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt());
+                    inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty().subtract(inboundItemResponse.getReturnQty()));
+                    inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt().subtract(inboundItemResponse.getReturnAmt()));
                 }
                 inboundItemVO.setAddOrEditFlag(true);
                 //endregion
@@ -1332,7 +1332,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         //endregion
 
         //region  修改采购订单
-        this.updateOrderMessageByHandle(inboundVO.getItemList(),inboundVO.getDeleteItemList());
+        this.updateOrderMessageByHandle(inboundVO.getItemList(), inboundVO.getDeleteItemList());
         //endregion
 
         //region  入账
@@ -1350,8 +1350,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 采购入库办理修改采购订单信息
-     * @date   : 2024/7/8 14:03
+     * @desc : 采购入库办理修改采购订单信息
+     * @date : 2024/7/8 14:03
      * @author : 寇珊珊
      */
     @Transactional(rollbackFor = {Exception.class})
@@ -1374,8 +1374,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                         BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
                         BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                         //分组后的明细 原入库数量和金额总和
-                        BigDecimal updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-                        BigDecimal updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        BigDecimal updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingQty() != null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                        BigDecimal updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingAmt() != null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                         //endregion
 
                         //region 提取删除分组后的明细
@@ -1417,8 +1417,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 BigDecimal purchaseSumQty = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
                 BigDecimal purchaseSumAmt = purchaseIntoItemVOListGroup.stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                 //分组后的明细 原入库数量和金额总和
-                BigDecimal updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingQty()!=null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-                BigDecimal updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it->it.getUpdatePurchaseIntoingAmt()!=null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                BigDecimal updatePurchaseIntoingQty = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingQty() != null).map(InboundItemVO::getUpdatePurchaseIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                BigDecimal updatePurchaseIntoingAmt = purchaseIntoItemVOListGroup.stream().filter(it -> it.getUpdatePurchaseIntoingAmt() != null).map(InboundItemVO::getUpdatePurchaseIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
                 //endregion
 
                 //region 反写订单数据
@@ -1555,8 +1555,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 采购入库撤销修改采购订单信息
-     * @date   : 2024/7/8 16:50
+     * @desc : 采购入库撤销修改采购订单信息
+     * @date : 2024/7/8 16:50
      * @author : 寇珊珊
      */
     @Transactional(rollbackFor = {Exception.class})
@@ -1597,8 +1597,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 校验库存是否存在和库存量是否足够本次退货作废
-     * @date   : 2024/7/6 10:52
+     * @desc : 校验库存是否存在和库存量是否足够本次退货作废
+     * @date : 2024/7/6 10:52
      * @author : 寇珊珊
      */
     @Transactional(
@@ -1655,10 +1655,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     this.checkInventoryExist(inboundItemResponseList);
                     //endregion
 
-                    //region 退账
-                    if (inboundResponse.getReceivableId() != null) {
-                        accountService.reversePayable(inboundResponse.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
-                    }
+                    //region 退账 不需要判断,判断反而不对,周兴 202407020
+//                    if (inboundResponse.getReceivableId() != null) {
+                    accountService.reversePayable(inboundResponse.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
+//                    }
                     //endregion
 
                     //region 修改明细
@@ -1695,10 +1695,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     );
                     //endregion
 
-                    //region  入账
-                    if (inboundResponse.getReceivableId() != null) {
-                        accountService.accPayable(inboundResponse.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
-                    }
+                    //region  入账 作废把账作废就行,不要再入账了 周兴 202407020
+//                    if (inboundResponse.getReceivableId() != null) {
+//                         accountService.accPayable(inboundResponse.getIntoId(), Constant.InventoryDocCode.INTOBOUND.getTableName());
+//                    }
                     //endregion
 
                     //region   调用库存

+ 135 - 58
src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java

@@ -144,6 +144,16 @@ public class InventoryService extends BaseService<Inventory> {
             inOutRecordVO.setAccDate(LocalDate.now());
             //可以输入负数标识  入库没有限制 所以这里给true 为了下面的校验库存
             inOutRecordVO.setCanNegativeFlag(true);
+            //重新赋值入库数量和入库金额要考虑到退货的情况
+            if (Constant.InventoryType.INBOUND.getName().equals(inOutRecordVO.getInventoryType()) &&
+                    !Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())
+            ) {
+                InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inOutRecordVO.getItemId());
+                if (inboundItemResponse != null && inboundItemResponse.getReturnQty() != null) {
+                    inOutRecordVO.setIntoQty(inOutRecordVO.getIntoQty().subtract(inboundItemResponse.getReturnQty()));
+                    inOutRecordVO.setIntoAmt(inOutRecordVO.getIntoAmt().subtract(inboundItemResponse.getReturnAmt()));
+                }
+            }
         }
         //region 校验是否传库存需要的数据
         this.checkInventory(inOutRecordVOList);
@@ -410,7 +420,7 @@ public class InventoryService extends BaseService<Inventory> {
                 if (delOutList.size() > 0) {
                     delOutList = delOutDetail.toJavaList(InOutRecordVO.class);
                     //赋值并校验库存流水数据
-                    delOutList = this.setInOutRecordMessageByInto(delOutList);
+                    delOutList = this.setInOutRecordMessageByOut(delOutList);
                     //库存相关反写
                     this.warehouseAdjustmentDelOut(delOutList);
                 } else {
@@ -616,7 +626,8 @@ public class InventoryService extends BaseService<Inventory> {
                     //endregion
 
                     //region  修改库存数量,可用量,金额等信息
-                    this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+//                    this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+                    this.updateInventory(inventoryResponse, inOutRecordVO);
                     //endregion
 
                     //region 库存流水
@@ -716,7 +727,8 @@ public class InventoryService extends BaseService<Inventory> {
                     //endregion
 
                     //修改库存数量
-                    this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+//                    this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+                    this.updateInventory(inventoryResponse, inOutRecordVO);
 
                     //region 库存流水
                     this.insertInboundRecord(inOutRecordVO);
@@ -912,6 +924,7 @@ public class InventoryService extends BaseService<Inventory> {
             //实体转换
             InOutRecord inOutRecordNeg = inOutRecordConvert.convertToPo(inOutRecordVO);
             //新建
+            inOutRecordNeg.setRecordId(null);
             inOutRecordMapper.insert(inOutRecordNeg);
 
             //新建正数流水
@@ -925,6 +938,7 @@ public class InventoryService extends BaseService<Inventory> {
             //业务单明细Id
             inOutRecord.setBiznisItemId(inOutRecordVO.getIntoItemId());
             //新建
+            inOutRecord.setRecordId(null);
             inOutRecordMapper.insert(inOutRecord);
 
         }
@@ -935,12 +949,20 @@ public class InventoryService extends BaseService<Inventory> {
                     (!Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) &&
                             Constant.InventoryType.INBOUND.getName().equals(inOutRecordVO.getInventoryType()))
             ) {
+                BigDecimal sumReturnQtyItem = BigDecimal.ZERO;
+                BigDecimal sumReturnAmtItem = BigDecimal.ZERO;
+                if (!Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())  &&
+                        !Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ) {
+                    InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inOutRecordVO.getBiznisItemId());
+                    sumReturnQtyItem = inboundItemResponse.getReturnQty();
+                    sumReturnAmtItem = inboundItemResponse.getReturnAmt();
+                }
                 //入库价
                 inOutRecordVO.setPriceInto(inOutRecordVO.getPriceInto().abs());
                 //入库数量
-                inOutRecordVO.setIntoQty(inOutRecordVO.getIntoQty().abs());
+                inOutRecordVO.setIntoQty(inOutRecordVO.getIntoQty().abs().add(sumReturnQtyItem));
                 //入库金额
-                inOutRecordVO.setIntoAmt(inOutRecordVO.getIntoAmt().abs());
+                inOutRecordVO.setIntoAmt(inOutRecordVO.getIntoAmt().abs().add(sumReturnAmtItem));
             }
             //endregion
 
@@ -950,7 +972,7 @@ public class InventoryService extends BaseService<Inventory> {
                             Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()))
             ) {
                 //入库价
-                inOutRecordVO.setPriceInto(inOutRecordVO.getPriceInto().abs().negate());
+                inOutRecordVO.setPriceInto(inOutRecordVO.getPriceInto().abs());
                 //入库数量
                 inOutRecordVO.setIntoQty(inOutRecordVO.getIntoQty().abs().negate());
                 //入库金额
@@ -959,6 +981,7 @@ public class InventoryService extends BaseService<Inventory> {
             //endregion
             //实体转换
             InOutRecord inOutRecord = inOutRecordConvert.convertToPo(inOutRecordVO);
+            inOutRecord.setRecordId(null);
             //新建
             inOutRecordMapper.insert(inOutRecord);
         }
@@ -1078,16 +1101,16 @@ public class InventoryService extends BaseService<Inventory> {
             //采购退货入库  把传入的负数转成正数
             if (Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
                 //出库数量
-                outboundItemCost.setOutQty(inOutRecordVO.getIntoQty().abs());
-                //出库单价
-                outboundItemCost.setCostPrice(inOutRecordVO.getPriceInto().abs());
+                outboundItemCost.setOutQty(qty);
                 //出库成本
-                outboundItemCost.setCostAmt(inOutRecordVO.getIntoAmt().abs());
+                outboundItemCost.setCostAmt(amount != null && amount.compareTo(BigDecimal.ZERO) > 0 ? amount : inOutRecordVO.getIntoAmt());
+                //出库单价
+                outboundItemCost.setCostPrice(amount != null && amount.compareTo(BigDecimal.ZERO) > 0 ? amount.divide(qty, 2, BigDecimal.ROUND_HALF_UP) : inOutRecordVO.getPriceInto());
             } else {
                 //出库数量
                 outboundItemCost.setOutQty(qty);
                 //出库成本
-                outboundItemCost.setCostAmt(amount != null && amount.compareTo(BigDecimal.ZERO) > 0 ? amount : inOutRecordVO.getPriceInto());
+                outboundItemCost.setCostAmt(amount != null && amount.compareTo(BigDecimal.ZERO) > 0 ? amount : inOutRecordVO.getIntoAmt());
                 //出库单价
                 outboundItemCost.setCostPrice(amount != null && amount.compareTo(BigDecimal.ZERO) > 0 ? amount.divide(qty, 2, BigDecimal.ROUND_HALF_UP) : inOutRecordVO.getPriceInto());
             }
@@ -1128,11 +1151,10 @@ public class InventoryService extends BaseService<Inventory> {
                     //清零标识
                     inventoryBatchVO.setZeroFlag(true);
                     inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
-                    //单价
-                    inOutRecordVO.setPriceInto(inventoryBatchResponse.getCostPrice());
-                    //金额
-                    inOutRecordVO.setIntoAmt(inOutRecordVO.getIntoQty().multiply(inventoryBatchResponse.getCostPrice()));
-
+                    //存货单价
+                    inOutRecordVO.setCostPrice(inventoryBatchResponse.getCostPrice());
+                    //存货总额
+                    inOutRecordVO.setCostAmt(inventoryBatchResponse.getCostAmt());
                     //region  出库成本 todo  2024年5月20日15:46:01  库存批次有几条出库成本就有几条
                     //除了销售退货出库  其他类型出库要新建出库成本  采购退货 出库成本 正数
                     if ((Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()) &&
@@ -1159,13 +1181,10 @@ public class InventoryService extends BaseService<Inventory> {
                         //清零标识
                         inventoryBatchVO.setZeroFlag(false);
                         inventoryBatchMapper.updateAmountAndQuantity(inventoryBatchVO);
-                        //单价
-                        inOutRecordVO.setPriceInto(inventoryBatchResponse.getCostPrice());
-                        //金额
-                        inOutRecordVO.setIntoAmt(inOutRecordVO.getIntoQty().multiply(inventoryBatchResponse.getCostPrice()));
                         //金额每次更新完要重新运算
                         notEnoughAmount = notEnoughAmount.add(qty.multiply(inventoryBatchResponse.getCostPrice()));
-
+                        //存货总额
+                        inOutRecordVO.setCostAmt(notEnoughAmount);
                         //region  出库成本 todo  2024年5月20日15:46:01  库存批次有几条出库成本就有几条
                         //除了销售退货出库  其他类型出库要新建出库成本  采购退货 出库成本 正数
                         if ((Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()) &&
@@ -1279,8 +1298,8 @@ public class InventoryService extends BaseService<Inventory> {
                     //当前编辑的数据在库存批次中不存在
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_BATCH_DOES_NOT_EXIST.getMessage());
                 } else {
-                    //数据库中库存批次数量和传入数量一致 可以更改
-                    if (inventoryBatchResponse.getInvQty().compareTo(inOutRecordVO.getQtyBeforeUpdate() != null ? inOutRecordVO.getQtyBeforeUpdate().abs() : inOutRecordVO.getIntoQty().abs()) == 0) {
+                    //数据库中库存批次数量和传入数量一致 可以更改 todo 2024年7月18日17:17:32 大于等于就行 和z沟通过
+                    if (inventoryBatchResponse.getInvQty().compareTo(inOutRecordVO.getQtyBeforeUpdate() != null ? inOutRecordVO.getQtyBeforeUpdate().abs() : inOutRecordVO.getIntoQty().abs()) >= 0) {
                         InventoryBatch inventoryBatch = new InventoryBatch();
                         //来源单ID
                         inventoryBatch.setFromId(inOutRecordVO.getBiznisId());
@@ -1325,7 +1344,8 @@ public class InventoryService extends BaseService<Inventory> {
             //endregion
 
             //region  修改库存数量,可用量,金额等信息
-            this.updateInventoryMessageDelete(inventoryResponse, inOutRecordVO);
+//            this.updateInventoryMessageDelete(inventoryResponse, inOutRecordVO);
+            this.updateInventory(inventoryResponse, inOutRecordVO);
             //endregion
 
             //region  根据来源id和来源明细id查询数据 库存流水删除
@@ -1412,6 +1432,45 @@ public class InventoryService extends BaseService<Inventory> {
     }
 
     /**
+     * @desc : 删除用-----修改库存数量,可用量,金额等信息
+     * @date : 2024/4/10 15:05
+     * @author : 寇珊珊
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public void updateInventory(InventoryResponse inventoryResponse, InOutRecordVO inOutRecordVO) {
+
+        //region  根据库存id查询库存批次明细 汇总金额
+        List<InventoryBatchResponse> inventoryBatchResponseList = inventoryBatchMapper.selectAmountAndQuantity(new InventoryBatchQuery().setInvId(inventoryResponse.getInvId()));
+        //库存资产汇总  ---库存需要
+        BigDecimal costAmt = BigDecimal.ZERO;
+        // 库存量从批次进行汇总 周兴 2024-7-20
+        BigDecimal invQty = BigDecimal.ZERO;
+        if (inventoryBatchResponseList.size() > 0) {
+            costAmt = inventoryBatchResponseList.stream().map(InventoryBatchResponse::getCostAmt).reduce(BigDecimal.ZERO, BigDecimal::add)
+                    .setScale(6, BigDecimal.ROUND_HALF_UP);
+            invQty = inventoryBatchResponseList.stream().map(InventoryBatchResponse::getInvQty).reduce(BigDecimal.ZERO, BigDecimal::add)
+                    .setScale(6, BigDecimal.ROUND_HALF_UP);
+        }
+        //endregion
+
+        //region 库存数量重算
+        Inventory inventory = new Inventory();
+        //库存id
+        inventory.setInvId(inventoryResponse.getInvId());
+        inventory.setInvQty(invQty);
+        inventory.setCostAmt(costAmt);
+        //可用量  库存数量-出库中数量-冻结数量
+        inventory.setUsableQty(inventory.getInvQty().subtract(inventoryResponse.getFreezeQty()).subtract(inventoryResponse.getOutingQty()));
+        //存货单价
+        inventory.setCostPrice(costAmt.compareTo(BigDecimal.ZERO) > 0 ?
+                costAmt.divide(inventory.getInvQty(), BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
+        inventoryMapper.updateAmtAndQty(inventory);
+        //endregion
+    }
+
+    /**
      * @desc : 修改源出库信息
      * @date : 2024/4/1 14:30
      * @author : 寇珊珊
@@ -1472,9 +1531,9 @@ public class InventoryService extends BaseService<Inventory> {
             rollbackFor = {Exception.class}
     )
     public List<InOutRecordVO> insertOrUpdateInbound(List<InOutRecordVO> inOutRecordVOList) {
-        BigDecimal sumOutQty = inOutRecordVOList.stream().map(InOutRecordVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
         //新建
         if (inOutRecordVOList.get(0).getAddOrEditFlag()) {
+            BigDecimal sumOutQty = inOutRecordVOList.stream().map(InOutRecordVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
             //region  总单
             Inbound inbound = new Inbound();
             //获取 id/单号
@@ -1531,15 +1590,8 @@ public class InventoryService extends BaseService<Inventory> {
         }
         //编辑
         else {
-            //region  编辑入库单数量
+            //region查询总单
             InboundResponse inboundResponse = inboundMapper.selectMessageByOtherQuery(new InboundQuery().setFromId(inOutRecordVOList.get(0).getBiznisId()));
-            Inbound inbound = new Inbound();
-            inbound.setIntoId(inboundResponse.getIntoId());
-            inbound.setIntoQty(sumOutQty.abs());
-            inboundMapper.update(inbound,
-                    new UpdateWrapper<Inbound>().lambda()
-                            .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
-            );
             //endregion
 
             //region 明细
@@ -1562,6 +1614,18 @@ public class InventoryService extends BaseService<Inventory> {
                 inOutRecordVO.setIntoItemId(inboundItemResponse.getItemId());
             }
             //endregion
+
+            //region  编辑入库单数量  编辑的时候把所有明细查出来  计算和在反写
+            List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectMessageByOtherCondition(new InboundItemQuery().setFromId(inOutRecordVOList.get(0).getBiznisId()));
+            BigDecimal sumOutQty = inboundItemResponses.stream().map(InboundItemResponse::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            Inbound inbound = new Inbound();
+            inbound.setIntoId(inboundResponse.getIntoId());
+            inbound.setIntoQty(sumOutQty);
+            inboundMapper.update(inbound,
+                    new UpdateWrapper<Inbound>().lambda()
+                            .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
+            );
+            //endregion
         }
 
         return inOutRecordVOList;
@@ -1742,7 +1806,8 @@ public class InventoryService extends BaseService<Inventory> {
                 //endregion
 
                 //region  修改/新建   库存数量,可用量,金额等信息
-                this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+//                this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+                this.updateInventory(inventoryResponse, inOutRecordVO);
                 //endregion
 
                 //region 库存流水
@@ -1834,7 +1899,8 @@ public class InventoryService extends BaseService<Inventory> {
                 //endregion
 
                 //region  修改/新建   库存数量,可用量,金额等信息
-                this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+//                this.updateInventoryMessageAdd(inventoryResponse, inOutRecordVO);
+                this.updateInventory(inventoryResponse, inOutRecordVO);
                 //endregion
 
                 //region 库存流水
@@ -1855,20 +1921,6 @@ public class InventoryService extends BaseService<Inventory> {
             rollbackFor = {Exception.class}
     )
     public void updateIntobound(List<InOutRecordVO> inOutRecordVOList) {
-        BigDecimal sumOutQty = inOutRecordVOList.stream().map(InOutRecordVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-        BigDecimal sumOutAmt = inOutRecordVOList.stream().map(InOutRecordVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-        //region  编辑入库单数量
-        InboundResponse inboundResponse = inboundMapper.selectMessageByOtherQuery(new InboundQuery().setIntoId(inOutRecordVOList.get(0).getBiznisId()));
-        Inbound inbound = new Inbound();
-        inbound.setIntoId(inboundResponse.getIntoId());
-        inbound.setIntoQty(sumOutQty);
-        inbound.setIntoAmt(sumOutAmt);
-        inboundMapper.update(inbound,
-                new UpdateWrapper<Inbound>().lambda()
-                        .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
-        );
-        //endregion
-
         //region 明细
         for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
             //根据id查询入库明细,用于计算入库明细的库存数量
@@ -1881,21 +1933,44 @@ public class InventoryService extends BaseService<Inventory> {
             //已入库数量
             inboundItem.setIntoQty(inOutRecordVO.getIntoQty());
             //已入库金额
-            inboundItem.setIntoAmt(inOutRecordVO.getIntoAmt());
-            //成本单价
-            inboundItem.setCostPrice(inOutRecordVO.getCostPrice());
+            inboundItem.setIntoAmt(inOutRecordVO.getIntoQty().multiply(inboundItemResponse.getPriceInto()));
             //成本金额
-            inboundItem.setCostAmt(inOutRecordVO.getIntoAmt());
+            //采购退货特殊处理存负数
+            if(Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVOList.get(0).getInventoryDocCode())){
+                inboundItem.setCostAmt(inOutRecordVO.getCostAmt().negate());
+            }else{
+                inboundItem.setCostAmt(inOutRecordVO.getCostAmt());
+            }
+            //成本单价
+            inboundItem.setCostPrice(inOutRecordVO.getCostAmt().divide(inOutRecordVO.getIntoQty(),2, BigDecimal.ROUND_HALF_UP).abs());
             //库存id
             inboundItem.setInvId(inOutRecordVO.getInvId());
             //库存数量 =  已入库数量-出库数量 -已入库退货数量
-            inboundItem.setInvQty(inboundItem.getIntoQty().subtract(inboundItemResponse.getOutQty()).subtract(inboundItemResponse.getReturnQty()));
+            if (!Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVOList.get(0).getInventoryDocCode())) {
+                inboundItem.setInvQty(inboundItem.getIntoQty().subtract(inboundItemResponse.getOutQty()).subtract(inboundItemResponse.getReturnQty()));
+            }
             inboundItemMapper.update(inboundItem,
                     new UpdateWrapper<InboundItem>().lambda()
                             .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
             );
         }
         //endregion
+
+        //region  编辑入库单数量
+        InboundResponse inboundResponse = inboundMapper.selectMessageByOtherQuery(new InboundQuery().setIntoId(inOutRecordVOList.get(0).getBiznisId()));
+        List<InboundItemResponse> inboundItemResponses = inboundItemMapper.selectMessageByOtherCondition(new InboundItemQuery().setIntoId(inOutRecordVOList.get(0).getBiznisId()));
+        BigDecimal sumOutQty = inboundItemResponses.stream().map(InboundItemResponse::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+        BigDecimal sumOutAmt = inboundItemResponses.stream().map(InboundItemResponse::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+        Inbound inbound = new Inbound();
+        inbound.setIntoId(inboundResponse.getIntoId());
+        inbound.setIntoQty(sumOutQty);
+        inbound.setIntoAmt(sumOutAmt);
+        inboundMapper.update(inbound,
+                new UpdateWrapper<Inbound>().lambda()
+                        .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
+        );
+        //endregion
+
     }
 
     /**
@@ -1948,8 +2023,8 @@ public class InventoryService extends BaseService<Inventory> {
                 //当前编辑的数据在库存批次中不存在
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_BATCH_DOES_NOT_EXIST.getMessage());
             } else {
-                //数据库中库存批次数量和传入数量一致 可以更改
-                if (inventoryResponse.getInvQty().compareTo(inOutRecordVO.getIntoQty().abs()) == 0) {
+                //数据库中库存批次数量和传入数量一致 可以更改  todo 2024年7月18日17:17:32 大于等于就行 和z沟通过
+                if (inventoryResponse.getInvQty().compareTo(inOutRecordVO.getIntoQty().abs()) >= 0) {
                     InventoryBatch inventoryBatch = new InventoryBatch();
                     //来源单ID
                     inventoryBatch.setFromId(inOutRecordVO.getBiznisId());
@@ -1965,7 +2040,8 @@ public class InventoryService extends BaseService<Inventory> {
             //endregion
 
             //region  修改库存数量,可用量,金额等信息
-            this.updateInventoryMessageDelete(inventoryResponse, inOutRecordVO);
+//            this.updateInventoryMessageDelete(inventoryResponse, inOutRecordVO);
+            this.updateInventory(inventoryResponse, inOutRecordVO);
             //endregion
 
             //region  根据来源id和来源明细id查询数据 库存流水删除
@@ -2020,7 +2096,8 @@ public class InventoryService extends BaseService<Inventory> {
             //endregion
 
             //region  修改库存数量,可用量,金额等信息
-            this.updateInventoryMessageDelete(inventoryResponse, inOutRecordVO);
+//            this.updateInventoryMessageDelete(inventoryResponse, inOutRecordVO);
+            this.updateInventory(inventoryResponse, inOutRecordVO);
             //endregion
 
             //region  根据来源id和来源明细id查询数据 库存流水删除

+ 12 - 0
src/main/java/com/dk/mdm/service/mac/ReceiptService.java

@@ -1,5 +1,7 @@
 package com.dk.mdm.service.mac;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
@@ -17,6 +19,8 @@ import com.dk.mdm.mapper.mst.CustomerMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountItemMapper;
 import com.dk.mdm.mapper.mst.MoneyAccountMapper;
 import com.dk.mdm.mapper.mst.SaleChannelMapper;
+import com.dk.mdm.model.pojo.ivt.Inbound;
+import com.dk.mdm.model.pojo.ivt.OutboundItem;
 import com.dk.mdm.model.pojo.mac.*;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
@@ -228,6 +232,14 @@ public class ReceiptService extends BaseService<RecPay> {
                 recPayVO.setObjectId(listCustomer.get(0).getCusId());
                 recPay.setObjectId(listCustomer.get(0).getCusId());
             }
+        }else{ //如果有客户id 更新 客户信息
+            Customer customer = new Customer();
+            customer.setCusId(recPayVO.getObjectId()).setCusName(recPayVO.getCusName())
+                    .setCusPhone(recPayVO.getCusPhone()).setAddressArea(recPayVO.getAddressArea()).setAddressName(recPayVO.getAddressName())
+                    .setAddressNo(recPayVO.getAddressNo()).setAddressGcj02(recPayVO.getAddressGcj02()).setAddressFull(recPayVO.getAddressFull());
+
+            //修改
+            customerMapper.update(customer,   new UpdateWrapper<Customer>().lambda().eq(Customer::getCusId, UUID.fromString(customer.getCusId())));
         }
         // 总单保存
         super.insert(recPay);

+ 170 - 12
src/main/java/com/dk/mdm/service/mst/CusFollowService.java

@@ -1,5 +1,6 @@
 package com.dk.mdm.service.mst;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -36,11 +37,20 @@ import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
@@ -418,27 +428,39 @@ public class CusFollowService extends BaseService<CusFollow> {
             Customer customer = customerMapper.selectById(follow.getCusId());
             if (customer != null) {
                 String loginType = "4";
-                List<String> list = new ArrayList<>();
+//                List<String> list = new ArrayList<>();
+                Map<String, String> keywordMap = new HashMap<>();
                 if (Constant.BasicDataConstant.FOLLOW_STATUS_4.getValue().equals(follow.getFollowStatus()) ||
-                        Constant.BasicDataConstant.FOLLOW_STATUS_1.getValue().equals(follow.getFollowStatus())) {
-                    list.add("您有客户需要跟进");
+                        Constant.BasicDataConstant.FOLLOW_STATUS_1.getValue().equals(follow.getFollowStatus()) ||
+                        Constant.BasicDataConstant.FOLLOW_STATUS_5.getValue().equals(follow.getFollowStatus())) {
+//                    list.add("您有客户需要跟进");
+                    keywordMap.put("remark", "您有客户需要跟进");
                     loginType = "4";
 
                 } else if (Constant.BasicDataConstant.FOLLOW_STATUS_6.getValue().equals(follow.getFollowStatus())) {
-                    list.add("您有客户需要量尺服务");
+//                    list.add("您有客户需要量尺服务");
+                    keywordMap.put("remark", "您有客户需要量尺服务");
                     loginType = "6";
 
                 } else if (Constant.BasicDataConstant.FOLLOW_STATUS_2.getValue().equals(follow.getFollowStatus())) {
-                    list.add("您有客户邀约进店");
+//                    list.add("您有客户邀约进店");
+                    keywordMap.put("remark", "您有客户邀约进店");
                     loginType = "2";
 
                 } else if (Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(follow.getFollowStatus())) {
-                    list.add("您有客户需要约尺服务");
+//                    list.add("您有客户需要约尺服务");
+                    keywordMap.put("remark", "您有客户需要约尺服务");
                     loginType = "3";
                 }
-                list.add(customer.getCusName());
-                list.add(customer.getCusPhone());
-                // 查询跟进人的openid和publicOpenId
+//                list.add(customer.getCusName());
+//                list.add(customer.getCusPhone());
+                LocalDateTime followTime = follow.getFollowTime();
+                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+                keywordMap.put("cusName", customer.getCusName());
+                keywordMap.put("cusPhone", customer.getCusPhone());
+                keywordMap.put("followTime", followTime.format(formatter));
+                // 查询跟进人的openid和publicOpenId   7.19 加了userWxId 刘尧
                 ResponseResultVO<?> resultVO = userFeign.getUser(followStaff.getWxUserId());
                 // 如果没有成功返回,状态设置为待审
                 if (resultVO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) {
@@ -451,11 +473,14 @@ public class CusFollowService extends BaseService<CusFollow> {
                         Map<String, Object> mapMessage = new HashMap<>();
                         mapMessage.put("loginType", loginType);
                         mapMessage.put("otherParam", follow);
-                        mapMessage.put("publicOpenId", user.get("publicOpenId"));
+//                        mapMessage.put("publicOpenId", user.get("publicOpenId"));
+                        mapMessage.put("userWxId", user.get("userWxId"));
                         mapMessage.put("first", "客户跟进提醒");
-                        mapMessage.put("keywordList", list);
+//                        mapMessage.put("keywordList", list);
+                        mapMessage.put("keywordMap", keywordMap);
                         mapMessage.put("remark", "客户跟进备注");
-                        sendUniformMessage(mapMessage);
+//                        sendUniformMessage(mapMessage);
+                        wxMessagePush(mapMessage);
                     }
                 }
 
@@ -529,6 +554,47 @@ public class CusFollowService extends BaseService<CusFollow> {
     }
 
     /**
+     * @desc : 向用户推送小程序订阅消息方法
+     * @author : 刘尧
+     * @date : 2024-07-19 08:56
+     * */
+    public ResponseResultVO<?> wxMessagePush(Map<String, Object> map) {
+        // 获取微信Token
+        String wxToken = getWxToken();
+        Map<String, Object> params = new HashMap<>();
+        // 接口调用凭证
+        params.put("access_token", wxToken);
+        // 所需下发的订阅模板id
+        params.put("template_id", "z3REuwft6NLPxVW8s5HN1UgWjFstWjD0QfCXNLTa0LA");
+        // 点击模板卡片后的跳转页面
+        if (map.containsKey("otherParam")) {
+            params.put("page", "pages/welcome/welcome?loginType=" + map.get("loginType").toString() + "&otherParam=" + map.get("otherParam").toString());
+        } else {
+            params.put("page", "pages/welcome/welcome?loginType=" + map.get("loginType").toString());
+        }
+        // 接收者(用户)的 openid
+        params.put("touser", map.get("userWxId"));
+        // 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;
+        params.put("miniprogram_state", "trial");
+
+        // 获取客户信息
+        Object keywordMap = map.get("keywordMap");
+        Map<String, Object> personMap = BeanUtil.beanToMap(keywordMap);
+
+        // 构造对应的显示信息 和模板数据结构对应
+        JSONObject data = new JSONObject();
+        data.put("time4", createDataItem("value", String.valueOf(personMap.get("followTime"))));
+        data.put("thing1", createDataItem("value", String.valueOf(personMap.get("cusName"))));
+        data.put("phone_number2", createDataItem("value", String.valueOf(personMap.get("cusPhone"))));
+        data.put("thing6", createDataItem("value", String.valueOf(personMap.get("remark"))));
+        data.put("thing5", createDataItem("value", String.valueOf(map.get("remark"))));
+        params.put("data", data);
+
+        ResponseResultVO<JSONObject> post = HttpUtils.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + wxToken, params);
+        return post;
+    }
+
+    /**
      * @author : jyh
      * @date : 2023-10-11 16:23
      * @desc : 调用中控服务获取公众号的token
@@ -790,4 +856,96 @@ public class CusFollowService extends BaseService<CusFollow> {
     public ResponseResultVO<List<Map>> selectCusFollow(CusFollowQuery cusFollowQuery) {
         return ResponseResultUtil.success(cusFollowMapper.selectCusFollow(cusFollowQuery));
     }
+
+    /**
+     * @desc : 构造消息推送模板中data值
+     * @author : 刘尧
+     * @date : 2024-07-19 08:56
+     * */
+    private static Map<String, Object> createDataItem(String name, String value) {
+        Map<String, Object> item = new HashMap<>();
+        item.put(name, value);
+        return item;
+    }
+
+    /**
+     * @desc : 微信公众平台后台配置测试用
+     * @author : 刘尧
+     * @date : 2024-07-19 08:56
+     * */
+    public void wxMessageTest(HttpServletRequest request, HttpServletResponse response) {
+        String signature = request.getParameter("signature");
+        String timestamp = request.getParameter("timestamp");
+
+        String nonce = request.getParameter("nonce");
+
+        String echostr = request.getParameter("echostr");
+        // 和小程序后台配置的token保持一致
+        String token = "dPM4EILWQqeEsEmft9pKMIll4VGZ6pJK";
+        // 将下面三个参数拼接成字符串
+        StringBuffer content = new StringBuffer();
+        content.append(timestamp);
+        content.append(nonce);
+        content.append(token);
+        PrintWriter out = null;
+        try {
+            out = response.getWriter();
+            MessageDigest md = MessageDigest.getInstance("SHA-1");
+            // 对拼接好的字符串进行sha1加密
+            byte[] digest = md.digest(content.toString().getBytes());
+            String tmpStr = byteToStr(digest);
+            //获得加密后的字符串与signature对比
+            if (tmpStr != null && tmpStr.equals(signature.toUpperCase())){
+                out.print(echostr);
+                out.flush();
+            }
+        } catch (NoSuchAlgorithmException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            out.close();
+        }
+    }
+
+    /**
+     * @desc : 获取微信小程序后台Token
+     * @author : 刘尧
+     * @date : 2024-07-19 08:56
+     * */
+    private String getWxToken(){
+        String appId = config.getAppId();
+        String appSecret = config.getAppSecret();
+        ResponseResultVO<JSONObject> tokenRes = HttpUtils.get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appId + "&secret=" + appSecret);
+        JSONObject data = tokenRes.getData();
+        return String.valueOf(data.get("access_token"));
+    }
+
+    /**
+     * @desc : 将字节转化为十六进制字符串
+     * @author : 刘尧
+     * @date : 2024-07-19 08:56
+     * */
+    private static String byteToStr(byte[] byteArray) {
+        String strDigest = "";
+        for (int i = 0; i < byteArray.length; i++) {
+            strDigest += byteToHexStr(byteArray[i]);
+        }
+        return strDigest;
+    }
+
+    /**
+     * @desc : 将字节转换成对应的两位十六进制字符串
+     * @author : 刘尧
+     * @date : 2024-07-19 08:56
+     * */
+    private static String byteToHexStr(byte mByte) {
+        char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A',
+                'B', 'C', 'D', 'E', 'F' };
+        char[] tempArr = new char[2];
+        tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
+        tempArr[1] = Digit[mByte & 0X0F];
+        String s = new String(tempArr);
+        return s;
+    }
 }

+ 1 - 0
src/main/java/com/dk/mdm/service/mst/GoodsSkuService.java

@@ -148,6 +148,7 @@ public class GoodsSkuService extends BaseService<GoodsSku> {
 			inboundItemVO.setIntoingAmt(goodsSkuVO.getIntoQty().multiply(goodsSkuVO.getPriceInto()));
 			inboundItemVO.setPriceInto(goodsSkuVO.getPriceInto());
 			inboundItemVO.setCostPrice(goodsSkuVO.getPriceInto());
+			inboundItemVO.setCostAmt(inboundItemVO.getIntoingAmt());
 			inboundItemVO.setIntoAmt(goodsSkuVO.getIntoQty().multiply(goodsSkuVO.getPriceInto()));
 			inboundItemVO.setIntoQty(goodsSkuVO.getIntoQty());
 			inboundItemVO.setItemIndex(0);

+ 12 - 0
src/main/java/com/dk/mdm/service/mst/StaffService.java

@@ -744,6 +744,18 @@ public class StaffService extends BaseService<Staff> {
     }
 
     /**
+     * @desc : 更新员工的登录标识
+     * @author : 姜永辉
+     * @date : 2023/1/9 10:49
+     */
+    @Transactional(rollbackFor = {Exception.class} )
+    public ResponseResultVO<Boolean> updateFeignStaffFlgCanLogin(List<String> list) {
+        //  FlgCanLogin  登录系统(1:PC端,2:移动端,3:PC+移动端, 4:无)
+        staffMapper.updateFeignStaffFlgCanLogin(list);
+        return ResponseResultUtil.success();
+    }
+
+    /**
      * @desc : 保存权限方法
      * @author : 姜永辉
      * @date : 2023/1/9 10:49

+ 61 - 37
src/main/java/com/dk/mdm/service/report/ReportService.java

@@ -1,7 +1,6 @@
 package com.dk.mdm.service.report;
 
 import cn.afterturn.easypoi.excel.entity.ExportParams;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.dk.common.model.pojo.PageList;
@@ -18,13 +17,21 @@ import com.dk.mdm.mapper.report.ReportMapper;
 import com.dk.mdm.model.report.ExcelDataHandler;
 import com.dk.mdm.model.report.ExcelExportStyleImpl;
 import com.dk.mdm.model.report.ExcelIndex;
-import com.dk.mdm.model.report.analysis.*;
-import com.dk.mdm.model.report.department.*;
-import com.dk.mdm.model.report.from.*;
+import com.dk.mdm.model.report.analysis.BudgetQuotationStaff;
+import com.dk.mdm.model.report.analysis.PotentialCustomerAnalysis;
+import com.dk.mdm.model.report.analysis.PotentialCustomerAnalysisStaff;
+import com.dk.mdm.model.report.department.DepartmentCollectionRanking;
+import com.dk.mdm.model.report.department.DepartmentTransactionRanking;
+import com.dk.mdm.model.report.from.PotentialCustomerAnalysisFrom;
+import com.dk.mdm.model.report.from.Transaction;
 import com.dk.mdm.model.report.product.ProductDistribution;
-import com.dk.mdm.model.report.received.*;
+import com.dk.mdm.model.report.received.ArrearsInfo;
+import com.dk.mdm.model.report.received.ArrearsInfoStaff;
+import com.dk.mdm.model.report.received.ReceivedTask;
+import com.dk.mdm.model.report.received.ReceivedTaskStaff;
 import com.dk.mdm.model.report.sale.*;
-import com.dk.mdm.model.report.staff.*;
+import com.dk.mdm.model.report.staff.StaffCollectionRanking;
+import com.dk.mdm.model.report.staff.StaffTransactionRanking;
 import com.google.common.collect.ImmutableMap;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,14 +42,12 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.rmi.MarshalledObject;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * @author : 常皓宁
@@ -586,47 +591,27 @@ public class ReportService {
             return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL, "请检查分页参数!");
         }
 
-        List<Map<String, Object>>  list = new ArrayList<>();
         List<Object> objects = new ArrayList<>();
         if (param.get("macIds") instanceof ArrayList<?>) {
             for (Object o : (List<?>) param.get("macIds")) {
                 objects.add(String.class.cast(o));
             }
         }
-        if (param.get("macIds") != null && objects.size() > 0){
-            String json = JSON.toJSONString(param.get("macIds"));
-            JSONArray jsonArray = JSONArray.parseArray(json);
-            for (Object o : jsonArray.stream().toArray()) {
-                param.put("macId", o);
-                // 获取资金日记账
-                if (list.isEmpty()) {
-                    list = reportMapper.getFundReport(param);
-                }else {
-                    List<Map<String, Object>> fundReport = reportMapper.getFundReport(param);
-                    JSONObject jObject = JSONObject.parseObject(list.get(0).get("f_get_fund_report").toString());
-                    JSONObject jObjectNew = JSONObject.parseObject(fundReport.get(0).get("f_get_fund_report").toString());
-                    List dataList = jObject.get("data") != null ? JSONObject.parseArray(jObject.get("data").toString())
-                            .toJavaList(Map.class) : new ArrayList();
-                    List dataNewList = jObjectNew.get("data") != null ? JSONObject.parseArray(jObjectNew.get("data").toString())
-                            .toJavaList(Map.class) : new ArrayList();
-                    dataList.addAll(dataNewList);
-                    jObject.put("data", dataList);
-                    list.get(0).put("f_get_fund_report", jObject);
-                }
-            }
-        }else {
-            // 获取资金日记账
-            list = reportMapper.getFundReport(param);
+        if (objects.isEmpty()){
+            param.remove("macIds");
         }
-
-        // 定义返回值
-        PageList data = new PageList<>();
+        // 获取资金日记账
+        List<Map<String, Object>> list = reportMapper.getFundReport(param);
         JSONObject jObject = JSONObject.parseObject(list.get(0).get("f_get_fund_report").toString());
         List dataList = jObject.get("data") != null ? JSONObject.parseArray(jObject.get("data").toString())
                 .toJavaList(Map.class) : new ArrayList();
+
+        // 定义返回值
+        PageList data = new PageList<>();
         data.setPageSize((int) param.get("pageSize")).setCurrentPage((int) param.get("currentPage"))
                 .setTotal(Long.parseLong(jObject.get("pageTotal").toString()))
                 .setList(dataList);
+
         if ("查询成功".equals(jObject.get("message").toString())) {
             return ResponseResultUtil.success(data);
         } else {
@@ -1179,4 +1164,43 @@ public class ReportService {
         return ResponseResultUtil.success(jObject);
     }
 
+    /**
+     * @desc   : 资金日记账
+     * @author : 姜宁
+     * @date   : 2024/7/19 15:27
+     */
+    public ResponseResultVO<PageList<Map<String, Object>>> getFundReportWeb(Map<String, Object> param) {
+        // 校验分页参数
+        if (param.get("pageSize") == null || param.get("currentPage") == null) {
+            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL, "请检查分页参数!");
+        }
+
+        List<Object> objects = new ArrayList<>();
+        if (param.get("macIds") instanceof ArrayList<?>) {
+            for (Object o : (List<?>) param.get("macIds")) {
+                objects.add(String.class.cast(o));
+            }
+        }
+        if (objects.isEmpty()){
+            param.remove("macIds");
+        }
+        // 获取资金日记账
+        List<Map<String, Object>> list = reportMapper.getFundReportWeb(param);
+        JSONObject jObject = JSONObject.parseObject(list.get(0).get("f_get_fund_report_web").toString());
+        List dataList = jObject.get("data") != null ? JSONObject.parseArray(jObject.get("data").toString())
+                .toJavaList(Map.class) : new ArrayList();
+
+        // 定义返回值
+        PageList data = new PageList<>();
+        data.setPageSize((int) param.get("pageSize")).setCurrentPage((int) param.get("currentPage"))
+                .setTotal(Long.parseLong(jObject.get("pageTotal").toString()))
+                .setList(dataList);
+
+        if ("查询成功".equals(jObject.get("message").toString())) {
+            return ResponseResultUtil.success(data);
+        } else {
+            return ResponseResultUtil.error(666, jObject.get("message").toString());
+        }
+    }
+
 }