# Conflicts:
#	dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java
#	dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java
This commit is contained in:
xiaofajia 2024-10-18 18:11:06 +08:00
commit 6f8f2b7a3a
16 changed files with 261 additions and 24 deletions

View File

@ -55,6 +55,8 @@ public class BaseConstants {
public static final Integer BATCH_SIZE = 100;
/**资质临期通知模板*/
public static final String QUALS_INTERIM_PERIOD = "quals_interim_period";
/**站内信模版*/
public static final String TICKET_EMPLOY = "ticket_employ";
/**资质过期通知模板*/
public static final String QUALS_EXPIRED = "quals_expired";
/** 资产临期通知模板 */
@ -123,4 +125,6 @@ public class BaseConstants {
public static final String REPAIR_RECORD_TYPE_KSSG = "kssg";
/** 施工中 */
public static final String REPAIR_RECORD_TYPE_SGZ = "sgz";
}

View File

@ -46,7 +46,11 @@ public enum RecordTypeEnum {
/**
* 施工中
*/
SGZ("sgz","施工中");
SGZ("sgz","施工中"),
/**
* 接单
*/
jd("jd","接单");
/**
* code
@ -64,7 +68,7 @@ public enum RecordTypeEnum {
* @param code code
* @return cn.iocoder.yudao.common.SystemEnum
**/
public static RecordTypeEnum getRepairRole(String code) {
public static RecordTypeEnum getEnumByCode(String code) {
for (RecordTypeEnum thisEnum : RecordTypeEnum.values()) {
if (thisEnum.getCode().equalsIgnoreCase(code)) {
// 找到对应的枚举

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.common;
/**
* 维修系统常量
* @author vinjor-M
* @date 17:44 2024/10/18
**/
public class RepairCons {
/**工单-待处理*/
public static final String TICKETS_WAITING = "waiting";
/**工单-所有*/
public static final String TICKETS_ALL = "all";
}

View File

@ -69,6 +69,15 @@ public interface RepairWorkerService extends IService<RepairWorker> {
**/
List<RepairWorker> listByTicketId(String ticketId);
/**
* 向指定用户发送消息
* @author PQZ
* @date 16:27 2024/10/18
* @param userId 用户id
* @param text 消息通知内容
**/
void sentMessage(Long userId,String text);
/**
* 通过班组长的id查该班组的员工
*

View File

@ -2,13 +2,18 @@ package cn.iocoder.yudao.module.base.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.app.controller.admin.NotifyMessageSocket;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.mapper.RepairWorkerMapper;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO;
import cn.iocoder.yudao.module.base.vo.RepairWorkerSaveReqVO;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
@ -16,14 +21,18 @@ 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.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.TICKET_EMPLOY;
/**
* 维修工人 Service 实现类
*
@ -39,6 +48,12 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
@Resource
@Lazy
private DlRepairTitemService dlRepairTitemService;
@Resource
private NotifyMessageSendApi sendApi;
@Autowired
private NotifyMessageSocket notifyMessageSocket;
@Resource
private AdminUserApi userApi;
/**
@ -50,7 +65,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
**/
@Override
public void saveWorkers(List<UserDTO> userList) {
if (CollectionUtil.isNotEmpty(userList)){
if (CollectionUtil.isNotEmpty(userList)) {
//获取已有的维修工人ID列表
List<Long> existingWorkerIds = workerMapper.getAllWorkerIds();
@ -98,18 +113,18 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
**/
@Override
public IPage<RepairWorkerRespVO> queryListPage(RepairWorkerPageReqVO pageReqVO, Page<RepairWorkerRespVO> page) {
return workerMapper.queryListPage(pageReqVO,page);
return workerMapper.queryListPage(pageReqVO, page);
}
/**
* 通过工单ID查到工单ID中所选择的员工信息
*
* @param ticketId 工单ID
* @author 小李
* @date 15:53 2024/10/14
* @param ticketId 工单ID
**/
@Override
public List<RepairWorker> listByTicketId(String ticketId){
public List<RepairWorker> listByTicketId(String ticketId) {
// 查工单的项目信息
List<DlRepairTitem> titems = dlRepairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>()
.and(item -> {
@ -122,6 +137,34 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
}
/**
* 向指定用户发送消息
*
* @param userId 用户id
* @param text 消息通知内容
* @author PQZ
* @date 16:27 2024/10/18
**/
@Override
public void sentMessage(Long userId, String text) {
try {
//获取当前登录用户
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
// 准备发送参数
Map<String, Object> templateParams = new HashMap<>();
// 发送模版内容
templateParams.put("text", text);
// 发送站内信
sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO()
.setUserId(userId)
.setTemplateCode(TICKET_EMPLOY).setTemplateParams(templateParams));
//发送语音提醒
notifyMessageSocket.sendMessage(text, loginUser.getTenantId().toString(), userId.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 通过班组长的id查该班组的员工
*
@ -129,7 +172,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
* @date 16:55 2024/10/14
**/
@Override
public List<RepairWorker> listByLeads(){
public List<RepairWorker> listByLeads() {
// 取班组长的记录
RepairWorker worker = baseMapper.selectOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId()));
// 根据班组长的工种查所有该工程的工人
@ -149,7 +192,7 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
public boolean getIfLeader() {
Long userId = SecurityFrameworkUtils.getLoginUserId();
LambdaQueryWrapper<RepairWorker> queryWrapper = new LambdaQueryWrapper<RepairWorker>()
.eq(RepairWorker::getUserId,userId);
.eq(RepairWorker::getUserId, userId);
List<RepairWorker> list = this.list(queryWrapper);
return !list.isEmpty() && "1".equals(list.get(0).getIsLeads());
}

View File

@ -128,4 +128,13 @@ public class RepairProjectController {
List<RepairProject> list = repairProjectService.list(new LambdaQueryWrapper<RepairProject>().eq(RepairProject::getName, name));
return success(list.stream().max(Comparator.comparing(RepairProject::getCreateTime)).orElse(null));
}
/**
* 获取维修项目和分类
* @return
*/
@GetMapping("/getRepairProjectAndCateGory")
public CommonResult getRepairProjectAndCateGory(){
return success(repairProjectService.getRepairProjectAndCateGory());
}
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.project.mapper;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.vo.RepairProjectAppvo;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -9,6 +10,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 维修项目 Mapper
*
@ -28,4 +31,9 @@ public interface RepairProjectMapper extends BaseMapper<RepairProject> {
**/
IPage<RepairProjectRespVO> selectListPage(@Param("entity") RepairProjectPageReqVO pageReqVO, Page<RepairProjectRespVO> page);
/**
* 查询维修项目和维修项目分类信息
* @return
*/
List<RepairProjectAppvo> selectProjectAndCateGory();
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.project.service;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.vo.RepairProjectAppvo;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
@ -9,6 +10,8 @@ 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;
/**
* 维修项目 Service 接口
*
@ -56,4 +59,9 @@ public interface RepairProjectService extends IService<RepairProject> {
IPage<RepairProjectRespVO> queryListPage(RepairProjectPageReqVO pageReqVO, Page<RepairProjectRespVO> page);
/**
* 查询服务分类和维修项目列表
* @return
*/
List<RepairProjectAppvo> getRepairProjectAndCateGory();
}

View File

@ -1,9 +1,13 @@
package cn.iocoder.yudao.module.project.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import cn.iocoder.yudao.module.project.mapper.RepairProjectMapper;
import cn.iocoder.yudao.module.project.service.RepairProjectService;
import cn.iocoder.yudao.module.project.vo.RepairProjectAppvo;
import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO;
import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO;
@ -14,6 +18,9 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 维修项目 Service 实现类
@ -82,5 +89,36 @@ public class RepairProjectServiceImpl extends ServiceImpl<RepairProjectMapper, R
return repairProjectMapper.selectListPage(pageReqVO,page);
}
/**
* 查询服务分类和维修项目列表
*
* @return
*/
@Override
public List<RepairProjectAppvo> getRepairProjectAndCateGory() {
List<RepairProjectAppvo> repairProjectAppvos = repairProjectMapper.selectProjectAndCateGory();
// 提取并去重 typeId
List<String> uniqueTypeIds = repairProjectAppvos.stream()
.map(RepairProjectAppvo::getTypeId)
.distinct()
.collect(Collectors.toList());
List<RepairProjectAppvo> list = new ArrayList<>();
for (String uniqueTypeId : uniqueTypeIds) {
RepairProjectAppvo repairProjectAppvo = new RepairProjectAppvo();
repairProjectAppvo.setTypeId(uniqueTypeId);
if (ObjectUtil.isNotEmpty(uniqueTypeId)) {
List<RepairProjectAppvo> filteredList = repairProjectAppvos.stream()
.filter(appvo -> uniqueTypeId.equals(appvo.getTypeId()))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(filteredList)) {
repairProjectAppvo.setTypeName(filteredList.get(0).getTypeName());
repairProjectAppvo.setGroupList(BeanUtil.copyToList(filteredList, RepairProject.class));
}
}
list.add(repairProjectAppvo);
}
return list;
}
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.project.vo;
import cn.iocoder.yudao.module.project.entity.RepairProject;
import lombok.Data;
import java.util.List;
@Data
public class RepairProjectAppvo extends RepairProject{
private String typeName;
private String typeId;
private List<RepairProject> groupList;
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.tickets.controller.admin;
import cn.iocoder.yudao.common.RepairCons;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
@ -9,6 +10,7 @@ import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -171,6 +173,10 @@ public class DlRepairTicketsController {
@RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){
Page<DlRepairTickets> page = new Page<>(pageNo, pageSize);
if(StringUtils.isEmpty(repairTicketsReqVO.getSelectType())){
//查询类型为空默认查待处理的
repairTicketsReqVO.setSelectType(RepairCons.TICKETS_WAITING);
}
return success(dlRepairTicketsService.getPageType(repairTicketsReqVO, page));
}

View File

@ -27,13 +27,21 @@ public interface DlRepairTicketsMapper extends BaseMapper<DlRepairTickets> {
IPage<DlRepairTickets> getTicketsPage(@Param("map") DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page);
/**
* 分类查询工单分页
* 分类查询工单分页----待处理的
*
* @author 小李
* @date 16:26 2024/10/12
* @param repairTicketsReqVO 查询对象
**/
IPage<DlRepairTickets> getPageType(@Param("map") DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page);
/**
* 分类查询工单分页----所有记录
*
* @author 小李
* @date 16:26 2024/10/12
* @param repairTicketsReqVO 查询对象
**/
IPage<DlRepairTickets> getPageTypeAll(@Param("map") DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page);
}

View File

@ -3,10 +3,7 @@ package cn.iocoder.yudao.module.tickets.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.RepairErrorCodeConstants;
import cn.iocoder.yudao.common.RepairRoleEnum;
import cn.iocoder.yudao.common.TicketsStatusEnum;
import cn.iocoder.yudao.common.TicketsWorkStatusEnum;
import cn.iocoder.yudao.common.*;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
@ -53,6 +50,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -139,6 +137,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Resource
@Lazy
private RepairRecordsService recordsService;
@Autowired
private RepairRecordsService repairRecordsService;
/**
* 维修工单表 新增
@ -224,6 +224,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
bookingService.updateById(dlRepairBooking);
}
repairOrderInfoService.saveOrderInfo(repairOrderInfo);
//最后记录操作日志--创建工单
repairRecordsService.saveRepairRecord(ticketsRespVO.getId(),null, RecordTypeEnum.CJGD.getCode(),"创建工单",null);
}
/**
@ -422,7 +424,11 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
}else{
return null;
}
return baseMapper.getPageType(repairTicketsReqVO, page);
if(RepairCons.TICKETS_WAITING.equals(repairTicketsReqVO.getSelectType())){
return baseMapper.getPageType(repairTicketsReqVO, page);
}else{
return baseMapper.getPageTypeAll(repairTicketsReqVO, page);
}
}
/**
@ -481,14 +487,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
public void updateTake(String id){
// 改变时看看是否已经被接了
int update = baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getTicketsWorkStatus, "02")
.set(DlRepairTickets::getTicketsWorkStatus, TicketsWorkStatusEnum.RECEIVED)
.and(item -> {
item.eq(DlRepairTickets::getId, id)
.eq(DlRepairTickets::getTicketsWorkStatus, "01");
.eq(DlRepairTickets::getTicketsWorkStatus, TicketsWorkStatusEnum.WAITING_RECEIVING);
}));
if (update != 1){
throw exception0(500, "工单已被其他人接单了");
}
//最后记录操作日志--接单
repairRecordsService.saveRepairRecord(id,null, RecordTypeEnum.jd.getCode(), "接单",null);
}
/**
@ -513,6 +521,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
if (update != 1) {
throw exception0(500, "工单已开始");
}
workerService.sentMessage(reqVO.getNowRepairId(),"您有新的工单要处理");
//最后记录操作日志--指派施工
repairRecordsService.saveRepairRecord(reqVO.getId(),null, RecordTypeEnum.ZPSG.getCode(),"指派施工",null);
}
/**

View File

@ -25,4 +25,6 @@ public class DlRepairTicketsReqVO extends DlRepairTickets {
/** 工单中项目指定的施工人员的ids */
private List<Long> userIds;
/** 查询类型(waiting 待处理的 | all 所有数据) */
private String selectType;
}

View File

@ -33,4 +33,16 @@
ORDER BY
drp.create_time DESC
</select>
<select id="selectProjectAndCateGory" resultType="cn.iocoder.yudao.module.project.vo.RepairProjectAppvo">
SELECT
drp.*,
dbt.id AS typeId,
dbt.name AS typeName
FROM
dl_repair_project drp
LEFT JOIN dl_base_type dbt ON drp.type = dbt.id
AND dbt.deleted = 0 AND dbt.type = "03"
WHERE
drp.deleted = 0
</select>
</mapper>

View File

@ -203,17 +203,65 @@
and drt.is_finish = #{map.isFinish}
</if>
<if test="map.userIds != null and map.userIds.size > 0">
and (
<foreach item="item" collection="map.userIds" index="index" open="" separator="or" close="">
find_in_set(#{item}, drti.repair_ids) > 0
and (drt.tickets_status = '05')
and (drt.now_repair_id in
<foreach collection="map.userIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
)
</if>
<if test="map.isFinish != null and map.isFinish != '' and map.isFinish == 0 and map.userIds != null and map.userIds.size > 0">
and (drt.now_repair_id in
<foreach collection="map.userIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
order by drt.create_time desc
</select>
<select id="getPageTypeAll" resultMap="BaseResultMap">
select drt.*,
drti.id AS item_id,
drti.ticket_id AS item_ticket_id,
drti.item_name AS item_item_name,
drti.item_count AS item_item_count,
drti.item_unit AS item_item_unit,
drti.item_price AS item_item_price,
drti.item_discount AS item_item_discount,
drti.item_money AS item_item_money,
drti.repair_ids AS item_repair_ids,
drti.repair_names AS item_repair_names,
drti.sale_id AS item_sale_id,
drti.sale_name AS item_sale_name,
drti.item_type AS item_item_type,
drti.project_id AS item_project_id,
drti.part_id AS item_part_id,
drti.other_id AS item_other_id,
drti.item_type_id AS item_type_id,
drti.item_status AS item_item_status,
drti.remark AS item_remark
from dl_repair_tickets drt
left join dl_repair_titem drti
on drt.id = drti.ticket_id AND drti.deleted = '0'
where drt.deleted = '0'
<if test="map.ticketNo != null and map.ticketNo != ''">
and (
drt.ticket_no like concat('%', #{map.ticketNo}, '%')
or
drt.car_no like concat('%', #{map.ticketNo}, '%')
or
drt.user_name like concat('%', #{map.ticketNo}, '%')
or
drt.user_mobile like concat('%', #{map.ticketNo}, '%')
or
drt.remark like concat('%', #{map.ticketNo}, '%')
)
</if>
<if test="map.searchTimeArray != null and map.searchTimeArray.length > 0">
and drt.create_time between #{map.searchTimeArray[0]} and #{map.searchTimeArray[1]}
</if>
<if test="map.adviserId != null and map.adviserId != ''">
and drt.adviser_id = #{map.adviserId}
</if>
<if test="map.userIds != null and map.userIds.size > 0">
and (
<foreach item="item" collection="map.userIds" index="index" open="" separator="or" close="">
find_in_set(#{item}, drt.now_repair_id) > 0
</foreach>
)
</if>
order by drt.create_time desc