18482106067 2 سال پیش
والد
کامیت
9b69e19433

+ 1 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/AddressDefaultTypeEnum.java

@@ -11,7 +11,7 @@ import lombok.Getter;
 public enum AddressDefaultTypeEnum {
 
     //普通
-    NO(0, "普通"),
+    NO(0, ""),
     //装货地址
     SHIPMENT(1, "装货"),
     //收货地址

+ 20 - 4
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmAddressService.java

@@ -163,19 +163,35 @@ public class KwmAddressService {
     @Transactional(rollbackFor = {})
     public void bindDefault(BindDefaultReqVo reqVo) {
         KwmAddress kwmAddress = kwmAddressMapper.selectById(reqVo.getId());
-        if (Objects.isNull(kwmAddress)) {
+        if (Objects.isNull(kwmAddress) || kwmAddress.getDelFlag().equals(Global.YES)) {
             throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ADDRESS_NOT_EXISTS);
         }
 
-        Long userId = LoginUserHolder.getUserId();
+
         Long entId = kwmAddress.getEntId();
+        Long userId = LoginUserHolder.getUserId();
         Date date = new Date();
         Integer defaultType = kwmAddress.getDefaultType();
         Integer setDefaultType = reqVo.getDefaultType();
 
-        //相等则取消
-        if (!defaultType.equals(AddressDefaultTypeEnum.NO.getCode())) {
+//        LambdaQueryWrapper<KwmAddress> wrapper = new LambdaQueryWrapper<>();
+//        wrapper.eq(KwmAddress::getEntId, entId).
+//                eq(KwmAddress::getDelFlag, Global.NO).
+//                eq(KwmAddress::getStatus, Global.NO);
+//        List<KwmAddress> entAddress = kwmAddressMapper.selectList(wrapper);
+//        List<Integer> defaultTypeList = entAddress.stream().map(KwmAddress::getDefaultType).distinct().toList();
+//        if (defaultType.equals(AddressDefaultTypeEnum.SHIPMENT.getCode()) && (defaultTypeList.contains(AddressDefaultTypeEnum.SHIPMENT.getCode()) || defaultTypeList.contains(AddressDefaultTypeEnum.BOTH.getCode()))) {
+//            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_021);
+//        }
+//
+//        if (defaultType.equals(AddressDefaultTypeEnum.TAKE.getCode()) && (defaultTypeList.contains(AddressDefaultTypeEnum.TAKE.getCode()) || defaultTypeList.contains(AddressDefaultTypeEnum.BOTH.getCode()))) {
+//            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_021);
+//        }
+
+        //当前是收货或者卸货
+        if (!defaultType.equals(AddressDefaultTypeEnum.NO.getCode()) && !defaultType.equals(AddressDefaultTypeEnum.BOTH.getCode())) {
             if (defaultType.equals(setDefaultType)) {
+                //相等则取消
                 kwmAddress.setDefaultType(AddressDefaultTypeEnum.NO.getCode());
             } else {
                 kwmAddress.setDefaultType(AddressDefaultTypeEnum.BOTH.getCode());

+ 31 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/service/KwmCooperateManageService.java

@@ -495,6 +495,36 @@ public class KwmCooperateManageService {
         if (CollectionUtils.isNotEmpty(child)) {
             longs.addAll(child.stream().map(EntCacheResDto::getId).toList());
         }
-        return cooperateByEnt.stream().filter(item -> longs.contains(item.getTargetEntId())).toList();
+
+        List<FindCooperateByEntResVo> findCooperateByEntResVos = cooperateByEnt.stream().filter(item -> longs.contains(item.getTargetEntId())).toList();
+        if (CollectionUtils.isEmpty(findCooperateByEntResVos)) {
+            return Collections.emptyList();
+        }
+
+        //由于是以对方单位为第一单位查,所以这里要取反一下
+        long entIdTemp;
+        long contactsId;
+        String entIdName;
+        String contacts;
+        String phone;
+        for (FindCooperateByEntResVo findCooperateByEntResVo : findCooperateByEntResVos) {
+            entIdTemp = findCooperateByEntResVo.getEntId();
+            entIdName = findCooperateByEntResVo.getEntName();
+            contactsId = findCooperateByEntResVo.getContactsId();
+            contacts = findCooperateByEntResVo.getContacts();
+            phone = findCooperateByEntResVo.getPhone();
+
+            findCooperateByEntResVo.setEntId(findCooperateByEntResVo.getTargetEntId());
+            findCooperateByEntResVo.setEntName(findCooperateByEntResVo.getTargetEntName());
+            findCooperateByEntResVo.setContactsId(findCooperateByEntResVo.getTargetContactsId());
+            findCooperateByEntResVo.setContacts(findCooperateByEntResVo.getTargetContacts());
+            findCooperateByEntResVo.setPhone(findCooperateByEntResVo.getTargetPhone());
+            findCooperateByEntResVo.setTargetEntId(entIdTemp);
+            findCooperateByEntResVo.setTargetEntName(entIdName);
+            findCooperateByEntResVo.setTargetContactsId(contactsId);
+            findCooperateByEntResVo.setTargetContacts(contacts);
+            findCooperateByEntResVo.setTargetPhone(phone);
+        }
+        return findCooperateByEntResVos;
     }
 }

+ 23 - 16
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -284,23 +284,29 @@ public class KwsEnterpriseService {
         }
 
         /*2、存企业类型,一个企业可以有多个类型*/
-        List<KwsEntType> kwsEntTypes = new ArrayList<>();
+        List<KwsEntType> listByEntId = kwsEntTypeDao.findListByEntId(entId);
+        List<Integer> typeList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(listByEntId)) {
+            typeList = listByEntId.stream().map(KwsEntType::getType).toList();
+        }
+        List<Integer> finalTypeList = typeList;
         Arrays.stream(reqVo.getEntTypes().split(",")).toList().forEach(item -> {
-            KwsEntType kwsEntType = new KwsEntType();
-            kwsEntType.setEntId(entId);
-            kwsEntType.setType(Integer.parseInt(item));
-            kwsEntType.setId(new IdWorker(1).nextId());
-            kwsEntType.setStatus(Global.NO);
-            kwsEntType.setCreateBy(userId);
-            kwsEntType.setCreateTime(date);
-            kwsEntType.setUpdateBy(userId);
-            kwsEntType.setUpdateTime(date);
-            kwsEntType.setDelFlag(Global.NO);
-            kwsEntTypes.add(kwsEntType);
+            if (!finalTypeList.contains(item)) {
+                KwsEntType kwsEntType = new KwsEntType();
+                kwsEntType.setEntId(entId);
+                kwsEntType.setType(Integer.parseInt(item));
+                kwsEntType.setId(new IdWorker(1).nextId());
+                kwsEntType.setStatus(Global.NO);
+                kwsEntType.setCreateBy(userId);
+                kwsEntType.setCreateTime(date);
+                kwsEntType.setUpdateBy(userId);
+                kwsEntType.setUpdateTime(date);
+                kwsEntType.setDelFlag(Global.NO);
+                if (kwsEntTypeDao.insert(kwsEntType) <= 0) {
+                    throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
+                }
+            }
         });
-        if (kwsEntTypeDao.saveBatch(kwsEntTypes) != kwsEntTypes.size()) {
-            throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
-        }
 
         /*3、存企业证书*/
         List<KwsEntCertificate> kwsEntCertificates = new ArrayList<>();
@@ -385,6 +391,7 @@ public class KwsEnterpriseService {
         /*新增审批记录*/
         KwsEntCheckTrack kwsEntCheckTrack = new KwsEntCheckTrack();
         kwsEntCheckTrack.setEntId(entId);
+        kwsEntCheckTrack.setRemark(reqVo.getRemark());
         if (kwsEntCheckTrackDao.insert(kwsEntCheckTrack) <= 0) {
             throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
         }
@@ -695,7 +702,7 @@ public class KwsEnterpriseService {
         BeanUtils.copyProperties(kwsEnterprise, entDetailResVo);
         List<KwsEntType> listByEntIds = kwsEntTypeDao.findListByEntIds(Collections.singletonList(kwsEnterprise.getId()));
         if (CollectionUtils.isNotEmpty(listByEntIds)) {
-            entDetailResVo.setEntTypes(String.join(Global.COMMA, listByEntIds.stream().map(KwsEntType::getType).map(String::valueOf).toList()));
+            entDetailResVo.setEntTypes(String.join(Global.COMMA, listByEntIds.stream().map(KwsEntType::getType).map(String::valueOf).distinct().toList()));
         }
         return entDetailResVo;
     }