소스 검색

Merge branch 'master' into test

# Conflicts:
#	hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java
yzc 1 년 전
부모
커밋
0b2c2f834d

+ 1 - 0
hx-common/src/main/java/com/fjhx/common/enums/FlowStatusEnum1.java

@@ -17,6 +17,7 @@ public enum FlowStatusEnum1 {
     UNDER_REVIEW(10, "审批中"),
     REJECT(20, "驳回"),
     PASS(30, "通过"),
+    UPDATE_LOADING(60, "变更中"),
     UPDATE(70, "变更"),
     CANCELLATION(88, "作废"),
     TERMINATION(99, "终止"),

+ 2 - 1
hx-purchase/src/main/resources/mapper/pay/PayDetailMapper.xml

@@ -48,8 +48,9 @@
         pay_detail t1
         LEFT JOIN pay t2 ON t1.pay_id = t2.id
         <where>
+            pay_type != 3
             <if test="purchaseIds neq null and purchaseIds.size() > 0">
-                <foreach collection="purchaseIds" item="purchaseId" open="purchase_id IN (" separator="," close=")">
+                <foreach collection="purchaseIds" item="purchaseId" open="AND purchase_id IN (" separator="," close=")">
                     #{purchaseId}
                 </foreach>
             </if>

+ 9 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/Contract.java

@@ -319,6 +319,15 @@ public class Contract extends BasePo {
     private Integer versions;
 
     /**
+     * 是否显示
+     */
+    private Integer isShow;
+
+
+    @TableField(exist = false)
+    private Long upId;
+
+    /**
      * 交接单附件列表
      */
     @TableField(exist = false)

+ 0 - 1
hx-sale/src/main/java/com/fjhx/sale/entity/pack/po/PackDetailProduct.java

@@ -59,5 +59,4 @@ public class PackDetailProduct extends BasePo {
      * 备注
      */
     private String remark;
-
 }

+ 4 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/pack/vo/PackDetailProductVo.java

@@ -14,4 +14,8 @@ import lombok.Setter;
 @Setter
 public class PackDetailProductVo extends PackDetailProduct {
 
+    /**
+     * 业务ID
+     */
+    private Long businessId;
 }

+ 205 - 26
hx-sale/src/main/java/com/fjhx/sale/flow/ContractUpdateFlow.java

@@ -2,9 +2,11 @@ package com.fjhx.sale.flow;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.*;
+import com.fjhx.area.utils.CustomizeAreaUtil;
 import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.utils.Assert;
+import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
 import com.fjhx.flow.enums.FlowStatusEnum;
 import com.fjhx.sale.entity.claim.po.ClaimContract;
@@ -15,9 +17,12 @@ import com.fjhx.sale.entity.contract.po.ContractProject;
 import com.fjhx.sale.entity.contract.po.ContractShipment;
 import com.fjhx.sale.service.claim.ClaimContractService;
 import com.fjhx.sale.service.contract.ContractProductService;
+import com.fjhx.sale.service.contract.ContractProjectService;
 import com.fjhx.sale.service.contract.ContractService;
+import com.fjhx.sale.service.contract.ContractShipmentService;
 import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.core.domain.BasePo;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +54,13 @@ public class ContractUpdateFlow extends FlowDelegate {
     @Autowired
     private ClaimContractService claimContractService;
 
+
+    @Autowired
+    private ContractProjectService contractProjectService;
+
+    @Autowired
+    private ContractShipmentService contractShipmentService;
+
     @Override
     public String getFlowKey() {
         return "contract_update_flow";
@@ -63,14 +75,34 @@ public class ContractUpdateFlow extends FlowDelegate {
      */
     @Override
     public Long start(Long flowId, JSONObject submitData) {
-
         ContractDto contract = submitData.toJavaObject(ContractDto.class);
 
-        Assert.notEmpty(contract.getOldContractId(), "原合同id不能为空");
-
-        //变更 用原来合同号加后缀
+        // 原合同id不能为空
+        Long oldContractId = contract.getOldContractId();
+        if (oldContractId == null) {
+            throw new ServiceException("原合同id不能为空");
+        }
+        //查询原合同
         Contract oldContract = contractService.getById(contract.getOldContractId());
-        Assert.notEmpty(oldContract, "查询不到原合同信息");
+        if (ObjectUtil.isEmpty(oldContract)) {
+            throw new ServiceException("查询不到原合同信息");
+        }
+        //更新原样品单状态为变更中
+        oldContract.setStatus(FlowStatusEnum1.UPDATE_LOADING.getKey());
+        contractService.updateById(oldContract);
+        //查询旧合同的订单产品
+        List<ContractProduct> oldContractProductList = contractProductService.list(q -> q.eq(ContractProduct::getContractId, oldContractId));
+        if (CollectionUtils.isEmpty(oldContractProductList)) {
+            throw new ServiceException("原合同没有产品");
+        }
+        Map<Long, List<ContractProduct>> oldContractProductMap = oldContractProductList.stream().collect(Collectors.groupingBy(ContractProduct::getId));
+        List<ContractProduct> newContractProductList = contract.getContractProductList();
+        if (CollectionUtils.isEmpty(newContractProductList)) {
+            throw new ServiceException("变更合同产品不能为空");
+        }
+        /**
+         * 赋值新的变更合同号
+         */
         String code = oldContract.getCode();
         Matcher matcher = Pattern.compile(".*\\((.*?)\\)$").matcher(code);
         int index = 2;
@@ -79,29 +111,91 @@ public class ContractUpdateFlow extends FlowDelegate {
             code = code.substring(0, code.lastIndexOf("("));
         }
         contract.setCode(code + "(" + index + ")");
+        contract.setIsShow(1);//隐藏当前数据
+        /**
+         * 计算新合同的剩余数量
+         */
+        for (ContractProduct newCp : newContractProductList) {
+            newCp.setExpendQuantity(newCp.getQuantity());
+            if (ObjectUtil.isNotEmpty(newCp.getId())) {//如果新合同产品ID不为空
+                //取出旧合同
+                ContractProduct oldContractProduct = oldContractProductMap.getOrDefault(newCp.getId(), null).get(0);
+                //取出旧合同包装方式
+                JSONObject oldJson = JSONObject.parseObject(oldContractProduct.getEhsdJson());
+                String oldPackMethod = oldJson.getOrDefault("packMethod", null) == null ? null : oldJson.getOrDefault("packMethod", null).toString();
+                //取出新合同包装方式
+                JSONObject newJson = JSONObject.parseObject(newCp.getEhsdJson());
+                String newPackMethod = newJson.getOrDefault("packMethod", null) == null ? null : oldJson.getOrDefault("packMethod", null).toString();
+                /**
+                 * 商品英文名、尺寸、包装方式、数量 没有变更---取原本的剩余数量
+                 */
+                if (oldContractProduct.getQuantity().compareTo(newCp.getQuantity()) == 0
+                        && StringUtils.equals(oldContractProduct.getProductName(), newCp.getProductName())
+                        && StringUtils.equals(oldContractProduct.getProductModel(), newCp.getProductModel())
+                        && StringUtils.equals(oldPackMethod, newPackMethod)) {
+                    //取出旧的剩余数量
+                    newCp.setExpendQuantity(oldContractProduct.getExpendQuantity());
+                }
+            }
+        }
+        return update(contract);
+    }
 
-        //变更合同提前操作数据
-        contract = opDate(contract);
-
-        //清空id 方便后面生成新合同
-        contract.setId(null);
-        // 清空合同产品id
+    /**
+     * 变更
+     *
+     * @param contract
+     * @return
+     */
+    public Long update(ContractDto contract) {
+        // 赋值城市省份信息
+        CustomizeAreaUtil.setAreaId(contract);
+        SysUser loginUser = SecurityUtils.getLoginUser().getUser();
+        contract.setUserName(loginUser.getNickName());
+        contract.setBuyCityId(contract.getCityId());
+        contract.setBuyCountryId(contract.getCountryId());
+        contract.setBuyProvinceId(contract.getProvinceId());
+        contract.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
+//        contract.setRate(ExchangeRateUtil.getCnyToCodeRate(contract.getCurrency()));
+        contractService.save(contract);
+
+        // 保存合同产品
         List<ContractProduct> contractProductList = contract.getContractProductList();
         if (CollectionUtils.isNotEmpty(contractProductList)) {
-            contractProductList.forEach(item -> item.setId(null));
+            for (ContractProduct c : contractProductList) {
+                c.setId(IdWorker.getId());
+                c.setContractId(contract.getId());
+//                ObsFileUtil.saveFile(c.getFileList(), c.getId());
+            }
+            contractProductService.saveBatch(contractProductList);
         }
-        // 清空收费项目id
+
+        // 保存收费项目
         List<ContractProject> contractProjectList = contract.getContractProjectList();
         if (CollectionUtils.isNotEmpty(contractProjectList)) {
-            contractProjectList.forEach(item -> item.setId(null));
+            for (ContractProject c : contractProjectList) {
+                c.setId(IdWorker.getId());
+                c.setContractId(contract.getId());
+            }
+            contractProjectService.saveBatch(contractProjectList);
         }
-        // 清空自定义出货id
+
+        // 保存自定义出货
         List<ContractShipment> contractShipmentList = contract.getContractShipmentList();
         if (CollectionUtils.isNotEmpty(contractShipmentList)) {
-            contractShipmentList.forEach(item -> item.setId(null));
+            for (ContractShipment c : contractShipmentList) {
+                c.setId(IdWorker.getId());
+                c.setContractId(contract.getId());
+            }
+            contractShipmentService.saveBatch(contractShipmentList);
         }
 
-        contract = contractFlow.commStart(contract, 0);
+        // 交接单附件列表
+        ObsFileUtil.copyFileAndSave(contract.getFileList(), contract.getId(), 1);
+
+        // 包装指示附件列表
+        ObsFileUtil.copyFileAndSave(contract.getPackageFileList(), contract.getId(), 2);
+
         return contract.getId();
     }
 
@@ -114,32 +208,117 @@ public class ContractUpdateFlow extends FlowDelegate {
      */
     @Override
     public void end(Long flowId, Long businessId, JSONObject submitData) {
-
-        contractFlow.end(flowId, businessId, submitData);
-
-        // 通过业务id查询合同数据
-        Contract contract = contractService.getById(businessId);
-
-        // 原合同改为作废状态
-        Long oldContractId = contract.getOldContractId();
+        // 通过业务ID查询合同数据
+        Contract newContract = contractService.getById(businessId);
+        if (ObjectUtils.isEmpty(newContract)) {
+            throw new ServiceException("合同不存在");
+        }
+        long oldContractId = newContract.getOldContractId();//取出旧的合同ID
         Contract oldContract = contractService.getById(oldContractId);
         if (oldContract == null) {
             throw new ServiceException("原合同不存在");
         }
+        //替换新数据ID为临时ID
+        long temNewId = IdWorker.getId();
+        Contract temNewUpContract = new Contract();
+        temNewUpContract.setId(temNewId);
+        temNewUpContract.setUpId(businessId);
+        contractService.updateContract(temNewUpContract);
+
+        long temOldId = IdWorker.getId();
+        Contract temOldUpContract = new Contract();
+        temOldUpContract.setId(temOldId);
+        temOldUpContract.setUpId(oldContractId);
+        contractService.updateContract(temOldUpContract);
+
+
+        //查询新数据产品、收费、出货
+        List<Long> newContractProductIds = contractProductService.list(Wrappers.<ContractProduct>query().lambda().select(ContractProduct::getId).eq(ContractProduct::getContractId, businessId)).stream().map(ContractProduct::getId).collect(Collectors.toList());
+        List<Long> newContractProjectIds = contractProjectService.list(Wrappers.<ContractProject>query().lambda().select(ContractProject::getId).eq(ContractProject::getContractId, businessId)).stream().map(ContractProject::getId).collect(Collectors.toList());
+        List<Long> newContractShipmentIds = contractShipmentService.list(Wrappers.<ContractShipment>query().lambda().select(ContractShipment::getId).eq(ContractShipment::getContractId, businessId)).stream().map(ContractShipment::getId).collect(Collectors.toList());
+
+
+        //查询旧数据产品、收费、出货
+        List<Long> oldContractProductIds = contractProductService.list(Wrappers.<ContractProduct>query().lambda().select(ContractProduct::getId).eq(ContractProduct::getContractId, oldContractId)).stream().map(ContractProduct::getId).collect(Collectors.toList());
+        List<Long> oldContractProjectIds = contractProjectService.list(Wrappers.<ContractProject>query().lambda().select(ContractProject::getId).eq(ContractProject::getContractId, oldContractId)).stream().map(ContractProject::getId).collect(Collectors.toList());
+        List<Long> oldContractShipmentIds = contractShipmentService.list(Wrappers.<ContractShipment>query().lambda().select(ContractShipment::getId).eq(ContractShipment::getContractId, oldContractId)).stream().map(ContractShipment::getId).collect(Collectors.toList());
+
+
+        /**
+         * 处理新合同---
+         */
+        newContract.setId(oldContractId);//id赋值为旧合同的id
+        newContract.setStatus(FlowStatusEnum1.PASS.getKey());
+        newContract.setApprovedDate(new Date());
+        newContract.setUpId(temNewId);
+        newContract.setOldContractId(businessId);
+        newContract.setIsShow(0);//显示新合同
+        contractService.updateContract(newContract);
+        //修改合同产品相关数据
+        if (CollectionUtils.isNotEmpty(newContractProductIds)) {
+            contractProductService.update(Wrappers.<ContractProduct>update().lambda().set(ContractProduct::getContractId, oldContractId).in(ContractProduct::getId, newContractProductIds));
+        }
+        //修改合同收费相关数据
+        if (CollectionUtils.isNotEmpty(newContractProjectIds)) {
+            contractProjectService.update(Wrappers.<ContractProject>update().lambda().set(ContractProject::getContractId, oldContractId).in(ContractProject::getId, newContractProjectIds));
+        }
+        //修改合同出货相关数据
+        if (CollectionUtils.isNotEmpty(newContractShipmentIds)) {
+            contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId, oldContractId).in(ContractShipment::getId, newContractShipmentIds));
+        }
+
+        /**
+         * 处理旧的合同---
+         */
+        oldContract.setId(businessId);
         oldContract.setStatus(FlowStatusEnum1.UPDATE.getKey());
         oldContract.setIsChange("1");
         contractService.updateById(oldContract);
 
         //删除到账认领数据
         claimContractService.remove(q -> q.eq(ClaimContract::getContractId, oldContractId));
+        oldContract.setUpId(temOldId);
+        oldContract.setIsShow(1);//隐藏旧合同
+        contractService.updateContract(oldContract);
+        //修改合同产品相关数据
+        if (CollectionUtils.isNotEmpty(oldContractProductIds)) {
+            contractProductService.update(Wrappers.<ContractProduct>update().lambda().set(ContractProduct::getContractId, businessId).in(ContractProduct::getId, oldContractProductIds));
+        }
+        //修改合同出货相关数据
+        if (CollectionUtils.isNotEmpty(oldContractProjectIds)) {
+            //修改合同收费相关数据
+            contractProjectService.update(Wrappers.<ContractProject>update().lambda().set(ContractProject::getContractId, businessId).in(ContractProject::getId, oldContractProjectIds));
+        }
+        //修改合同出货相关数据
+        if (CollectionUtils.isNotEmpty(oldContractShipmentIds)) {
+            //修改合同出货相关数据
+            contractShipmentService.update(Wrappers.<ContractShipment>update().lambda().set(ContractShipment::getContractId, businessId).in(ContractShipment::getId, oldContractShipmentIds));
+        }
+        ObsFileUtil.exchangeBusinessId(oldContractId, businessId);
     }
 
+    /**
+     * 重新发起
+     *
+     * @param flowId
+     * @param businessId
+     * @param flowStatus
+     * @param submitData
+     */
     @Override
     public void relaunch(Long flowId, Long businessId, FlowStatusEnum flowStatus, JSONObject submitData) {
         super.relaunch(flowId, businessId, flowStatus, submitData);
         reStart(submitData);
     }
 
+
+    /**
+     * 驳回
+     *
+     * @param flowId
+     * @param businessId
+     * @param flowStatus
+     */
     @Override
     public void reject(Long flowId, Long businessId, FlowStatusEnum flowStatus) {
         super.reject(flowId, businessId, flowStatus);

+ 1 - 0
hx-sale/src/main/java/com/fjhx/sale/mapper/contract/ContractMapper.java

@@ -96,4 +96,5 @@ public interface ContractMapper extends BaseMapper<Contract> {
      */
     List<AccountRunningWaterVo> getAccountRunningWaterByContractId(@Param("contractId") Long contractId);
 
+    void updateContract(Contract contract);
 }

+ 2 - 1
hx-sale/src/main/java/com/fjhx/sale/mapper/documents/DocumentsMapper.java

@@ -5,6 +5,7 @@ import com.fjhx.sale.entity.documents.po.Documents;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.sale.entity.documents.vo.DocumentsVo;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -21,6 +22,6 @@ public interface DocumentsMapper extends BaseMapper<Documents> {
     /**
      * 单证表分页
      */
-    Page<DocumentsVo> getPage(@Param("page") Page<Object> page, @Param("ew") QueryWrapper<Object> wrapper);
+    Page<DocumentsVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<Documents> wrapper);
 
 }

+ 2 - 0
hx-sale/src/main/java/com/fjhx/sale/service/contract/ContractService.java

@@ -181,4 +181,6 @@ public interface ContractService extends BaseService<Contract> {
      * 根据合同id获取合同的资金流水信息
      */
     List<AccountRunningWaterVo> getAccountRunningWaterByContractId(Long contractId);
+
+    void updateContract(Contract contract);
 }

+ 12 - 0
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -89,6 +89,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.core.context.SecurityContext;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -1612,4 +1613,15 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
     public List<AccountRunningWaterVo> getAccountRunningWaterByContractId(Long contractId) {
         return baseMapper.getAccountRunningWaterByContractId(contractId);
     }
+
+    /**
+     * 修改合同
+     *
+     * @param contract
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void updateContract(Contract contract) {
+        baseMapper.updateContract(contract);
+    }
 }

+ 16 - 4
hx-sale/src/main/java/com/fjhx/sale/service/documents/impl/DocumentsServiceImpl.java

@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.JSONWriter;
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -29,7 +28,6 @@ import com.fjhx.sale.entity.documents.po.DocumentsTransport;
 import com.fjhx.sale.entity.documents.vo.DocumentsVo;
 import com.fjhx.sale.entity.pack.po.PackDetail;
 import com.fjhx.sale.entity.pack.po.PackDetailGoods;
-import com.fjhx.sale.entity.pack.po.PackDetailProduct;
 import com.fjhx.sale.entity.pack.po.PackShipment;
 import com.fjhx.sale.mapper.documents.DocumentsMapper;
 import com.fjhx.sale.service.contract.ContractProjectService;
@@ -43,6 +41,8 @@ import com.fjhx.sale.service.pack.PackDetailProductService;
 import com.fjhx.sale.service.pack.PackDetailService;
 import com.fjhx.sale.service.pack.PackShipmentService;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -109,8 +109,18 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
      */
     @Override
     public Page<DocumentsVo> getPage(DocumentsSelectDto dto) {
-        QueryWrapper<Object> wrapper = Wrappers.query();
-        wrapper.orderByDesc("d.create_time");
+        IWrapper<Documents> wrapper = getWrapper();
+        wrapper.orderByDesc("d",Documents::getCreateTime);
+        if (StringUtils.isNotEmpty(dto.getKeyword())) {
+            //归属公司
+            List<Long> corporationIds = corporationService.listObject(Corporation::getId, q -> q.like(Corporation::getName, dto.getKeyword()));
+            List<Long> customerIds = customerService.listObject(Customer::getId, q -> q.like(Customer::getName, dto.getKeyword()));
+            wrapper.and(q -> q
+                    .like("c", Contract::getCode, dto.getKeyword())
+                    .or().in("c", Contract::getSellCorporationId, corporationIds)
+                    .or().in("c", Contract::getBuyCorporationId, customerIds)
+            );
+        }
         Page<DocumentsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         //切换数据源
         DynamicDataSourceContextHolder.push(SourceConstant.COMMON);
@@ -381,6 +391,8 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
                     JSONObject object = new JSONObject();
                     // 项号
                     object.put("num", num);
+                    //产品id
+                    object.put("productId", product.getProductId());
                     // 商品编号(13位)原10位海关编码+3位检验检疫附加编码
                     object.put("customsCode", product.getCustomsCode());
                     // 商品名称

+ 20 - 14
hx-sale/src/main/java/com/fjhx/sale/service/pack/impl/PackShipmentServiceImpl.java

@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.sale.entity.documents.po.Documents;
 import com.fjhx.sale.entity.pack.dto.PackShipmentDto;
 import com.fjhx.sale.entity.pack.dto.PackShipmentSelectDto;
+import com.fjhx.sale.entity.pack.po.PackDetail;
 import com.fjhx.sale.entity.pack.po.PackDetailGoods;
 import com.fjhx.sale.entity.pack.po.PackShipment;
 import com.fjhx.sale.entity.pack.vo.PackShipmentVo;
@@ -23,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
@@ -101,25 +103,29 @@ public class PackShipmentServiceImpl extends ServiceImpl<PackShipmentMapper, Pac
         if (ObjectUtil.isEmpty(dto.getPackDetailIds())){
             throw  new ServiceException("参数缺失:包装明细单ID不能为null");
         }
+        List<Map<String,Object>> list = new ArrayList<>();
         String packDetailIds = dto.getPackDetailIds();
         //获取到包装明细单ID列表
         List<String> ids = Arrays.asList(packDetailIds.split(","));
-        //查询自定义货物
-        List<PackDetailGoods> goodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().in(PackDetailGoods::getPackDetailId,ids));
-        if(CollectionUtils.isNotEmpty(goodsList)){
-            List<Map<String,Object>> list = new ArrayList<>();
-            for(PackDetailGoods p : goodsList){
-                Map<String,Object> map = new HashMap<>();
-                map.put("businessId",p.getId());
-                map.put("price",0);
-                map.put("quantity",p.getQuantity());
-                map.put("subDescription",p.getRemark());
-                map.put("type","20");
-                list.add(map);
+        for(String id : ids){
+            List<PackDetailGoods> goodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().eq(PackDetailGoods::getPackDetailId,id));
+            if(CollectionUtils.isNotEmpty(goodsList)){
+                //添加货物
+                for(PackDetailGoods p : goodsList){
+                    Map<String,Object> map = new HashMap<>();
+                    map.put("businessId",p.getId());
+                    map.put("price",0);
+                    map.put("quantity",p.getQuantity());
+                    map.put("subDescription",p.getRemark());
+                    map.put("type","20");
+                    list.add(map);
+                }
+            }else{
+                List<Map<String,Object>> productList = baseMapper.productDetailList(Arrays.asList(id));
+                list.addAll(productList);
             }
-            return list;
         }
-        return baseMapper.productDetailList(ids);
+        return list;
     }
 
 }

+ 13 - 0
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -215,4 +215,17 @@
           AND c.id = #{contractId}
     </select>
 
+    <update id="updateContract" parameterType="com.fjhx.sale.entity.contract.po.Contract">
+        update contract
+        <set>
+            <if test="id != null">id = #{id},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="isChange != null">is_change = #{isChange},</if>
+            <if test="isShow != null">is_show = #{isShow},</if>
+            <if test="oldContractId != null">old_contract_id = #{oldContractId},</if>
+            <if test="approvedDate != null">approved_date = DATE_FORMAT(NOW(),'%Y-%m-%d %H:%m:%s'),</if>
+            update_time = sysdate()
+        </set>
+        where id = #{upId}
+    </update>
 </mapper>

+ 8 - 21
hx-sale/src/main/resources/mapper/pack/PackShipmentMapper.xml

@@ -24,27 +24,14 @@
     </select>
     <select id="productDetailList" resultType="java.util.Map">
         SELECT
-        id as businessId,
-        remark,
-        null as subDescription,
-        null as customsCode,
-        quantity,
-        null as price,
-        10 as type
-        FROM
-        pack_detail_goods dg
-        <where>
-            <include refid="productDetail"/>
-        </where>
-        UNION
-        SELECT
-        dg.id AS businessId,
-        json_unquote( pi.standard_json -> '$.englishName' ) remark,
-        dg.product_name AS subDescription,
-        json_unquote ( pi.standard_json -> '$.customsCode' ) AS customsCode,
-        dg.quantity,
-        cp.price AS price,
-        20 AS type
+            pack_detail_id AS packDetailId,
+            dg.id AS businessId,
+            json_unquote( pi.standard_json -> '$.englishName' ) remark,
+            dg.product_name AS subDescription,
+            json_unquote ( pi.standard_json -> '$.customsCode' ) AS customsCode,
+            dg.quantity,
+            cp.price AS price,
+            20 AS type
         FROM
         pack_detail_product dg
         LEFT JOIN bytesailing_item.product_info pi ON dg.product_id = pi.id

+ 1 - 1
hx-wms/src/main/java/com/fjhx/wms/service/stock/impl/StockServiceImpl.java

@@ -543,7 +543,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
     /**
      * 改变库存数量
      */
-    private void changeStock(List<? extends InOutBo> list, Long warehouseId, JournalType journalType) {
+    private synchronized void changeStock(List<? extends InOutBo> list, Long warehouseId, JournalType journalType) {
 
         Map<Long, BigDecimal> map = list.stream().collect(Collectors.toMap(
                 InOutBo::getProductId,