Compare commits

...

6 Commits

Author SHA1 Message Date
330dad2bcb try catch 处理 2024-10-28 10:40:30 +08:00
Vinjor
6a03253d26 1 2024-10-27 16:12:09 +08:00
xiaofajia
32015dd9db 补正入库方法,跑通流程 2024-10-26 21:31:57 +08:00
xiaofajia
8f548f45be 维修工单新增客户处更新 2024-10-26 20:55:02 +08:00
xiaofajia
e8b1e7a655 Merge branch 'dev' of http://122.51.230.86:3000/dianliang/lanan-system into dev 2024-10-26 17:52:48 +08:00
xiaofajia
dc6a6e1bc4 超时自动总检 2024-10-26 17:52:36 +08:00
7 changed files with 215 additions and 73 deletions

View File

@ -126,5 +126,7 @@ public class BaseConstants {
/** 施工中 */
public static final String REPAIR_RECORD_TYPE_SGZ = "sgz";
/** 字典:超时自动总检配置 */
public static final String AUTO_INSPECTION = "auto_inspection";
}

View File

@ -205,8 +205,12 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
CustomerMain customerMain = new CustomerMain();
customerMain.setDataFrom("01");
customerMainService.saveOrUpdate(customerMain);
try {
customerInfoService.insertPartnerCustomerInfo(customerInfo);
}catch (Exception ignored){
}
customerInfoService.insertPartnerCustomerInfo(customerInfo);
}
//追加订单明细记录
orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"线下订单创建",new Date(),0L,"1"));

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.job;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* 超时自动总检的定时任务
*
* @author 小李
* @date 16:32 2024/10/26
**/
@Component
@TenantJob
@Slf4j
public class AutoInspectionJob implements JobHandler {
@Resource
private DlRepairTicketsService repairTicketsService;
@Override
public String execute(String param) throws Exception {
repairTicketsService.autoInspection();
return null;
}
}

View File

