Răsfoiți Sursa

集采订单同步销售订单、同步库存、同步销售价格

ms-blue 1 lună în urmă
părinte
comite
ee599ac7b6

+ 2 - 2
jshERP-web/src/views/bill/modules/AssembleModal.vue

@@ -171,8 +171,8 @@ export default {
             validateRules: [{ required: true, message: '${title}不能为空' }],
           },
           {
-            title: '条码',
-            key: 'barCode',
+            title: '批次号',
+            key: 'batchNumber',
             width: '12%',
             type: FormTypes.popupJsh,
             kind: 'material',

+ 2 - 2
jshERP-web/src/views/bill/modules/DisassembleModal.vue

@@ -171,8 +171,8 @@ export default {
             validateRules: [{ required: true, message: '${title}不能为空' }],
           },
           {
-            title: '条码',
-            key: 'barCode',
+            title: '批次号',
+            key: 'batchNumber',
             width: '12%',
             type: FormTypes.popupJsh,
             kind: 'material',

+ 11 - 0
src/main/java/com/jsh/erp/controller/OpenController.java

@@ -51,6 +51,17 @@ public class OpenController {
         return syncTescoSystemService.syncOrder(param);
     }
 
+    @ApiOperation(value = "同步集采库存")
+    @PostMapping(value = "/sync-tesco-stock")
+    public String sycnTescoStock(@RequestBody List<Long> mIdList){
+        return syncTescoSystemService.sycnTescoStock(mIdList);
+    }
+
+    @PostMapping(value = "/sync-tesco-saleprice")
+    public String sycnTescoSalePrice(@RequestBody List<Long> mIdList){
+        return syncTescoSystemService.sycnTescoSalePrice(mIdList);
+    }
+
 
 
 }

+ 3 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialCurrentStockMapperEx.java

@@ -1,6 +1,7 @@
 package com.jsh.erp.datasource.mappers;
 
 import com.jsh.erp.datasource.entities.MaterialCurrentStock;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -20,4 +21,6 @@ public interface MaterialCurrentStockMapperEx {
     BigDecimal getCurrentUnitPriceByMId(@Param("materialId") Long materialId);
 
     void batchDeleteByDepots(@Param("ids") String ids[]);
+
+    List<MaterialCurrentStock4SystemSku> getCurrentStockMapByMdIdList(@Param("materialIdList") List<Long> materialIdList);
 }

+ 3 - 0
src/main/java/com/jsh/erp/datasource/mappers/MaterialMapperEx.java

@@ -2,6 +2,7 @@ package com.jsh.erp.datasource.mappers;
 
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import com.jsh.erp.datasource.vo.MaterialVoSearch;
 import org.apache.ibatis.annotations.Param;
 
@@ -164,6 +165,8 @@ public interface MaterialMapperEx {
 
     List<MaterialVo4Unit> getMaterialBySystemSku(@Param("systemSkuArray") String [] systemSkuArray);
 
+    List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(@Param("idList") List<Long> idList);
+
     List<PDADepotItemVO> inventoryInquiry();
 
 

+ 143 - 0
src/main/java/com/jsh/erp/datasource/vo/MaterialCurrentStock4SystemSku.java

@@ -0,0 +1,143 @@
+package com.jsh.erp.datasource.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @Description TODO
+ * @Author MS.BLUE
+ * @Date 2025-04-16
+ */
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL) // 序列化时忽略null
+@JsonIgnoreProperties(ignoreUnknown = true)// 反序列化时忽略未知属性
+public class MaterialCurrentStock4SystemSku {
+
+    /**
+     * 商品id
+     */
+    private Long mId;
+
+    /**
+     * 商品名称
+     */
+    private String mName;
+
+    /**
+     * 商品单位-单个单位
+     */
+    private String unit;
+
+    /**
+     * 多单位商品
+     */
+
+    private Long unitId;
+
+    /**
+     * 是否是多单位商品
+     */
+    private boolean isLargeUnit;
+
+    /**
+     * 系统商品编码
+     */
+    private String systemSku;
+
+    /**
+     * 基础单位
+     */
+    private String basicUnit;
+
+    /**
+     * 其他单位
+     */
+    private String otherUnit;
+
+    /**
+     * 其他单位2
+     */
+    private String otherUnitTwo;
+
+    /**
+     * 其他单位3
+     */
+    private String otherUnitThree;
+
+    /**
+     * 基础单位-总库存
+     */
+    private BigDecimal basicUnitTotalStock;
+
+    /**
+     * 其他单位-总库存
+     * =
+     * {@link #basicUnitTotalStock}
+     * ÷{@link #ratio}
+     */
+    private BigDecimal otherUnitTotalStock;
+
+    /**
+     * 其他单位2-总库存
+     * =
+     * {@link #basicUnitTotalStock}
+     * ÷{@link #ratioTwo}
+     */
+    private BigDecimal otherUnitTwoTotalStock;
+
+    /**
+     * 其他单位3-总库存
+     * =
+     * {@link #basicUnitTotalStock}
+     * ÷{@link #ratioThree}
+     */
+    private BigDecimal otherUnitThreeTotalStock;
+
+    /**
+     * 其他单位-比率
+     */
+    private BigDecimal ratio;
+
+    /**
+     * 其他单位2-比率
+     */
+    private BigDecimal ratioTwo;
+
+    /**
+     * 其他单位3-比率
+     */
+    private BigDecimal ratioThree;
+
+
+    /**
+     * 基础单位-销售价格
+     */
+    private BigDecimal basicUnitSalePrice;
+
+    /**
+     * 其他单位-销售价格
+     * =
+     * {@link #basicUnitSalePrice}
+     * * {@link #ratio}
+     */
+    private BigDecimal otherUnitSalePrice;
+
+    /**
+     * 其他单位2-销售价格
+     * =
+     * {@link #basicUnitSalePrice}
+     * * {@link #ratioTwo}
+     */
+    private BigDecimal otherUnitTwoSalePrice;
+
+    /**
+     * 其他单位3-销售价格
+     * =
+     * {@link #basicUnitSalePrice}
+     * * {@link #ratioThree}
+     */
+    private BigDecimal otherUnitThreeSalePrice;
+}

+ 3 - 0
src/main/java/com/jsh/erp/service/MaterialService.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import com.jsh.erp.datasource.vo.MaterialWarnListVo;
 import com.jsh.erp.utils.BaseResponseInfo;
 import org.springframework.transaction.annotation.Transactional;
@@ -174,6 +175,8 @@ public interface MaterialService extends IService<Material> {
 
     List<MaterialVo4Unit> getMaterialBySystemSku(List<String> systemSkuList);
 
+    List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(List<Long> idList);
+
     /**
      * 获取商品提醒
      * @return

+ 129 - 2
src/main/java/com/jsh/erp/service/SyncTescoSystemService.java

@@ -4,31 +4,36 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jsh.erp.constants.ExceptionConstants;
-import com.jsh.erp.datasource.entities.DepotHeadVo4Body;
 import com.jsh.erp.datasource.entities.MaterialVo4Unit;
 import com.jsh.erp.datasource.entities.Supplier;
 import com.jsh.erp.datasource.entities.Unit;
+import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapperEx;
 import com.jsh.erp.datasource.tesco.request.ErpXsddReqVO;
 import com.jsh.erp.datasource.vo.DepotHeadXsddRequestVO;
 import com.jsh.erp.datasource.vo.DepotItemXsddRequestVO;
 import com.jsh.erp.datasource.vo.Material4UnitPrice;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.utils.HttpClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * @Description TODO
@@ -52,6 +57,15 @@ public class SyncTescoSystemService {
     @Resource
     private SupplierService supplierService;
 
+    @Resource
+    private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
+
+    @Value("${tesco.sycnErpMaterialStockUrl}")
+    private String sycnErpMaterialStockUrl;
+
+    @Value("${tesco.sycnErpMaterialPriceUrl}")
+    private String sycnErpMaterialPriceUrl;
+
     public String syncSystemSku(String param) {
         logger.info("获取商品系统sku,返回信息集采系统 param:{}", param);
         JSONObject result = new JSONObject();
@@ -176,6 +190,118 @@ public class SyncTescoSystemService {
         return result.toJSONString();
     }
 
+    public String sycnTescoStock(Long mId){
+        return sycnTescoStock(Arrays.asList(mId));
+    }
+
+    public String sycnTescoStock(List<Long> mIdList) {
+        List<MaterialCurrentStock4SystemSku> stockList = materialCurrentStockMapperEx.getCurrentStockMapByMdIdList(mIdList);
+        if (!CollectionUtils.isEmpty(stockList)) {
+            try {
+                for (MaterialCurrentStock4SystemSku stock : stockList) {
+                    Unit unitInfo = new Unit(); // 查询多单位信息
+                    stock.setBasicUnit(stock.getUnit());
+                    stock.setBasicUnitTotalStock(stock.getBasicUnitTotalStock().setScale(0, RoundingMode.DOWN));
+                    if (stock.getUnitId() != null) {
+                        unitInfo = materialService.findUnit(stock.getMId());
+                        stock.setBasicUnit(unitInfo.getBasicUnit());
+                        stock.setLargeUnit(true);
+                        processOtherUnitStock(stock, unitInfo);
+                    }
+                }
+                String jsonParam = new ObjectMapper().writeValueAsString(stockList);
+                logger.info("同步集采库存请求参数:{}", jsonParam);
+                String response = HttpClient.httpPost(sycnErpMaterialStockUrl, jsonParam);
+                logger.info("同步集采库存响应:{}", response);
+                return jsonParam;
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+
+        }
+        return null;
+    }
+
+    private void processOtherUnitStock(MaterialCurrentStock4SystemSku stock, Unit unitInfo) {
+        if (StringUtils.isNotEmpty(unitInfo.getOtherUnit())) {
+            BigDecimal otherUnitTotalStock = stock.getBasicUnitTotalStock().divide(unitInfo.getRatio(), 0, RoundingMode.DOWN);
+            String otherUnitStr = "1" + unitInfo.getOtherUnit() + "=" + unitInfo.getRatio().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+            stock.setOtherUnit(otherUnitStr);
+            stock.setRatio(unitInfo.getRatio().setScale(0, RoundingMode.DOWN));
+            stock.setOtherUnitTotalStock(otherUnitTotalStock);
+
+            if (StringUtils.isNotEmpty(unitInfo.getOtherUnitTwo())) {
+                BigDecimal otherUnitTwoTotalStock = stock.getBasicUnitTotalStock().divide(unitInfo.getRatioTwo(), 0, RoundingMode.DOWN);
+                String otherUnitTwoStr = "1" + unitInfo.getOtherUnitTwo() + "=" + unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                stock.setOtherUnitTwo(otherUnitTwoStr);
+                stock.setRatioTwo(unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN));
+                stock.setOtherUnitTwoTotalStock(otherUnitTwoTotalStock);
+
+                if (StringUtils.isNotEmpty(unitInfo.getOtherUnitThree())) {
+                    BigDecimal otherUnitThreeTotalStock = stock.getBasicUnitTotalStock().divide(unitInfo.getRatioThree(), 0, RoundingMode.DOWN);
+                    String otherUnitThreeStr = "1" + unitInfo.getOtherUnitThree() + "=" + unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                    stock.setOtherUnitTwo(otherUnitThreeStr);
+                    stock.setRatioThree(unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN));
+                    stock.setOtherUnitThreeTotalStock(otherUnitThreeTotalStock);
+                }
+            }
+        }
+    }
+
+    public String sycnTescoSalePrice(List<Long> mIdList) {
+        try {
+            List<MaterialCurrentStock4SystemSku> mList = materialService.getMaterialCurrentPriceByIdList(mIdList);
+            if (!CollectionUtils.isEmpty(mList)) {
+                for (MaterialCurrentStock4SystemSku material : mList){
+                    Unit unitInfo = new Unit(); // 查询多单位信息
+                    material.setBasicUnit(material.getUnit());
+                    if (material.getUnitId() != null) {
+                        unitInfo = materialService.findUnit(material.getMId());
+                        material.setBasicUnit(unitInfo.getBasicUnit());
+                        material.setLargeUnit(true);
+
+                        processOtherUnitSalePrice(material, unitInfo);
+                    }
+                }
+
+                String jsonParam = new ObjectMapper().writeValueAsString(mList);
+                logger.info("同步集采销售价格请求参数:{}", jsonParam);
+                String response = HttpClient.httpPost(sycnErpMaterialPriceUrl, jsonParam);
+                logger.info("同步集采销售价格响应:{}", response);
+                return jsonParam;
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return null;
+    }
+
+    private void processOtherUnitSalePrice(MaterialCurrentStock4SystemSku stock, Unit unitInfo) {
+        if (StringUtils.isNotEmpty(unitInfo.getOtherUnit())) {
+            BigDecimal otherUnitSalePrice = stock.getBasicUnitSalePrice().multiply(unitInfo.getRatio());
+            String otherUnitStr = "1" + unitInfo.getOtherUnit() + "=" + unitInfo.getRatio().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+            stock.setOtherUnit(otherUnitStr);
+            stock.setRatio(unitInfo.getRatio().setScale(0, RoundingMode.DOWN));
+            stock.setOtherUnitSalePrice(otherUnitSalePrice);
+
+            if (StringUtils.isNotEmpty(unitInfo.getOtherUnitTwo())) {
+                BigDecimal otherUnitTwoSalePrice = stock.getBasicUnitSalePrice().multiply(unitInfo.getRatioTwo());
+                String otherUnitTwoStr = "1" + unitInfo.getOtherUnitTwo() + "=" + unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                stock.setOtherUnitTwo(otherUnitTwoStr);
+                stock.setRatioTwo(unitInfo.getRatioTwo().setScale(0, RoundingMode.DOWN));
+                stock.setOtherUnitTwoSalePrice(otherUnitTwoSalePrice);
+
+                if (StringUtils.isNotEmpty(unitInfo.getOtherUnitThree())) {
+                    BigDecimal otherUnitThreeSalePrice = stock.getBasicUnitSalePrice().multiply(unitInfo.getRatioThree());
+                    String otherUnitThreeStr = "1" + unitInfo.getOtherUnitThree() + "=" + unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN) + unitInfo.getBasicUnit();
+                    stock.setOtherUnitTwo(otherUnitThreeStr);
+                    stock.setRatioThree(unitInfo.getRatioThree().setScale(0, RoundingMode.DOWN));
+                    stock.setOtherUnitThreeSalePrice(otherUnitThreeSalePrice);
+                }
+            }
+        }
+    }
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     private void buildOrderAndItem(ErpXsddReqVO erpXsddReqVO) throws Exception {
         // 1. 初始化订单基本信息
@@ -200,6 +326,7 @@ public class SyncTescoSystemService {
         if (supplier == null) {
             // 如果客户不存在,创建新客户
             supplier = new Supplier();
+            supplier.setEnabled(true);
             supplier.setSupplier(customer.getName());
             supplier.setTelephone(customer.getAccount());
             supplier.setContacts(customer.getReceiverName());

+ 13 - 0
src/main/java/com/jsh/erp/service/impl/DepotHeadServiceImpl.java

@@ -5,12 +5,16 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.jsh.erp.constants.BusinessConstants;
 import com.jsh.erp.constants.ExceptionConstants;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.DepotHeadMapper;
 import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
 import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
+import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapper;
+import com.jsh.erp.datasource.mappers.MaterialCurrentStockMapperEx;
 import com.jsh.erp.datasource.pda.dto.PDADepotHeadDTO;
 import com.jsh.erp.datasource.pda.dto.PDADepotMaterialDto;
 import com.jsh.erp.datasource.pda.vo.PDADepotHeadVO;
@@ -22,6 +26,7 @@ import com.jsh.erp.query.QueryWrapperX;
 import com.jsh.erp.service.*;
 import com.jsh.erp.util.QRCodeGenerator;
 import com.jsh.erp.utils.ExcelUtils;
+import com.jsh.erp.utils.HttpClient;
 import com.jsh.erp.utils.PageUtils;
 import com.jsh.erp.utils.StringUtil;
 import com.jsh.erp.utils.Tools;
@@ -92,6 +97,8 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
     private MaterialService materialService;
     @Resource
     private MaterialExtendService materialExtendService;
+    @Resource
+    private SyncTescoSystemService syncTescoSystemService;
 
     /**
      * PDA查询订单
@@ -1841,11 +1848,17 @@ public class DepotHeadServiceImpl extends ServiceImpl<DepotHeadMapper, DepotHead
             Long headId = list.get(0).getId();
             /** 销售订单 单据子表信息 */
             depotItemService.saveOrderItem(depotHead, depotItemList);
+            List<Long> mIdList = depotItemList.stream().map(DepotItemXsddRequestVO::getMaterialId).collect(Collectors.toList());
+            //同步集采库存
+            syncTescoSystemService.sycnTescoStock(mIdList);
         }
+
         logService.insertLog("销售订单", new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(depotHead.getNumber()).toString(), ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest());
         return "";
     }
 
