Compare commits

...

15 Commits

Author SHA1 Message Date
xyc
d81fa731c5 更新 2025-05-20 14:19:26 +08:00
xyc
cd806c9ac0 更新 2025-05-20 13:05:36 +08:00
xyc
c770cbbea1 更新 2025-05-19 18:00:17 +08:00
xyc
4b60ceaac2 Merge branch 'master' into insp 2025-05-16 13:46:00 +08:00
xyc
041424ef82 更新 2025-05-16 13:34:51 +08:00
xyc
8c487c02ec 更新 2025-05-16 13:06:32 +08:00
xyc
58e87424ac 更新 2025-05-16 11:41:28 +08:00
xyc
c262a88fd9 更新 2025-05-15 16:49:25 +08:00
xyc
3cfd01fd9b Merge branch 'driver' into insp 2025-05-13 14:14:13 +08:00
xyc
a5015bddbb 更新 2025-05-10 17:50:41 +08:00
xyc
5caea1c148 更新 2025-05-07 16:10:13 +08:00
xyc
be3af2bd64 更新 2025-05-07 16:07:32 +08:00
xyc
e5f0684799 更新 2025-04-30 17:50:58 +08:00
xyc
5d48ccc1bd 更新 2025-04-30 13:18:46 +08:00
xyc
914f1d107d 更新 2025-04-28 15:21:05 +08:00
58 changed files with 1764 additions and 307 deletions

View File

@ -38,6 +38,11 @@
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>

View File

@ -0,0 +1,12 @@
package cn.iocoder.yudao.common.service;
public interface InspectionNoticeService {
/**
* 向指定用户发送消息
*
* @param userId 用户id
* @param text 消息通知内容
**/
void sentMessage(Long userId, String text);
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.common.service.impl;
import cn.iocoder.yudao.common.SystemEnum;
import cn.iocoder.yudao.common.service.InspectionNoticeService;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
import static cn.iocoder.yudao.common.BaseConstants.TICKET_EMPLOY;
@Service
@RequiredArgsConstructor
public class InspectionNoticeServiceImpl implements InspectionNoticeService {
private final NotifyMessageSendApi sendApi;
/**
* 向指定用户发送消息
*
* @param userId 用户id
* @param text 消息通知内容
**/
@Override
public void sentMessage(Long userId, String text) {
// 准备发送参数
Map<String, Object> templateParams = new HashMap<>();
// 发送模版内容
templateParams.put("text", text);
// 发送站内信
sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
.setUserId(userId)
.setTemplateCode(TICKET_EMPLOY)
.setSystemCode(SystemEnum.INSPECTION.getCode())
.setTemplateParams(templateParams));
}
}

View File