@ -46,6 +46,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
/**
* 针对表dl_repair_so(采购单领料单)的数据库操作Service实现
@ -109,6 +110,14 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@Override
public void createRepairSo(DlRepairSoRespVO repairSoRespVO) {
repairSoRespVO.setSoTime(new Date());
// 加个判断可能出现没有设置价格的情况
if (repairSoRespVO.getGoodsList() != null){
repairSoRespVO.getGoodsList().forEach(item -> {
if (item.getGoodsPrice() == null){
throw exception0(500, "有配件未设置进价");
}
});
}
//保存供应商
if (StringUtils.isEmpty(repairSoRespVO.getSupplierId())){
//采购单中录入供应商或无供应商情况
@ -500,8 +509,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
List<DlRepairSoi> pmsWaresList = repairSoiService.listByIds(filterWare.stream().map(DlRepairSoi::getId).collect(Collectors.toList()));
//初始化本次入库采购品
List<DlRepairSoi> inWaresList = new ArrayList<>();
//原始配件库相关配件
List<RepairWares> waresList = waresService.listByIds(pmsWaresList.stream().map(DlRepairSoi::getWareId).collect(Collectors.toList()));
//原始配件库相关配件---不是用wareId是用GoodsIdwareId是仓库
List<RepairWares> waresList = waresService.listByIds(pmsWaresList.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
/*2、采购单转入库单*/
//入库单关联采购单
@ -542,10 +551,10 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
repairSoiService.saveBatch(inWaresList);
/*4、原始配件库处理*/
//入库配件按照原始配件库id分组目的取出数量
Map<String, DlRepairSoi> wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getWareId, soi -> soi));
//采购配件按照按照原始配件库id分组目的取出价格
Map<String, DlRepairSoi> itemsMap = pmsWaresList.stream().collect(Collectors.toMap(DlRepairSoi::getWareId,soi -> soi));
//入库配件按照原始配件库id分组目的取出数量---不是用wareId是用GoodsIdwareId是仓库
Map<String, DlRepairSoi> wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getGoodsId, soi -> soi));
//采购配件按照按照原始配件库id分组目的取出价格---不是用wareId是用GoodsIdwareId是仓库
Map<String, DlRepairSoi> itemsMap = pmsWaresList.stream().collect(Collectors.toMap(DlRepairSoi::getGoodsId,soi -> soi));
waresList.forEach(item -> {
DlRepairSoi filterSoi = wareMap.get(item.getId());
DlRepairSoi itemSoi = itemsMap.get(item.getId());

View File

@ -209,4 +209,12 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @param id 维修工单ID
**/
boolean syncTicketWaresToTicket(String id);
/**
* 超时自动总检
*
* @author 小李
* @date 16:35 2024/10/26
**/
void autoInspection();
}

View File

@ -66,6 +66,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
@ -153,7 +155,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
private DlTwItemService twItemService;
/**
* 维修工单表 新增
*
@ -165,29 +166,29 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@DSTransactional
public DlRepairTicketsRespVO createTickets(DlRepairTicketsRespVO ticketsRespVO) {
// 验证
if (ObjectUtil.isEmpty(ticketsRespVO.getCarId())){
if (ObjectUtil.isEmpty(ticketsRespVO.getCarId())) {
throw exception0(500, "车辆信息为空");
}
if (ObjectUtil.isEmpty(ticketsRespVO.getAdviserId())){
if (ObjectUtil.isEmpty(ticketsRespVO.getAdviserId())) {
throw exception0(500, "服务顾问为空");
}
ticketsRespVO.getItemList().forEach(item -> {
if (ObjectUtil.isEmpty(item.getRepairIds()) || ObjectUtil.isEmpty(item.getSaleId())){
String message = "";
switch (item.getItemType()){
case "01":
message += "项目:";
break;
case "02":
message += "配件:";
break;
case "03":
message += "其他:";
}
message += (item.getItemName() + (ObjectUtil.isEmpty(item.getRepairIds()) ? "施工人员" : "销售人员") + "为空");
throw exception0(500, message);
}
});
// ticketsRespVO.getItemList().forEach(item -> {
// if (ObjectUtil.isEmpty(item.getRepairIds()) || ObjectUtil.isEmpty(item.getSaleId())) {
// String message = "";
// switch (item.getItemType()) {
// case "01":
// message += "项目:";
// break;
// case "02":
// message += "配件:";
// break;
// case "03":
// message += "其他:";
// }
// message += (item.getItemName() + (ObjectUtil.isEmpty(item.getRepairIds()) ? "施工人员" : "销售人员") + "为空");
// throw exception0(500, message);
// }
// });
// 门店信息
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
@ -324,7 +325,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
if (CollectionUtil.isNotEmpty(wares)) {
// 单位字典
List<DictDataRespDTO> recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_UNIT);
Map<String,String> unitMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
Map<String, String> unitMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
Set<String> ids = wares.stream().map(DlRepairTitemReqVO::getPartId).collect(Collectors.toSet());
List<RepairWares> repairWares = waresService.listByIds(ids);
@ -348,8 +349,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
List<RepairRecordsRespVO> records = repairRecordsService.queryList(entity);
// 操作记录类型
List<DictDataRespDTO> recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE);
Map<String,String> typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel));
result.setRecords(records.stream().peek(item->item.setType(typeMap.get(item.getType()))).collect(Collectors.toList()));
Map<String, String> typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
result.setRecords(records.stream().peek(item -> item.setType(typeMap.get(item.getType()))).collect(Collectors.toList()));
return result;
}
@ -377,7 +378,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
public void setTicketsPaid(DlRepairTicketsRespVO repairTicketsRespVO) {
// 更新订单状态
RepairOrderInfo one = repairOrderInfoService.getOne(new LambdaQueryWrapper<RepairOrderInfo>().eq(RepairOrderInfo::getGoodsId, repairTicketsRespVO.getId()));
if (ObjectUtil.isEmpty(one)){
if (ObjectUtil.isEmpty(one)) {
throw exception0(500, "系统异常");
}
RepairOrderInfo repairOrderInfo = new RepairOrderInfo();
@ -422,6 +423,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 新增车辆信息
if (ObjectUtil.isNotEmpty(customerAndCarVO.getCarInfo())) {
if (ObjectUtil.isEmpty(customerAndCarVO.getCarInfo().getId())) {
customerAndCarVO.getCarInfo().setUserId(Long.valueOf(customerAndCarVO.getUserInfo().getId()));
carMainService.createCarMain(customerAndCarVO.getCarInfo());
} else {
carMainService.updateCarMain(customerAndCarVO.getCarInfo());
@ -682,7 +684,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 因为目前的配件申请表在申请的时候就把配件加到工单中了但后续的领取并没有同步到工单所以如果这里是员工直接完成移交给服务顾问就需要同步一下
boolean flag = syncTicketWaresToTicket(respVO.getId());
if (!flag){
if (!flag) {
throw exception0(500, "系统异常");
}
} else {
@ -813,7 +815,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
);
boolean flag = syncTicketWaresToTicket(respVO.getId());
if (!flag){
if (!flag) {
throw exception0(500, "系统异常");
}
@ -825,12 +827,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 用于同步一个工单的所有配件申请表的数据到维修工单主要针对已领取数量小于申请数量的情况
*
* @param id 维修工单ID
* @author 小李
* @date 9:52 2024/10/26
* @param id 维修工单ID
**/
**/
@Override
public boolean syncTicketWaresToTicket(String id){
public boolean syncTicketWaresToTicket(String id) {
// 先查满足条件的申请表
ArrayList<String> status = new ArrayList<>();
status.add("01"); // 待审核
@ -870,16 +872,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 可能出现配件申请单审核通过了没有任何领取或全部退了的情况所以如果itemCount等于0直接把这个数据删掉
// 过滤出需要删除的数据
List<DlRepairTitem> delItems = AllItems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(delItems)){
if (CollectionUtil.isNotEmpty(delItems)) {
// 删除需要删的
titemService.removeBatchByIds(delItems);
Set<String> delIds = delItems.stream().map(DlRepairTitem::getId).collect(Collectors.toSet());
// 得到需要改的
List<DlRepairTitem> updateItems = AllItems.stream().filter(item -> delIds.contains(item.getId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(updateItems)){
if (CollectionUtil.isNotEmpty(updateItems)) {
titemService.updateBatchById(updateItems);
}
}else {
} else {
// 没有需要删的就是全部都需要改
titemService.updateBatchById(AllItems);
}
@ -919,21 +921,21 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
**/
@Override
public Map<String, Integer> getBossNum() {
Map<String,Integer> rtnMap = new HashMap<>();
Map<String, Integer> rtnMap = new HashMap<>();
int workingNum = 0;
int doneNum = 0;
List<DlRepairTickets> repairTickets = this.list();
if(!repairTickets.isEmpty()){
Map<String,List<DlRepairTickets>> ifFinishMap = repairTickets.stream().collect(Collectors.groupingBy(DlRepairTickets::getIsFinish));
if(ifFinishMap.containsKey("0")){
if (!repairTickets.isEmpty()) {
Map<String, List<DlRepairTickets>> ifFinishMap = repairTickets.stream().collect(Collectors.groupingBy(DlRepairTickets::getIsFinish));
if (ifFinishMap.containsKey("0")) {
workingNum = ifFinishMap.get("0").size();
}
if(ifFinishMap.containsKey("1")){
if (ifFinishMap.containsKey("1")) {
doneNum = ifFinishMap.get("1").size();
}
}
rtnMap.put("workingNum",workingNum);
rtnMap.put("doneNum",doneNum);
rtnMap.put("workingNum", workingNum);
rtnMap.put("doneNum", doneNum);
return rtnMap;
}
@ -972,13 +974,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
, tickets.getCarNo(), type, noticeCusVO.getName(), noticeCusVO.getMobile()
);
// todo 小程序通知客户
if(null!=cus && StringUtils.isNotEmpty(cus.getPhoneNumber())){
if (null != cus && StringUtils.isNotEmpty(cus.getPhoneNumber())) {
// 短信通知客户
SendSmsUtil.sendMsgCommon(new String[]{message}, cus.getPhoneNumber(), "1400852709", "蓝安汽车小程序", "2143603");
}
// 记录日志
String recordStr = noticeCusVO.getName()
+ "通知客户取车:"+message;
+ "通知客户取车:" + message;
repairRecordsService.saveRepairRecord(noticeCusVO.getId(), null, RecordTypeEnum.TZQC.getCode(), recordStr, null);
}
@ -1020,19 +1022,19 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 新增工单子项
*
* @param respVO 主要有两个参数主表ID,itemList(这个需要前端处理成子表的对象能接收的数据)
* @author 小李
* @date 19:59 2024/10/24
* @param respVO 主要有两个参数主表ID,itemList(这个需要前端处理成子表的对象能接收的数据)
**/
@Override
@DSTransactional
public void addItems(DlRepairTicketsRespVO respVO){
public void addItems(DlRepairTicketsRespVO respVO) {
// 先判断是否施工人员和销售人员是否都设置了
respVO.getItemList().forEach(item -> {
if (ObjectUtil.isEmpty(item.getRepairIds())){
if (ObjectUtil.isEmpty(item.getRepairIds())) {
throw exception0(500, "施工人员尚未设置");
}
if (ObjectUtil.isEmpty(item.getSaleId())){
if (ObjectUtil.isEmpty(item.getSaleId())) {
throw exception0(500, "销售人员尚未设置");
}
});
@ -1043,10 +1045,93 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 更新主表
boolean flag = computeTicket(respVO.getId());
if (!flag){
if (!flag) {
throw exception0(500, "系统错误");
}
}
/**
* 超时自动总检
*
* @author 小李
* @date 16:35 2024/10/26
**/
@Override
@DSTransactional
public void autoInspection() {
// 查所有需要总检但还没总检的工单
List<DlRepairTickets> tickets = baseMapper.selectList(new LambdaQueryWrapper<DlRepairTickets>().eq(DlRepairTickets::getTicketsWorkStatus, "05"));
// 如果没有直接退出
if (CollectionUtil.isEmpty(tickets)) {
return;
}
// 获取超时自动总检配置的时间
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList(BaseConstants.AUTO_INSPECTION);
// 理论上是只有一个的但防止被删了或者别的什么原因直接报错
DictDataRespDTO dictDataRespDTO = dataList.stream().findFirst().orElse(null);
if (ObjectUtil.isEmpty(dictDataRespDTO)) {
log.error("超时自动总检时间没有配置");
return;
}
// 计算超时的工单
// 超时时间
int time = Integer.parseInt(dictDataRespDTO.getValue());
List<DlRepairTickets> list = tickets.stream().filter(item -> {
// 当前时间---放到里面是因为如果数据量多动态获取当前时间更能满足需求
LocalDateTime now = LocalDateTime.now();
return ChronoUnit.MINUTES.between(item.getUpdateTime(), now) > time;
}).collect(Collectors.toList());
// 同步工单的配件申请表到工单,如果都没超时退出
if (CollectionUtil.isEmpty(list)) {
return;
}
// 先取总检们
// 取这个角色的角色信息
RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.INSPECTION.getCode());
// 通过角色信息查有这个角色的人
List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());
// 如果没有总检直接报错退出
if (CollectionUtil.isEmpty(ids)) {
log.error("系统中没有总检");
return;
}
// 在过滤一次主要是过滤掉没法同步申请表到工单的数据
List<DlRepairTickets> result = list.stream().filter(item -> {
boolean flag = syncTicketWaresToTicket(item.getId());
// 如果出现更新不到的情况
if (!flag) {
// 通知总检让其手动操作
ids.forEach(id -> {
repairWorkerService.sentMessage(id, "待总检工单:" + item.getTicketNo() + "已经超时,但无法自动总检,请手动处理");
});
}
return flag;
}).collect(Collectors.toList());
// 如果没有记录同步成功报错并退出
if (CollectionUtil.isEmpty(result)) {
log.error("自动总检失败,原因可能是无法同步申请表到工单");
}
// 移交服务顾问
List<DlRepairTickets> updateTickets = result.stream().map(item -> {
DlRepairTickets ticket = new DlRepairTickets();
ticket.setId(item.getId());
ticket.setNowRepairId(Long.valueOf(item.getAdviserId()));
ticket.setNowRepairName(item.getAdviserName());
return ticket;
}).collect(Collectors.toList());
baseMapper.updateById(updateTickets);
// 通知总检和服务顾问
result.forEach(item -> {
repairWorkerService.sentMessage(Long.valueOf(item.getAdviserId()), "您有新的工单可以出厂检验");
ids.forEach(id -> {
repairWorkerService.sentMessage(id, "工单:" + item.getTicketNo() + "已由系统自动总检并移交服务顾问");
});
// 记录日志
repairRecordsService.saveRepairRecord(item.getId(), null, RecordTypeEnum.ZJ.getCode(), "该工单由系统自动总检完成", null);
});
}
}

View File

@ -590,31 +590,35 @@ public class RescueDriverInfoServiceImpl extends ServiceImpl<RescueDriverInfoMap
//处理redis
DriverInfo driverInfo = driverInfoService.getById(rescueInfo.getDriverId());
AdminUserRespDTO user = userService.getUser(driverInfo.getUserId());
try{
// 收集客户信息
PartnerCustomerInfo customerInfo = new PartnerCustomerInfo();
customerInfo.setCustomerName(rescueInfo.getConnectionName());
customerInfo.setCustomerPhone(rescueInfo.getConnectionPhone());
customerInfo.setUserId(rescueInfo.getUserId());
// 收集客户信息
PartnerCustomerInfo customerInfo = new PartnerCustomerInfo();
customerInfo.setCustomerName(rescueInfo.getConnectionName());
customerInfo.setCustomerPhone(rescueInfo.getConnectionPhone());
customerInfo.setUserId(rescueInfo.getUserId());
// 收集客户车辆信息
List<ShopUserCar> userCarList = new ArrayList<>();
ShopUserCar userCar = new ShopUserCar();
userCar.setCarNo(rescueInfo.getLicenseNum());
userCar.setCarModel(rescueInfo.getCarType());
userCar.setCarBrand(rescueInfo.getCarBrand());
userCar.setUserId(user.getId());
userCarList.add(userCar);
// 收集客户车辆信息
List<ShopUserCar> userCarList = new ArrayList<>();
ShopUserCar userCar = new ShopUserCar();
userCar.setCarNo(rescueInfo.getLicenseNum());
userCar.setCarModel(rescueInfo.getCarType());
userCar.setCarBrand(rescueInfo.getCarBrand());
userCar.setUserId(user.getId());
userCarList.add(userCar);
customerInfo.setUserCarList(userCarList);
customerInfo.setUserCarList(userCarList);
// 设置客户来源
CustomerMain customerMain = new CustomerMain();
customerMain.setDataFrom("02");
customerMainService.saveOrUpdate(customerMain);
// 设置客户来源
CustomerMain customerMain = new CustomerMain();
customerMain.setDataFrom("02");
customerMainService.saveOrUpdate(customerMain);
// 调用插入客户信息的方法
customerInfoService.insertPartnerCustomerInfo(customerInfo);
}catch (Exception ignored){
}
// 调用插入客户信息的方法
customerInfoService.insertPartnerCustomerInfo(customerInfo);
//所在顶级机构