+
+
     /**
      * 根据商品id获取最后一条销售订单
      * @param mid 商品id

+ 4 - 0
src/main/java/com/jsh/erp/service/impl/DepotItemServiceImpl.java

@@ -18,6 +18,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
 import com.jsh.erp.exception.JshException;
 import com.jsh.erp.query.LambdaQueryWrapperX;
 import com.jsh.erp.service.*;
+import com.jsh.erp.utils.HttpClient;
 import com.jsh.erp.utils.StringUtil;
 import com.jsh.erp.utils.Tools;
 import org.slf4j.Logger;
@@ -1331,6 +1332,9 @@ public class DepotItemServiceImpl extends ServiceImpl<DepotItemMapper, DepotItem
         }
     }
 
+
+
+
     @Override
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public BigDecimal getFinishNumber(Long meId, Long id, Long headerId, Unit unitInfo, String materialUnit, String linkType) {

+ 14 - 8
src/main/java/com/jsh/erp/service/impl/MaterialServiceImpl.java

@@ -10,6 +10,7 @@ import com.jsh.erp.constants.ExceptionConstants;
 import com.jsh.erp.datasource.entities.*;
 import com.jsh.erp.datasource.mappers.*;
 import com.jsh.erp.datasource.pda.vo.PDADepotItemVO;
+import com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku;
 import com.jsh.erp.datasource.vo.MaterialVoSearch;
 import com.jsh.erp.datasource.vo.MaterialWarnListVo;
 import com.jsh.erp.exception.BusinessRunTimeException;
@@ -210,14 +211,11 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
                             //设置初始库
                             insertInitialStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number), lowSafeStock, highSafeStock);
                             //设置当前库
-                            //insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
-                            //更新当前库存
-                            depotItemService.updateCurrentStockFun(mId, depotId);
+                            insertCurrentStockByMaterialAndDepot(depotId, mId, parseBigDecimalEx(number));
                         }
                     }
                 }
             }
-
             logService.insertLog("商品",
                     new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(m.getName()).toString(), request);
             return 1;
@@ -240,6 +238,7 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
     public int updateMaterial(JSONObject obj, HttpServletRequest request) throws Exception{
         Material material = JSONObject.parseObject(obj.toJSONString(), Material.class);
+
         try{
             //修改商品属性
             materialMapper.updateByPrimaryKeySelective(material);
@@ -1633,12 +1632,19 @@ public class MaterialServiceImpl extends ServiceImpl<MaterialMapper, Material> i
 
     @Override
     public List<MaterialVo4Unit> getMaterialBySystemSku(List<String> systemSkuList) {
-        if (CollectionUtil.isEmpty(systemSkuList)){
+        if (CollectionUtil.isEmpty(systemSkuList)) {
             return null;
         }
-        String[] systemSkuArray = systemSkuList.toArray(new String[0]);
-        List<MaterialVo4Unit> list =  materialMapperEx.getMaterialBySystemSku(systemSkuArray);
-        return list;
+        String[] systemSkuArray = systemSkuList.toArray(new String[systemSkuList.size()]);
+        return materialMapperEx.getMaterialBySystemSku(systemSkuArray);
+    }
+
+    @Override
+    public List<MaterialCurrentStock4SystemSku> getMaterialCurrentPriceByIdList(List<Long> idList) {
+        if (CollectionUtil.isEmpty(idList)) {
+            return null;
+        }
+        return materialMapperEx.getMaterialCurrentPriceByIdList(idList);
     }
 
     /**

+ 4 - 1
src/main/resources/application-dev.yml

@@ -1,6 +1,6 @@
 server:
   #端口号
-  port: 8080
+  port: 9080
   tomcat:
     basedir: F:/kaifa/temp #文件上传临时路径
 
@@ -30,3 +30,6 @@ aliyun:
     bucketName: xiangli-erp
     miniProgramAppId: wxd716cb744e32271a
     linkUrl: https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com
+tesco:
+  sycnErpMaterialStockUrl: http://localhost:8088/no-auth/erp/sync-stock
+  sycnErpMaterialPriceUrl: http://localhost:8088/no-auth/erp/sync-saleprice

+ 4 - 0
src/main/resources/application-pro.yml

@@ -30,3 +30,7 @@ aliyun:
     bucketName: xiangli-erp
     miniProgramAppId: wxd716cb744e32271a
     linkUrl: https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com
+
+tesco:
+  sycnErpMaterialStockUrl: https://tesco.xianglitech.com.cn/prod-api/no-auth/erp/sync-stock
+  sycnErpMaterialPriceUrl: https://tesco.xianglitech.com.cn/prod-api/no-auth/erp/sync-saleprice

+ 4 - 0
src/main/resources/application-test.yml

@@ -30,3 +30,7 @@ aliyun:
     bucketName: xiangli-erp
     miniProgramAppId: wxd716cb744e32271a
     linkUrl: https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com
+
+tesco:
+  sycnErpMaterialStockUrl: https://test.xianglitech.com.cn/stage-api/no-auth/erp/sync-stock
+  sycnErpMaterialPriceUrl: https://test.xianglitech.com.cn/stage-api/no-auth/erp/sync-saleprice

+ 20 - 0
src/main/resources/mapper_xml/MaterialCurrentStockMapperEx.xml

@@ -31,6 +31,26 @@
         select ifnull(mcs.current_unit_price,0) as current_unit_price from jsh_material_current_stock mcs where mcs.material_id=#{materialId} limit 1
     </select>
 
+    <select id="getCurrentStockMapByMdIdList" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
+        SELECT m.id                                             AS mId,
+               m.name                                           AS mName,
+               m.unit                                           AS unit,
+               m.unit_id                                        AS unitId,
+               m.system_sku                                     AS systemSku,
+               SUM(mcs.current_number)                          AS basicUnitTotalStock,
+               MIN(mcs.current_unit_price)                      AS basicUnitSalePrice
+        FROM jsh_material_current_stock mcs
+        LEFT JOIN jsh_material m ON m.id = mcs.material_id
+        WHERE m.id IN
+        <foreach collection="materialIdList" item="materialId" index="index" separator="," open="(" close=")">
+            #{materialId}
+        </foreach>
+        AND ifnull(mcs.delete_flag,'0') !='1'
+        AND ifnull(m.delete_flag,'0') !='1'
+        GROUP BY m.id, m.system_sku
+    </select>
+
+
     <update id="batchDeleteByDepots">
         update jsh_material_current_stock
         set delete_flag='1'

+ 27 - 0
src/main/resources/mapper_xml/MaterialMapperEx.xml

@@ -862,4 +862,31 @@
         and ifnull(me.delete_flag,'0') !='1'
     </select>
 
+    <select id="getMaterialCurrentPriceByIdList" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultType="com.jsh.erp.datasource.vo.MaterialCurrentStock4SystemSku">
+        WITH RankedExtend AS (
+            SELECT
+                me.*,
+                ROW_NUMBER() OVER (PARTITION BY me.material_id ORDER BY me.batch_number DESC) AS rn
+            FROM jsh_material_extend me
+            LEFT JOIN jsh_material m ON m.id = me.material_id
+            WHERE ifnull(me.delete_Flag, '0') != '1'
+              AND m.id IN (
+                <foreach collection="idList" item="systemSku" separator=",">
+                    #{systemSku}
+                </foreach>
+            )
+        )
+        SELECT
+            m.id                                             AS mId,
+            m.name                                           AS mName,
+            m.unit                                           AS unit,
+            m.unit_id                                        AS unitId,
+            m.system_sku                                     AS systemSku,
+            re.wholesale_decimal                             AS basicUnitSalePrice
+        FROM jsh_material m
+        LEFT JOIN RankedExtend re ON m.id = re.material_id AND re.rn = 1
+        WHERE ifnull(m.delete_flag, '0') != '1' AND re.id IS NOT NULL
+        ORDER BY m.id DESC
+    </select>
+
 </mapper>