@ -143,9 +143,9 @@ public class AppSwiperController extends BaseController {
LoginUser user = SecurityFrameworkUtils.getLoginUser();
queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).eq(ShopMallPartners::getType, "jc").eq(ShopMallPartners::getIsBanned, "0").last("limit 1");
ShopMallPartners partner = partnersService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(partner)) {
return error("信息有误");
}
// if (ObjectUtil.isEmpty(partner)) {
// return error("信息有误");
// }
AdminUserDO sysUser = userService.getUser(user.getId());
Map<String, Object> map = new HashMap<>();
map.put("user", sysUser);

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.config.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ReminderMessage {
private Long taskId; // 任务id
private Long userId; // 用户id
private String message; // 消息
}

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.config.service;
import cn.iocoder.yudao.module.config.entity.ReminderMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Set;
/**
* Redis 延迟队列服务
*/
@Service
public class RedisDelayedQueueService {
private static final String REDIS_KEY = "appointment:reminder:queue";
@Autowired
private StringRedisTemplate redisTemplate;
private final ObjectMapper objectMapper = new ObjectMapper();
public void addToQueue(ReminderMessage message, long triggerTimeMillis) {
try {
String json = objectMapper.writeValueAsString(message);
redisTemplate.opsForZSet().add(REDIS_KEY, json, triggerTimeMillis);
} catch (JsonProcessingException e) {
throw new RuntimeException("Failed to add reminder to Redis", e);
}
}
public Set<String> fetchDueMessages(long currentTimeMillis) {
return redisTemplate.opsForZSet()
.rangeByScore(REDIS_KEY, 0, currentTimeMillis);
}
public void removeMessage(String json) {
redisTemplate.opsForZSet().remove(REDIS_KEY, json);
}
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.config.service;
import cn.iocoder.yudao.module.appBase.controller.admin.InspectionSocket;
import cn.iocoder.yudao.module.config.entity.ReminderMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class ReminderHandler {
@Autowired
private InspectionSocket inspectionSocket;
public void handleReminder(ReminderMessage message) {
// 调用websocket发送消息
inspectionSocket.sendMessage(message.getMessage(), String.valueOf(message.getUserId()));
}
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.config.task;
import cn.iocoder.yudao.module.config.entity.ReminderMessage;
import cn.iocoder.yudao.module.config.service.ReminderHandler;
import cn.iocoder.yudao.module.config.service.RedisDelayedQueueService;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Set;
@Slf4j
@Component
public class AppointmentReminderTask {
@Autowired
private RedisDelayedQueueService queueService;
@Autowired
private ReminderHandler reminderHandler;
@Scheduled(fixedRate = 60_000)
public void checkReminderQueue() {
long now = System.currentTimeMillis();
Set<String> dueMessages = queueService.fetchDueMessages(now);
for (String json : dueMessages) {
try {
ReminderMessage message = new ObjectMapper().readValue(json, ReminderMessage.class);
// 执行提醒
reminderHandler.handleReminder(message);
log.info("处理提醒成功:{}", message);
// 移除已处理任务
queueService.removeMessage(json);
} catch (Exception e) {
log.error("解析或处理提醒失败", e);
}
}
}
}

View File

@ -62,4 +62,27 @@ public class InspectionConstants {
* 接车完成类型 - 接车订单表
*/
public static final Integer INSPECTION_MEET_CAR_ORDER_IS_MEET_CAR_COMPLETE_TYPE_MEET_CAR_ORDER = 1;
/**
* 检测websocket消息内容-客户即将到店
*/
public static final String INSPECTION_WEBSOCKET_MESSAGE_CONTENT_CUSTOMER_ARRIVE = "客户即将到店";
// =======================================站内信模板=======================================
/**
* 检测站内信模板-客户预约通知
*/
public static final String INSPECTION_NOTICE_TEMPLATE_CUSTOMER_APPOINTMENT = "%s预约了%s-%s 将于%s %s到店 联系电话:%s";
/**
* 检测站内信模板-分配员工接车
*/
public static final String INSPECTION_NOTICE_TEMPLATE_ASSIGN_STAFF_MEET_CAR = "您有的新的接车订单需要处理 接车时间:%s 车牌号:%s 详细信息请前往接车列表";
/**
* 检测站内信模板-分配员工接车 没有车牌号
*/
public static final String INSPECTION_NOTICE_TEMPLATE_ASSIGN_STAFF_MEET_CAR_NO_CAR_NO = "您有的新的接车订单需要处理 接车时间:%s 详细信息请前往接车列表";
}

View File

@ -14,6 +14,8 @@ import cn.iocoder.yudao.module.shop.service.IShopCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.iocoder.yudao.module.core.controller.BaseController;
import java.text.ParseException;
import java.util.List;
@RestController
@ -124,8 +126,7 @@ public class AppGoodsController extends BaseController {
* 预约功能
*/
@PostMapping("/appointmentInspection")
public CommonResult appointmentInspection(@RequestBody InspectionAppointment appointment)
{
public CommonResult appointmentInspection(@RequestBody InspectionAppointment appointment) throws ParseException {
return success(appointmentService.appointmentInspection(appointment));
}
/**

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.inspection.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
@ -69,10 +70,11 @@ public class InspectionFileController extends BaseController {
*/
@GetMapping("/listByPermission")
public CommonResult listByPermission(InspectionFile inspectionFile) throws Exception {
ShopMallPartners partners = partnerService.shopInfoByUserId();
inspectionFile.setPartnerId(partners.getPartnerId());
if (ObjectUtil.isEmpty(inspectionFile.getServicePackageId())){
inspectionFile.setServicePackageId("jiance");
}
//判断当前登陆人的角色是否是可以查看文件
boolean ifFile = permissionApi.hasDictTypeRole("ins_file_role");
boolean ifFile = permissionApi.hasDictTypeRole(inspectionFile.getDictType());
if (ifFile) {
return success(inspectionFileService.selectInspectionFileList(inspectionFile));
}else {

View File

@ -33,9 +33,7 @@ public class InspectionFileRecordController extends BaseController {
*/
@GetMapping("/get/{id}")
public CommonResult<?> getByFileId(@PathVariable Long id) {
List<InspectionFileRecord> list = inspectionFileRecordService.list(Wrappers.lambdaQuery(InspectionFileRecord.class)
.eq(InspectionFileRecord::getFileId, id)
.orderBy(true, true, InspectionFileRecord::getCreateTime));
List<InspectionFileRecord> list = inspectionFileRecordService.getRecordList(id);
return CommonResult.success(list);
}

View File

@ -276,7 +276,7 @@ public class InspectionInfoController extends BaseController {
*/
@GetMapping("isExamine")
public CommonResult isExamine() {
return success(inspectionInfoService.isExamine());
return success(inspectionInfoService.isExamine("jcsfdl"));
}
/**
@ -386,4 +386,27 @@ public class InspectionInfoController extends BaseController {
public CommonResult<?> meetCarPhoto(@RequestBody InspectionWorkNode inspectionWorkNode) {
return success(inspectionInfoService.meetCarPhoto(inspectionWorkNode));
}
/**
* 修改异常工单
*
* @param inspectionWorkNode
* @return
*/
@PostMapping("/updateException")
public CommonResult<?> updateException(@RequestBody InspectionWorkNode inspectionWorkNode) {
inspectionWorkNodeService.updateException(inspectionWorkNode.getInspectionInfoId(), inspectionWorkNode.getIdList());
return success("操作成功");
}
/**
* 员工 引车接单
*
* @return
*/
@PostMapping("/leadCar")
public CommonResult<?> leadCar(@RequestBody InspectionInfo inspectionInfo) {
inspectionInfoService.leadCar(inspectionInfo);
return success("操作成功");
}
}

View File

@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionMeetCarOrder;
import cn.iocoder.yudao.module.inspection.service.InspectionMeetCarOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @Description: 接车订单
@ -31,9 +28,12 @@ public class InspectionMeetCarOrderController {
*/
@PostMapping("/add")
public CommonResult<?> add(@RequestBody InspectionMeetCarOrder order) {
// 设置接车员id
order.setMeetManId(SecurityFrameworkUtils.getLoginUserId());
inspectionMeetCarOrderService.add(order);
return CommonResult.ok();
}
@GetMapping("/get")
public CommonResult<?> get(Long id){
return CommonResult.success(inspectionMeetCarOrderService.getById(id));
}
}

View File

@ -179,6 +179,19 @@ public class InspectionStaffController extends BaseController {
return success(inspectionStaffService.addFolder(userId));
}
/**
* 获取已完成项目
* @param userId 用户id
* @return
*/
@GetMapping("/getFinishProjectByUserId")
public CommonResult<?> getFinishProjectByUserId(@RequestParam("userId") Long userId,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
return success(inspectionStaffService.getFinishProjectByUserId(page, userId));
}
/**
* 校验信息
*

View File

@ -823,6 +823,18 @@ public class PartnerOwnController extends BaseController {
return success(partnerList.getProjectBelowStandardByIds(ids,status,type));
}
/**
* 根据inspection_info的id查有的项目名称
*
* @param ids inspection_info的id
* @author 小李
* @date 14:52 2024/12/10
**/
@GetMapping("/getProjectExceptionByIds")
public CommonResult<?> getProjectExceptionByIds(@RequestParam(value = "ids") Long[] ids,@RequestParam(value = "status",required = false) String status,@RequestParam(value = "type",required = false) String type) {
return success(partnerList.getProjectExceptionByIds(ids,status,type));
}
/**
* 根据时间查订单
*

View File

@ -75,6 +75,23 @@ public class InspectionAppointment extends TenantBaseDO
// 车辆注册时间
private Date carRegisterDate;
private String address;
private String meetOrderId;
// 选择的时间段
private String time;
@TableField(exist = false)
private String skuName;
@TableField(exist = false)
private String meetName;
@TableField(exist = false)
private Integer isMeet;
@TableField(exist = false)
private String pickCarAppointmentDay;
@TableField(exist = false)
private String pickCarAppointmentTime;
@TableField(exist = false)
private String adressDetail;
@TableField(exist = false)
private String isUse;
@TableField(exist = false)
private String owner;
}

View File

@ -12,7 +12,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import cn.iocoder.yudao.annotation.Excel;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import org.apache.commons.compress.harmony.pack200.NewAttributeBands;
/**
* equInfo对象 inspection_equ_info

View File

@ -53,6 +53,9 @@ public class InspectionFile extends TenantBaseDO
/** 员工、设备的默认文件夹*/
private String defaultKey;
/** 服务套餐id */
private String servicePackageId;
/**
* 是否为员工附 0- 1-
*/
@ -67,4 +70,7 @@ public class InspectionFile extends TenantBaseDO
@TableField(exist = false)
private String fileType;
@TableField(exist = false)
private String dictType;
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.inspection.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.time.LocalDateTime;
@ -44,4 +45,7 @@ public class InspectionFileRecord extends TenantBaseDO {
* 预警时间
*/
private Date warnTime;
@TableField(exist = false)
private String nickname;
}

View File

@ -65,6 +65,10 @@ public class InspectionInfo extends TenantBaseDO
//是否重审
private String isRetrial;
private String remark;
/** 复检次数 */
private Integer recheckCount;
/** 重检次数 */
private Integer reinspectCount;
/** 0进行中1已结束 */
@Excel(name = "0进行中1已结束")
@ -147,6 +151,7 @@ public class InspectionInfo extends TenantBaseDO
//2024-03-27新增字段
//其他联系人手机号
private String otherPhone;
// private String otherName;
private String driverLicenesImg;
//是否线上支付0否1是
private String isPayOnline;
@ -184,4 +189,14 @@ public class InspectionInfo extends TenantBaseDO
private Integer sourceType;
@TableField(exist = false)
private String meetCarId;
@TableField(exist = false)
private String meetAddress;
@TableField(exist = false)
private String latitude; // 维度
@TableField(exist = false)
private String longitude; // 经度
@TableField(exist = false)
private String appointmentDay; // 经度
@TableField(exist = false)
private String appointmentTime; // 经度
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.inspection.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class InspectionLeadRecord extends TenantBaseDO {
/**
* 主键
*/
private Long id;
/**
* 检测工单id
*/
private String inspectionId;
/**
* 用户id
*/
private Long userId;
}

View File

@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.inspection.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@ -28,6 +30,10 @@ public class InspectionMeetCarOrder extends TenantBaseDO {
private String userAddress; // 用户地址
private String meetAddress; // 接车地址
private String latitude; // 维度
private String longitude; // 经度
private String carNum; // 车牌号
private String carNature; // 使用性质
@ -45,4 +51,34 @@ public class InspectionMeetCarOrder extends TenantBaseDO {
private Integer isMeet; // 是否接车 0未接 1已接
private String inspectionInfoId;
private String appointmentDay; // 预约日期
private String appointmentTime; // 预约时间
//客户来源
private String customerSource;
//商品id
private Long goodsId;
//商品名称
private String goodsTitle;
private Long skuId;
private String skuName;
/**
* 接车类型 0接待 1上门取车
*/
private Integer meetType;
@TableField(exist = false)
private Long appointmentId;
/** 接车拍照的内容*/
@TableField(exist = false)
private String content;
/** 接车拍照 */
@TableField(exist = false)
private String images;
}

View File

@ -85,6 +85,11 @@ public class InspectionWorkNode extends TenantBaseDO {
*/
private String status;
/**
* 检测次数
*/
private Integer nodeCount;
/**
* 1-退办理 2-选择重审 3-项目完成
@ -108,4 +113,6 @@ public class InspectionWorkNode extends TenantBaseDO {
/** 接车时所传的id*/
@TableField(exist = false)
private String meetCarId;
@TableField(exist = false)
private List<String> idList;
}

View File

@ -4,6 +4,8 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionFileRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Description: 检测文档记录表
* @Author: 86187
@ -12,4 +14,10 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface InspectionFileRecordMapper extends BaseMapper<InspectionFileRecord> {
/**
* 获取检测文档记录
* @param id
* @return
*/
List<InspectionFileRecord> getRecordList(Long id);
}

View File

@ -0,0 +1,25 @@
package cn.iocoder.yudao.module.inspection.mapper;
import cn.iocoder.yudao.module.inspection.entity.InspectionLeadRecord;
import cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods;
import cn.iocoder.yudao.module.inspection.query.GoodsQuery;
import cn.iocoder.yudao.module.inspection.vo.GoodsVo;
import cn.iocoder.yudao.module.inspection.vo.PartnerListVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 车检商品表(ShopInspectionGoods)表数据库访问层
*
* @author makejava
* @since 2023-08-01 16:04:13
*/
@Mapper
public interface InspectionLeadRecordMapper extends BaseMapper<InspectionLeadRecord> {
}

View File

@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.inspection.mapper;
import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject;
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
import cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -39,5 +41,14 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
*/
void recheck(@Param("list") List<InspectionWorkNode> workNodes, @Param("status") String status);
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
List<StaffProjectCountVO> getStaffCount(DlInspectionProject dlInspectionProject);
/**
* 根据检测id获取异常节点
* @param idList
* @return
*/
List<Map<String, Object>> selectExceptionNodesByInspectionIds(@Param("ids") List<Long> idList);
IPage<Map<String, Object>> selectStaffProjectByUserId(@Param("page")Page<Map<String, Object>> page, @Param("userId") Long userId);
}

View File

@ -34,4 +34,10 @@ public class OrderTableQuery {
/** 车龄 */
private Integer carYear;
/** 检测类型*/
private String skuName;
/** 等于1时是查询预约转订单 */
private String type;
}

View File

@ -187,6 +187,15 @@ public interface AppInspectionPartnerService extends IService<ShopMallPartners>
**/
Map<Long, List<Map<String, String>>> getProjectBelowStandardByIds(Long[] ids, String status, String type);
/**
* 根据inspection_info的id查有的项目名称
*
* @param ids inspection_info的id
* @author 小李
* @date 14:52 2024/12/10
**/
Map<Long, List<Map<String, String>>> getProjectExceptionByIds(Long[] ids, String status, String type);
/**
* 根据时间查订单
*

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import cn.iocoder.yudao.module.inspection.entity.InspectionAppointment;
import cn.iocoder.yudao.module.inspection.entity.InspectionPickCar;
import java.text.ParseException;
import java.util.List;
/**
@ -65,7 +66,7 @@ public interface IInspectionAppointmentService extends IService<InspectionAppoi
*/
public int deleteInspectionAppointmentById(Long id);
Long appointmentInspection(InspectionAppointment appointment);
Long appointmentInspection(InspectionAppointment appointment) throws ParseException;
Long editAppointment(InspectionAppointment appointment);
void delAppointment(Long appointmentId);
Long pickCarInspection(InspectionPickCar pickCar) throws Exception;

View File

@ -2,8 +2,6 @@ package cn.iocoder.yudao.module.inspection.service;
import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
import cn.iocoder.yudao.module.inspection.entity.TreeCommonResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;

View File

@ -111,7 +111,7 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
* 判断app当前检测人是否有审核权限
* @return
*/
Boolean isExamine();
Boolean isExamine(String code);
/**
* 获取某个工单针对当前操作用户某个状态的项目们
@ -153,4 +153,10 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
* @param inspectionWorkNode
*/
Boolean meetCarPhoto(InspectionWorkNode inspectionWorkNode);
/**
* 引车
* @param inspectionInfo
*/
void leadCar(InspectionInfo inspectionInfo);
}

View File

@ -75,4 +75,18 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode>
* @return
*/
List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject);
/**
* 根据检测id获取异常节点
*
* @param idList
* @return
*/
List<Map<String, Object>> selectExceptionNodesByInspectionIds(List<Long> idList);
/**
* 完成异常节点
* @param idList
*/
void updateException(Long inspectionInfoId,List<String> idList);
}

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.inspection.service;
import cn.iocoder.yudao.module.inspection.entity.InspectionFileRecord;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* @Description: 检测文档记录表
* @Author: 86187
@ -10,4 +12,11 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @Version: 1.0
*/
public interface InspectionFileRecordService extends IService<InspectionFileRecord> {
/**
* 获取检测文档记录列表
*
* @param id 文档id
* @return 检测文档记录列表
*/
List<InspectionFileRecord> getRecordList(Long id);
}

View File

@ -0,0 +1,10 @@
package cn.iocoder.yudao.module.inspection.service;
import cn.iocoder.yudao.module.inspection.entity.InspectionLeadRecord;
import com.baomidou.mybatisplus.extension.service.IService;
public interface InspectionLeadRecordService extends IService<InspectionLeadRecord> {
}

View File

@ -75,5 +75,12 @@ public interface InspectionStaffService extends IService<InspectionStaff> {
* @return 文件夹id
*/
Long addFolder(Long userId);
/**
* 获取已完成项目
* @param userId
* @return
*/
IPage<Map<String, Object>> getFinishProjectByUserId(Page<Map<String, Object>> page, Long userId);
}

View File

@ -40,17 +40,15 @@ import cn.iocoder.yudao.module.system.service.dict.DictDataService;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.util.AddressSplitter;
import cn.iocoder.yudao.util.SendSmsUtil;
import cn.iocoder.yudao.util.VehicleLicenseOCR;
import cn.iocoder.yudao.util.*;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import cn.iocoder.yudao.util.StringUtils;
import cn.iocoder.yudao.module.inspection.entity.*;
import cn.iocoder.yudao.module.inspection.mapper.AppInspectionPartnerMapper;
import cn.iocoder.yudao.module.inspection.query.PartnerListQuery;
@ -879,7 +877,6 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
} else {
seriesObjectData.add(Double.valueOf(String.valueOf(orderInfo.get("passRatio"))));
}
}
categories.addAll(list1.stream().map(it -> {
return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle();
@ -1576,6 +1573,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
res.setGoodsPrice(order.getGoodsPrice());
res.setGoodsName(sku.getSkuName());
res.setIsOnline(order.getIsOnline());
res.setRecheckCount(info.getRecheckCount());
res.setReinspectCount(info.getReinspectCount());
res.setIsRetrial(info.getIsRetrial());
res.setIsPass(info.getIsPass());
res.setRemark(info.getRemark());
@ -1923,6 +1922,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
Map<String, Integer> map = baseMapper.staticsTable2(partnerId, startTime, endTime);
// 查询未完成 所有时间
Map<String, Integer> stringIntegerMap = baseMapper.staticsTable2(partnerId, null, null);
map.put("allJxzNum", stringIntegerMap.get("jxzNum"));
return map;
}
@ -2028,6 +2031,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
Collectors.mapping(InspectionWorkNode::getProjectId, Collectors.toList())));
for (Long id : ids) {
List<String> values = map.get(id);
if (ObjectUtil.isEmpty(values)) {
result.put(id, "");
continue;
}
String names = values.stream().filter(projectMap::containsKey).map(projectMap::get).collect(Collectors.joining(","));
result.put(id, names);
}
@ -2047,8 +2054,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
List<InspectionWorkNode> inspectionWorkNodes = inspectionWorkNodeService
.list(new LambdaQueryWrapper<InspectionWorkNode>()
.in(InspectionWorkNode::getInspectionInfoId, Arrays.asList(ids))
.eq(StrUtil.isNotEmpty(status),InspectionWorkNode::getStatus, status)
.eq(StrUtil.isNotEmpty(type),InspectionWorkNode::getType, type));
.eq(StrUtil.isNotEmpty(status), InspectionWorkNode::getStatus, status)
.eq(StrUtil.isNotEmpty(type), InspectionWorkNode::getType, type));
if (ObjectUtil.isEmpty(inspectionWorkNodes)) {
return Collections.emptyMap(); // 返回空Map而非null避免NPE
}
@ -2089,6 +2096,40 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
Collectors.toList())));
}
/**
* 根据inspection_info的id查不合格项目名称
*
* @param ids inspection_info的id
* @author 小李
* @date 14:52 2024/12/10
**/
@Override
public Map<Long, List<Map<String, String>>> getProjectExceptionByIds(Long[] ids, String status, String type) {
if (ids == null || ids.length == 0) {
return Collections.emptyMap();
}
// 1. 调用 Mapper 拿到所有异常节点
List<Long> idList = Arrays.asList(ids);
List<Map<String, Object>> raw = inspectionWorkNodeService
.selectExceptionNodesByInspectionIds(idList);
if (raw.isEmpty()) {
return Collections.emptyMap();
}
// 2. inspectionInfoId 分组并转换成 List<Map<String,String>>
return raw.stream()
.collect(Collectors.groupingBy(
m -> ((Number) m.get("inspectionInfoId")).longValue(), // key工单ID
Collectors.mapping(m -> {
Map<String, String> map = new HashMap<>();
map.put("id", m.get("nodeId").toString());
map.put("name", m.get("projectName").toString());
return map;
}, Collectors.toList())
));
}
/**
* 根据时间查订单
*
@ -2180,6 +2221,24 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
*/
@Override
public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) {
return inspectionWorkNodeService.getStaffCount(dlInspectionProject);
List<Map<String, Object>> staffCount = inspectionWorkNodeService.getStaffCount(dlInspectionProject);
// 根据userId查询检测工单表 接车人
List<InspectionInfo> list = inspectionInfoService.list(Wrappers.<InspectionInfo>lambdaQuery()
.eq(InspectionInfo::getIsMeetCar, 1));
// 统计每个 meetManId 的数量避免 null key 异常
Map<Long, Long> meetManIdCountMap = list.stream()
.filter(info -> info.getMeetManId() != null) // 过滤 null
.collect(Collectors.groupingBy(InspectionInfo::getMeetManId, Collectors.counting()));
for (Map<String, Object> stringObjectMap : staffCount) {
Long userId = (Long) stringObjectMap.get("userId");
List<Map<String, Object>> children = (List<Map<String, Object>>) stringObjectMap.get("children");
stringObjectMap.put("meetCarCount", meetManIdCountMap.get(userId));
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("count", meetManIdCountMap.get(userId) == null ? 0 : meetManIdCountMap.get(userId));
objectObjectHashMap.put("projectName", "接车");
children.add(objectObjectHashMap);
}
return staffCount;
}
}

View File

