|
|
@@ -4,11 +4,13 @@ import java.util.*;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sckw.contract.dao.KwcContractLogisticsUnitMapper;
|
|
|
+import com.sckw.contract.model.entity.KwcContractLogisticsGoods;
|
|
|
import com.sckw.contract.model.entity.KwcContractLogisticsUnit;
|
|
|
import com.sckw.contract.model.vo.req.LogisticsBaseInfoReqVo;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.CooperateTypeEnum;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
@@ -38,12 +40,20 @@ public class KwcContractLogisticsUnitService {
|
|
|
*/
|
|
|
public void saveContractLogisticsUnit(Long contractId, LogisticsBaseInfoReqVo baseInfo) throws SystemException {
|
|
|
List<Long> entIdList = new ArrayList<>();
|
|
|
- entIdList.add(baseInfo.getCheckedEntId());
|
|
|
- entIdList.add(baseInfo.getCarrierEntId());
|
|
|
- Map<Long, EntCacheResDto> entCacheResDtoMap = commonBusinessService.queryEntCacheMapByIds(entIdList);
|
|
|
+ if (Objects.nonNull(baseInfo.getCheckedEntId())) {
|
|
|
+ entIdList.add(baseInfo.getCheckedEntId());
|
|
|
+ }
|
|
|
|
|
|
- Date date = new Date();
|
|
|
- saveCheckAndCarrier(contractId, entCacheResDtoMap, date, baseInfo);
|
|
|
+ if (Objects.nonNull(baseInfo.getCarrierEntId())) {
|
|
|
+ entIdList.add(baseInfo.getCarrierEntId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(entIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, EntCacheResDto> entCacheResDtoMap = commonBusinessService.queryEntCacheMapByIds(entIdList);
|
|
|
+ saveCheckAndCarrier(contractId, entCacheResDtoMap, baseInfo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -52,33 +62,40 @@ public class KwcContractLogisticsUnitService {
|
|
|
* @author: czh
|
|
|
* @date 2023/7/16
|
|
|
*/
|
|
|
- private void saveCheckAndCarrier(Long contractId, Map<Long, EntCacheResDto> entCacheResDtoMap, Date date, LogisticsBaseInfoReqVo logisticsBaseInfoReqVo) {
|
|
|
+ private void saveCheckAndCarrier(Long contractId, Map<Long, EntCacheResDto> entCacheResDtoMap, LogisticsBaseInfoReqVo logisticsBaseInfoReqVo) throws SystemException {
|
|
|
+ Date date = new Date();
|
|
|
//存托运企业
|
|
|
+ Long checkedEntId = logisticsBaseInfoReqVo.getCheckedEntId();
|
|
|
KwcContractLogisticsUnit kwcContractLogisticsUnit = new KwcContractLogisticsUnit();
|
|
|
- kwcContractLogisticsUnit.setId(new IdWorker(1L).nextId());
|
|
|
- kwcContractLogisticsUnit.setContractId(contractId);
|
|
|
- kwcContractLogisticsUnit.setUnitType(CooperateTypeEnum.CONSIGN.getCode());
|
|
|
- kwcContractLogisticsUnit.setEntId(logisticsBaseInfoReqVo.getCheckedEntId());
|
|
|
- saveEnt(entCacheResDtoMap, kwcContractLogisticsUnit);
|
|
|
- kwcContractLogisticsUnit.setSignPhone(logisticsBaseInfoReqVo.getCheckedPhone());
|
|
|
- kwcContractLogisticsUnit.setStatus(Global.NO);
|
|
|
- kwcContractLogisticsUnit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
- kwcContractLogisticsUnit.setCreateTime(date);
|
|
|
- kwcContractLogisticsUnit.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
- kwcContractLogisticsUnit.setUpdateTime(date);
|
|
|
- kwcContractLogisticsUnit.setDelFlag(Global.NO);
|
|
|
- if (kwcContractLogisticsUnitMapper.insert(kwcContractLogisticsUnit) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+ if (Objects.nonNull(checkedEntId)) {
|
|
|
+ kwcContractLogisticsUnit.setId(new IdWorker(1L).nextId());
|
|
|
+ kwcContractLogisticsUnit.setContractId(contractId);
|
|
|
+ kwcContractLogisticsUnit.setUnitType(CooperateTypeEnum.CONSIGN.getCode());
|
|
|
+ kwcContractLogisticsUnit.setEntId(checkedEntId);
|
|
|
+ saveEnt(entCacheResDtoMap, kwcContractLogisticsUnit);
|
|
|
+ kwcContractLogisticsUnit.setSignPhone(logisticsBaseInfoReqVo.getCheckedPhone());
|
|
|
+ kwcContractLogisticsUnit.setStatus(Global.NO);
|
|
|
+ kwcContractLogisticsUnit.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ kwcContractLogisticsUnit.setCreateTime(date);
|
|
|
+ kwcContractLogisticsUnit.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ kwcContractLogisticsUnit.setUpdateTime(date);
|
|
|
+ kwcContractLogisticsUnit.setDelFlag(Global.NO);
|
|
|
+ if (kwcContractLogisticsUnitMapper.insert(kwcContractLogisticsUnit) <= 0) {
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//存承运运企业
|
|
|
- kwcContractLogisticsUnit.setId(new IdWorker(1L).nextId());
|
|
|
- kwcContractLogisticsUnit.setUnitType(CooperateTypeEnum.CARRIAGE.getCode());
|
|
|
- kwcContractLogisticsUnit.setEntId(logisticsBaseInfoReqVo.getCarrierEntId());
|
|
|
- saveEnt(entCacheResDtoMap, kwcContractLogisticsUnit);
|
|
|
- kwcContractLogisticsUnit.setSignPhone(logisticsBaseInfoReqVo.getCarrierPhone());
|
|
|
- if (kwcContractLogisticsUnitMapper.insert(kwcContractLogisticsUnit) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+ Long carrierEntId = logisticsBaseInfoReqVo.getCarrierEntId();
|
|
|
+ if (Objects.nonNull(carrierEntId)) {
|
|
|
+ kwcContractLogisticsUnit.setId(new IdWorker(1L).nextId());
|
|
|
+ kwcContractLogisticsUnit.setUnitType(CooperateTypeEnum.CARRIAGE.getCode());
|
|
|
+ kwcContractLogisticsUnit.setEntId(carrierEntId);
|
|
|
+ saveEnt(entCacheResDtoMap, kwcContractLogisticsUnit);
|
|
|
+ kwcContractLogisticsUnit.setSignPhone(logisticsBaseInfoReqVo.getCarrierPhone());
|
|
|
+ if (kwcContractLogisticsUnitMapper.insert(kwcContractLogisticsUnit) <= 0) {
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -110,6 +127,21 @@ public class KwcContractLogisticsUnitService {
|
|
|
wrapper.eq(KwcContractLogisticsUnit::getStatus, Global.NO);
|
|
|
return kwcContractLogisticsUnitMapper.selectList(wrapper);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return 修改个数
|
|
|
+ * @desc: 修改
|
|
|
+ * @param: list 实体类
|
|
|
+ * @author: czh
|
|
|
+ * @date 2023/7/17
|
|
|
+ */
|
|
|
+ public int updateBatch(List<KwcContractLogisticsUnit> list) {
|
|
|
+ int count = 0;
|
|
|
+ for (KwcContractLogisticsUnit kwcContractLogisticsUnit : list) {
|
|
|
+ count += kwcContractLogisticsUnitMapper.updateById(kwcContractLogisticsUnit);
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|