This commit is contained in:
许允枞 2025-03-12 18:06:49 +08:00
parent ec8b8c2a96
commit e8569635de
5 changed files with 75 additions and 20 deletions

View File

@ -372,8 +372,8 @@ public class PartnerOwnController extends BaseController {
* 店铺核销功能 * 店铺核销功能
*/ */
@PostMapping("/takeOut") @PostMapping("/takeOut")
public CommonResult takeOut(Long partnerId, Long orderId, Long workId, String carNum) throws Exception { public CommonResult takeOut(@RequestBody InspectionInfo inspectionInfo) throws Exception {
partnerList.takeOut(partnerId, orderId, workId, carNum); partnerList.takeOut(inspectionInfo);
return success(); return success();
} }

View File

@ -169,4 +169,6 @@ public class InspectionInfo extends TenantBaseDO
private String leadManName; private String leadManName;
@TableField(exist = false) @TableField(exist = false)
private Integer additionalRecording; private Integer additionalRecording;
@TableField(exist = false)
private String orderId;
} }

View File

@ -99,7 +99,7 @@ public interface AppInspectionPartnerService extends IService<ShopMallPartners>
Long orderDetailByCode(Long partnerId, String code) throws Exception; Long orderDetailByCode(Long partnerId, String code) throws Exception;
void takeOut(Long partnerId, Long orderId, Long workId, String carNum) throws Exception; void takeOut(InspectionInfo inspectionInfo) throws Exception;
void addWorker(Long partnerId, String realName, String phoneNum, Long postId) throws Exception; void addWorker(Long partnerId, String realName, String phoneNum, Long postId) throws Exception;

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.appBase.controller.admin.InspectionSocket;
import cn.iocoder.yudao.module.config.service.IInspSysConfigService; import cn.iocoder.yudao.module.config.service.IInspSysConfigService;
import cn.iocoder.yudao.module.inspection.query.OrderTableQuery; import cn.iocoder.yudao.module.inspection.query.OrderTableQuery;
import cn.iocoder.yudao.module.label.vo.LabelRespVO; import cn.iocoder.yudao.module.label.vo.LabelRespVO;
@ -24,6 +25,7 @@ import cn.iocoder.yudao.module.payment.entity.OrderInfo;
import cn.iocoder.yudao.module.payment.entity.OrderInfoDetail; import cn.iocoder.yudao.module.payment.entity.OrderInfoDetail;
import cn.iocoder.yudao.module.payment.service.IOrderInfoDetailService; import cn.iocoder.yudao.module.payment.service.IOrderInfoDetailService;
import cn.iocoder.yudao.module.shop.service.IShopMallPartnersService; import cn.iocoder.yudao.module.shop.service.IShopMallPartnersService;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
@ -62,6 +64,7 @@ import cn.iocoder.yudao.module.shop.service.IShopUserCarService;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -130,6 +133,13 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
private IShopMallPartnersService partnersService; private IShopMallPartnersService partnersService;
@Resource @Resource
private DlInspectionProjectService projectService; private DlInspectionProjectService projectService;
@Autowired
@Lazy
private AppInspectionPartnerService appInspectionPartnerService;
@Autowired
private InspectionSocket inspectionSocket;
@Autowired
private IInspectionWorkNodeService workNodeService;
@Override @Override
public IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, PartnerListQuery partnerListQuery) { public IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, PartnerListQuery partnerListQuery) {
@ -1309,20 +1319,24 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void takeOut(Long partnerId, Long orderId, Long workId, String carNum) throws Exception { public void takeOut(InspectionInfo inspectionInfo) throws Exception {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
ShopMallPartners partners = appInspectionPartnerService.shopInfoByUserId();
AdminUserDO user = userService.getUser(loginUser.getId()); AdminUserDO user = userService.getUser(loginUser.getId());
ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); ShopMallPartners partnersTmp = baseMapper.selectById(partners.getPartnerId());
if (!partnersTmp.getUserId().equals(user.getId())) { if (!partnersTmp.getUserId().equals(user.getId())) {
return; return;
} }
OrderInfo orderInfo = orderService.getById(orderId); OrderInfo orderInfo = orderService.getById(inspectionInfo.getOrderId());
if (!orderInfo.getPartnerId().equals(partnerId)) { if (!orderInfo.getPartnerId().equals(partners.getPartnerId())) {
throw new Exception("您无核销权限"); throw new Exception("您无核销权限");
} }
if (!orderInfo.getOrderStatus().equals("1") && !ObjectUtil.isEmpty(orderInfo.getValidationTime())) { if (!orderInfo.getOrderStatus().equals("1") && !ObjectUtil.isEmpty(orderInfo.getValidationTime())) {
throw new Exception("已核销请不要重复核销"); throw new Exception("已核销请不要重复核销");
} }
if (CollUtil.isEmpty(inspectionInfo.getInspectionWorkNodes())) {
throw new Exception("请选择检测项目");
}
//处理订单信息 //处理订单信息
orderInfo.setOrderStatus("2"); orderInfo.setOrderStatus("2");
orderInfo.setValidationTime(new Date()); orderInfo.setValidationTime(new Date());
@ -1339,7 +1353,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
info.setUserId(orderInfo.getUserId()); info.setUserId(orderInfo.getUserId());
info.setPartnerId(orderInfo.getPartnerId()); info.setPartnerId(orderInfo.getPartnerId());
info.setInspectionOrderId(orderInfo.getId()); info.setInspectionOrderId(orderInfo.getId());
info.setCarNum(carNum); info.setCarNum(inspectionInfo.getCarNum());
info.setCategoryId(goods.getGoodsCategoryId()); info.setCategoryId(goods.getGoodsCategoryId());
info.setYear(DateUtil.format(new Date(), "yyyy")); info.setYear(DateUtil.format(new Date(), "yyyy"));
info.setMonth(DateUtil.format(new Date(), "yyyy-MM")); info.setMonth(DateUtil.format(new Date(), "yyyy-MM"));
@ -1347,12 +1361,12 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
info.setStartTime(new Date()); info.setStartTime(new Date());
info.setStatus("0"); info.setStatus("0");
//获取修理工信息 //获取修理工信息
PartnerWorker worker = partnerWorkerService.getById(workId); // PartnerWorker worker = partnerWorkerService.getById(workId);
AdminUserDO sysUser = userService.getUser(worker.getUserId()); AdminUserDO sysUser = userService.getUser(inspectionInfo.getWorkId());
info.setWorkerName(sysUser.getNickname()); info.setWorkerName(sysUser.getNickname());
info.setWorkerPhone(sysUser.getMobile()); info.setWorkerPhone(sysUser.getMobile());
info.setWorkerAvatar(sysUser.getAvatar()); info.setWorkerAvatar(sysUser.getAvatar());
info.setWorkId(workId); info.setWorkId(inspectionInfo.getWorkId());
info.setCustomerSource("线上客户"); info.setCustomerSource("线上客户");
//20240327 追加字段 //20240327 追加字段
info.setOtherPhone(orderInfo.getOtherPhone()); info.setOtherPhone(orderInfo.getOtherPhone());
@ -1360,16 +1374,19 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
info.setIsPayOnline(orderInfo.getIsPayOnline()); info.setIsPayOnline(orderInfo.getIsPayOnline());
info.setIsPickCar(orderInfo.getIsPickCar()); info.setIsPickCar(orderInfo.getIsPickCar());
info.setRemark(orderInfo.getRemark()); info.setRemark(orderInfo.getRemark());
info.setCarNum(orderInfo.getCarNo()); info.setCarNum(inspectionInfo.getCarNum());
info.setBuyName(orderInfo.getRealName());
info.setBuyPhone(orderInfo.getPhonenumber());
info.setUserId(orderInfo.getUserId());
inspectionInfoService.save(info); inspectionInfoService.save(info);
//增加客户信息 //增加客户信息
LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PartnerCustomerInfo::getPartnerId, partnerId).eq(PartnerCustomerInfo::getUserId, orderInfo.getUserId()); queryWrapper.eq(PartnerCustomerInfo::getPartnerId, partners.getPartnerId()).eq(PartnerCustomerInfo::getUserId, orderInfo.getUserId());
PartnerCustomerInfo customerInfo = customerInfoService.getOne(queryWrapper); PartnerCustomerInfo customerInfo = customerInfoService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(customerInfo)) { if (ObjectUtil.isEmpty(customerInfo)) {
AdminUserDO buyUser = userService.getUser(orderInfo.getUserId()); AdminUserDO buyUser = userService.getUser(orderInfo.getUserId());
customerInfo = new PartnerCustomerInfo(); customerInfo = new PartnerCustomerInfo();
customerInfo.setPartnerId(partnerId); customerInfo.setPartnerId(partners.getPartnerId());
customerInfo.setUserId(buyUser.getId()); customerInfo.setUserId(buyUser.getId());
customerInfo.setCustomerPhone(buyUser.getMobile()); customerInfo.setCustomerPhone(buyUser.getMobile());
customerInfo.setCustomerName(buyUser.getNickname()); customerInfo.setCustomerName(buyUser.getNickname());
@ -1378,11 +1395,11 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
customerInfoService.save(customerInfo); customerInfoService.save(customerInfo);
} }
InspectionStepInfo stepInfo = new InspectionStepInfo(); // InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(info.getId().intValue()); // stepInfo.setInspectionInfoId(info.getId().intValue());
stepInfo.setContent("检测开始"); // stepInfo.setContent("检测开始");
stepInfo.setTitle("检测开始"); // stepInfo.setTitle("检测开始");
this.addStepInfo(stepInfo); // this.addStepInfo(stepInfo);
//开始检测短信发送 //开始检测短信发送
// 获取当前日期和时间 // 获取当前日期和时间
LocalDateTime currentTime = LocalDateTime.now(); LocalDateTime currentTime = LocalDateTime.now();
@ -1398,6 +1415,43 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
log.error(ignored.getMessage()); log.error(ignored.getMessage());
} }
List<InspectionWorkNode> inspectionWorkNodes = inspectionInfo.getInspectionWorkNodes();
inspectionWorkNodes.stream().forEach(inspectionWorkNode -> {
//检测工单id
inspectionWorkNode.setInspectionInfoId(info.getId());
//将节点状态设置为未开始
inspectionWorkNode.setStatus("0");
});
workNodeService.saveBatch(inspectionWorkNodes);
//检测步骤表插入检测开始
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(info.getId())));
stepInfo.setTitle("检测开始");
stepInfo.setCreateTime(new Date());
stepInfo.setCreator(Integer.parseInt(String.valueOf(loginUser.getId())));
this.addStepInfo(stepInfo);
List<Integer> roleIds = new ArrayList<>();
/*获取所有的角色id*/
if (CollUtil.isNotEmpty(inspectionWorkNodes)) {
roleIds = inspectionWorkNodes.stream().map(inspectionWorkNode -> inspectionWorkNode.getRoleId()).collect(Collectors.toList());
}
//根据角色id获取所有用户
List<UserDTO> listByUserId = roleService.getListByUserIds(roleIds);
List<Long> ids = listByUserId.stream().map(UserDTO::getId).collect(Collectors.toList());
if (ObjectUtil.isNotNull(inspectionInfo.getLeadManId())) {
ids.add(inspectionInfo.getLeadManId());
}
//给ids去重
ids = ids.stream().distinct().collect(Collectors.toList());
// 获取当前共单引车员的id
if (CollUtil.isNotEmpty(ids) && ObjectUtil.isNull(inspectionInfo.getAdditionalRecording())) {
for (Long id : ids) {
inspectionSocket.sendMessage("接工单", id.toString());
}
}
} }
@Override @Override

View File

@ -355,7 +355,6 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
for (Long id : ids) { for (Long id : ids) {
inspectionSocket.sendMessage("接工单", id.toString()); inspectionSocket.sendMessage("接工单", id.toString());
} }
} }