@ -1,14 +1,31 @@
package cn.iocoder.yudao.module.inspection.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.common.service.InspectionNoticeService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.appBase.controller.admin.InspectionSocket;
import cn.iocoder.yudao.module.config.entity.ReminderMessage;
import cn.iocoder.yudao.module.config.service.RedisDelayedQueueService;
import cn.iocoder.yudao.module.constant.InspectionConstants;
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
import cn.iocoder.yudao.module.shop.service.IShopConfigService;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
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.alibaba.fastjson.JSONObject;
@ -29,6 +46,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import static cn.iocoder.yudao.module.constant.InspectionConstants.INSPECTION_WEBSOCKET_MESSAGE_CONTENT_CUSTOMER_ARRIVE;
import static cn.iocoder.yudao.util.DistanceUtil.getDistanceMeter;
/**
@ -38,12 +58,17 @@ import static cn.iocoder.yudao.util.DistanceUtil.getDistanceMeter;
* @date 2023-08-24
*/
@Service
public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppointmentMapper,InspectionAppointment> implements IInspectionAppointmentService
{
public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppointmentMapper, InspectionAppointment> implements IInspectionAppointmentService {
@Autowired
private AppInspectionPartnerService partnerService;
@Autowired
private InspectionSocket inspectionSocket;
@Resource
private DictDataApi dictDataApi;
@Resource
private RoleService roleService;
@Autowired
private AppInspectionGoodsService goodsService;
@Autowired
private InspectionGoodsSkuService skuService;
@ -53,6 +78,11 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
private IShopConfigService configService;
@Autowired
private IInspectionPickCarService pickCarService;
@Autowired
private RedisDelayedQueueService redisDelayedQueueService;
@Autowired
private InspectionNoticeService noticeService;
/**
* 查询请填写功能名称
*
@ -60,8 +90,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
* @return 请填写功能名称
*/
@Override
public InspectionAppointment selectInspectionAppointmentById(Long id)
{
public InspectionAppointment selectInspectionAppointmentById(Long id) {
return baseMapper.selectInspectionAppointmentById(id);
}
@ -72,9 +101,8 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
* @return 请填写功能名称
*/
@Override
public IPage<InspectionAppointment> selectInspectionAppointmentList(Page<InspectionAppointment> page, InspectionAppointment inspectionAppointment)
{
return baseMapper.selectInspectionAppointmentList(page,inspectionAppointment);
public IPage<InspectionAppointment> selectInspectionAppointmentList(Page<InspectionAppointment> page, InspectionAppointment inspectionAppointment) {
return baseMapper.selectInspectionAppointmentList(page, inspectionAppointment);
}
/**
@ -84,8 +112,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
* @return 结果
*/
@Override
public int insertInspectionAppointment(InspectionAppointment inspectionAppointment)
{
public int insertInspectionAppointment(InspectionAppointment inspectionAppointment) {
return baseMapper.insertInspectionAppointment(inspectionAppointment);
}
@ -96,8 +123,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
* @return 结果
*/
@Override
public int updateInspectionAppointment(InspectionAppointment inspectionAppointment)
{
public int updateInspectionAppointment(InspectionAppointment inspectionAppointment) {
inspectionAppointment.setUpdateTime(DateUtils.getNowDate());
return baseMapper.updateInspectionAppointment(inspectionAppointment);
}
@ -109,8 +135,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
* @return 结果
*/
@Override
public int deleteInspectionAppointmentByIds(Long[] ids)
{
public int deleteInspectionAppointmentByIds(Long[] ids) {
return baseMapper.deleteInspectionAppointmentByIds(ids);
}
@ -121,13 +146,13 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
* @return 结果
*/
@Override
public int deleteInspectionAppointmentById(Long id)
{
public int deleteInspectionAppointmentById(Long id) {
return baseMapper.deleteInspectionAppointmentById(id);
}
@Override
public Long appointmentInspection(InspectionAppointment appointment) {
@Transactional
public Long appointmentInspection(InspectionAppointment appointment) throws ParseException {
//当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
appointment.setUserId(loginUser.getId());
@ -135,73 +160,162 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
InspectionGoodsSku sku = skuService.getById(appointment.getSkuId());
ShopInspectionGoods goods = goodsService.getById(sku.getGoodsId());
appointment.setPartnerId(Long.parseLong(goods.getPartnerId().toString()));
appointment.setGoodsTitle(goods.getTitle()+"-"+sku.getSkuName());
appointment.setGoodsTitle(goods.getTitle() + "-" + sku.getSkuName());
appointment.setGoodsId(goods.getId());
String phone = "";
//预约到店需要下发短信
try {
ShopMallPartners partners = partnerService.getById(goods.getPartnerId());
AdminUserDO sysUser = userService.getUser(partners.getUserId());
if (appointment.getIsPickCar().equals("0")){
if (StringUtils.isNotEmpty(appointment.getOtherPhone())){
if (appointment.getIsPickCar().equals("0")) {
if (StringUtils.isNotEmpty(appointment.getOtherPhone())) {
phone = appointment.getOtherPhone();
//给联系人发送
// new String[]{Optional.ofNullable(appointment.getCarNo()).orElse(""),
// appointment.getAppointmentDay(),partners.getPartnerName(),partners.getAddress(),sysUser.getNickname()+" "+sysUser.getMobile()
//// },appointment.getOtherPhone(),"1400852709","机动车管家小程序","2112754");
// }
SendSmsUtil.sendMsgCommon(null,appointment.getOtherPhone(),"1400852709","机动车管家小程序","2386324");
SendSmsUtil.sendMsgCommon(null, appointment.getOtherPhone(), "1400852709", "蓝安汽车销售有限公司", "2386324");
}else {
} else {
phone = ownUser.getMobile();
//给本人发送
//给联系人发送
//给联系人发送
// new String[]{Optional.ofNullable(appointment.getCarNo()).orElse(""),
// appointment.getAppointmentDay(),partners.getPartnerName(),partners.getAddress(),sysUser.getNickname()+" "+sysUser.getMobile()
//// },ownUser.getMobile(),"1400852709","机动车管家小程序","2112754");
// }
//// }
SendSmsUtil.sendMsgCommon(null
,ownUser.getMobile(),"1400852709","蓝安汽车销售有限公司","2386324");
}
}else {
if (StringUtils.isNotEmpty(appointment.getOtherPhone())){
} else {
if (StringUtils.isNotEmpty(appointment.getOtherPhone())) {
phone = appointment.getOtherPhone();
//给联系人发送
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
,partners.getPartnerName(),sysUser.getNickname(),sysUser.getMobile()
, partners.getPartnerName(), sysUser.getNickname(), sysUser.getMobile()
// },appointment.getOtherPhone(),"1400852709","机动车管家小程序","2112792");
},appointment.getOtherPhone(),"1400852709","机动车管家小程序","2386324");
}, appointment.getOtherPhone(), "1400852709", "机动车管家小程序", "2386324");
}else {
} else {
phone = ownUser.getMobile();
//给本人发送
//给联系人发送
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
,partners.getPartnerName(),sysUser.getNickname(),sysUser.getMobile()
, partners.getPartnerName(), sysUser.getNickname(), sysUser.getMobile()
// },ownUser.getMobile(),"1400852709","机动车管家小程序","2112792");
},ownUser.getMobile(),"1400852709","机动车管家小程序","2386324");
}, ownUser.getMobile(), "1400852709", "机动车管家小程序", "2386324");
}
}
//给检测站发送
//给联系人发送
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(appointment.getCarNo()).orElse("")
,appointment.getGoodsTitle()
, appointment.getGoodsTitle()
// },sysUser.getMobile(),"1400852709","机动车管家小程序","2112868");
},sysUser.getMobile(),"1400852709","机动车管家小程序","2386324");
}catch (Exception ignored){
}, sysUser.getMobile(), "1400852709", "机动车管家小程序", "2386324");
} catch (Exception ignored) {
log.error(ignored.getMessage());
}
baseMapper.insert(appointment);
// 发送提示音
//根据dictType查询角色
List<DictDataRespDTO> roleList = dictDataApi.getDictDataList("inspection_appointmentInspection_accept");
List<String> codes = roleList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList());
//根据角色查询用户
List<UserDTO> userListByCodes = roleService.getUserListByCodes(codes);
// 组装消息
String day = Objects.equals(appointment.getAppointmentPeriod(), "0") ? "上午" : "下午";
if (ObjectUtil.isNotEmpty(appointment.getTime())) {
day += " " + appointment.getTime();
}
String msg = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_CUSTOMER_APPOINTMENT, appointment.getOwner() == null ? phone : appointment.getOwner(), goods.getTitle(), sku.getSkuName(), appointment.getAppointmentDay(), day, phone);
for (UserDTO userListByCode : userListByCodes) {
// 添加消息队列
inspectionSocket.sendMessage("客户预约", userListByCode.getId().toString());
ReminderMessage message = new ReminderMessage(appointment.getId(), userListByCode.getId(), INSPECTION_WEBSOCKET_MESSAGE_CONTENT_CUSTOMER_ARRIVE);
long triggerTimeMillis = 0L;
if (ObjectUtil.isEmpty(appointment.getTime())) {
triggerTimeMillis = getArrivalTime(appointment.getAppointmentDay(), appointment.getAppointmentPeriod()).minusMinutes(10).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
} else {
// 日期拼接上时间
triggerTimeMillis = calculateTimestamp(appointment.getAppointmentDay(), appointment.getTime());
}
redisDelayedQueueService.addToQueue(message, triggerTimeMillis);
// 发送站内信
noticeService.sentMessage(userListByCode.getId(), msg);
}
return appointment.getId();
}
/**
* 计算给定日期和时间段的起始时间提前十分钟的时间戳
*
* @param date 日期字符串格式为"yyyy-MM-dd"
* @param timeRange 时间段字符串格式为"HH:mm-HH:mm"例如 "08:00-09:00"
* @return 返回起始时间提前十分钟的时间戳以毫秒为单位
* @throws ParseException 如果日期或时间格式不正确抛出此异常
*/
public static long calculateTimestamp(String date, String timeRange) throws ParseException {
// 提取时间段中的起始时间
String[] times = timeRange.split("-");
if (times.length != 2) {
throw new ParseException("时间格式不正确,应为 HH:mm-HH:mm", 0);
}
String startTime = times[0];
// 拼接日期和起始时间
String dateTime = date + " " + startTime;
// 解析时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date parsedDate = sdf.parse(dateTime);
// 返回提前十分钟的时间戳
return parsedDate.getTime() - (10 * 60 * 1000);
}
/**
* appointmentDay appointmentPeriod 转为 LocalDateTime
*
* @return LocalDateTime 类型的到店时间
*/
public static LocalDateTime getArrivalTime(String appointmentDay, String appointmentPeriod) {
LocalDate date = LocalDate.parse(appointmentDay); // 例如 2025-05-08
LocalTime time;
if ("0".equals(appointmentPeriod)) {
time = LocalTime.of(9, 0); // 上午 9:00
} else if ("1".equals(appointmentPeriod)) {
time = LocalTime.of(14, 0); // 下午 2:00
} else {
throw new IllegalArgumentException("appointmentPeriod 非法: " + appointmentPeriod);
}
return LocalDateTime.of(date, time);
}
@Override
public Long editAppointment(InspectionAppointment appointment) {
//判断是否需要删除上门取车
InspectionAppointment oldAppointment = baseMapper.selectById(appointment.getId());
if (oldAppointment.getIsPickCar().equals("1")&&appointment.getIsPickCar().equals("0")){
if (oldAppointment.getIsPickCar().equals("1") && appointment.getIsPickCar().equals("0")) {
pickCarService.removeById(oldAppointment.getPickCarId());
}
if (oldAppointment.getIsPickCar().equals("1")&&appointment.getIsPickCar().equals("1")){
if(!oldAppointment.getPickCarId().equals(appointment.getPickCarId())){
if (oldAppointment.getIsPickCar().equals("1") && appointment.getIsPickCar().equals("1")) {
if (!oldAppointment.getPickCarId().equals(appointment.getPickCarId())) {
pickCarService.removeById(oldAppointment.getPickCarId());
}
}
@ -214,9 +328,9 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
//给检测站发送
//给联系人发送
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(oldAppointment.getCarNo()).orElse("")},
sysUser.getMobile(),"1400852709","机动车管家小程序","2112863");
sysUser.getMobile(), "1400852709", "机动车管家小程序", "2112863");
}catch (Exception e){
} catch (Exception e) {
}
@ -227,12 +341,12 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
@Transactional(rollbackFor = Exception.class)
public void delAppointment(Long appointmentId) {
InspectionAppointment oldAppointment = baseMapper.selectById(appointmentId);
if (ObjectUtil.isNotEmpty(oldAppointment.getOrderId())){
if (ObjectUtil.isNotEmpty(oldAppointment.getOrderId())) {
baseMapper.deleteById(appointmentId);
}else {
} else {
baseMapper.deleteById(appointmentId);
if (ObjectUtil.isNotEmpty(oldAppointment.getPickCarId())){
if (ObjectUtil.isNotEmpty(oldAppointment.getPickCarId())) {
pickCarService.removeById(oldAppointment.getPickCarId());
}
@ -242,14 +356,14 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
AdminUserDO sysUser = userService.getUser(partners.getUserId());
//给检测站发送
//给联系人发送
SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(oldAppointment.getCarNo()).orElse("")},
sysUser.getMobile(),"1400852709","机动车管家小程序","2112869");
// SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(oldAppointment.getCarNo()).orElse("")},
// sysUser.getMobile(),"1400852709","机动车管家小程序","2112869");
}
@Override
public Long pickCarInspection(InspectionPickCar pickCar) throws Exception {
JSONObject jsonObject = this.computeDistanceAndPrice(pickCar.getGoodsId(), pickCar.getLongitude(), pickCar.getLatitude(),pickCar.getType());
if (pickCar.getType().equals("sku")){
JSONObject jsonObject = this.computeDistanceAndPrice(pickCar.getGoodsId(), pickCar.getLongitude(), pickCar.getLatitude(), pickCar.getType());
if (pickCar.getType().equals("sku")) {
InspectionGoodsSku goodsSku = skuService.getById(pickCar.getGoodsId());
pickCar.setGoodsId(Long.parseLong(goodsSku.getGoodsId().toString()));
}
@ -267,97 +381,97 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
}
@Override
public JSONObject appointmentDateList(Long goodsId,String type) {
if (type.equals("sku")){
public JSONObject appointmentDateList(Long goodsId, String type) {
if (type.equals("sku")) {
InspectionGoodsSku goodsSku = skuService.getById(goodsId);
goodsId = Long.parseLong(goodsSku.getGoodsId().toString());
}
JSONObject res =new JSONObject();
List<JSONObject> resList =new ArrayList<>();
JSONObject res = new JSONObject();
List<JSONObject> resList = new ArrayList<>();
List<Date> sevenDaysList = getSevenDaysList();
for (Date date : sevenDaysList) {
JSONObject item =new JSONObject();
String dateStr = DateUtil.format(date,"yyyy-MM-dd");
item.put("dateStr",dateStr);
JSONObject item = new JSONObject();
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
item.put("dateStr", dateStr);
item.put("weekStr", getDayOfWeek(date));
LambdaQueryWrapper<InspectionAppointment> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InspectionAppointment::getAppointmentDay, dateStr).eq(InspectionAppointment::getAppointmentPeriod,"0");
LambdaQueryWrapper<InspectionAppointment> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InspectionAppointment::getAppointmentDay, dateStr).eq(InspectionAppointment::getAppointmentPeriod, "0");
long morningCount = this.count(queryWrapper);
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InspectionAppointment::getAppointmentDay, dateStr).eq(InspectionAppointment::getAppointmentPeriod,"1");
queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InspectionAppointment::getAppointmentDay, dateStr).eq(InspectionAppointment::getAppointmentPeriod, "1");
long afterCount = this.count(queryWrapper);
item.put("morningCount", morningCount);
item.put("afterCount", afterCount);
resList.add(item);
}
res.put("dataList",resList);
res.put("dataList", resList);
ShopInspectionGoods goods = goodsService.getById(goodsId);
ShopMallPartners partner = partnerService.getById(goods.getPartnerId());
res.put("partnerName",partner.getPartnerName());
res.put("address",partner.getAddress());
res.put("partnerId",partner.getPartnerId());
res.put("partnerName", partner.getPartnerName());
res.put("address", partner.getAddress());
res.put("partnerId", partner.getPartnerId());
return res;
}
@Override
public JSONObject pickCarInfo( ) {
JSONObject res =new JSONObject();
List<JSONObject> resList =new ArrayList<>();
public JSONObject pickCarInfo() {
JSONObject res = new JSONObject();
List<JSONObject> resList = new ArrayList<>();
List<Date> sevenDaysList = getSevenDaysList();
for (Date date : sevenDaysList) {
JSONObject item =new JSONObject();
String dateStr = DateUtil.format(date,"yyyy-MM-dd");
item.put("dateStr",dateStr);
JSONObject item = new JSONObject();
String dateStr = DateUtil.format(date, "yyyy-MM-dd");
item.put("dateStr", dateStr);
item.put("weekStr", getDayOfWeek(date));
resList.add(item);
}
res.put("dataList",resList);
res.put("dataList", resList);
//当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
AdminUserDO user = userService.getUser(loginUser.getId());
res.put("userPhone",user.getMobile());
res.put("userPhone", user.getMobile());
return res;
}
@Override
public JSONObject computeDistanceAndPrice(Long goodsId,Double longitude,Double latitude,String type) throws Exception {
if (StringUtils.isNotEmpty(type)&&type.equals("sku")){
public JSONObject computeDistanceAndPrice(Long goodsId, Double longitude, Double latitude, String type) throws Exception {
if (StringUtils.isNotEmpty(type) && type.equals("sku")) {
InspectionGoodsSku sku = skuService.getById(goodsId);
goodsId = Long.parseLong(sku.getGoodsId().toString());
}
ShopInspectionGoods goods = goodsService.getById(goodsId);
ShopMallPartners partner = partnerService.getById(goods.getPartnerId());
JSONObject res =new JSONObject();
JSONObject res = new JSONObject();
String longitude1 = partner.getLongitude();
String latitude1 = partner.getLatitude();
if (StringUtils.isEmpty(longitude1)||StringUtils.isEmpty(latitude1)){
if (StringUtils.isEmpty(longitude1) || StringUtils.isEmpty(latitude1)) {
throw new Exception("超出距离无法上门");
}
Long distanceMeter = getDistanceMeter(Double.parseDouble(longitude1), Double.parseDouble(latitude1), longitude, latitude);
if (distanceMeter>20000){
if (distanceMeter > 20000) {
throw new Exception("超出距离无法上门");
}
res.put("distance",distanceMeter);
res.put("distance", distanceMeter);
ShopConfig shopConfig = configService.selectShopConfigById(1L);
//20公里价格
res.put("pickPrice",shopConfig.getPickCarTwenty());
res.put("pickPrice", shopConfig.getPickCarTwenty());
if (distanceMeter<10000){
if (distanceMeter < 10000) {
//10公里价格
res.put("pickPrice",shopConfig.getPickCarTen());
res.put("pickPrice", shopConfig.getPickCarTen());
}
if (distanceMeter<5000){
if (distanceMeter < 5000) {
//5公里价格
res.put("pickPrice",shopConfig.getPickCarFive());
res.put("pickPrice", shopConfig.getPickCarFive());
}
return res;
}
@Override
public IPage<InspectionAppointment> getAppointmentList(Page<InspectionAppointment> page, Long partnerId, String phoneNum, String carNo, String startTime, String endTime) {
return baseMapper.getAppointmentList(page,partnerId,phoneNum,carNo,startTime,endTime);
return baseMapper.getAppointmentList(page, partnerId, phoneNum, carNo, startTime, endTime);
}
@Override
@ -381,6 +495,7 @@ public class InspectionAppointmentServiceImpl extends ServiceImpl<InspectionAppo
return sevenDaysList;
}
public static String getDayOfWeek(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);

View File

@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.inspection.service.InspectionFileRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description: 检测文档记录表
* @Author: 86187
@ -16,4 +18,14 @@ import org.springframework.stereotype.Service;
*/
@Service
public class InspectionFileRecordServiceImpl extends ServiceImpl<InspectionFileRecordMapper, InspectionFileRecord> implements InspectionFileRecordService {
/**
* 获取检测文档记录列表
*
* @param id 文档id
* @return 检测文档记录列表
*/
@Override
public List<InspectionFileRecord> getRecordList(Long id) {
return baseMapper.getRecordList(id);
}
}

View File

@ -234,6 +234,7 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
} else {
queryWrapper.isNull(InspectionFile::getFatherId);
}
queryWrapper.eq(InspectionFile::getServicePackageId, inspectionFile.getServicePackageId());
queryWrapper.orderByAsc(InspectionFile::getType);
queryWrapper.orderByDesc(InspectionFile::getCreateTime);
if (ObjectUtil.isNotEmpty(inspectionFile.getFileName())) {
@ -339,6 +340,7 @@ public class InspectionFileServiceImpl extends ServiceImpl<InspectionFileMapper,
// 2. 获取所有文件及文件夹信息避免多次查询数据库
// 1. 查询所有文件信息确保只查询必要的字段并通过索引优化文件名的like查询
List<InspectionFile> fileList = this.list(Wrappers.lambdaQuery(InspectionFile.class)
.eq(InspectionFile::getServicePackageId, inspectionFile.getServicePackageId())
.select(InspectionFile::getId, InspectionFile::getFileName, InspectionFile::getFatherId, InspectionFile::getFilePath, InspectionFile::getType) // 仅查询必要字段
// .like(ObjectUtil.isNotEmpty(inspectionFile.getFileName()), InspectionFile::getFileName, inspectionFile.getFileName())
.orderBy(false, false, InspectionFile::getCreateTime));

View File

@ -21,6 +21,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.common.service.InspectionNoticeService;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
@ -111,6 +112,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
private IInspectionWorkNodeService workNodeService;
@Autowired
private InspectionStepInfoService inspectionStepInfoService;
@Autowired
private InspectionNoticeService noticeService;
@Resource
private CustomerMainService customerMainService;
@Autowired
@ -120,6 +123,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
@Resource
private RoleMapper roleMapper;
@Resource
private InspectionLeadRecordService inspectionLeadRecordService;
@Resource
@Lazy
private DlInspectionProjectService projectService;
@Autowired
@ -171,6 +176,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
String buyName = StringUtils.isNotEmpty(inspectionInfo.getBuyName()) ? inspectionInfo.getBuyName() : "未知客户";
String buyPhone = StringUtils.isNotEmpty(inspectionInfo.getBuyPhone()) ? inspectionInfo.getBuyPhone() : StringUtils.isNotEmpty(inspectionInfo.getBuyName()) ? inspectionInfo.getBuyName() : "";
AdminUserDO user = getAdminUserDO(buyPhone);
if (ObjectUtils.isEmpty(user)) {
//新增用户
UserSaveReqVO userSaveReqVO = new UserSaveReqVO();
@ -192,40 +198,79 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
InspectionGoodsSku sku = skuService.getById(inspectionInfo.getSkuId());
ShopInspectionGoods goods = goodsService.getById(sku.getGoodsId());
ShopMallPartners partner = appInspectionPartnerService.getById(goods.getPartnerId());
OrderInfo orderInfo = new OrderInfo();
orderInfo.setPartnerId(partners.getPartnerId());
orderInfo.setGoodsId(Long.parseLong(goods.getId().toString()));
orderInfo.setGoodsTitle(goods.getTitle());
orderInfo.setGoodsType("jc");
orderInfo.setGoodNum(1);
orderInfo.setSkuId(Long.parseLong(sku.getId().toString()));
orderInfo.setSkuName(sku.getSkuName());
orderInfo.setGoodsPrice(goods.getPrice());
orderInfo.setStartTime(new Date());
orderInfo.setOrderTime(new Date());
orderInfo.setOrderType("jc");
orderInfo.setUserId(user.getId());
orderInfo.setRealName(user.getNickname());
orderInfo.setIsOnline("0");
orderInfo.setPhonenumber(user.getMobile());
orderInfo.setPartnerName(partner.getPartnerName());
orderInfo.setOrderNo("线下订单-" + System.currentTimeMillis());
//赊账的情况
orderInfo.setOrderStatus("0");
orderInfoService.save(orderInfo);
//判断有没有传预约信息
if (ObjectUtil.isNotNull(inspectionInfo.getAppointmentId())) {
//根据预约id查询预约信息
InspectionAppointment appointment1 = inspectionAppointmentService.getById(inspectionInfo.getAppointmentId());
if (ObjectUtil.isNotEmpty(appointment1.getOrderId())) {
// 需要核销订单表
// 查询订单
orderInfo = orderInfoService.getById(appointment1.getOrderId());
} else {
orderInfo.setPartnerId(partners.getPartnerId());
orderInfo.setGoodsId(Long.parseLong(goods.getId().toString()));
orderInfo.setGoodsTitle(goods.getTitle());
orderInfo.setGoodsType("jc");
orderInfo.setGoodNum(1);
orderInfo.setSkuId(Long.parseLong(sku.getId().toString()));
orderInfo.setSkuName(sku.getSkuName());
orderInfo.setGoodsPrice(goods.getPrice());
orderInfo.setStartTime(new Date());
orderInfo.setOrderTime(new Date());
orderInfo.setOrderType("jc");
orderInfo.setUserId(user.getId());
orderInfo.setRealName(user.getNickname());
orderInfo.setIsOnline("0");
orderInfo.setPhonenumber(user.getMobile());
orderInfo.setPartnerName(partner.getPartnerName());
orderInfo.setOrderNo("线下订单-" + System.currentTimeMillis());
//赊账的情况
orderInfo.setOrderStatus("0");
orderInfoService.save(orderInfo);
//修改预约信息表的orderId
InspectionAppointment appointment = new InspectionAppointment();
appointment.setOrderId(orderInfo.getId());
inspectionAppointmentService.update(Wrappers.<InspectionAppointment>lambdaUpdate()
.eq(InspectionAppointment::getId, inspectionInfo.getAppointmentId())
.set(InspectionAppointment::getOrderId, orderInfo.getId()));
}
//修改订单的核销时间
orderInfoService.update(Wrappers.<OrderInfo>lambdaUpdate()
.eq(OrderInfo::getId, orderInfo.getId())
.set(OrderInfo::getValidationTime, new Date()));
} else {
orderInfo.setPartnerId(partners.getPartnerId());
orderInfo.setGoodsId(Long.parseLong(goods.getId().toString()));
orderInfo.setGoodsTitle(goods.getTitle());
orderInfo.setGoodsType("jc");
orderInfo.setGoodNum(1);
orderInfo.setSkuId(Long.parseLong(sku.getId().toString()));
orderInfo.setSkuName(sku.getSkuName());
orderInfo.setGoodsPrice(goods.getPrice());
orderInfo.setStartTime(new Date());
orderInfo.setOrderTime(new Date());
orderInfo.setOrderType("jc");
orderInfo.setUserId(user.getId());
orderInfo.setRealName(user.getNickname());
orderInfo.setIsOnline("0");
orderInfo.setPhonenumber(user.getMobile());
orderInfo.setPartnerName(partner.getPartnerName());
orderInfo.setOrderNo("线下订单-" + System.currentTimeMillis());
//赊账的情况
orderInfo.setOrderStatus("0");
orderInfoService.save(orderInfo);
//修改预约信息表的orderId
InspectionAppointment appointment = new InspectionAppointment();
appointment.setOrderId(orderInfo.getId());
inspectionAppointmentService.update(Wrappers.<InspectionAppointment>lambdaUpdate()
.eq(InspectionAppointment::getId, inspectionInfo.getAppointmentId())
.set(InspectionAppointment::getOrderId, orderInfo.getId()));
//修改订单的核销时间
orderInfoService.update(Wrappers.<OrderInfo>lambdaUpdate()
.eq(OrderInfo::getId, orderInfo.getId())
.set(OrderInfo::getValidationTime, new Date()));
}
inspectionInfo.setInspectionOrderId(orderInfo.getId());
inspectionInfo.setPartnerId(partners.getPartnerId());
@ -265,7 +310,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
}
//增加客户信息
LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PartnerCustomerInfo::getPartnerId, inspectionInfo.getPartnerId()).eq(PartnerCustomerInfo::getUserId, orderInfo.getUserId());
queryWrapper.eq(PartnerCustomerInfo::getPartnerId, inspectionInfo.getPartnerId()).eq(PartnerCustomerInfo::getUserId, orderInfo.getUserId()).last("limit 1");
PartnerCustomerInfo customerInfo = customerInfoService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(customerInfo)) {
customerInfo = new PartnerCustomerInfo();
@ -480,17 +525,38 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateLeadMan(InspectionInfo inspectionInfo) {
int i = baseMapper.updateById(inspectionInfo);
if (i > 0) {
if (ObjectUtil.isNotEmpty(inspectionInfo.getLeadManId())) {
inspectionSocket.sendMessage("接工单", inspectionInfo.getLeadManId().toString());
}
if (ObjectUtil.isNotEmpty(inspectionInfo.getMeetManId())) {
inspectionSocket.sendMessage("接工单", inspectionInfo.getMeetManId().toString());
}
Map<String, Object> info = new HashMap<>();
if (inspectionInfo.getSourceType() == 1) {
// 修改接车订单表
inspectionMeetCarOrderService.update(Wrappers.<InspectionMeetCarOrder>lambdaUpdate()
.eq(InspectionMeetCarOrder::getId, inspectionInfo.getId())
.set(InspectionMeetCarOrder::getMeetManId, inspectionInfo.getMeetManId()));
// 查询接车订单信息
InspectionMeetCarOrder order = inspectionMeetCarOrderService.getById(inspectionInfo.getId());
info.put("meetManId", order.getMeetManId());
info.put("day",order.getAppointmentDay());
info.put("carNo", order.getCarNum());
} else {
int i = baseMapper.updateById(inspectionInfo);
}
return i;
if (ObjectUtil.isNotEmpty(inspectionInfo.getLeadManId())) {
inspectionSocket.sendMessage("接工单", inspectionInfo.getLeadManId().toString());
}
if (ObjectUtil.isNotEmpty(inspectionInfo.getMeetManId())) {
inspectionSocket.sendMessage("接工单", inspectionInfo.getMeetManId().toString());
}
saveLeadRecord(inspectionInfo.getId(), inspectionInfo.getMeetManId());
// // 发送站内信
// String msg = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_ASSIGN_STAFF_MEET_CAR, info.get("day"), inspectionInfo.getCarNum());
// noticeService.sentMessage(inspectionInfo.getLeadManId(), msg);
return 1;
}
/**
@ -611,7 +677,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
* @return
*/
@Override
public Boolean isExamine() {
public Boolean isExamine(String code) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//获取当前登陆人的所有角色
List<UserRoleDO> userRoles = roleService.getByUserId(loginUser.getId());
@ -621,7 +687,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
//判断当前角色集合中的code是否包含jcyszz
if (CollectionUtil.isNotEmpty(roleList)) {
List<RoleDO> filteredRoleList = roleList.stream()
.filter(role -> role.getCode().contains("jcsfdl"))
.filter(role -> role.getCode().contains(code))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(filteredRoleList)) {
return true;
@ -784,9 +850,9 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
Map<String, Long> result = new ConcurrentHashMap<>(); // 线程安全
// 这里 `5` 而不是 `6`因为 i `0` 开始
CompletableFuture<Void>[] futures = new CompletableFuture[8];
CompletableFuture<Void>[] futures = new CompletableFuture[9];
for (int i = 0; i < 8; i++) { // 改为 `0~4`
for (int i = 0; i < 9; i++) { // 改为 `0~4`
final String status = String.valueOf(i + 1);
// 深拷贝对象防止多线程修改冲突
@ -851,7 +917,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
int update = baseMapper.update(Wrappers.<InspectionInfo>lambdaUpdate()
.eq(InspectionInfo::getId, inspectionWorkNode.getMeetCarId())
.set(InspectionInfo::getIsMeetCar, InspectionConstants.INSPECTION_MEET_CAR_ORDER_IS_MEET_CAR_YES));
}else if (Objects.equals(inspectionWorkNode.getSourceType(), InspectionConstants.INSPECTION_MEET_CAR_ORDER_IS_MEET_CAR_COMPLETE_TYPE_MEET_CAR_ORDER)) {
} else if (Objects.equals(inspectionWorkNode.getSourceType(), InspectionConstants.INSPECTION_MEET_CAR_ORDER_IS_MEET_CAR_COMPLETE_TYPE_MEET_CAR_ORDER)) {
// 修改接车订单表为已接车
inspectionMeetCarOrderService.update(Wrappers.<InspectionMeetCarOrder>lambdaUpdate()
.eq(InspectionMeetCarOrder::getId, inspectionWorkNode.getMeetCarId())
@ -861,4 +927,35 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
return true;
}
/**
* 引车
*
* @param inspectionInfo
*/
@Override
public void leadCar(InspectionInfo inspectionInfo) {
// 获取当前登陆人
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
inspectionInfo.setLeadManId(loginUser.getId());
baseMapper.updateById(inspectionInfo);
saveLeadRecord(inspectionInfo.getId(), loginUser.getId());
}
/**
* 保存引车员记录
*
* @param inspectionInfoId 检测单ID
* @param userId 引车员ID
*/
private void saveLeadRecord(Long inspectionInfoId, Long userId) {
InspectionLeadRecord inspectionLeadRecord = InspectionLeadRecord.builder()
.inspectionId(String.valueOf(inspectionInfoId))
.userId(userId)
.build();
// 添加引车记录
inspectionLeadRecordService.save(inspectionLeadRecord);
}
}

View File

@ -0,0 +1,54 @@
package cn.iocoder.yudao.module.inspection.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionGoodsSku;
import cn.iocoder.yudao.module.inspection.entity.InspectionLeadRecord;
import cn.iocoder.yudao.module.inspection.entity.ShopInspectionCategory;
import cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods;
import cn.iocoder.yudao.module.inspection.mapper.AppInspectionGoodsMapper;
import cn.iocoder.yudao.module.inspection.mapper.InspectionLeadRecordMapper;
import cn.iocoder.yudao.module.inspection.query.GoodsQuery;
import cn.iocoder.yudao.module.inspection.service.AppInspectionGoodsService;
import cn.iocoder.yudao.module.inspection.service.InspectionGoodsSkuService;
import cn.iocoder.yudao.module.inspection.service.InspectionLeadRecordService;
import cn.iocoder.yudao.module.inspection.service.ShopInspectionCategoryService;
import cn.iocoder.yudao.module.inspection.vo.GoodsDetail;
import cn.iocoder.yudao.module.inspection.vo.GoodsVo;
import cn.iocoder.yudao.module.inspection.vo.OrderGoodsInfo;
import cn.iocoder.yudao.module.inspection.vo.PartnerListVo;
import cn.iocoder.yudao.module.partner.entity.PartnerWorker;
import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService;
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
import cn.iocoder.yudao.module.shop.entity.ShopCoupon;
import cn.iocoder.yudao.module.shop.entity.UserBalance;
import cn.iocoder.yudao.module.shop.service.IShopConfigService;
import cn.iocoder.yudao.module.shop.service.IShopCouponService;
import cn.iocoder.yudao.module.shop.service.IUserBalanceService;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class InspectionLeadRecordServiceImpl extends ServiceImpl<InspectionLeadRecordMapper, InspectionLeadRecord> implements InspectionLeadRecordService {
}

View File

@ -1,13 +1,27 @@
package cn.iocoder.yudao.module.inspection.service.impl;
import cn.iocoder.yudao.module.inspection.entity.InspectionMeetCarOrder;
import cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods;
import cn.iocoder.yudao.module.inspection.mapper.AppInspectionGoodsMapper;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.common.service.InspectionNoticeService;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.appBase.controller.admin.InspectionSocket;
import cn.iocoder.yudao.module.config.entity.ReminderMessage;
import cn.iocoder.yudao.module.config.service.RedisDelayedQueueService;
import cn.iocoder.yudao.module.constant.InspectionConstants;
import cn.iocoder.yudao.module.inspection.entity.*;
import cn.iocoder.yudao.module.inspection.mapper.InspectionMeetCarOrderMapper;
import cn.iocoder.yudao.module.inspection.service.AppInspectionGoodsService;
import cn.iocoder.yudao.module.inspection.service.InspectionMeetCarOrderService;
import cn.iocoder.yudao.module.inspection.service.*;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.ZoneId;
import static cn.iocoder.yudao.module.constant.InspectionConstants.INSPECTION_WEBSOCKET_MESSAGE_CONTENT_CUSTOMER_ARRIVE;
import static cn.iocoder.yudao.module.inspection.service.impl.InspectionAppointmentServiceImpl.getArrivalTime;
/**
* @Description: 接车订单
@ -16,14 +30,115 @@ import org.springframework.stereotype.Service;
* @Version: 1.0
*/
@Service
@RequiredArgsConstructor
public class InspectionMeetCarOrderServiceImpl extends ServiceImpl<InspectionMeetCarOrderMapper, InspectionMeetCarOrder> implements InspectionMeetCarOrderService {
private final InspectionSocket inspectionSocket;
private final IInspectionAppointmentService inspectionAppointmentService;
private final IInspectionPickCarService inspectionPickCarService;
private final InspectionStepInfoService inspectionStepInfoService;
private final InspectionGoodsSkuService skuService;
private final IShopInspectionGoodsService goodsService;
private final RedisDelayedQueueService redisDelayedQueueService;
private final InspectionNoticeService noticeService;
/**
* 添加接车订单
*
* @param order 接车订单
*/
@Override
@Transactional
public void add(InspectionMeetCarOrder order) {
boolean ifSendMessage = true;
// 设置接车员id
if (order.getMeetManId() == null) {
order.setMeetManId(SecurityFrameworkUtils.getLoginUserId());
ifSendMessage = false;
}
if (ObjectUtil.isNotEmpty(order.getSkuId())) {
InspectionGoodsSku sku = skuService.getById(order.getSkuId());
ShopInspectionGoods goods = goodsService.getById(sku.getGoodsId());
order.setGoodsId(Long.parseLong(goods.getId().toString()));
order.setGoodsTitle(goods.getTitle());
order.setSkuName(sku.getSkuName());
}
save(order);
//指派的接车人
if (ifSendMessage) {
// 修改预约表的接车订单id字段
inspectionAppointmentService.update(Wrappers.<InspectionAppointment>lambdaUpdate()
.eq(InspectionAppointment::getId, order.getAppointmentId())
.set(InspectionAppointment::getMeetOrderId, order.getId()));
// 获取预约表的信息
InspectionAppointment appointment = inspectionAppointmentService.getById(order.getAppointmentId());
if (ObjectUtil.isNotEmpty(appointment)) {
// 判断是否有上门取车
if (appointment.getIsPickCar().equals("1")) {
InspectionPickCar pickCar = inspectionPickCarService.getById(appointment.getPickCarId());
//获取详细地址和经纬度修改接车订单表
update(Wrappers.<InspectionMeetCarOrder>lambdaUpdate()
.eq(InspectionMeetCarOrder::getId, order.getId())
.set(InspectionMeetCarOrder::getMeetAddress, pickCar.getAdressDetail())
.set(InspectionMeetCarOrder::getLatitude, pickCar.getLatitude())
.set(InspectionMeetCarOrder::getLongitude, pickCar.getLongitude())
.set(InspectionMeetCarOrder::getAppointmentDay, pickCar.getAppointmentDay())
.set(InspectionMeetCarOrder::getAppointmentTime, pickCar.getAppointmentTime()));
inspectionSocket.sendMessage("接工单", order.getMeetManId().toString());
} else {
update(Wrappers.<InspectionMeetCarOrder>lambdaUpdate()
.eq(InspectionMeetCarOrder::getId, order.getId())
.set(InspectionMeetCarOrder::getAppointmentDay, appointment.getAppointmentDay()));
// 设置消息提醒
ReminderMessage message = new ReminderMessage(appointment.getId(), order.getMeetManId(), INSPECTION_WEBSOCKET_MESSAGE_CONTENT_CUSTOMER_ARRIVE);
long triggerTimeMillis = getArrivalTime(appointment.getAppointmentDay(), appointment.getAppointmentPeriod()).minusMinutes(10).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
redisDelayedQueueService.addToQueue(message, triggerTimeMillis);
}
// 发送站内信
String msg = "";
if (ObjectUtil.isNotEmpty(appointment.getCarNo())) {
msg = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_ASSIGN_STAFF_MEET_CAR, appointment.getAppointmentDay(), appointment.getCarNo() == null ? "" : appointment.getCarNo(), appointment.getAppointmentPeriod());
} else {
msg = String.format(InspectionConstants.INSPECTION_NOTICE_TEMPLATE_ASSIGN_STAFF_MEET_CAR_NO_CAR_NO, appointment.getAppointmentDay(), appointment.getAppointmentPeriod());
}
noticeService.sentMessage(order.getMeetManId(), msg);
}
}
if (StrUtil.isNotEmpty(order.getContent()) || StrUtil.isNotEmpty(order.getImages())) {
// 在步骤表里添加一条记录
InspectionStepInfo inspectionStepInfo = new InspectionStepInfo();
inspectionStepInfo.setInspectionInfoId(order.getId());
//设置开始时间
inspectionStepInfo.setCreateTime(DateUtil.date());
inspectionStepInfo.setCreator(Integer.parseInt(SecurityFrameworkUtils.getLoginUserId() + ""));
inspectionStepInfo.setTitle("接车拍照");
inspectionStepInfo.setContent(order.getContent());
inspectionStepInfo.setImages(order.getImages());
inspectionStepInfo.setStepNum(1);
inspectionStepInfo.setUpdater(Integer.parseInt(SecurityFrameworkUtils.getLoginUserId() + ""));
inspectionStepInfo.setUpdateTime(DateUtil.date());
inspectionStepInfoService.save(inspectionStepInfo);
//修改订单表为已接车
update(Wrappers.<InspectionMeetCarOrder>lambdaUpdate()
.eq(InspectionMeetCarOrder::getId, order.getId())
.set(InspectionMeetCarOrder::getIsMeet, 1));
}
}
}

View File

@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
import cn.iocoder.yudao.module.inspection.entity.InspectionPickCar;
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
import cn.iocoder.yudao.module.inspection.mapper.InspectionStaffMapper;
import cn.iocoder.yudao.module.inspection.mapper.InspectionWorkNodeMapper;
import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
@ -64,6 +65,9 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
@Autowired
private IInspectionFileService inspectionFileService;
@Autowired
private InspectionWorkNodeMapper inspectionWorkNodeMapper;
/**
* 获取检测员工分页
*
@ -242,12 +246,23 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
this.update(Wrappers.<InspectionStaff>lambdaUpdate().eq(InspectionStaff::getUserId, userId).set(InspectionStaff::getFolderId, folderId));
}
return folderId;
}else {
} else {
log.error("用户不存在");
return null;
}
}
/**
* 获取已完成项目
*
* @param userId
* @return
*/
@Override
public IPage<Map<String, Object>> getFinishProjectByUserId(Page<Map<String, Object>> page, Long userId) {
return inspectionWorkNodeMapper.selectStaffProjectByUserId(page,userId);
}
/**
* 保存检测员工
*

View File

@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.inspection.service.DlInspectionProjectService;
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService;
import cn.iocoder.yudao.module.inspection.service.InspectionStepInfoService;
import cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
@ -195,6 +196,11 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
}
//根据流程id获取流程
InspectionWorkNode workNode = this.getById(inspectionWorkNode.getId());
if (ObjectUtil.isNotEmpty(workNode.getNodeCount())) {
inspectionWorkNode.setNodeCount(workNode.getNodeCount() + 1);
} else {
inspectionWorkNode.setNodeCount(1);
}
//根据工单id查询工单
InspectionInfo inspectionInfo = inspectionInfoService.selectInspectionInfoById(workNode.getInspectionInfoId());
@ -215,6 +221,12 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
// 更新或插入步骤信息
DlInspectionProject project = inspectionProjectService.getOne(new LambdaQueryWrapper<DlInspectionProject>()
.eq(DlInspectionProject::getId, workNode.getProjectId()));
// 判断检测项目是否包含制证
if (ObjectUtil.isNotEmpty(project)) {
if (project.getProjectName().contains("制证")) {
flag = false;
}
}
List<InspectionStepInfo> stepInfos = inspectionStepService.list(new LambdaQueryWrapper<InspectionStepInfo>()
.and(i -> i.eq(InspectionStepInfo::getInspectionInfoId, workNode.getInspectionInfoId())
.eq(InspectionStepInfo::getWorkNodeId, workNode.getId())
@ -360,6 +372,12 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
InspectionInfo info = inspectionInfoService.getById(workNodes.getInspectionInfoId());
info.setIsRetrial("1");
info.setIsPass("0");
// 设置检测次数加一
if (ObjectUtil.isNotEmpty(info.getReinspectCount())) {
info.setReinspectCount(info.getReinspectCount() + 1);
} else {
info.setReinspectCount(1);
}
//更新工单表
inspectionInfoService.updateById(info);
@ -383,13 +401,13 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
// 添加步骤信息表
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(Integer.parseInt(workNodes.getInspectionInfoId().toString()));
stepInfo.setTitle("");
stepInfo.setTitle("");
stepInfo.setCreateTime(DateUtil.date());
stepInfo.setCreator(Integer.parseInt(loginUser.getId().toString()));
if (ObjectUtil.isNotEmpty(workNodes.getRemark())) {
stepInfo.setContent(workNodes.getRemark());
}else {
stepInfo.setContent("审了" + projectNames + "项目");
} else {
stepInfo.setContent("");
}
if (ObjectUtil.isNotEmpty(workNodes.getDealImages())) {
stepInfo.setImages(workNodes.getDealImages());
@ -414,7 +432,6 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
for (Long id : ids) {
inspectionSocket.sendMessage("接工单", id.toString());
}
}
}
@ -426,7 +443,81 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
*/
@Override
public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) {
return baseMapper.getStaffCount(dlInspectionProject);
Map<Long, Map<String, Object>> tempMap = new LinkedHashMap<>();
List<StaffProjectCountVO> staffCount = baseMapper.getStaffCount(dlInspectionProject);
for (StaffProjectCountVO vo : staffCount) {
Map<String, Object> userEntry = tempMap.computeIfAbsent(vo.getUserId(), k -> {
Map<String, Object> m = new HashMap<>();
m.put("userId", vo.getUserId());
m.put("nickname", vo.getNickname());
m.put("totalCount", 0L); // 初始总数
m.put("children", new ArrayList<Map<String, Object>>());
return m;
});
// 添加项目
List<Map<String, Object>> children = (List<Map<String, Object>>) userEntry.get("children");
Map<String, Object> project = new HashMap<>();
project.put("projectName", vo.getProjectName());
project.put("count", vo.getCount());
project.put("id", vo.getId());
children.add(project);
// 累加总数
Long currentTotal = (Long) userEntry.get("totalCount");
userEntry.put("totalCount", currentTotal + vo.getCount());
}
// 转成 List 并按 totalCount 降序排序
return tempMap.values().stream()
.peek(userEntry -> {
// 排序每个用户下的项目 children
List<Map<String, Object>> children = (List<Map<String, Object>>) userEntry.get("children");
children.sort((a, b) -> Long.compare((Long) b.get("count"), (Long) a.get("count")));
})
.sorted((a, b) -> Long.compare((Long) b.get("totalCount"), (Long) a.get("totalCount")))
.collect(Collectors.toList());
}
/**
* 根据检测id获取异常节点
*
* @param idList
* @return
*/
@Override
public List<Map<String, Object>> selectExceptionNodesByInspectionIds(List<Long> idList) {
return baseMapper.selectExceptionNodesByInspectionIds(idList);
}
/**
* 完成异常节点
*
* @param idList
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateException(Long inspectionInfoId, List<String> idList) {
// 1. 修改工单表为已完成
inspectionInfoService.update(Wrappers.lambdaUpdate(InspectionInfo.class)
.eq(InspectionInfo::getId, inspectionInfoId)
.set(InspectionInfo::getIsPass, "1")
.set(InspectionInfo::getStatus, "1"));
// 2.修改工单节点表为已完成
update(Wrappers.lambdaUpdate(InspectionWorkNode.class)
.in(InspectionWorkNode::getId, idList)
.set(InspectionWorkNode::getStatus, "2")
.set(InspectionWorkNode::getType, "1"));
// 3.新增工单步骤表为消除异常项目
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(Integer.parseInt(String.valueOf(inspectionInfoId)));
stepInfo.setTitle("消除异常项目");
stepInfo.setCreateTime(new Date());
stepInfo.setCreator(Integer.parseInt(String.valueOf(SecurityFrameworkUtils.getLoginUserId())));
inspectionStepService.save(stepInfo);
}
/**
@ -491,28 +582,35 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
}
/**
*
*
*
* @param inspectionWorkNode
*/
public void retrial(InspectionWorkNode inspectionWorkNode) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//通过流程节点id查询流程
InspectionWorkNode workNode = this.getById(inspectionWorkNode.getId());
//通过工单id获取工单
InspectionInfo info = inspectionInfoService.getById(inspectionWorkNode.getInspectionInfoId());
info.setIsRetrial("1");
info.setIsPass("0");
info.setStatus("2");
// info.setStatus("2");
// info.setNowOrderNum(workNode.getOrderNum());
// 通过流程id获取项目
List<String> workNodeIds = inspectionWorkNode.getWorkNodes().stream().map(InspectionWorkNode::getId).collect(Collectors.toList());
// 将所有项目重新走一遍
// 复检的项目重走一遍
this.update(new UpdateWrapper<InspectionWorkNode>()
.set("status", "0")
.set("status", "3")
.set("type", null)
.eq("inspection_info_id", inspectionWorkNode.getInspectionInfoId()));
.in("id", workNodeIds));
//跟新工单表
// 复检次数加一
if (ObjectUtil.isNotNull(info.getRecheckCount())) {
info.setRecheckCount(info.getRecheckCount() + 1);
} else {
info.setRecheckCount(1);
}
//更新工单表
inspectionInfoService.updateById(info);
//获取重审的节点的roleID
@ -524,20 +622,52 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
// }
// sendSocketMessage(ids);
// 查询项目id
List<InspectionWorkNode> inspectionWorkNodes = baseMapper.selectBatchIds(workNodeIds);
List<String> projectIds = inspectionWorkNodes.stream().map(InspectionWorkNode::getProjectId).collect(Collectors.toList());
List<DlInspectionProject> projectList = inspectionProjectService.list(Wrappers.<DlInspectionProject>lambdaQuery()
.in(DlInspectionProject::getId, projectIds));
// 将项目名称以逗号隔开
String projectNames = projectList.stream().map(DlInspectionProject::getProjectName).collect(Collectors.joining(""));
// /*将当前步骤修改完已完成*/
// if (ObjectUtil.isNotNull(workNodes.getId())) {
// workNodes.setStatus("2");
// baseMapper.updateById(workNodes);
// }
// 添加步骤信息表
InspectionStepInfo stepInfo = new InspectionStepInfo();
stepInfo.setInspectionInfoId(Integer.parseInt(inspectionWorkNode.getInspectionInfoId().toString()));
stepInfo.setWorkNodeId(inspectionWorkNode.getId());
stepInfo.setTitle("重检");
stepInfo.setTitle("复检");
stepInfo.setCreateTime(DateUtil.date());
stepInfo.setCreator(Integer.parseInt(loginUser.getId().toString()));
if (ObjectUtil.isNotEmpty(inspectionWorkNode.getRemark())) {
stepInfo.setContent(inspectionWorkNode.getRemark());
} else {
stepInfo.setContent("复检了" + projectNames + "项目");
}
if (ObjectUtil.isNotEmpty(inspectionWorkNode.getDealImages())) {
stepInfo.setImages(inspectionWorkNode.getDealImages());
}
stepInfo.setCreateTime(DateUtil.date());
stepInfo.setCreator(Integer.parseInt(loginUser.getId().toString()));
inspectionStepService.save(stepInfo);
// 添加步骤信息表
// InspectionStepInfo stepInfo = new InspectionStepInfo();
// stepInfo.setInspectionInfoId(Integer.parseInt(inspectionWorkNode.getInspectionInfoId().toString()));
// stepInfo.setWorkNodeId(inspectionWorkNode.getId());
// stepInfo.setTitle("复检");
// if (ObjectUtil.isNotEmpty(inspectionWorkNode.getRemark())) {
// stepInfo.setContent(inspectionWorkNode.getRemark());
// }
// if (ObjectUtil.isNotEmpty(inspectionWorkNode.getDealImages())) {
// stepInfo.setImages(inspectionWorkNode.getDealImages());
// }
// stepInfo.setCreateTime(DateUtil.date());
// stepInfo.setCreator(Integer.parseInt(loginUser.getId().toString()));
// inspectionStepService.save(stepInfo);
}
public void sendSocketMessage(List<Long> userIds) {
@ -551,4 +681,4 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
}
}
}
}
}

View File

@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.inspection.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.inspection.entity.InspectionGoodsSku;
import cn.iocoder.yudao.module.inspection.service.InspectionGoodsSkuService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.iocoder.yudao.util.StringUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionCategoryTemplate;
@ -18,7 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* (ShopInspectionCategory)表服务实现类
@ -33,6 +39,8 @@ public class ShopInspectionCategoryServiceImpl extends ServiceImpl<ShopInspectio
private IInspectionCategoryTemplateService templateService;
@Autowired
private IShopInspectionGoodsService goodsService;
@Autowired
private InspectionGoodsSkuService skuService;
@Override
@Transactional(rollbackFor = Exception.class)
@ -49,15 +57,92 @@ public class ShopInspectionCategoryServiceImpl extends ServiceImpl<ShopInspectio
@Override
@Transactional(rollbackFor = Exception.class)
public void updateByIdVo(ShopInspectionCategory category) {
// 1. 更新分类信息
this.updateById(category);
// 2. 删除原有模板 SKU
templateService.deleteByCategoryId(category.getId());
// 3. 设置模板的 categoryId
List<InspectionCategoryTemplate> templates = category.getTemplates();
LocalDateTime now = LocalDateTime.now();
for (InspectionCategoryTemplate template : templates) {
template.setCategoryId(category.getId());
template.setCreateTime(now);
}
// 4. 批量保存模板
templateService.saveBatch(templates);
// 5. 查询该分类下所有商品
List<ShopInspectionGoods> goodsList = goodsService.list(Wrappers.<ShopInspectionGoods>lambdaQuery()
.eq(ShopInspectionGoods::getGoodsCategoryId, category.getId()));
if (goodsList.isEmpty()) return;
// 6. 查询所有商品的现有 SKU
List<Integer> goodsIds = goodsList.stream().map(ShopInspectionGoods::getId).collect(Collectors.toList());
List<InspectionGoodsSku> existingSkuList = skuService.list(Wrappers.<InspectionGoodsSku>lambdaQuery()
.in(InspectionGoodsSku::getGoodsId, goodsIds));
// 7. 构建当前应存在 SKU key: goodsId + "_" + skuName
Set<String> currentTemplateKeys = new HashSet<>();
for (ShopInspectionGoods goods : goodsList) {
for (InspectionCategoryTemplate template : templates) {
currentTemplateKeys.add(goods.getId() + "_" + template.getSkuName());
}
}
// 8. 删除多余的 SKU逻辑删除
List<Integer> toDeleteIds = existingSkuList.stream()
.filter(sku -> !currentTemplateKeys.contains(sku.getGoodsId() + "_" + sku.getSkuName()))
.map(InspectionGoodsSku::getId)
.collect(Collectors.toList());
if (!toDeleteIds.isEmpty()) {
skuService.update(Wrappers.<InspectionGoodsSku>lambdaUpdate()
.in(InspectionGoodsSku::getId, toDeleteIds)
.set(InspectionGoodsSku::getDeleted, 1)
.set(InspectionGoodsSku::getUpdateTime, now));
}
// 9. 分别处理新增和更新
Map<String, InspectionGoodsSku> existingSkuMap = existingSkuList.stream()
.collect(Collectors.toMap(sku -> sku.getGoodsId() + "_" + sku.getSkuName(), Function.identity(), (a, b) -> a));
List<InspectionGoodsSku> toInsert = new ArrayList<>();
List<InspectionGoodsSku> toUpdate = new ArrayList<>();
for (ShopInspectionGoods goods : goodsList) {
for (InspectionCategoryTemplate template : templates) {
String key = goods.getId() + "_" + template.getSkuName();
InspectionGoodsSku exist = existingSkuMap.get(key);
if (exist == null) {
// 新增
InspectionGoodsSku newSku = new InspectionGoodsSku();
newSku.setGoodsId(goods.getId().intValue());
newSku.setSkuName(template.getSkuName());
newSku.setPrice(template.getSkuPrice());
newSku.setCreateTime(now);
toInsert.add(newSku);
} else {
// 更新
exist.setPrice(template.getSkuPrice());
exist.setUpdateTime(now);
toUpdate.add(exist);
}
}
}
if (!toInsert.isEmpty()) {
skuService.saveBatch(toInsert);
}
if (!toUpdate.isEmpty()) {
skuService.updateBatchById(toUpdate);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void removeByIdsVo(List<Long> idList) throws Exception {

View File

@ -6,6 +6,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.shop.entity.ShopConfig;
@ -15,6 +16,7 @@ import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.iocoder.yudao.util.StringUtils;
@ -52,6 +54,8 @@ public class ShopInspectionGoodsServiceImpl extends ServiceImpl<ShopInspectionGo
private AppInspectionPartnerService appInspectionPartnerService;
@Autowired
private InspectionGoodsSkuService skuService;
@Autowired
private ShopInspectionCategoryService shopInspectionCategoryService;
@ -161,7 +165,27 @@ public class ShopInspectionGoodsServiceImpl extends ServiceImpl<ShopInspectionGo
public int insertShopInspectionGoods(ShopInspectionGoods shopInspectionGoods)
{
shopInspectionGoods.setListingStatus("0");
return baseMapper.insert(shopInspectionGoods);
baseMapper.insert(shopInspectionGoods);
// 根据商品分类id查询商品分类
ShopInspectionCategory category = shopInspectionCategoryService.getById(shopInspectionGoods.getGoodsCategoryId());
if (ObjectUtil.isNotEmpty(category)) {
// 获取模板列表
List<InspectionCategoryTemplate> templates = categoryTemplateService.list(Wrappers.<InspectionCategoryTemplate>lambdaQuery()
.eq(InspectionCategoryTemplate::getCategoryId, category.getId()));
List<InspectionGoodsSku> skuList = new ArrayList<>();
for (InspectionCategoryTemplate template : templates) {
InspectionGoodsSku sku = new InspectionGoodsSku();
sku.setGoodsId(shopInspectionGoods.getId());
sku.setSkuName(template.getSkuName());
sku.setPrice(template.getSkuPrice());
sku.setDbPrice(template.getSkuPrice());
sku.setDwPrice(template.getSkuPrice());
sku.setYgPrice(template.getSkuPrice());
skuList.add(sku);
}
skuService.saveBatch(skuList);
}
return 1;
}
/**

View File

@ -34,6 +34,10 @@ public class InspectionInfoVo {
private String remark;
private String buyUserName;
private String buyUserPhone;
/** 复检次数 */
private Integer recheckCount;
/** 重检次数 */
private Integer reinspectCount;
@TableField(exist = false)
private String buyName;

View File

@ -0,0 +1,12 @@
package cn.iocoder.yudao.module.inspection.vo;
import lombok.Data;
@Data
public class StaffProjectCountVO {
private String id;
private Long userId;
private Long count;
private String nickname;
private String projectName;
}

View File

@ -182,61 +182,140 @@
<!-- ORDER BY orderCount DESC; &#45;&#45; 根据接单数量进行降序排序-->
<!-- </select>-->
<select id="getStaffCount" resultType="java.util.Map"
<!-- <select id="getStaffCount" resultType="java.util.Map"-->
<!-- parameterType="cn.iocoder.yudao.module.inspection.entity.DlInspectionProject">-->
<!-- SELECT-->
<!-- iwn.deal_user_id, &#45;&#45; 处理人员ID-->
<!-- su.nickname, &#45;&#45; 处理人员名称-->
<!-- su.avatar, &#45;&#45; 处理人员头像-->
<!-- COUNT(DISTINCT iwn.id) AS orderCount, &#45;&#45; 统计每个员工的唯一订单数量-->
<!-- SUM(IFNULL(royalty.royalty_amount, 0) / 100) AS royaltyAmount, &#45;&#45; 计算每个员工的总佣金-->
<!-- su.mobile, &#45;&#45; 处理人员手机号-->
<!-- COALESCE(waijianCount, 0) AS waijianCount, &#45;&#45; 包含“外检”的订单数量-->
<!-- COALESCE(anjianCount, 0) AS anjianCount, &#45;&#45; 包含“安检”的订单数量-->
<!-- COALESCE(proj_stats.otherCount, 0) AS otherCount &#45;&#45; 其他订单数量(排除“外检”和“安检”)-->
<!-- FROM-->
<!-- inspection_work_node iwn-->
<!-- LEFT JOIN system_users su ON su.id = iwn.deal_user_id &#45;&#45; 处理人员信息-->
<!-- LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id-->
<!-- LEFT JOIN order_info orders ON info.inspection_order_id = orders.id-->
<!-- LEFT JOIN inspection_project_royalty AS royalty-->
<!-- ON iwn.project_id = royalty.project_id-->
<!-- AND orders.goods_id = royalty.goods_id-->
<!-- LEFT JOIN (-->
<!-- SELECT-->
<!-- iwn.deal_user_id,-->
<!-- SUM(CASE WHEN proj.project_name LIKE '环检外检%' THEN 1 ELSE 0 END) AS waijianCount,-->
<!-- SUM(CASE WHEN proj.project_name LIKE '安检%' THEN 1 ELSE 0 END) AS anjianCount,-->
<!-- SUM(-->
<!-- CASE-->
<!-- WHEN proj.project_name NOT LIKE '环检外检%'-->
<!-- AND proj.project_name NOT LIKE '安检%'-->
<!-- THEN 1 ELSE 0-->
<!-- END-->
<!-- ) AS otherCount &#45;&#45; 统计不包含“外检”和“安检”的订单-->
<!-- FROM-->
<!-- inspection_work_node iwn-->
<!-- LEFT JOIN inspection_project AS proj ON iwn.project_id = proj.id-->
<!-- LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id-->
<!-- WHERE iwn.deleted = 0 &#45;&#45; 排除已删除的数据-->
<!-- AND iwn.deal_user_id IS NOT NULL &#45;&#45; 排除 deal_user_id 为 NULL 的记录-->
<!-- AND iwn.status = 2-->
<!-- AND info.status = 1-->
<!-- GROUP BY-->
<!-- iwn.deal_user_id-->
<!-- ) proj_stats ON iwn.deal_user_id = proj_stats.deal_user_id &#45;&#45; 获取“外检”和“安检”的统计-->
<!-- <where>-->
<!-- iwn.deleted = 0 &#45;&#45; 排除已删除的数据-->
<!-- AND iwn.deal_user_id IS NOT NULL &#45;&#45; 排除 deal_user_id 为 NULL 的记录-->
<!-- AND iwn.status = 2-->
<!-- AND info.status = 1-->
<!-- <if test="id != null and id != ''">-->
<!-- AND iwn.project_id = #{id} &#45;&#45; 只在这里加上id过滤-->
<!-- </if>-->
<!-- </where>-->
<!-- GROUP BY-->
<!-- iwn.deal_user_id &#45;&#45; 根据处理人员ID进行分组-->
<!-- ORDER BY-->
<!-- orderCount DESC; &#45;&#45; 根据接单数量进行降序排序-->
<!-- </select>-->
<select id="getStaffCount" resultType="cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO"
parameterType="cn.iocoder.yudao.module.inspection.entity.DlInspectionProject">
SELECT
ip.id,ip.project_name, count(iwn.id) as count,is2.user_id,su.nickname
FROM inspection_staff is2
LEFT JOIN inspection_work_node iwn ON is2.user_id = iwn.deal_user_id
LEFT JOIN inspection_project ip ON iwn.project_id = ip.id
LEFT JOIN system_users su on su.id = is2.user_id
WHERE
ip.id in (
SELECT
ip2.id
FROM
inspection_project ip2
WHERE
ip2.deleted = 0
)
group by is2.user_id,ip.project_name
</select>
<select id="selectExceptionNodesByInspectionIds" resultType="java.util.Map">
SELECT
iwn.deal_user_id, -- 处理人员ID
su.nickname, -- 处理人员名称
su.avatar, -- 处理人员头像
COUNT(DISTINCT iwn.id) AS orderCount, -- 统计每个员工的唯一订单数量
SUM(IFNULL(royalty.royalty_amount, 0) / 100) AS royaltyAmount, -- 计算每个员工的总佣金
su.mobile, -- 处理人员手机号
COALESCE(waijianCount, 0) AS waijianCount, -- 包含“外检”的订单数量
COALESCE(anjianCount, 0) AS anjianCount, -- 包含“安检”的订单数量
COALESCE(proj_stats.otherCount, 0) AS otherCount -- 其他订单数量(排除“外检”和“安检”)
FROM
inspection_work_node iwn
LEFT JOIN system_users su ON su.id = iwn.deal_user_id -- 处理人员信息
LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id
LEFT JOIN order_info orders ON info.inspection_order_id = orders.id
LEFT JOIN inspection_project_royalty AS royalty
ON iwn.project_id = royalty.project_id
AND orders.goods_id = royalty.goods_id
LEFT JOIN (
w.inspection_info_id AS inspectionInfoId,
w.id AS nodeId,
p.project_name AS projectName
FROM inspection_work_node w
INNER JOIN inspection_project p
ON p.id = w.project_id
WHERE w.inspection_info_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND w.status &lt;&gt; '2' <!-- 未完成 -->
AND EXISTS ( <!-- 同时“制证”节点已完成 -->
SELECT 1
FROM inspection_work_node w2
INNER JOIN inspection_project p2
ON p2.id = w2.project_id
WHERE w2.inspection_info_id = w.inspection_info_id
AND p2.project_name LIKE '%制证%'
AND w2.status = '2'
AND w2.type = 1
)
ORDER BY w.order_num
</select>
<select id="selectStaffProjectByUserId" resultType="java.util.Map">
SELECT
iwn.deal_user_id,
SUM(CASE WHEN proj.project_name LIKE '环检外检%' THEN 1 ELSE 0 END) AS waijianCount,
SUM(CASE WHEN proj.project_name LIKE '安检%' THEN 1 ELSE 0 END) AS anjianCount,
SUM(
CASE
WHEN proj.project_name NOT LIKE '环检外检%'
AND proj.project_name NOT LIKE '安检%'
THEN 1 ELSE 0
END
) AS otherCount -- 统计不包含“外检”和“安检”的订单
FROM
inspection_work_node iwn
LEFT JOIN inspection_project AS proj ON iwn.project_id = proj.id
LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id
WHERE iwn.deleted = 0 -- 排除已删除的数据
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录
AND iwn.status = 2
AND info.status = 1
GROUP BY
iwn.deal_user_id
) proj_stats ON iwn.deal_user_id = proj_stats.deal_user_id -- 获取“外检”和“安检”的统计
<where>
iwn.deleted = 0 -- 排除已删除的数据
AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录
AND iwn.status = 2
AND info.status = 1
<if test="id != null and id != ''">
AND iwn.project_id = #{id} -- 只在这里加上id过滤
</if>
</where>
GROUP BY
iwn.deal_user_id -- 根据处理人员ID进行分组
ORDER BY
orderCount DESC; -- 根据接单数量进行降序排序
ii.id AS inspectionInfoId,
ii.user_id AS userId,
ii.user_name AS userName,
ii.buy_name AS buyName,
ii.buy_phone AS buyPhone,
ii.car_num AS carNum,
ii.car_model AS carModel,
ii.car_status AS carStatus,
ii.start_time AS startTime,
ii.end_time AS endTime,
ii.unit_name AS unitName,
ii.partner_id,
ii.work_id AS workId,
ii.worker_name AS workerName,
ii.worker_phone AS workerPhone,
ii.worker_avatar AS workerAvatar,
CASE
WHEN ii.is_pass = '0' THEN '不通过'
WHEN ii.is_pass = '1' THEN '通过'
WHEN ii.is_pass IS NULL THEN '进行中'
ELSE '未知'
END AS status,
GROUP_CONCAT(ip.project_name ORDER BY iwn.order_num SEPARATOR ',') AS projectName
FROM inspection_work_node iwn
LEFT JOIN inspection_info ii ON iwn.inspection_info_id = ii.id
LEFT JOIN inspection_project ip ON ip.id = iwn.project_id
WHERE
iwn.deal_user_id = #{userId}
AND iwn.status = '2'
AND iwn.deleted = b'0'
GROUP BY ii.id
ORDER BY ii.start_time DESC;
</select>
</mapper>

View File

@ -144,8 +144,17 @@ FROM
<select id="hotGoodsList" resultType="cn.iocoder.yudao.module.inspection.vo.HotGoodsVo">
SELECT
goods.title AS goodsName,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then oi.goods_price else 0 end ) AS salesAmount,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then 1 else 0 end ) AS salesNum
ROUND(
SUM(
CASE
WHEN (ii.`status` = '1' AND ii.is_pass = '1') OR ii.`status` = '0'
THEN oi.goods_price
ELSE 0
END
) / 100.0,
2
) AS salesAmount,
SUM( case when (ii.`status`='1' and ii.is_pass = '1') or (ii.`status`='0') then 1 else 0 end ) AS salesNum
FROM
shop_inspection_goods goods
left join order_info oi on oi.goods_id = goods.id and validation_time is not null and validation_time like concat(#{dateStr},'%')
@ -220,34 +229,82 @@ where sig.partner_id =#{partnerId}
</if>
order by pw.create_time desc
</select>
<select id="inspectionList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
SELECT
info.id,info.worker_name,info.worker_phone,info.worker_avatar,info.`status`,info.is_pass,info.start_time,info.end_time,step.title as lastTitle,
su.nickname buyName,su.mobile as buyPhone,oi.order_no as orderNo,oi.pay_money+oi.balance as realPayMoney,oi.goods_title as goodsName,info.car_num,info.is_retrial,
info.customer_source as customerSource, info.other_phone as otherPhone,oi.sku_id as skuId, oi.sku_name as skuName,oi.goods_price as goodsPrice
from
inspection_info info
LEFT JOIN inspection_step_info step ON info.id = step.inspection_info_id
LEFT JOIN
inspection_work_node iwn ON info.id = iwn.inspection_info_id
INNER JOIN system_users su on su.id = info.user_id
INNER JOIN order_info oi on oi.id = info.inspection_order_id
WHERE info.partner_id = #{partnerId}
<!-- 待复检 -->
<if test="status == 4">
-- AND ii.status = '2'
AND iwn.status = '3'
AND info.status != '1'
</if>
<if test="status != 4">
AND info.status = #{status}
</if>
<if test="carNum!=null and carNum!=''">
and info.car_num like concat('%',#{carNum},'%')
</if>
GROUP BY info.id
order by info.create_time desc
</select>
<select id="inspectionList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
SELECT
info.id,
info.worker_name,
info.worker_phone,
info.worker_avatar,
info.`status`,
info.is_pass,
info.start_time,
info.end_time,
step.title AS lastTitle,
su.nickname AS buyName,
su.mobile AS buyPhone,
oi.order_no AS orderNo,
oi.pay_money + oi.balance AS realPayMoney,
oi.goods_title AS goodsName,
info.car_num,
info.is_retrial,
info.customer_source AS customerSource,
info.other_phone AS otherPhone,
oi.sku_id AS skuId,
oi.sku_name AS skuName,
oi.goods_price AS goodsPrice
FROM inspection_info info
LEFT JOIN inspection_step_info step
ON info.id = step.inspection_info_id
LEFT JOIN inspection_work_node iwn
ON info.id = iwn.inspection_info_id
INNER JOIN system_users su
ON su.id = info.user_id
INNER JOIN order_info oi
ON oi.id = info.inspection_order_id
WHERE info.partner_id = #{partnerId}
<!-- 待复检 -->
<if test="status == 4">
AND iwn.status = '3'
AND info.status != '1'
</if>
<!-- 异常工单 -->
<if test="status == 5">
<!-- 有“制证”节点已完成 -->
AND EXISTS (
SELECT 1
FROM inspection_work_node w
JOIN inspection_project p
ON p.id = w.project_id
WHERE w.inspection_info_id = info.id
AND p.project_name LIKE '%制证%'
AND w.status = '2'
AND w.type = '1'
)
<!-- 同一工单还有其它节点未完成 -->
AND EXISTS (
SELECT 1
FROM inspection_work_node w2
WHERE w2.inspection_info_id = info.id
AND w2.status &lt;&gt; '2'
)
</if>
<!-- 其它普通状态 -->
<if test="status != 4 and status != 5">
AND info.status = #{status}
</if>
<!-- 车牌号模糊 -->
<if test="carNum != null and carNum != ''">
AND info.car_num LIKE CONCAT('%', #{carNum}, '%')
</if>
GROUP BY info.id
ORDER BY info.create_time DESC
</select>
<select id="workerInspectionList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionInfo">
SELECT
info.id,info.worker_name,info.worker_phone,info.worker_avatar,info.`status`,info.is_pass,info.start_time,info.end_time,step.title as lastTitle,
@ -415,14 +472,27 @@ FROM
and ii.create_time BETWEEN #{startTime} and #{endTime}
</select>
<select id="staticsTable2" resultType="java.util.Map">
SELECT
count(1) allNum,
IFNULL(SUM(ii.status='0'),0) jxzNum,
IFNULL(SUM(ii.status='1'),0) ywcNum
FROM
inspection_info ii
WHERE ii.partner_id =#{partnerId} and ii.deleted = 0
and ii.create_time BETWEEN #{startTime} and #{endTime}
SELECT
count(1) allNum,
IFNULL(SUM(ii.status='0'),0) jxzNum,
IFNULL(SUM(ii.status='1'),0) ywcNum,
IFNULL(SUM(oi.sku_name LIKE '%年审%'),0) nsNum,
IFNULL(SUM(oi.sku_name LIKE '%上户%'),0) shNum,
IFNULL(SUM(oi.sku_name LIKE '%非定检%'),0) fdjNum,
IFNULL(SUM(oi.sku_name LIKE '%双燃料%'),0) srlNum,
IFNULL(SUM(oi.sku_name LIKE '%其他检测%'),0) qtjcNum,
IFNULL(SUM(ii.recheck_count),0) recheckNum,
IFNULL(SUM(ii.reinspect_count),0) reinspectNum
FROM
inspection_info ii
LEFT JOIN order_info oi on oi.id = ii.inspection_order_id
<where>
ii.partner_id =#{partnerId} and ii.deleted = 0 and oi.deleted = 0
<if test="startTime != null and endTime != null">
and ii.create_time BETWEEN #{startTime} and #{endTime}
</if>
</where>
</select>
<select id="newStaticsTable2" resultType="java.util.Map">
SELECT
@ -580,11 +650,13 @@ FROM
ELSE '已支付'
END AS pay,
CASE
WHEN oi.pay_type IS NOT NULL THEN '已支付'
WHEN has_status_0_or_null THEN '检测中'
WHEN (ii.status = 0 OR ii.status = 2) AND has_status_1 THEN '检测中'
WHEN (COALESCE(max_iwn_status, 0) = 2 OR ii.status = 1) THEN '已完成'
/*WHEN THEN '检测中'*/
/*WHEN (COALESCE(max_iwn_status, 0) = 2 OR ii.status = 1) THEN '已完成'*/
WHEN ( ii.status = 1) THEN '已完成'
/*WHEN ((ii.status = 0 OR ii.status = 2) AND has_status_1 OR has_status_0_or_null)THEN '检测中'*/
WHEN ((ii.status = 0 OR ii.status = 2))THEN '检测中'
WHEN (ii.status = 0 OR ii.status = 2) AND COALESCE(max_iwn_status, 0) = 0 THEN '待检测'
WHEN (ii.status = 1 ) AND ii.is_pass = 0 THEN '退办理'
ELSE '未知状态'
END AS status,
ii.is_pass,
@ -593,6 +665,9 @@ FROM
FROM order_info oi
INNER JOIN inspection_info ii
ON oi.id = ii.inspection_order_id
<if test="query.type == 1">
INNER JOIN inspection_appointment ia ON oi.id = ia.order_id
</if>
LEFT JOIN (
SELECT inspection_info_id,
MAX(COALESCE(status, 0)) AS max_iwn_status,
@ -606,6 +681,9 @@ FROM
<if test="query.payType!=null and query.payType!=''">
AND oi.pay_type = #{query.payType}
</if>
<if test="query.skuName!=null and query.skuName!=''">
AND oi.sku_name LIKE concat('%',#{query.skuName},'%')
</if>
<if test="query.customerSource!=null and query.customerSource!=''">
AND ii.customer_source = #{query.customerSource}
</if>
@ -634,6 +712,9 @@ FROM
<when test="query.chooseStatus == '3'.toString()">
t.status = '已完成'
</when>
<when test="query.chooseStatus == '4'.toString()">
t.status = '退办理'
</when>
</choose>
</where>
ORDER BY t.create_time DESC;
@ -702,17 +783,22 @@ FROM
</select>
<select id="queryInspectionSkuList" resultType="java.util.Map">
SELECT
sku_name AS skuName,
COUNT(*) AS orderCount
s.sku_name AS skuName,
IFNULL(COUNT(o.id),0) AS orderCount
FROM
order_info
<where>
sku_name IN ('年审', '上户', '双燃料', '非定检', '其他检测')
<if test="startTime != null">
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
</where>
(
SELECT '年审' AS sku_name
UNION ALL SELECT '上户'
UNION ALL SELECT '双燃料'
UNION ALL SELECT '非定检'
UNION ALL SELECT '其他检测'
) s
LEFT JOIN order_info o
ON o.sku_name = s.sku_name
<if test="startTime != null">
AND o.create_time BETWEEN #{startTime} AND #{endTime}
</if>
GROUP BY
sku_name;
s.sku_name
</select>
</mapper>

View File

@ -32,10 +32,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectInspectionAppointmentById" parameterType="Long" resultMap="InspectionAppointmentResult">
select ia.*,su.nickname as buyName, su.mobile as buyPhoneNum
<select id="selectInspectionAppointmentById" parameterType="Long" >
select ia.*,su.nickname as buyName, su.mobile as buyPhoneNum,su2.nickname as meetName,imco.is_meet,ic.appointment_day as pickCarAppointmentDay,ic.appointment_time as pickCarAppointmentTime,ic.adress_detail,ia.is_use
from inspection_appointment ia
left join system_users su on su.id = ia.user_id
LEFT JOIN inspection_meet_car_order imco ON imco.id = ia.meet_order_id
LEFT JOIN system_users su2 on su2.id = imco.meet_man_id
LEFT JOIN inspection_pick_car ic on ic.id = ia.pick_car_id
where ia.id = #{id}
</select>

View File

@ -3,4 +3,11 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.inspection.mapper.InspectionFileRecordMapper">
<select id="getRecordList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionFileRecord">
select record.*,user.nickname
from inspection_file_record record
LEFT JOIN system_users user on record.creator = user.id
where record.file_id = #{id}
and record.deleted = 0
</select>
</mapper>

View File

@ -369,6 +369,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND ii.status != '1'
ORDER BY iwn.update_time DESC
</if>
<!-- 新增lead_man_id 为空 -->
<if test="inspectionInfo.status == 9">
AND ii.lead_man_id IS NULL
AND ii.status = '0'
ORDER BY ii.update_time DESC
</if>
</where>
) AS subquery
WHERE rn = 1;
@ -388,6 +394,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ii.meet_man_id AS meet_id,
ii.tenant_id,
ii.create_time,
null AS meetAddress,
null AS latitude,
null AS longitude,
null AS appointmentDay,
null AS appointmentTime,
0 AS source_type
FROM inspection_info ii
WHERE ii.deleted = 0 AND ii.meet_man_id = #{inspectionInfo.dealUserId} AND ii.is_meet_car = '0' AND ii.status != '1'
@ -411,6 +422,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
imco.meet_man_id,
imco.tenant_id,
imco.create_time,
imco.meet_address AS meetAddress,
imco.latitude,
imco.longitude,
imco.appointment_day,
imco.appointment_time,
1 AS source_type
FROM inspection_meet_car_order imco
WHERE imco.deleted = 0 AND imco.meet_man_id = #{inspectionInfo.dealUserId} AND imco.is_meet = '0'
@ -545,6 +561,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND iwn.type = '0'
AND ii.status != '1'
</if>
<!-- 新增lead_man_id 为空 -->
<if test="inspectionInfo.status == 9">
AND ii.lead_man_id IS NULL
AND ii.status = '0'
</if>
</where>
</if>
<if test="inspectionInfo.status == 6">

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.inspection.mapper.InspectionLeadRecordMapper">
</mapper>

View File

@ -37,7 +37,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
@Tag(name = "管理后台 - 用户")
@RestController
@RequestMapping("/system/user")
@RequestMapping("/system/user")
@Validated
public class UserController {
@ -180,7 +180,7 @@ public class UserController {
/**
* 通过角色id查询用户列表
* @param roleId
* @param roleId 角色id
* @return
*/
@GetMapping("/selectByRoleId")
@ -188,4 +188,14 @@ public class UserController {
return success(userService.selectByRoleId(roleId));
}
/**
* 判断当前登录用户是否拥有某个角色
* @param roleCode 角色code
* @return
*/
@GetMapping("/ifLoginUserHasRoleByCode")
public CommonResult<?> ifLoginUserHasRoleByCode(String roleCode){
return success(userService.ifLoginUserHasRoleByCode(roleCode));
}
}

View File

@ -48,16 +48,17 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 微信小程序端修改用户个人信息
*
* @param userInfoVO 用户对象
* @author vinjor-M
* @date 20:11 2024/10/11
* @param userInfoVO 用户对象
**/
**/
void updateCusInfo(UserInfoVO userInfoVO);
/**
* 更新用户的最后登陆信息
*
* @param id 用户编号
* @param id 用户编号
* @param loginIp 登陆 IP
*/
void updateUserLogin(Long id, String loginIp);
@ -65,7 +66,7 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 修改用户个人信息
*
* @param id 用户编号
* @param id 用户编号
* @param reqVO 用户个人信息
*/
void updateUserProfile(Long id, @Valid UserProfileUpdateReqVO reqVO);
@ -73,7 +74,7 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 修改用户个人密码
*
* @param id 用户编号
* @param id 用户编号
* @param reqVO 更新用户个人密码
*/
void updateUserPassword(Long id, @Valid UserProfileUpdatePasswordReqVO reqVO);
@ -96,12 +97,13 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 修改用户所属部门
*
* @param id 用户id
* @param deptId H部门id
* @author vinjor-M
* @date 16:34 2024/8/2
* @param id 用户id
* @param deptId H部门id
**/
void updateUserDept(Long id,Long deptId);
**/
void updateUserDept(Long id, Long deptId);
/**
* 修改状态
@ -125,13 +127,15 @@ public interface AdminUserService extends IService<AdminUserDO> {
* @return 用户对象信息
*/
AdminUserDO getUserByUsername(String username);
/**
* 通过用户名查询用户
*
* @param username 用户名
* @return 用户对象信息
*/
AdminUserDO getUserByUsername(String username,Long tenantId);
AdminUserDO getUserByUsername(String username, Long tenantId);
/**
* 通过用户名查询用户---不带租户ID
*
@ -147,6 +151,7 @@ public interface AdminUserService extends IService<AdminUserDO> {
* @return 用户对象信息
*/
AdminUserDO getUserByMobile(String mobile);
/**
* 通过手机号获取用户(不带租户id)
*
@ -245,14 +250,16 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 判断密码是否匹配
*
* @param rawPassword 未加密的密码
* @param rawPassword 未加密的密码
* @param encodedPassword 加密后的密码
* @return 是否匹配
*/
boolean isPasswordMatch(String rawPassword, String encodedPassword);
List<AdminUserDO> getUsersByRoleRescue(String roleCode, String searchValue, List<String> deptIds);
IPage<AdminUserDO> getUsersByRoleRescueTow(Page<AdminUserDO> page,String roleCode, String searchValue, List<String> deptIds);
List<AdminUserDO> getUsersByRoleRescue(String roleCode, String searchValue, List<String> deptIds);
IPage<AdminUserDO> getUsersByRoleRescueTow(Page<AdminUserDO> page, String roleCode, String searchValue, List<String> deptIds);
Integer getStudentNumberByUserId(Long jlId);
List<String> getStudentNumber(Long id);
@ -263,12 +270,14 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 根据openid和租户id查询用户
*
* @param openId 微信id
* @param tenantId 租户id可能为null
* @author vinjor-M
* @date 11:29 2024/9/24
* @param openId 微信id
* @param tenantId 租户id可能为null
**/
AdminUserDO selectUserByOpenId(String openId,String tenantId);
AdminUserDO selectUserByOpenId(String openId, String tenantId);
/**
* 设置用户openId
*
@ -277,19 +286,21 @@ public interface AdminUserService extends IService<AdminUserDO> {
* @author vinjor-M
* @date 15:45 2024/9/24
**/
void setOpenId(Long userId,String openId);
void setOpenId(Long userId, String openId);
/**
* 根据手机号查询所有用户--员工
* @author vinjor-M
* @date 14:43 2024/10/16
*
* @param phone 手机号
* @return java.util.List<cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO>
**/
* @author vinjor-M
* @date 14:43 2024/10/16
**/
List<AdminUserDO> selectListByPhoneStaff(String phone);
/**
* 根据角色id查询用户
*
* @param roleId
* @return
*/
@ -297,8 +308,17 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 查询用户信息(排除掉租户)
*
* @param reqVO
* @return
*/
Map<String, Object> queryUserIgnoreTenant(AuthLoginReqVO reqVO);
/**
* 判断当前登录用户是否拥有某个角色
*
* @param roleCode 角色编码
* @return
*/
Boolean ifLoginUserHasRoleByCode(String roleCode);
}

View File

@ -26,12 +26,15 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqV
import cn.iocoder.yudao.module.system.controller.app.user.UserInfoVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
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.dal.mysql.dept.UserPostMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.dept.PostService;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -43,6 +46,7 @@ import com.mzt.logapi.service.impl.DiffParseFunction;
import com.mzt.logapi.starter.annotation.LogRecord;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@ -52,6 +56,7 @@ import javax.annotation.Resource;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -94,6 +99,9 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
@Resource
private ConfigApi configApi;
@Autowired
private RoleService roleService;
@Override
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}",
@ -662,6 +670,32 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
return baseMapper.queryUserIgnoreTenant(reqVO);
}
/**
* 判断当前登录用户是否拥有某个角色
*
* @param roleCode 角色编码
* @return
*/
@Override
public Boolean ifLoginUserHasRoleByCode(String roleCode) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//获取当前登陆人的所有角色
List<UserRoleDO> userRoles = roleService.getByUserId(loginUser.getId());
List<Long> userRoleIds = userRoles.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
List<RoleDO> roleList = roleService.getRoleList(userRoleIds);
//判断当前角色集合中的code是否包含jcyszz
if (CollectionUtil.isNotEmpty(roleList)) {
List<RoleDO> filteredRoleList = roleList.stream()
.filter(role -> role.getCode().contains(roleCode))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(filteredRoleList)) {
return true;
}
}
return false;
}
/**
* 对密码进行加密
*