|
|
|
@ -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<String> getIsItTimeout(String param) throws Exception { |
|
|
|
|
logger.info("查询处理超时的数据>>>>>>>>{}",param); |
|
|
|
|
logger.info("查询处理超时的数据>>>>>>>>{}", param); |
|
|
|
|
aftersalesWorkOrderService.getIsItTimeout(); |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@XxlJob("modifyClaimStatus") |
|
|
|
|
public ReturnT<String> updateModifyClaimStatus(String param) throws Exception { |
|
|
|
|
logger.info("修改预账单工单是否可以申述>>>>>>>>{}",param); |
|
|
|
|
public ReturnT<String> updateModifyClaimStatus(String param) throws Exception { |
|
|
|
|
logger.info("修改预账单工单是否可以申述>>>>>>>>{}", param); |
|
|
|
|
aftersalesWorkOrderService.updateModifyClaimStatus(); |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据异常列表创建异常工单 |
|
|
|
|
* |
|
|
|
|
* @param param |
|
|
|
|
* @return |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
@XxlJob("autoCreateWorkOrder") |
|
|
|
|
public ReturnT<String> autoCreateWorkOrder(String param) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<AftersalesAbnormalRecordEntity> 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<AftersalesAbnormalRecordEntity> 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<User> 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<AftersalesAbnormalPackageEntity> 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<AftersalesProcessorEntity> processorEntityList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
AftersalesProcessorEntity aftersalesProcessorEntity = new AftersalesProcessorEntity(); |
|
|
|
|
|
|
|
|
|
aftersalesProcessorEntity.setWarehouseId(entityByCarsNo.getStartWarehouseId()); |
|
|
|
|
//责任方
|
|
|
|
|
aftersalesProcessorEntity.setTypesOf("1"); |
|
|
|
|
|
|
|
|
|
processorEntityList.add(aftersalesProcessorEntity); |
|
|
|
|
|
|
|
|
|
aftersalesWorkOrder.setProcessorEntityList(processorEntityList); |
|
|
|
|
|
|
|
|
|
//责任人
|
|
|
|
|
|
|
|
|
|
List<AftersalesPersonResponsibleDTO> personResponsibleDTO = new ArrayList<>(); |
|
|
|
|
AftersalesPersonResponsibleDTO aftersalesPersonResponsibleDTO = new AftersalesPersonResponsibleDTO(); |
|
|
|
|
|
|
|
|
|
aftersalesPersonResponsibleDTO.setTypesOf("1"); |
|
|
|
|
|
|
|
|
|
// 需要获取到仓库的负责人
|
|
|
|
|
Map<String, Object> 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<String, Object> findWareManagerUser(String teandId, Long deptId) { |
|
|
|
|
Map<String, Object> map = null; |
|
|
|
|
R<List<User>> listR = userClient.userInfoByDept(teandId, deptId); |
|
|
|
|
Long userId = null; |
|
|
|
|
String userName = null; |
|
|
|
|
|
|
|
|
|
if (listR.isSuccess()) { |
|
|
|
|
Dept dept = deptClient.findEntityById(deptId); |
|
|
|
|
List<User> data = listR.getData(); |
|
|
|
|
R<String> 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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|