Forráskód Böngészése

1.修改缓存懒加载
2.修改承运订单导入bug

lengfaqiang 2 éve
szülő
commit
94f38c6ac1

+ 6 - 1
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -17,7 +17,6 @@ import com.sckw.core.model.enums.LoginMethodEnum;
 import com.sckw.core.model.enums.SystemTypeEnum;
 import com.sckw.core.utils.*;
 import com.sckw.core.web.constant.HttpStatus;
-import com.sckw.core.web.constant.RequestConstant;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.model.LoginUserInfo;
 import com.sckw.core.web.response.HttpResult;
@@ -33,8 +32,10 @@ import com.sckw.system.api.model.dto.req.UserLoginReqDto;
 import com.sckw.system.api.model.dto.res.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
+import org.redisson.api.RSet;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -577,6 +578,10 @@ public class AuthServiceImpl implements IAuthService {
                 if (enterpriseIds.size() > 0) {
                     enterpriseIds = enterpriseIds.stream().distinct().collect(Collectors.toList());
                     String key = Global.getCustomerManagerUserLoginKey(loginUserInfo.getSystemType(), loginUserInfo.getId());
+                    RSet<Object> set = RedissonUtils.getSet(key);
+                    if (CollectionUtils.isNotEmpty(set)){
+                        RedissonUtils.delete(key);
+                    }
                     RedissonUtils.putSet(key, enterpriseIds);
                     loginUserInfo.setAuthEntIdList(enterpriseIds);
                 }

+ 1 - 1
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dubbo/RemoteContractServiceImpl.java

@@ -164,7 +164,7 @@ public class RemoteContractServiceImpl implements RemoteContractService {
      */
     @Override
     public ContractLogisticsOrderResDto getContractByContractNo(String contractNo, Long acceptId, Long consignId) {
-        ContractLogisticsOrderResDto logisticsOrderResDto = null;
+        ContractLogisticsOrderResDto logisticsOrderResDto = new ContractLogisticsOrderResDto();
         List<KwcContractLogistics> list = kwcContractLogisticsMapper.selectIsSole(contractNo, acceptId, consignId);
         if (list.size() > 0) {
             KwcContractLogistics contractLogistics = list.get(0);

+ 1 - 0
sckw-modules/sckw-order/src/main/java/com/sckw/order/dubbo/TradeOrderStatisticsServiceImpl.java

@@ -28,6 +28,7 @@ public class TradeOrderStatisticsServiceImpl implements TradeOrderStatisticsServ
 
     @Override
     public Map<Integer, Integer> getOrderNumByTopEntId(Long topEntId,List<Long> enterpriseIds) {
+        enterpriseIds.add(topEntId);
         enterpriseIds=enterpriseIds.stream().distinct().collect(Collectors.toList());
         Map<Integer, Integer> map = new HashMap<>(Global.NUMERICAL_FOUR);
         map.put(Global.NUMERICAL_ONE, Global.NUMERICAL_ZERO);

+ 1 - 1
sckw-modules/sckw-order/src/main/resources/mapper/KwoTradeOrderMapper.xml

@@ -20,7 +20,7 @@
             <if test="topEntId != null ">
                 and u.top_ent_id = #{topEntId}
             </if>
-            <if test="enterpriseIds != null and enterpriseIds.size() != 0">
+            <if test="enterpriseIds != null and enterpriseIds.size() > 0">
                 and o.ent_id in
                 <foreach collection="enterpriseIds" item="item" open="(" close=")" separator=",">
                     #{item}

+ 5 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/res/OperationGoodsDetail.java

@@ -213,4 +213,9 @@ public class OperationGoodsDetail implements Serializable {
      */
     private List<GoodsAttributesDetail> attributes;
 
+    /**
+     * 辅助单位
+     */
+    private List<GoodsUnitDetail> assistUnit;
+
 }

+ 18 - 5
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/operation/GoodsManagerService.java

@@ -3,6 +3,7 @@ package com.sckw.product.service.operation;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.model.vo.TableBottom;
@@ -21,11 +22,9 @@ import com.sckw.product.model.dto.OperatorGoodsListQueryDTO;
 import com.sckw.product.model.vo.req.OperatorGoodsExportQueryVO;
 import com.sckw.product.model.vo.req.OperatorGoodsListQueryVO;
 import com.sckw.product.model.vo.req.OperatorGoodsStsQueryVO;
-import com.sckw.product.model.vo.res.GoodsDetail;
-import com.sckw.product.model.vo.res.GoodsList;
-import com.sckw.product.model.vo.res.OperationGoodsDetail;
-import com.sckw.product.model.vo.res.OperationGoodsList;
+import com.sckw.product.model.vo.res.*;
 import com.sckw.product.service.KwpGoodsService;
+import com.sckw.product.service.KwpGoodsUnitService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
 import com.sckw.system.api.model.dto.res.KwsUserResDto;
@@ -57,6 +56,7 @@ public class GoodsManagerService {
 
     private final KwpGoodsService kwpGoodsService;
     private final KwpGoodsMapper kwpGoodsMapper;
+    private final KwpGoodsUnitService kwpGoodsUnitService;
 
 
     /**
@@ -153,7 +153,20 @@ public class GoodsManagerService {
      */
     public OperationGoodsDetail getDetail(Long id) {
         GoodsDetail goodsDetail = kwpGoodsService.detail(id);
-        return BeanUtils.copyProperties(goodsDetail, OperationGoodsDetail.class);
+        OperationGoodsDetail operationGoodsDetail = new OperationGoodsDetail();
+        BeanUtils.copyProperties(goodsDetail, operationGoodsDetail);
+        //商品辅助单位信息
+        Map<String, SysDictResDto> finalUnitMap = remoteSystemService.queryDictMapByType(DictTypeEnum.UNIT_TYPE.getType());
+        List<GoodsUnitDetail> assistUnit = kwpGoodsUnitService.findGoodsUnitDetail(id);
+        if (CollectionUtils.isNotEmpty(assistUnit)) {
+            //数据组装
+            assistUnit.forEach(e -> {
+                e.setFromUnitName(finalUnitMap != null ? (finalUnitMap.get(e.getFromUnit()) != null ? finalUnitMap.get(e.getFromUnit()).getLabel() : null) : null);
+                e.setToUnitName(finalUnitMap != null ? (finalUnitMap.get(e.getToUnit()) != null ? finalUnitMap.get(e.getToUnit()).getLabel() : null) : null);
+            });
+        }
+        operationGoodsDetail.setAssistUnit(assistUnit);
+        return operationGoodsDetail;
     }
 
     /**

+ 2 - 2
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwWorkService.java

@@ -29,7 +29,7 @@ import java.util.*;
 @Service
 public class KwWorkService {
 
-    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 8000)
+    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)
     private TransportStatisticsService transportStatisticsService;
 
     @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)
@@ -38,7 +38,7 @@ public class KwWorkService {
     @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)
     private RemoteContractService remoteContractService;
 
-    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)
+    @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 800000)
     private TradeOrderStatisticsService tradeOrderStatisticsService;
 
     @DubboReference(version = "1.0.0", group = "design", check = false,timeout = 80000)

+ 38 - 1
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -36,6 +36,7 @@ import com.sckw.system.model.vo.req.*;
 import com.sckw.system.model.vo.res.*;
 import jakarta.servlet.http.HttpServletRequest;
 import jakarta.servlet.http.HttpServletResponse;
+import org.redisson.api.RSet;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -385,13 +386,49 @@ public class KwsEnterpriseService {
         kwsEnterprise.setRegTime(date);
         kwsEnterprise.setUpdateBy(LoginUserHolder.getUserId());
         //默认给一个客户经理(admin账号)
-        if (StringUtils.isBlank(reqVo.getManager())) {
+        if (Objects.isNull(reqVo.getManager())) {
             List<KwsUserSystemTypeVo> userSystemTypeVos = userDao.selectUserBySystemType(SystemTypeEnum.MANAGE.getCode());
             if (CollectionUtils.isNotEmpty(userSystemTypeVos)) {
                 KwsUserSystemTypeVo kwsUserSystemTypeVo = userSystemTypeVos.get(0);
                 kwsEnterprise.setManager(kwsUserSystemTypeVo.getId());
             }
         }
+        //更新缓存
+        List<Long> enterpriseIds = new ArrayList<>();
+        if (LoginUserHolder.getSystemType().equals(SystemTypeEnum.MANAGE.getCode())) {
+            if (LoginUserHolder.getIsMain().equals(Global.YES)) {
+                //获取所有企业id
+                List<Long> enterpriseIdList = remoteUserService.findAllEnterprise();
+                if (Objects.nonNull(enterpriseIdList) && enterpriseIdList.size() > 0) {
+                    enterpriseIds.addAll(enterpriseIdList);
+                }
+                //获取所有运营端账号关联的企业(客户经理关联的企业)
+                List<Long> userIds = remoteUserService.selectUserBySystemType(SystemTypeEnum.MANAGE.getCode());
+                /**带有数据权限*/
+                List<Long> enterpriseListByIds = remoteUserService.findEnterpriseListByIds(userIds);
+                if (Objects.nonNull(enterpriseListByIds) && enterpriseListByIds.size() > 0) {
+                    enterpriseIds.addAll(enterpriseListByIds);
+                }
+                //无数据权限,运营账号(客户经理关联)关联的企业即可
+//                    enterpriseIds = remoteUserService.findEnterpriseListByUserIds(userIds);
+            } else {
+                List<Long> serviceEnterpriseIds = remoteUserService.findEnterpriseIds(LoginUserHolder.getUserId());
+                if (Objects.nonNull(serviceEnterpriseIds) && serviceEnterpriseIds.size() > 0) {
+                    enterpriseIds.addAll(serviceEnterpriseIds);
+                }
+            }
+        }
+        if (enterpriseIds.size() > 0) {
+            enterpriseIds.add(kwsEnterprise.getId());
+            enterpriseIds = enterpriseIds.stream().distinct().collect(Collectors.toList());
+            String key = Global.getCustomerManagerUserLoginKey(LoginUserHolder.getSystemType(), LoginUserHolder.getUserId());
+            RSet<Object> set = RedissonUtils.getSet(key);
+            if (CollectionUtils.isNotEmpty(set)) {
+                RedissonUtils.delete(key);
+            }
+            RedissonUtils.putSet(key, enterpriseIds);
+        }
+
         List<KwsEntCheckTrack> list = kwsEntCheckTrackDao.findList(entId);
         kwsEnterprise.setApproval(list.stream().anyMatch(item -> item.getStatus().equals(Global.NO)) ? ApprovalEnum.REFRESH.getCode() : ApprovalEnum.PROCESS.getCode());
         if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {

+ 1 - 1
sckw-modules/sckw-system/src/main/resources/mapper/KwsUserDao.xml

@@ -379,7 +379,7 @@
   <select id="selectUserBySystemType" resultType="com.sckw.system.model.vo.res.KwsUserSystemTypeVo">
       select u.id AS id,u.system_type AS systemType,u.account AS account,u.name AS name, u.phone AS phone,u.is_main as isMain
       from kws_user AS u
-      where u.del_flag = 0 and u.status = 0 and u.system_type = #{systemType}
+      where u.del_flag = 0 and u.status = 0 and is_main =0 and u.system_type = #{systemType}
     </select>
 
     <select id="selectUserBySystemTypeAndMain" resultType="com.sckw.system.model.vo.res.KwsUserSystemTypeVo">

+ 12 - 6
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/Import/KwtAcceptCarriageOrderImportService.java

@@ -288,7 +288,7 @@ public class KwtAcceptCarriageOrderImportService {
             /**根据合同计算当前单据状态*/
             /**判断生成物流订单应生成哪一种单据状态*/
             String contractNo = excelImport.getContract().trim();
-            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo,acceptCarriageEnterprise.getId(),consignEnterprise.getId());
+            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo, acceptCarriageEnterprise.getId(), consignEnterprise.getId());
             /**状态判断
              * 是否是已签约合同
              * */
@@ -562,7 +562,7 @@ public class KwtAcceptCarriageOrderImportService {
                 EntAddressResDto entAddressResDto = unloadAddressMap.get(unloadAddressName);
                 EntAddressResDto entAddressResDto1 = allAddressResMap.get(unloadAddressName);
                 if (entAddressResDto == null) {
-                    if (entAddressResDto1.getName().equals(loadAddressName)) {
+                    if (entAddressResDto1.getName().equals(unloadAddressName)) {
                         unloadAddress.setName(entAddressResDto1.getName());
                         unloadAddress.setContacts(entAddressResDto1.getContacts());
                         unloadAddress.setPhone(entAddressResDto1.getPhone());
@@ -573,7 +573,7 @@ public class KwtAcceptCarriageOrderImportService {
                         unloadAddress.setLng(entAddressResDto1.getLng());
                     }
                 } else {
-                    if (entAddressResDto.getName().equals(loadAddressName)) {
+                    if (entAddressResDto.getName().equals(unloadAddressName)) {
                         unloadAddress.setName(entAddressResDto.getName());
                         unloadAddress.setContacts(entAddressResDto.getContacts());
                         unloadAddress.setPhone(entAddressResDto.getPhone());
@@ -728,8 +728,8 @@ public class KwtAcceptCarriageOrderImportService {
                 throw new RuntimeException("第" + number + "行商品分类信息不存在");
             }
             String contractNo = excelImport.getContract().trim();
-            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo,acceptCarriageEnterprise.getId(),consignEnterprise.getId());
-            if (commonInfoResDto == null ) {
+            ContractLogisticsOrderResDto commonInfoResDto = remoteContractService.getContractByContractNo(contractNo, acceptCarriageEnterprise.getId(), consignEnterprise.getId());
+            if (commonInfoResDto == null || (commonInfoResDto.getId() == null)) {
                 throw new RuntimeException("第" + number + "行合同信息不存在");
             }
             if (commonInfoResDto.getConsignEntName() == null) {
@@ -795,6 +795,12 @@ public class KwtAcceptCarriageOrderImportService {
                     loadAddress.addAll(allAddress);
                     unloadAddress.addAll(allAddress);
                 }
+                if (loadAddress.size() < 1) {
+                    throw new RuntimeException("第" + number + "行承运企业在系统中并未维护该装货地址");
+                }
+                if (unloadAddress.size() < 1) {
+                    throw new RuntimeException("第" + number + "行承运企业在系统中并未维护该卸货地址");
+                }
                 if (loadAddress.size() > 0) {
                     loadAddress = loadAddress.stream().distinct().collect(Collectors.toList());
                     if (!loadAddress.contains(loadAddressName)) {
@@ -828,7 +834,7 @@ public class KwtAcceptCarriageOrderImportService {
                 Map<Long, EntCacheResDto> map = remoteSystemService.queryEntTreeByIds(Collections.singletonList(LoginUserHolder.getEntId()));
                 if (map != null) {
                     Long loginEntId = map.get(LoginUserHolder.getEntId()).getId();
-                    if (entIds.size() != 1 || (entIds.get(0) != loginEntId)) {
+                    if (entIds.size() != 1 || (!entIds.get(0).equals( loginEntId))) {
                         throw new RuntimeException("存在有承运单位与登录账号不属于同单位!");
                     }
                 } else {