From fc74c78d17c26ba2c1b7e087c21373f19454d9c5 Mon Sep 17 00:00:00 2001 From: "pref_mail@163.com" Date: Sun, 28 Apr 2024 19:53:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA=E5=B7=A5=E5=8D=95=20?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=BA=8E=E5=BC=82=E5=B8=B8=E7=AB=8B=E7=A2=91?= =?UTF-8?q?72=E5=B0=8F=E6=97=B6=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AftersalesAbnormalPackageEntity.java | 2 + .../AftersalesAbnormalRecordEntity.java | 1 + .../entity/AftersalesWorkOrderEntity.java | 5 + .../feign/IAftersalesWorkOrderClient.java | 10 + blade-service/logpm-aftersales/pom.xml | 7 + .../feign/AftersalesWorkOrderClient.java | 15 ++ .../jobhandler/AftersalesXxlJob.java | 213 +++++++++++++++++- .../AftersalesAbnormalPackageMapper.java | 2 + .../AftersalesAbnormalPackageMapper.xml | 3 + .../mapper/AftersalesWorkOrderMapper.java | 3 + .../mapper/AftersalesWorkOrderMapper.xml | 14 ++ .../service/IAftersalesWorkOrderService.java | 11 + .../impl/AftersalesWorkOrderServiceImpl.java | 42 +++- 13 files changed, 319 insertions(+), 9 deletions(-) diff --git a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalPackageEntity.java b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalPackageEntity.java index 04344ce1c..945511356 100644 --- a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalPackageEntity.java +++ b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalPackageEntity.java @@ -143,4 +143,6 @@ public class AftersalesAbnormalPackageEntity extends TenantEntity { @ApiModelProperty(value = "关联工单ID") private Long relatedWorkOrdersId; + private Integer packageFinish; + } diff --git a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalRecordEntity.java b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalRecordEntity.java index 17d2ab8b2..3a22ecef2 100644 --- a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalRecordEntity.java +++ b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesAbnormalRecordEntity.java @@ -97,4 +97,5 @@ public class AftersalesAbnormalRecordEntity extends TenantEntity { private Integer associationType; + } diff --git a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesWorkOrderEntity.java b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesWorkOrderEntity.java index 2839dc291..f68ebac53 100644 --- a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesWorkOrderEntity.java +++ b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/entity/AftersalesWorkOrderEntity.java @@ -293,6 +293,11 @@ public class AftersalesWorkOrderEntity extends TenantEntity { * 离职状态 */ private boolean departStatus; + + private Integer packageFinish; + + + /** * 金额总和 */ diff --git a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/feign/IAftersalesWorkOrderClient.java b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/feign/IAftersalesWorkOrderClient.java index bb4654ed8..6d42d4ab9 100644 --- a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/feign/IAftersalesWorkOrderClient.java +++ b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/feign/IAftersalesWorkOrderClient.java @@ -36,6 +36,7 @@ public interface IAftersalesWorkOrderClient { String API_PREFIX = "/work/client"; String TOP = API_PREFIX + "/top"; + String UPDATEWORKORDERSTATUS = API_PREFIX + "/updateWorkOrderStatus"; /** * 获取客服异常工单列表 @@ -47,4 +48,13 @@ public interface IAftersalesWorkOrderClient { @GetMapping(TOP) BladePage top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + + /** + * 修改异常工单上的数据 + * @param orderPackageCode 包件码 + * @param packageFinish 目前默认传 1 + * @return + */ + @GetMapping(UPDATEWORKORDERSTATUS) + Boolean updateWorkOrderStatus(@RequestParam("warehouseId") Long warehouseId,@RequestParam("orderPackageCode") String orderPackageCode, @RequestParam("packageFinish") Integer packageFinish); } diff --git a/blade-service/logpm-aftersales/pom.xml b/blade-service/logpm-aftersales/pom.xml index 62827fe63..a88f2dabe 100644 --- a/blade-service/logpm-aftersales/pom.xml +++ b/blade-service/logpm-aftersales/pom.xml @@ -83,6 +83,13 @@ 3.2.0.RELEASE compile + + + org.springblade + logpm-warehouse-api + 3.2.0.RELEASE + compile + diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/feign/AftersalesWorkOrderClient.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/feign/AftersalesWorkOrderClient.java index 11b216158..7a13068a7 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/feign/AftersalesWorkOrderClient.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/feign/AftersalesWorkOrderClient.java @@ -17,6 +17,7 @@ package com.logpm.aftersales.feign; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.aftersales.service.IAftersalesAbnormalPackageService; import lombok.AllArgsConstructor; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; @@ -40,6 +41,8 @@ public class AftersalesWorkOrderClient implements IAftersalesWorkOrderClient { private final IAftersalesWorkOrderService aftersalesWorkOrderService; + private final IAftersalesAbnormalPackageService aftersalesAbnormalPackageService; + @Override @GetMapping(TOP) public BladePage top(Integer current, Integer size) { @@ -50,4 +53,16 @@ public class AftersalesWorkOrderClient implements IAftersalesWorkOrderClient { return BladePage.of(page); } + @Override + @GetMapping(UPDATEWORKORDERSTATUS) + public Boolean updateWorkOrderStatus(Long warehouseId ,String orderPackageCode, Integer packageFinish) { + + + // 需要根据包件码和卸车作业节点找到异常工单的ID 0-F0BU 0-F0BO + aftersalesWorkOrderService.updateWorkOrderPackagFinish(warehouseId,orderPackageCode,packageFinish); + + + + return null; + } } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/jobhandler/AftersalesXxlJob.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/jobhandler/AftersalesXxlJob.java index 30be26ecb..ccd53fe71 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/jobhandler/AftersalesXxlJob.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/jobhandler/AftersalesXxlJob.java @@ -1,14 +1,40 @@ package com.logpm.aftersales.jobhandler; +import cn.hutool.core.date.DateUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.logpm.aftersales.dto.AftersalesPersonResponsibleDTO; +import com.logpm.aftersales.dto.AftersalesWorkOrderDTO; +import com.logpm.aftersales.entity.AftersalesAbnormalPackageEntity; +import com.logpm.aftersales.entity.AftersalesAbnormalRecordEntity; +import com.logpm.aftersales.entity.AftersalesProcessorEntity; +import com.logpm.aftersales.service.IAftersalesAbnormalRecordService; import com.logpm.aftersales.service.IAftersalesWorkOrderService; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataWarehouseClient; +import com.logpm.trunkline.entity.TrunklineCarsLoadEntity; +import com.logpm.trunkline.feign.ITrunklineCarsLoadClient; +import com.logpm.warehouse.entity.WarehouseWaybillEntity; +import com.logpm.warehouse.feign.IWarehouseWaybillClient; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.checkerframework.checker.units.qual.A; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.BeanUtil; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.entity.Dept; +import org.springblade.system.entity.User; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.feign.IUserClient; import org.springframework.stereotype.Component; +import java.util.*; + /** * @author 12702 */ @@ -19,18 +45,199 @@ public class AftersalesXxlJob { private final IAftersalesWorkOrderService aftersalesWorkOrderService; + private final IAftersalesAbnormalRecordService aftersalesAbnormalRecordService; + + private final IUserClient userClient; + private final ISysClient sysClient; + private final IDeptClient deptClient; + + private final IBasicdataWarehouseClient basicdataWarehouseClient; + + private final IWarehouseWaybillClient wallBillOrderService; + + private final ITrunklineCarsLoadClient trunklineCarsLoadClient; + + @XxlJob("syncWarehouseToNew") public ReturnT getIsItTimeout(String param) throws Exception { - logger.info("查询处理超时的数据>>>>>>>>{}",param); + logger.info("查询处理超时的数据>>>>>>>>{}", param); aftersalesWorkOrderService.getIsItTimeout(); return ReturnT.SUCCESS; } @XxlJob("modifyClaimStatus") - public ReturnT updateModifyClaimStatus(String param) throws Exception { - logger.info("修改预账单工单是否可以申述>>>>>>>>{}",param); + public ReturnT updateModifyClaimStatus(String param) throws Exception { + logger.info("修改预账单工单是否可以申述>>>>>>>>{}", param); aftersalesWorkOrderService.updateModifyClaimStatus(); return ReturnT.SUCCESS; } + + /** + * 根据异常列表创建异常工单 + * + * @param param + * @return + * @throws Exception + */ + @XxlJob("autoCreateWorkOrder") + public ReturnT autoCreateWorkOrder(String param) throws Exception { + + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(AftersalesAbnormalRecordEntity::getAbnormalType, 4); + queryWrapper.eq(AftersalesAbnormalRecordEntity::getAbnormalStatus, 0); + queryWrapper.eq(AftersalesAbnormalRecordEntity::getSendOrderStatus, 0); + //当前时间 减少72个小时 + queryWrapper.lt(AftersalesAbnormalRecordEntity::getCreateTime, new Date(System.currentTimeMillis() - 72 * 60 * 60 * 1000L)); + List list = aftersalesAbnormalRecordService.list(queryWrapper); + + for (AftersalesAbnormalRecordEntity aftersalesAbnormalRecordEntity : list) { + // 创建异常工单 + logger.info("创建异常工单>>>>>>>>{}", aftersalesAbnormalRecordEntity); + + + AftersalesWorkOrderDTO aftersalesWorkOrder = BeanUtil.copy(aftersalesAbnormalRecordEntity, AftersalesWorkOrderDTO.class); + aftersalesWorkOrder.setId(null); + // 构建创建异常工单VO + BladeUser bladeUser = new BladeUser(); + bladeUser.setUserId(aftersalesAbnormalRecordEntity.getCreateUser()); + + R userR = userClient.userInfoById(bladeUser.getUserId()); + + if (userR.isSuccess()) { + if (userR.getData() != null) { + bladeUser.setUserName(userR.getData().getRealName()); + } + } + bladeUser.setTenantId(aftersalesAbnormalRecordEntity.getTenantId()); + bladeUser.setDeptId(aftersalesAbnormalRecordEntity.getCreateDept() + ""); + + BasicdataWarehouseEntity basicdataWarehouseEntity = new BasicdataWarehouseEntity(); + basicdataWarehouseEntity.setId(aftersalesAbnormalRecordEntity.getUpWarehouseId()); + basicdataWarehouseEntity.setName(aftersalesAbnormalRecordEntity.getUpWarehouseName()); + + BasicdataWarehouseEntity warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(basicdataWarehouseEntity.getId()); + if (ObjectUtil.isNotEmpty(warehouseEntity)) { + basicdataWarehouseEntity.setCode(warehouseEntity.getCode()); + } + + // 完善数据 + List packageEntityList = new ArrayList<>(); + + AftersalesAbnormalPackageEntity aftersalesAbnormalPackageEntity = new AftersalesAbnormalPackageEntity(); + aftersalesAbnormalPackageEntity.setPackageCode(aftersalesAbnormalRecordEntity.getOrderPackageCode()); + aftersalesAbnormalPackageEntity.setWaybillNumber(aftersalesAbnormalRecordEntity.getWaybillNo()); + aftersalesAbnormalPackageEntity.setOrderCode(aftersalesAbnormalRecordEntity.getOrderCode()); + + + packageEntityList.add(aftersalesAbnormalPackageEntity); + aftersalesWorkOrder.setPackageEntityList(packageEntityList); + + + TrunklineCarsLoadEntity entityByCarsNo = trunklineCarsLoadClient.findEntityByCarsNo(aftersalesAbnormalRecordEntity.getCarsNo()); + + aftersalesWorkOrder.setTrainNumber(aftersalesAbnormalRecordEntity.getCarsNo()); + if (ObjectUtil.isNotEmpty(entityByCarsNo)) { + aftersalesWorkOrder.setVehicleRoute(entityByCarsNo.getCarsLineName()); + } + aftersalesWorkOrder.setInitiationIdentification("PC"); + aftersalesWorkOrder.setWorkOrderType("2"); + aftersalesWorkOrder.setDiscoveryNode("3"); + aftersalesWorkOrder.setWaybillNumber(aftersalesAbnormalRecordEntity.getWaybillNo()); + aftersalesWorkOrder.setOrderCode(aftersalesAbnormalRecordEntity.getOrderCode()); + + WarehouseWaybillEntity byWaybillNo = wallBillOrderService.findByWaybillNo(aftersalesWorkOrder.getWorkOrderNumber()); + if (byWaybillNo != null) { + aftersalesWorkOrder.setWaybillMall(byWaybillNo.getConsignee()); + } + + // 添加责任方 + + // 默认为干线创建运输的始发仓的仓库 + + List processorEntityList = new ArrayList<>(); + + AftersalesProcessorEntity aftersalesProcessorEntity = new AftersalesProcessorEntity(); + + aftersalesProcessorEntity.setWarehouseId(entityByCarsNo.getStartWarehouseId()); + //责任方 + aftersalesProcessorEntity.setTypesOf("1"); + + processorEntityList.add(aftersalesProcessorEntity); + + aftersalesWorkOrder.setProcessorEntityList(processorEntityList); + + //责任人 + + List personResponsibleDTO = new ArrayList<>(); + AftersalesPersonResponsibleDTO aftersalesPersonResponsibleDTO = new AftersalesPersonResponsibleDTO(); + + aftersalesPersonResponsibleDTO.setTypesOf("1"); + + // 需要获取到仓库的负责人 + Map wareManagerUser = findWareManagerUser(bladeUser.getTenantId(), warehouseEntity.getDepartment()); + + if (wareManagerUser != null) { + aftersalesPersonResponsibleDTO.setPersonResponsibleId(wareManagerUser.get("userId").toString()); + aftersalesPersonResponsibleDTO.setPersonResponsibleName(wareManagerUser.get("userName").toString()); + } + warehouseEntity = basicdataWarehouseClient.getEntityWarehouseId(aftersalesProcessorEntity.getWarehouseId()); + aftersalesPersonResponsibleDTO.setResponsibilityRatio("100"); + aftersalesPersonResponsibleDTO.setTypesOf("1"); + aftersalesPersonResponsibleDTO.setDifference("1"); + aftersalesPersonResponsibleDTO.setBusinessId(warehouseEntity.getId()); + aftersalesPersonResponsibleDTO.setBusinessName(warehouseEntity.getName()); + personResponsibleDTO.add(aftersalesPersonResponsibleDTO); + + aftersalesWorkOrder.setPersonResponsibleDTO(personResponsibleDTO); + + + aftersalesWorkOrderService.extractedSaveAndUpdate(aftersalesWorkOrder, bladeUser, basicdataWarehouseEntity); + + + // 更新状态 + aftersalesAbnormalRecordEntity.setSendOrderStatus(1); + aftersalesAbnormalRecordService.updateById(aftersalesAbnormalRecordEntity); + } + + + return ReturnT.SUCCESS; + } + + private Map findWareManagerUser(String teandId, Long deptId) { + Map map = null; + R> listR = userClient.userInfoByDept(teandId, deptId); + Long userId = null; + String userName = null; + + if (listR.isSuccess()) { + Dept dept = deptClient.findEntityById(deptId); + List data = listR.getData(); + R roleIs; + if (dept.getDeptCategory() == 4) { + // 获取仓库经理ID + roleIs = sysClient.getRoleIds(teandId, "仓库经理"); + } else if (dept.getDeptCategory() == 5) { + roleIs = sysClient.getRoleIds(teandId, "总部职能"); + } else { + roleIs = new R<>(); + roleIs.setSuccess(false); + } + if (roleIs.isSuccess()) { + String roleId = roleIs.getData(); + for (User datum : data) { + if (datum.getRoleId().contains(roleId)) { + userId = datum.getId(); + userName = datum.getRealName(); + map = new HashMap<>(); + map.put("userId", userId); + map.put("userName", userName); + } + } + } + } + return map; + } + } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.java index 7062aba4f..edb40ccf2 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.java @@ -61,4 +61,6 @@ public interface AftersalesAbnormalPackageMapper extends BaseMapper getAbnormalPackage(@Param("param") AftersalesAbnormalPackageEntity aftersalesAbnormalPackageEntity); List getTrunklines(@Param("orderPackageCode") String orderPackageCode); List getDeliver(@Param("orderPackageCode") String orderPackageCode); + + void updateAftersalesAbnormalPackageByWorkOrderIdAndPackCodeAndOtherNodex(@Param("workId") Long workId,@Param("orderPackageCode") String orderPackageCode, @Param("packageFinish") Integer packageFinish); } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.xml b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.xml index e63bb31a0..246360ecf 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.xml +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesAbnormalPackageMapper.xml @@ -25,6 +25,9 @@ + + update logpm_aftersales_abnormal_package set package_finish = #{packageFinish} where work_order_id = #{workId} and package_code = #{orderPackageCode} + + diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java index 45b097c04..b33abea7c 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java @@ -25,6 +25,7 @@ import com.logpm.aftersales.vo.AftersalesAbnormalPackageVO; import com.logpm.aftersales.vo.AftersalesWorkOrderVO; import com.logpm.aftersales.excel.AftersalesWorkOrderExcel; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import org.springblade.core.mp.base.BaseService; import org.springblade.core.secure.BladeUser; import org.springblade.core.tool.api.R; @@ -65,6 +66,8 @@ public interface IAftersalesWorkOrderService extends BaseService implements IAftersalesWorkOrderService { private final IAftersalesAbnormalPackageService aftersalesAbnormalPackageService; + private final AftersalesAbnormalPackageMapper aftersalesAbnormalPackageMapper; private final IAftersalesDecreaseImageService aftersalesDecreaseImageService; private final IAftersalesProcessorService aftersalesProcessorService; private final IAftersalesCompletionRecordService completionRecordService; @@ -323,6 +319,11 @@ public class AftersalesWorkOrderServiceImpl extends BaseServiceImpl workOrderByOrderPackageCodeAndWarehouseIdAndOtherNodex = baseMapper.findWorkOrderByOrderPackageCodeAndWarehouseIdAndOtherNodex(warehouseId, orderPackageCode, 2, 3); + // 对异常工单进行标识 + + for (AftersalesWorkOrderEntity orderByOrderPackageCodeAndWarehouseIdAndOtherNodex : workOrderByOrderPackageCodeAndWarehouseIdAndOtherNodex) { + // 更新这个异常工单下面的包件 + aftersalesAbnormalPackageMapper.updateAftersalesAbnormalPackageByWorkOrderIdAndPackCodeAndOtherNodex(orderByOrderPackageCodeAndWarehouseIdAndOtherNodex.getId(),orderPackageCode, packageFinish); + + orderByOrderPackageCodeAndWarehouseIdAndOtherNodex.setPackageFinish(packageFinish); + baseMapper.updateById(orderByOrderPackageCodeAndWarehouseIdAndOtherNodex); + + } + + + + + + + + + } }