|
|
|
@ -17,16 +17,42 @@
|
|
|
|
|
package com.logpm.distribution.feign; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.logpm.distribution.entity.DistributionSignforEntity; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataTripartiteWarehouseClient; |
|
|
|
|
import com.logpm.distribution.entity.*; |
|
|
|
|
import com.logpm.distribution.mapper.*; |
|
|
|
|
import com.logpm.distribution.service.IDistributionSignforService; |
|
|
|
|
import com.logpm.distribution.service.IDistributionStockService; |
|
|
|
|
import com.logpm.distribution.vo.DistributionSignPrintVO; |
|
|
|
|
import com.logpm.oldproject.dto.SignPushDataContactDTO; |
|
|
|
|
import com.logpm.oldproject.dto.SignPushDataDTO; |
|
|
|
|
import com.logpm.oldproject.dto.SignPushDataUnitDTO; |
|
|
|
|
import com.logpm.oldproject.entity.WarehouseEntity; |
|
|
|
|
import com.logpm.oldproject.feign.IOldSignPushClient; |
|
|
|
|
import com.logpm.oldproject.feign.IWarehouseClient; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.common.constant.RedisKeyConstant; |
|
|
|
|
import org.springblade.common.constant.stockup.StockAssignStatusConstant; |
|
|
|
|
import org.springblade.core.mp.support.BladePage; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.redis.cache.BladeRedis; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.core.tool.utils.ObjectUtil; |
|
|
|
|
import org.springblade.system.entity.User; |
|
|
|
|
import org.springblade.system.feign.IUserClient; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 签收管理 Feign实现类 |
|
|
|
|
* |
|
|
|
@ -35,20 +61,38 @@ import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
*/ |
|
|
|
|
@ApiIgnore() |
|
|
|
|
@RestController |
|
|
|
|
@Slf4j |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
public class DistributionSignforClient implements IDistributionSignforClient { |
|
|
|
|
|
|
|
|
|
private final IDistributionSignforService distributionSignforService; |
|
|
|
|
private final IDistributionSignforService distributionSignforService; |
|
|
|
|
|
|
|
|
|
private final IDistributionStockService distributionStockService; |
|
|
|
|
private final IOldSignPushClient oldSystemDataPushClient; |
|
|
|
|
private final DistributionSignforMapper distributionSignforMapper; |
|
|
|
|
private final DistributionDeliveryListMapper distributionDeliveryListMapper; |
|
|
|
|
private final DistributionReservationMapper distributionReservationMapper; |
|
|
|
|
|
|
|
|
|
private final DistributionDeliverySelfMapper distributionDeliverySelfMapper; |
|
|
|
|
|
|
|
|
|
private final DistributionDeliveryTripartiteMapper distributionDeliveryTripartiteMapper; |
|
|
|
|
private final IUserClient userClient; |
|
|
|
|
|
|
|
|
|
private final IBasicdataTripartiteWarehouseClient basicdataTripartiteWarehouseClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@GetMapping(TOP) |
|
|
|
|
public BladePage<DistributionSignforEntity> top(Integer current, Integer size) { |
|
|
|
|
Query query = new Query(); |
|
|
|
|
query.setCurrent(current); |
|
|
|
|
query.setSize(size); |
|
|
|
|
IPage<DistributionSignforEntity> page = distributionSignforService.page(Condition.getPage(query)); |
|
|
|
|
return BladePage.of(page); |
|
|
|
|
} |
|
|
|
|
private final IWarehouseClient warehouseClient; |
|
|
|
|
|
|
|
|
|
private BladeRedis bladeRedis; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@GetMapping(TOP) |
|
|
|
|
public BladePage<DistributionSignforEntity> top(Integer current, Integer size) { |
|
|
|
|
Query query = new Query(); |
|
|
|
|
query.setCurrent(current); |
|
|
|
|
query.setSize(size); |
|
|
|
|
IPage<DistributionSignforEntity> page = distributionSignforService.page(Condition.getPage(query)); |
|
|
|
|
return BladePage.of(page); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param signingId |
|
|
|
@ -59,4 +103,177 @@ public class DistributionSignforClient implements IDistributionSignforClient {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean clerkCheckPushData(Long id) { |
|
|
|
|
try { |
|
|
|
|
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 推送老系统签收队列"); |
|
|
|
|
//得到审核的任务ID
|
|
|
|
|
if (ObjectUtil.isEmpty(id)) { |
|
|
|
|
log.info(">>>>>>>>>>>>> clerkCheckPushDataHandler 签收ID为空"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//得到签收对象
|
|
|
|
|
DistributionSignforEntity distributionSignforEntity = distributionSignforMapper.selectById(id); |
|
|
|
|
|
|
|
|
|
//需要检测文员是否进行复核了
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(distributionSignforEntity)) { |
|
|
|
|
log.info(">>>>>>>>>>>> clerkCheckPushDataHandler distributionSignforEntity {}", distributionSignforEntity); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
// 得到配送计划
|
|
|
|
|
DistributionDeliveryListEntity distributionDeliveryListEntity = distributionDeliveryListMapper.selectById(distributionSignforEntity.getDeliveryId()); |
|
|
|
|
if (ObjectUtil.isEmpty(distributionDeliveryListEntity)) { |
|
|
|
|
log.info(">>>>>>>>>>> clerkCheckPushDataHandler distributionDeliveryListEntity {}", distributionDeliveryListEntity); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 得到配送客户
|
|
|
|
|
DistributionReservationEntity distributionReservationEntity = distributionReservationMapper.selectById(distributionSignforEntity.getReservationId()); |
|
|
|
|
if (ObjectUtil.isEmpty(distributionReservationEntity)) { |
|
|
|
|
log.info(">>>>>>>>>>>> clerkCheckPushDataHandler distributionReservationEntity {}", distributionReservationEntity); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//组合配送信息
|
|
|
|
|
SignPushDataDTO delivery = distributionDeliveryListMapper.selectPushOldDelivery(distributionSignforEntity.getReservationId(), distributionSignforEntity.getDeliveryId()); |
|
|
|
|
|
|
|
|
|
WarehouseEntity warehouseEntity = warehouseClient.findByName(distributionReservationEntity.getWarehouseName()); |
|
|
|
|
if (ObjectUtils.isNotNull(warehouseEntity)) { |
|
|
|
|
// 需要增加老系统的仓库ID
|
|
|
|
|
delivery.setWarehouseId(Long.parseLong(warehouseEntity.getId() + "")); |
|
|
|
|
delivery.setWarehouseName(warehouseEntity.getTitle()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//还需要配送的出库人、配送人、操作人信息
|
|
|
|
|
if (Func.isNotEmpty(delivery)) { |
|
|
|
|
if ("1".equals(delivery.getKind())) { |
|
|
|
|
//自主配送
|
|
|
|
|
DistributionDeliverySelfEntity distributionDeliverySelfEntity = distributionDeliverySelfMapper.selectOne(Wrappers.<DistributionDeliverySelfEntity>query().lambda() |
|
|
|
|
.eq(DistributionDeliverySelfEntity::getDeliveryId, delivery.getId()) |
|
|
|
|
.eq(DistributionDeliverySelfEntity::getIsMaster, 2) |
|
|
|
|
); |
|
|
|
|
if (Func.isNotEmpty(distributionDeliverySelfEntity)) { |
|
|
|
|
delivery.setOutId(Long.parseLong(distributionDeliverySelfEntity.getDriverId())); |
|
|
|
|
delivery.setOutName(distributionDeliverySelfEntity.getDriverName()); |
|
|
|
|
delivery.setOutPhone(distributionDeliverySelfEntity.getDriverPhone()); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
//外协
|
|
|
|
|
DistributionDeliveryTripartiteEntity distributionDeliveryTripartiteEntity = distributionDeliveryTripartiteMapper.selectOne(Wrappers.<DistributionDeliveryTripartiteEntity>query().lambda().eq(DistributionDeliveryTripartiteEntity::getDeliveryId, delivery.getId())); |
|
|
|
|
if (Func.isNotEmpty(distributionDeliveryTripartiteEntity)) { |
|
|
|
|
delivery.setOutName(distributionDeliveryTripartiteEntity.getDriverName()); |
|
|
|
|
delivery.setOutPhone(distributionDeliveryTripartiteEntity.getDriverPhone()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
R<User> userR = userClient.userInfoById(delivery.getAdministratorsId()); |
|
|
|
|
if (Func.isNotEmpty(userR)) { |
|
|
|
|
User user = userR.getData(); |
|
|
|
|
delivery.setAdministratorsName(user.getName()); |
|
|
|
|
delivery.setAdministratorsPhone(user.getPhone()); |
|
|
|
|
} |
|
|
|
|
DistributionStockupEntity distributionStockupEntity = distributionReservationMapper.selectStockup(distributionSignforEntity.getReservationId()); |
|
|
|
|
if (Func.isNotEmpty(distributionStockupEntity)) { |
|
|
|
|
if (distributionStockupEntity.getAssignStatus().equals(StockAssignStatusConstant.yizhipai.getValue())) { |
|
|
|
|
delivery.setOutToId(distributionStockupEntity.getStockupUserId()); |
|
|
|
|
delivery.setOutToName(distributionStockupEntity.getStockupUser()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查询客户信息
|
|
|
|
|
List<SignPushDataContactDTO> customer = distributionReservationMapper.selectPushOldCustomer(distributionSignforEntity.getReservationId()); |
|
|
|
|
if (Func.isNotEmpty(customer)) { |
|
|
|
|
//查询客户订单
|
|
|
|
|
List<SignPushDataUnitDTO> signPushDataUnitDTOS = new ArrayList<>(); |
|
|
|
|
if (distributionReservationEntity.getReservationNum() > 0) { |
|
|
|
|
//查询包件扫描签收
|
|
|
|
|
//查询包件扫描签收
|
|
|
|
|
List<SignPushDataUnitDTO> pushOldPackageLoading = distributionSignforMapper.selectPushOldPackageLoading(distributionSignforEntity.getReservationId(), distributionSignforEntity.getDeliveryId()); |
|
|
|
|
List<SignPushDataUnitDTO> pushOldPackageSigning = distributionSignforMapper.selectPushOldPackageSigning(distributionSignforEntity.getReservationId(), distributionSignforEntity.getDeliveryId()); |
|
|
|
|
if (Func.isNotEmpty(pushOldPackageLoading)) { |
|
|
|
|
buildNameAndPhone(pushOldPackageLoading); |
|
|
|
|
signPushDataUnitDTOS.addAll(pushOldPackageLoading); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(pushOldPackageSigning)) { |
|
|
|
|
buildNameAndPhone(pushOldPackageSigning); |
|
|
|
|
signPushDataUnitDTOS.addAll(pushOldPackageSigning); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (distributionReservationEntity.getReservationStockListNum() > 0) { |
|
|
|
|
//查询库存品扫描签收
|
|
|
|
|
List<SignPushDataUnitDTO> loadingPushOldInventory = distributionSignforMapper.selectLoadingPushOldInventory(distributionSignforEntity.getReservationId(), distributionSignforEntity.getDeliveryId()); |
|
|
|
|
List<SignPushDataUnitDTO> signingPushOldInventory = distributionSignforMapper.selectSigningPushOldInventory(distributionSignforEntity.getReservationId(), distributionSignforEntity.getDeliveryId()); |
|
|
|
|
if (Func.isNotEmpty(loadingPushOldInventory)) { |
|
|
|
|
buildNameAndPhone(loadingPushOldInventory); |
|
|
|
|
signPushDataUnitDTOS.addAll(loadingPushOldInventory); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(signingPushOldInventory)) { |
|
|
|
|
buildNameAndPhone(signingPushOldInventory); |
|
|
|
|
signPushDataUnitDTOS.addAll(signingPushOldInventory); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//查询签收图片
|
|
|
|
|
List<DistributionSignPrintVO> distributionSignPrintVOS = distributionSignforMapper.selectSignImgsUrl(distributionReservationEntity.getId()); |
|
|
|
|
|
|
|
|
|
if (Func.isNotEmpty(signPushDataUnitDTOS)) { |
|
|
|
|
SignPushDataContactDTO signPushDataContactDTO = customer.get(0); |
|
|
|
|
signPushDataContactDTO.setSignPushDataUnitDTOs(signPushDataUnitDTOS); |
|
|
|
|
if (Func.isNotEmpty(distributionSignPrintVOS)) { |
|
|
|
|
String urls = distributionSignPrintVOS.stream().map(DistributionSignPrintVO::getUrlRoute).collect(Collectors.joining(",")); |
|
|
|
|
signPushDataContactDTO.setImage(urls); |
|
|
|
|
} |
|
|
|
|
if (Func.isNotEmpty(distributionSignforEntity.getClerkSignRemarks())) { |
|
|
|
|
signPushDataContactDTO.setContact(distributionSignforEntity.getClerkSignRemarks()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//完成客户信息添加
|
|
|
|
|
delivery.setSignPushDataContactDTOs(customer); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Boolean b = oldSystemDataPushClient.pushOldSystemSignInfo(delivery); |
|
|
|
|
return b; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(">>>>> 推送老系统签收信息报错", e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildNameAndPhone(List<SignPushDataUnitDTO> pushOldPackageSigning) { |
|
|
|
|
for (SignPushDataUnitDTO signPushDataUnitDTO : pushOldPackageSigning) { |
|
|
|
|
User user = bladeRedis.get(RedisKeyConstant.USER_NAME_PHONE_KEY + signPushDataUnitDTO.getAdministratorsId()); |
|
|
|
|
log.info("buildNameAndPhone >>> 获取缓存的中的用户信息{}", user); |
|
|
|
|
if (user == null) { |
|
|
|
|
R<User> userT = userClient.userInfoById(signPushDataUnitDTO.getAdministratorsId()); |
|
|
|
|
if (userT.isSuccess()) { |
|
|
|
|
user = userT.getData(); |
|
|
|
|
bladeRedis.setEx(RedisKeyConstant.USER_NAME_PHONE_KEY + signPushDataUnitDTO.getAdministratorsId(), user, 3600L); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (ObjectUtils.isNotNull(user)) { |
|
|
|
|
assert user != null; |
|
|
|
|
signPushDataUnitDTO.setAdministratorsName(user.getName()); |
|
|
|
|
if (ObjectUtils.isNotEmpty(user.getAccount())) { |
|
|
|
|
signPushDataUnitDTO.setAdministratorsPhone(user.getAccount()); |
|
|
|
|
} else { |
|
|
|
|
if (ObjectUtils.isNotEmpty(user.getAccount())) { |
|
|
|
|
signPushDataUnitDTO.setAdministratorsPhone(user.getAccount()); |
|
|
|
|
} else { |
|
|
|
|
log.info("用户无电话号码且账号信息为空>>用户名称:{}", user.getName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|