From 11c1e759aa7876c0b685f232f5f3bdfee585e548 Mon Sep 17 00:00:00 2001 From: 13405411873 <1994398261@qq.com> Date: Fri, 1 Nov 2024 14:22:57 +0800 Subject: [PATCH] =?UTF-8?q?try=20catch=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InspectionInfoController.java | 9 +- .../service/IInspectionInfoService.java | 5 - .../impl/InspectionInfoServiceImpl.java | 193 ++++++------------ .../impl/PartnerCustomerInfoServiceImpl.java | 1 - 4 files changed, 59 insertions(+), 149 deletions(-) diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java index 735d8c3c..5b7aee92 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java @@ -97,12 +97,5 @@ public class InspectionInfoController extends BaseController return toAjax(inspectionInfoService.deleteInspectionInfoByIds(id)); } - /** - * 根据当前登陆人获取可以选择的工单 - * @return - */ - @GetMapping("geStelectInspection") - public CommonResult geStelectInspection(){ - return success(inspectionInfoService.geStelectInspection()); - } + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java index 5fc966d1..2f219ee3 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java @@ -75,9 +75,4 @@ public interface IInspectionInfoService extends IService Map workOrderData(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime); - /** - * 根据当前登陆人获取可以选择的工单 - * @return - */ - List geStelectInspection(); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java index f22ffd08..b03566c8 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java @@ -2,13 +2,9 @@ package cn.iocoder.yudao.module.inspection.service.impl; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; - -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.security.core.LoginUser; @@ -21,9 +17,7 @@ import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService; import cn.iocoder.yudao.module.payment.service.IOrderInfoDetailService; import cn.iocoder.yudao.module.payment.service.OrderInfoService; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; -import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; -import cn.iocoder.yudao.module.system.service.permission.RoleService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import cn.iocoder.yudao.util.SendSmsUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -55,7 +49,8 @@ import javax.annotation.Resource; * @date 2023-08-13 */ @Service -public class InspectionInfoServiceImpl extends ServiceImpl implements IInspectionInfoService { +public class InspectionInfoServiceImpl extends ServiceImpl implements IInspectionInfoService +{ @Autowired private AdminUserService userService; @Autowired @@ -77,15 +72,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl selectInspectionInfoList(Page page, InspectionInfo inspectionInfo) { - return baseMapper.selectInspectionInfoList(page, inspectionInfo); + public IPage selectInspectionInfoList(Page page, InspectionInfo inspectionInfo) + { + return baseMapper.selectInspectionInfoList(page,inspectionInfo); } /** @@ -119,23 +109,19 @@ public class InspectionInfoServiceImpl extends ServiceImpl workerQueryWrapper =new LambdaQueryWrapper<>(); -// workerQueryWrapper.eq(PartnerWorker::getUserId,loginUser.getId()).eq(PartnerWorker::getPartnerId,partners.getPartnerId()); -// PartnerWorker worker = workerService.getOne(workerQueryWrapper); -// if (ObjectUtils.isNotEmpty(worker)){ -// inspectionInfo.setWorkId(worker.getId()); -// }else { -// throw new Exception("请先将接待员加入员工"); -// } - if (ObjectUtils.isEmpty(inspectionInfo.getInspectionWorkNodes())) { - throw new RuntimeException("请选择检测项目"); + LambdaQueryWrapper workerQueryWrapper =new LambdaQueryWrapper<>(); + workerQueryWrapper.eq(PartnerWorker::getUserId,loginUser.getId()).eq(PartnerWorker::getPartnerId,partners.getPartnerId()); + PartnerWorker worker = workerService.getOne(workerQueryWrapper); + if (ObjectUtils.isNotEmpty(worker)){ + inspectionInfo.setWorkId(worker.getId()); + }else { + throw new Exception("请先将接待员加入员工"); } - //当前登陆人 就是检测人 - AdminUserDO workerUser = userService.getUser(loginUser.getId()); - String buyName = StringUtils.isNotEmpty(inspectionInfo.getBuyName()) ? inspectionInfo.getBuyName() : "未知客户"; - String buyPhone = StringUtils.isNotEmpty(inspectionInfo.getBuyPhone()) ? inspectionInfo.getBuyPhone() : StringUtils.isNotEmpty(inspectionInfo.getBuyName()) ? inspectionInfo.getBuyName() : "无"; + AdminUserDO workerUser =userService.getUser(worker.getUserId()); + String buyName = StringUtils.isNotEmpty(inspectionInfo.getBuyName())?inspectionInfo.getBuyName():"未知客户"; + String buyPhone = StringUtils.isNotEmpty(inspectionInfo.getBuyPhone())?inspectionInfo.getBuyPhone():StringUtils.isNotEmpty(inspectionInfo.getBuyName())?inspectionInfo.getBuyName():"无"; AdminUserDO user = userService.getUserByMobile(buyPhone); - if (ObjectUtils.isEmpty(user)) { + if (ObjectUtils.isEmpty(user)){ //新增用户 UserSaveReqVO userSaveReqVO = new UserSaveReqVO(); userSaveReqVO.setNickname(buyName); @@ -149,13 +135,13 @@ public class InspectionInfoServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(PartnerCustomerInfo::getPartnerId, inspectionInfo.getPartnerId()).eq(PartnerCustomerInfo::getUserId, orderInfo.getUserId()); + LambdaQueryWrapper queryWrapper =new LambdaQueryWrapper<>(); + queryWrapper.eq(PartnerCustomerInfo::getPartnerId,inspectionInfo.getPartnerId()).eq(PartnerCustomerInfo::getUserId,orderInfo.getUserId()); PartnerCustomerInfo customerInfo = customerInfoService.getOne(queryWrapper); - if (ObjectUtil.isEmpty(customerInfo)) { - customerInfo = new PartnerCustomerInfo(); + if (ObjectUtil.isEmpty(customerInfo)){ + customerInfo =new PartnerCustomerInfo(); customerInfo.setPartnerId(inspectionInfo.getPartnerId()); customerInfo.setUserId(user.getId()); customerInfo.setCustomerPhone(user.getMobile()); customerInfo.setCustomerName(user.getNickname()); customerInfo.setSex("0"); customerInfo.setUserAge(user.getUserAge()); - // 设置客户来源 CustomerMain customerMain = new CustomerMain(); customerMain.setDataFrom("01"); customerMainService.saveOrUpdate(customerMain); try { customerInfoService.insertPartnerCustomerInfo(customerInfo); - } catch (Exception ignored) { + }catch (Exception ignored){ } } //追加订单明细记录 - orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(), "线下订单创建", new Date(), 0L, "1")); - //默认当前流程的顺序为1 - inspectionInfo.setNowOrderNum(1); - //添加检测工单 - baseMapper.insert(inspectionInfo); - //补充检测流程 - List inspectionWorkNodes = inspectionInfo.getInspectionWorkNodes(); - //将检测工单流程补充检测工单id - inspectionWorkNodes.stream().forEach(inspectionWorkNode -> inspectionWorkNode.setInspectionInfoId(inspectionInfo.getId())); - workNodeService.saveBatch(inspectionWorkNodes); - - //检测步骤表插入检测开始 - InspectionStepInfo stepInfo = new InspectionStepInfo(); - stepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionInfo.getId()))); - stepInfo.setTitle("检测开始"); - stepInfo.setContent("检测开始"); - boolean save = inspectionStepInfoService.save(stepInfo); - return save ? 1 : 0; + orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"线下订单创建",new Date(),0L,"1")); + return baseMapper.insert(inspectionInfo); } @Override @@ -274,19 +243,19 @@ public class InspectionInfoServiceImpl extends ServiceImpl workerQueryWrapper = new LambdaQueryWrapper<>(); - workerQueryWrapper.eq(PartnerWorker::getUserId, loginUser.getId()).eq(PartnerWorker::getPartnerId, partners.getPartnerId()); + LambdaQueryWrapper workerQueryWrapper =new LambdaQueryWrapper<>(); + workerQueryWrapper.eq(PartnerWorker::getUserId,loginUser.getId()).eq(PartnerWorker::getPartnerId,partners.getPartnerId()); PartnerWorker worker = workerService.getOne(workerQueryWrapper); - AdminUserDO workerUser = userService.getUser(worker.getUserId()); - if (ObjectUtils.isNotEmpty(worker)) { + AdminUserDO workerUser =userService.getUser(worker.getUserId()); + if (ObjectUtils.isNotEmpty(worker)){ inspectionInfo.setWorkId(worker.getId()); - } else { + }else { throw new Exception("请先将接待员加入员工"); } - String buyName = StringUtils.isNotEmpty(inspectionInfo.getBuyName()) ? inspectionInfo.getBuyName() : "未知客户"; - String buyPhone = StringUtils.isNotEmpty(inspectionInfo.getBuyPhone()) ? inspectionInfo.getBuyPhone() : StringUtils.isNotEmpty(inspectionInfo.getBuyName()) ? inspectionInfo.getBuyName() : "无"; + String buyName = StringUtils.isNotEmpty(inspectionInfo.getBuyName())?inspectionInfo.getBuyName():"未知客户"; + String buyPhone = StringUtils.isNotEmpty(inspectionInfo.getBuyPhone())?inspectionInfo.getBuyPhone():StringUtils.isNotEmpty(inspectionInfo.getBuyName())?inspectionInfo.getBuyName():"无"; AdminUserDO user = userService.getUserByMobile(buyPhone); - if (ObjectUtils.isEmpty(user)) { + if (ObjectUtils.isEmpty(user)){ //新增用户 UserSaveReqVO userSaveReqVO = new UserSaveReqVO(); userSaveReqVO.setNickname(buyName); @@ -295,7 +264,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl workOrder(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime) { - return baseMapper.workOrder(partnerId, carNum, goodsTitle, customerSource, payType, startTime, roleId, endTime); + public List workOrder(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime){ + return baseMapper.workOrder(partnerId,carNum,goodsTitle, customerSource, payType, startTime,roleId,endTime); } @Override public IPage pageWorkOrder(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime, Page page) { - return baseMapper.pageWorkOrder(partnerId, carNum, goodsTitle, customerSource, payType, startTime, roleId, endTime, page); + return baseMapper.pageWorkOrder(partnerId,carNum,goodsTitle, customerSource, payType, startTime,roleId,endTime,page); } @Override - public List delworkOrder(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime) { - return baseMapper.delworkOrder(partnerId, carNum, goodsTitle, customerSource, payType, startTime, roleId, endTime); + public List delworkOrder(Long partnerId, String carNum, String goodsTitle,String customerSource,String payType,String startTime,Long roleId,String endTime){ + return baseMapper.delworkOrder(partnerId,carNum,goodsTitle, customerSource, payType, startTime,roleId,endTime); } @Override public IPage pageDelWorkOrder(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime, Page page) { - return baseMapper.pageDelWorkOrder(partnerId, carNum, goodsTitle, customerSource, payType, startTime, roleId, endTime, page); + return baseMapper.pageDelWorkOrder(partnerId,carNum,goodsTitle, customerSource, payType, startTime,roleId,endTime,page); } @Override public Map workOrderData(Long partnerId, String carNum, String goodsTitle, String customerSource, String payType, String startTime, Long roleId, String endTime) { - return baseMapper.workOrderData(partnerId, carNum, goodsTitle, customerSource, payType, startTime, roleId, endTime); - } - - /** - * 根据当前登陆人获取可以选择的工单 - * - * @return - */ - @Override - public List geStelectInspection() { - //获取当前登录人 - LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - //获取当前登陆人的角色 - List byUserId = roleService.getByUserId(loginUser.getId()); - List roleIds = byUserId.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList()); - //查询所有工单为进行中的 - List inspectionInfos = baseMapper.selectList(new LambdaQueryWrapper() - .eq(InspectionInfo::getStatus, 0)); - //根据工单id查询工单流程节点 - List infoIds = inspectionInfos.stream().map(inspectionInfo -> inspectionInfo.getId()).collect(Collectors.toList()); - if (ObjectUtils.isNotEmpty(infoIds)) { - List inspectionWorkNodes = workNodeService.list(new LambdaQueryWrapper() - .in(InspectionWorkNode::getInspectionInfoId, infoIds) - .eq(InspectionWorkNode::getDealUserId, null)); - - //工单集合 - List inspectionInfoList = new ArrayList<>(); - - //根据工单id查询工单流程节点 - Map> inspectionWorkNodeMap = inspectionWorkNodes.stream().collect(Collectors.groupingBy(InspectionWorkNode::getInspectionInfoId)); - for (InspectionInfo inspectionInfo : inspectionInfos) { - List inspectionWorkNodeList = inspectionWorkNodeMap.get(inspectionInfo.getId()); - //遍历工单流程节点 流程为key - if (CollectionUtil.isNotEmpty(inspectionWorkNodeList)) { - Map inspectionWorkMap = inspectionWorkNodeList.stream().collect(Collectors.toMap(InspectionWorkNode::getOrderNum, item -> item)); - InspectionWorkNode inspectionWorkNode = inspectionWorkMap.get(inspectionInfo.getNowOrderNum()); - if (inspectionWorkNode != null){ - //判断当前项目 当前登录人员 是否可以处理 - if (roleIds.contains(inspectionWorkNode.getRoleId())){ - inspectionInfo.setWorkNodeId(inspectionWorkNode.getId()); - inspectionInfoList.add(inspectionInfo); - } - } - } - } - return inspectionInfoList; - } - return null; + return baseMapper.workOrderData(partnerId,carNum,goodsTitle, customerSource, payType, startTime,roleId,endTime); } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/partner/service/impl/PartnerCustomerInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/partner/service/impl/PartnerCustomerInfoServiceImpl.java index 11155c96..834a7a1b 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/partner/service/impl/PartnerCustomerInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/partner/service/impl/PartnerCustomerInfoServiceImpl.java @@ -126,7 +126,6 @@ public class PartnerCustomerInfoServiceImpl extends ServiceImpl