|
|
@@ -29,13 +29,18 @@ import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
import com.sckw.core.utils.PageUtils;
|
|
|
import com.sckw.core.web.config.CustomConfig;
|
|
|
+import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.fleet.api.feign.DriverScoreFeignService;
|
|
|
import com.sckw.fleet.api.model.dto.UpdateDriverScoreDto;
|
|
|
import com.sckw.redis.constant.RedisConstant;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
+import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.sckw.contract.dao.KwcContractLogisticsScoreMapper;
|
|
|
@@ -49,9 +54,12 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
* @author tangyishan
|
|
|
* @date 2025-12-05
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisticsScoreService
|
|
|
{
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ private RemoteSystemService remoteSystemService;
|
|
|
@Autowired
|
|
|
private KwcContractLogisticsScoreMapper kwcContractLogisticsScoreMapper;
|
|
|
@Autowired
|
|
|
@@ -90,9 +98,14 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
logisticsScore.setPendingScore(scoreChangeMap.getOrDefault(logisticsScore.getId(), null));
|
|
|
}
|
|
|
}
|
|
|
+ Map<Long, EntCacheResDto> entCacheResDtoMap = remoteSystemService.queryEntCacheMapByIds(logisticsScores.stream().map(KwcContractLogisticsScore::getLogisticsEntId).toList());
|
|
|
pageInfo = ((Page<KwcContractLogisticsScore>) logisticsScores).toPageInfo(e -> {
|
|
|
LogisticsScoreResVo logisticsScoreResVo = new LogisticsScoreResVo();
|
|
|
BeanUtils.copyProperties(e, logisticsScoreResVo);
|
|
|
+ EntCacheResDto entCacheResDto = entCacheResDtoMap.get(e.getLogisticsEntId());
|
|
|
+ if(entCacheResDto!=null){
|
|
|
+ logisticsScoreResVo.setLogisticsEntName(entCacheResDto.getFirmName());
|
|
|
+ }
|
|
|
if(e.getPendingScore()!=null && e.getPendingScore().compareTo(BigDecimal.ZERO) > 0){
|
|
|
logisticsScoreResVo.setPendingScore("+"+e.getPendingScore());
|
|
|
}else if(e.getPendingScore()==null){
|
|
|
@@ -118,6 +131,7 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
{
|
|
|
//校验评分权限
|
|
|
KwcContractLogisticsScore logisticsScore = checkLogisticsScoreAuth(providerEntId, detailReqDto.getScoreId());
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(logisticsScore.getLogisticsEntId());
|
|
|
PageInfo<LogisticsScoreDetailResVo> pageInfo = new PageInfo<>(new ArrayList<>());
|
|
|
PageUtils.startPage();
|
|
|
detailReqDto.setScoreIds(Collections.singletonList(detailReqDto.getScoreId()));
|
|
|
@@ -134,7 +148,7 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
if(e.getScore() == null){
|
|
|
logisticsScoreDetailResVo.setScore("");
|
|
|
}
|
|
|
- logisticsScoreDetailResVo.setLogisticsEntName(logisticsScore.getLogisticsEntName());
|
|
|
+ logisticsScoreDetailResVo.setLogisticsEntName(entCacheResDto.getFirmName());
|
|
|
return logisticsScoreDetailResVo;
|
|
|
});
|
|
|
}
|
|
|
@@ -157,7 +171,8 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
if(logisticsScoreDetail == null){
|
|
|
return null;
|
|
|
}
|
|
|
- logisticsScoreDetail.setLogisticsEntName(logisticsScore.getLogisticsEntName());
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(logisticsScore.getLogisticsEntId());
|
|
|
+ logisticsScoreDetail.setLogisticsEntName(entCacheResDto.getFirmName());
|
|
|
LogisticsScoreDetailResVo logisticsScoreDetailResVo = new LogisticsScoreDetailResVo();
|
|
|
BeanUtils.copyProperties(logisticsScoreDetail,logisticsScoreDetailResVo);
|
|
|
logisticsScoreDetailResVo.setScore(logisticsScore.getScore().toString());
|
|
|
@@ -215,7 +230,7 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void initLogisticsScore(LogisticListReq.TradeBaseInfo baseInfo,Map<Long, EntCacheResDto> entCacheResDtoMap) {
|
|
|
+ public void initLogisticsScore(LogisticListReq.TradeBaseInfo baseInfo) {
|
|
|
KwcContractLogisticsScore logisticsScore = new KwcContractLogisticsScore();
|
|
|
|
|
|
long scoreId = new IdWorker(1L).nextId();
|
|
|
@@ -223,8 +238,6 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
//自动派单合同的托运单位等于当前登陆企业
|
|
|
logisticsScore.setProviderEntId(baseInfo.getProvideEntId());
|
|
|
logisticsScore.setLogisticsEntId(baseInfo.getPurchaseEntId());
|
|
|
- EntCacheResDto logisticsEnt = entCacheResDtoMap.get(baseInfo.getPurchaseEntId());
|
|
|
- logisticsScore.setLogisticsEntName(logisticsEnt != null ? logisticsEnt.getFirmName() : null);
|
|
|
logisticsScore.setScore(new BigDecimal(customConfig.getLogisticsInitScore()));
|
|
|
logisticsScore.setCreateBy(LoginUserHolder.getUserId());
|
|
|
Date date = new Date();
|
|
|
@@ -244,23 +257,14 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
LogisticsScoreDetailAddDto detailDto = new LogisticsScoreDetailAddDto();
|
|
|
detailDto.setScoreId(scoreId);
|
|
|
detailDto.setInfluenceBy(LoginUserHolder.getUserId());
|
|
|
- detailDto.setInfluenceByName(LoginUserHolder.getUserName());
|
|
|
detailDto.setAction("物流企业评分初始化");
|
|
|
detailDto.setScoreChange(logisticsScore.getScore());
|
|
|
detailDto.setScore(logisticsScore.getScore());
|
|
|
detailDto.setStatus(NumberConstant.ONE);
|
|
|
- initLogisticsScoreDetail(detailDto);
|
|
|
-
|
|
|
- //初始化司机评分,需要传参供应企业id,物流企业id,供应企业名称,评分变动,当前物流企业评分,变动原因
|
|
|
- UpdateDriverScoreDto updateDriverScoreDto = new UpdateDriverScoreDto();
|
|
|
- updateDriverScoreDto.setProviderEntId(logisticsScore.getProviderEntId());
|
|
|
- updateDriverScoreDto.setLogisticsEntId(logisticsScore.getLogisticsEntId());
|
|
|
- updateDriverScoreDto.setProviderEntName(LoginUserHolder.getEntName());
|
|
|
- updateDriverScoreDto.setScoreChange(logisticsScore.getScore());
|
|
|
- updateDriverScoreDto.setLogisticsEntScore(logisticsScore.getScore());
|
|
|
- updateDriverScoreDto.setAction(detailDto.getAction());
|
|
|
- updateDriverScoreDto.setOperatorType(1);
|
|
|
- driverScoreFeignService.update(updateDriverScoreDto);
|
|
|
+ KwcContractLogisticsScoreDetail logisticsScoreDetail = initLogisticsScoreDetail(detailDto);
|
|
|
+
|
|
|
+ //初始化司机评分
|
|
|
+ updateDriverScore(logisticsScore,logisticsScoreDetail,1);
|
|
|
}
|
|
|
} finally {
|
|
|
RedissonUtils.unlock(lockKey);
|
|
|
@@ -269,10 +273,11 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void initLogisticsScoreDetail(LogisticsScoreDetailAddDto detailDto) {
|
|
|
+ public KwcContractLogisticsScoreDetail initLogisticsScoreDetail(LogisticsScoreDetailAddDto detailDto) {
|
|
|
KwcContractLogisticsScoreDetail logisticsScoreDetail = buildLogisticsScoreDetail(detailDto);
|
|
|
logisticsScoreDetail.setScore(logisticsScoreDetail.getScoreChange());
|
|
|
kwcContractLogisticsScoreDetailMapper.insertKwcContractLogisticsScoreDetail(logisticsScoreDetail);
|
|
|
+ return logisticsScoreDetail;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -319,16 +324,8 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
logisticsScoreDetail.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
logisticsScoreDetail.setUpdateTime(new Date());
|
|
|
kwcContractLogisticsScoreDetailMapper.updateKwcContractLogisticsScoreDetail(logisticsScoreDetail);
|
|
|
- //修改司机评分,需要传参供应企业id,物流企业id,供应企业名称,评分变动,当前物流企业评分,变动原因
|
|
|
- UpdateDriverScoreDto updateDriverScoreDto = new UpdateDriverScoreDto();
|
|
|
- updateDriverScoreDto.setProviderEntId(logisticsScore.getProviderEntId());
|
|
|
- updateDriverScoreDto.setLogisticsEntId(logisticsScore.getLogisticsEntId());
|
|
|
- updateDriverScoreDto.setProviderEntName(LoginUserHolder.getEntName());
|
|
|
- updateDriverScoreDto.setScoreChange(logisticsScoreDetail.getScoreChange());
|
|
|
- updateDriverScoreDto.setLogisticsEntScore(logisticsScore.getScore());
|
|
|
- updateDriverScoreDto.setAction(logisticsScoreDetail.getAction());
|
|
|
- updateDriverScoreDto.setOperatorType(2);
|
|
|
- driverScoreFeignService.update(updateDriverScoreDto);
|
|
|
+ //修改司机评分
|
|
|
+ updateDriverScore(logisticsScore,logisticsScoreDetail,2);
|
|
|
}
|
|
|
}else{
|
|
|
throw new BusinessException("该评分已审批完成");
|
|
|
@@ -368,7 +365,6 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
}
|
|
|
//用户修改评分
|
|
|
detailDto.setInfluenceBy(LoginUserHolder.getUserId());
|
|
|
- detailDto.setInfluenceByName(LoginUserHolder.getUserName());
|
|
|
detailDto.setStatus(NumberConstant.ZERO);
|
|
|
detailDto.setAction("修改企业评分,原因:"+detailDto.getAction());
|
|
|
KwcContractLogisticsScoreDetail logisticsScoreDetail = buildLogisticsScoreDetail(detailDto);
|
|
|
@@ -401,7 +397,6 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
LogisticsScoreDetailAddDto detailAddDto = new LogisticsScoreDetailAddDto();
|
|
|
detailAddDto.setScoreId(logisticsScore.getId());
|
|
|
detailAddDto.setInfluenceBy(detailDto.getInfluenceBy());
|
|
|
- detailAddDto.setInfluenceByName(detailDto.getInfluenceByName());
|
|
|
detailAddDto.setAction(detailDto.getAction());
|
|
|
detailAddDto.setScoreChange(detailDto.getScoreChange());
|
|
|
detailAddDto.setScore(resultScore);
|
|
|
@@ -435,17 +430,8 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
kwcContractLogisticsScoreDetailMapper.insertKwcContractLogisticsScoreDetail(resetLogisticsScoreDetail);
|
|
|
//4.清除待审核评分
|
|
|
kwcContractLogisticsScoreDetailMapper.deleteKwcContractLogisticsScoreDetailByScoreId(logisticsScore.getId(),NumberConstant.ZERO);
|
|
|
- //重置司机评分,需要传参供应企业id,物流企业id,供应企业名称,评分变动,当前物流企业评分,变动原因
|
|
|
- UpdateDriverScoreDto updateDriverScoreDto = new UpdateDriverScoreDto();
|
|
|
- updateDriverScoreDto.setProviderEntId(logisticsScore.getProviderEntId());
|
|
|
- updateDriverScoreDto.setLogisticsEntId(logisticsScore.getLogisticsEntId());
|
|
|
- updateDriverScoreDto.setProviderEntName(LoginUserHolder.getEntName());
|
|
|
- updateDriverScoreDto.setScoreChange(resetLogisticsScoreDetail.getScoreChange());
|
|
|
- updateDriverScoreDto.setLogisticsEntScore(logisticsScore.getScore());
|
|
|
- updateDriverScoreDto.setAction(resetLogisticsScoreDetail.getAction());
|
|
|
- updateDriverScoreDto.setOperatorType(3);
|
|
|
- driverScoreFeignService.update(updateDriverScoreDto);
|
|
|
-
|
|
|
+ //重置司机评分
|
|
|
+ updateDriverScore(logisticsScore,resetLogisticsScoreDetail,3);
|
|
|
|
|
|
} finally {
|
|
|
RedissonUtils.unlock(lockKey);
|
|
|
@@ -453,6 +439,21 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void updateDriverScore(KwcContractLogisticsScore logisticsScore,KwcContractLogisticsScoreDetail logisticsScoreDetail,Integer operatorType){
|
|
|
+ UpdateDriverScoreDto updateDriverScoreDto = new UpdateDriverScoreDto();
|
|
|
+ updateDriverScoreDto.setProviderEntId(logisticsScore.getProviderEntId());
|
|
|
+ updateDriverScoreDto.setLogisticsEntId(logisticsScore.getLogisticsEntId());
|
|
|
+ updateDriverScoreDto.setScoreChange(logisticsScoreDetail.getScoreChange());
|
|
|
+ updateDriverScoreDto.setLogisticsEntScore(logisticsScore.getScore());
|
|
|
+ updateDriverScoreDto.setAction(logisticsScoreDetail.getAction());
|
|
|
+ updateDriverScoreDto.setOperatorType(operatorType);
|
|
|
+ HttpResult result = driverScoreFeignService.update(updateDriverScoreDto);
|
|
|
+ if(result.getCode()!= HttpStatus.SUCCESS_CODE){
|
|
|
+ log.error("更新司机评分失败,原因:{}",result.getMsg());
|
|
|
+ throw new BusinessException("更新司机评分失败,原因:"+result.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构建重置评分记录明细
|
|
|
*
|
|
|
@@ -465,7 +466,6 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
logisticsScoreDetail.setId(scoreDetailId);
|
|
|
logisticsScoreDetail.setScoreId(scoreId);
|
|
|
logisticsScoreDetail.setInfluenceBy(LoginUserHolder.getUserId());
|
|
|
- logisticsScoreDetail.setInfluenceByName(LoginUserHolder.getUserName());
|
|
|
logisticsScoreDetail.setAction("重置企业评分");
|
|
|
logisticsScoreDetail.setScore(new BigDecimal(customConfig.getLogisticsInitScore()));
|
|
|
logisticsScoreDetail.setScoreChange(null);
|
|
|
@@ -484,7 +484,6 @@ public class KwcContractLogisticsScoreServiceImpl implements IKwcContractLogisti
|
|
|
logisticsScoreDetail.setId(scoreDetailId);
|
|
|
logisticsScoreDetail.setScoreId(detailDto.getScoreId());
|
|
|
logisticsScoreDetail.setInfluenceBy(detailDto.getInfluenceBy());
|
|
|
- logisticsScoreDetail.setInfluenceByName(detailDto.getInfluenceByName());
|
|
|
logisticsScoreDetail.setAction(detailDto.getAction());
|
|
|
logisticsScoreDetail.setScoreChange(detailDto.getScoreChange());
|
|
|
logisticsScoreDetail.setScore(detailDto.getScore());
|