# Conflicts:
#	dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java
#	dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsReqVO.java
This commit is contained in:
xiaofajia 2024-11-05 10:38:42 +08:00
commit 56f84995cc
14 changed files with 169 additions and 5 deletions

View File

@ -61,6 +61,10 @@ public enum RecordTypeEnum {
TZTL("tztl","通知退料"),
/**审批配件申请单*/
SPPJSQD("sppjsqd","审批配件申请单"),
/**
* 添加维修项目
*/
TJWXXM("tjwxxm", "添加维修项目"),
/**
* 接单
*/

View File

@ -35,4 +35,13 @@ public interface RepairWorkerMapper extends BaseMapper<RepairWorker> {
* @date 2024年10月10日
**/
List<Long> getAllWorkerIds();
/**
* 根据userId查询维修工信息
* @author PQZ
* @date 17:28 2024/11/4
* @param userId 用户id
* @return cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO
**/
RepairWorkerRespVO getByUserId(Long userId);
}

View File

@ -27,6 +27,15 @@ public interface RepairWorkerService extends IService<RepairWorker> {
* @param userList 选中用户集合
**/
void saveWorkers(List<UserDTO> userList);
/**
* 根据用户id查询对应维修的角色维修工人则查询班组非维修工人查询角色
* @author PQZ
* @date 17:21 2024/11/4
* @param userId 用户id
* @return java.lang.String
**/
String getWorkerRoleName(Long userId);
/**
* 更新维修工人

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.base.entity.RepairRecordsItem;
import cn.iocoder.yudao.module.base.mapper.RepairRecordsMapper;
import cn.iocoder.yudao.module.base.service.RepairRecordsItemService;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.base.vo.RepairRecordsPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -36,6 +37,8 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
private AdminUserApi userApi;
@Resource
private RepairRecordsItemService itemService;
@Resource
private RepairWorkerService workerService;
/**
@ -82,6 +85,7 @@ public class RepairRecordsServiceImpl extends ServiceImpl<RepairRecordsMapper, R
List<RepairRecordsRespVO> list = repairRecordsMapper.queryRepairRecords(pageReqVO);
//为每一条维修记录设置查询附件
list.forEach(item -> {
item.setRoleName(workerService.getWorkerRoleName(item.getDealUserId()));
List<RepairRecordsItem> itemList = itemService.getByMainId(REPAIR_RECORD_TYPE_RECORD, item.getId(), pageReqVO.getIsOpen());
item.setItemList(itemList);
//相对路径按照分隔

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.base.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.common.RepairRoleEnum;
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;
@ -15,6 +16,9 @@ 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.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO;
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;
@ -57,6 +61,13 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
@Resource
private DictDataApi dictDataApi;
@Resource
@Lazy
private RoleApi roleApi;
@Resource
@Lazy
private PermissionApi permissionApi;
/**
* 批量创建维修工人
@ -87,6 +98,52 @@ public class RepairWorkerServiceImpl extends ServiceImpl<RepairWorkerMapper, Rep
}
}
/**
* 根据用户id查询对应维修的角色维修工人则查询班组非维修工人查询角色
*
* @param userId 用户id
* @return java.lang.String
* @author PQZ
* @date 17:21 2024/11/4
**/
@Override
public String getWorkerRoleName(Long userId) {
RepairWorkerRespVO worker = workerMapper.getByUserId(userId);
//如果为空说明不是维修工查询当前用户的角色
if (null != worker){
return worker.getWorkerTypeStr();
} else {
List<Long> roleIds = permissionApi.getRoleIdsByUserId(userId);
// 所有的角色信息
List<RoleReqDTO> roleList = roleApi.getRoleList();
// 过滤出登录用户有的角色信息
List<RoleReqDTO> collect = roleList.stream().filter(item -> roleIds.contains(item.getId())).collect(Collectors.toList());
// 取出角色code
List<String> codes = collect.stream().map(RoleReqDTO::getCode).collect(Collectors.toList());
//维修业务管理员
if (codes.contains(RepairRoleEnum.ADMIN.getCode())) {
return RepairRoleEnum.ADMIN.getName();
}
// 总检
if (codes.contains(RepairRoleEnum.INSPECTION.getCode())) {
return RepairRoleEnum.INSPECTION.getName();
}
// 服务顾问
if (codes.contains(RepairRoleEnum.ADVISOR.getCode())) {
return RepairRoleEnum.ADVISOR.getName();
}
// 维修仓库管理员
if (codes.contains(RepairRoleEnum.WAREHOUSE.getCode())) {
return RepairRoleEnum.WAREHOUSE.getName();
}
// 维修财务
if (codes.contains(RepairRoleEnum.WXCW.getCode())) {
return RepairRoleEnum.WXCW.getName();
}
}
return null;
}
@Override
public void updateWorker(RepairWorkerSaveReqVO updateReqVO) {
// 更新

View File

@ -16,5 +16,7 @@ public class RepairRecordsRespVO extends RepairRecords {
private List<RepairRecordsItem> itemList;
/**维修记录关联附件信息*/
private String images;
/**角色、岗位名称*/
private String roleName;
}

View File

@ -9,7 +9,7 @@ import lombok.Data;
@Data
@ExcelIgnoreUnannotated
public class RepairWorkerRespVO extends RepairWorker {
private String workerTypeStr;
}

View File

@ -345,8 +345,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
/*
领了什么配件领了多少个
*/
List<String> nameAndCount = list.stream().map(item -> item.getWaresName() + "(" + item.getWaresCount() + ")").collect(Collectors.toList());
remark += "确认领料" + String.join(",", nameAndCount);
List<String> nameAndCount = list.stream().map(item -> item.getWaresName() + "x" + item.getWaresCount()).collect(Collectors.toList());
remark += "确认领料" + String.join(";", nameAndCount);
// 记录日志
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.LL.getCode(), remark, image);
}

View File

@ -1,17 +1,22 @@
package cn.iocoder.yudao.module.tickets.controller.admin;
import cn.iocoder.yudao.common.RecordTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.service.DlRepairTitemService;
import cn.iocoder.yudao.module.tickets.vo.AddProjVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemReqVO;
import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemRespVO;
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;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.ok;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -30,6 +35,8 @@ public class DlRepairTitemController {
*/
@Resource
private DlRepairTitemService dlRepairTitemService;
@Resource
private RepairRecordsService repairRecordsService;
/**
* 维修工单子表 分页
@ -113,6 +120,26 @@ public class DlRepairTitemController {
return CommonResult.ok();
}
/**
* 添加维修项目
* @author vinjor-M
* @date 14:28 2024/11/4
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@PostMapping("/addNewProj")
@Operation(summary = "添加维修项目")
public CommonResult<?> addNewProj(@RequestBody AddProjVO addProjVO){
dlRepairTitemService.saveBatch(addProjVO.getItemList());
List<String> projNameList = addProjVO.getItemList().stream().map(DlRepairTitem::getItemName).collect(Collectors.toList());
//最后记录操作日志--创建工单
String remark = "添加维修项目"+String.join(", ",projNameList )+"";
if(StringUtils.isNotEmpty(addProjVO.getRemark())){
remark += "备注:"+addProjVO.getRemark();
}
repairRecordsService.saveRepairRecord(addProjVO.getItemList().get(0).getTicketId(), null, RecordTypeEnum.TJWXXM.getCode(), remark, addProjVO.getImage());
return CommonResult.success(addProjVO.getItemList().get(0).getTicketId());
}
/**
* 维修工单单个子项
*
@ -126,5 +153,6 @@ public class DlRepairTitemController {
dlRepairTitemService.removeItemById(id);
return CommonResult.ok();
}
}

View File

@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.*;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
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;
@ -962,6 +961,14 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
throw exception0(500, "工单已开始");
}
repairWorkerService.sentMessage(reqVO.getNowRepairId(), "您有新的工单要处理");
//最后记录操作日志--指派施工
String code = RecordTypeEnum.ZPSG.getCode();
String remark ="指派施工";
if(StringUtils.isNotEmpty(reqVO.getOperateCode())){
code = reqVO.getOperateCode();
remark = "维修完成移交下一班组维修";
}
repairRecordsService.saveRepairRecord(reqVO.getId(), null,code, remark, null);
// 获取当前操作人的身份
String userRole = getUserRole();
// 总检

View File

@ -421,6 +421,15 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
}));
// 要操作的库存数据
List<RepairWares> wares = repairWaresService.list(new LambdaQueryWrapper<RepairWares>().in(RepairWares::getId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())));
Map<String,String> waresNameMap = wares.stream().collect(Collectors.toMap(RepairWares::getId,RepairWares::getName));
String remarkStr="";
for(DlRepairSoi item:respVO.getRepairSois()){
//组装通知领取配件的文字
if(!"".equals(remarkStr)){
remarkStr +=";";
}
remarkStr += waresNameMap.get(item.getGoodsId())+"x"+item.getGoodsCount();
}
if (type.equals("02")) { // 领料
// 构造新数据
List<DlTwItem> newData = oldData.stream().map(item -> {
@ -512,7 +521,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
//插入记录
//最后记录操作日志--创建工单
repairRecordsService.saveRepairRecord(respVO.getTicketId(), null, "02".equals(type)?RecordTypeEnum.TZLL.getCode():RecordTypeEnum.TZTL.getCode(),
"02".equals(type)?"通知领料":"通知退料", null);
("02".equals(type)?"通知领料":"通知退料")+",配件明细:"+remarkStr, null);
// 通知维修工
// 查维修工的userId
repairWorkerService.sentMessage(respVO.getRepairId(), type.equals("02") ? "您有新的领料单需要确认" : "您有新的退料单需要确认");

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.tickets.vo;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import lombok.Data;
import java.util.List;
/**
* 维修过程中添加维修项目vo
* @author vinjor-M
* @date 14:43 2024/11/4
**/
@Data
public class AddProjVO {
/** 添加的项目信息 */
private List<DlRepairTitem> itemList;
/** 签字图片相对路径 */
private String image;
/** 备注内容 */
private String remark;
}

View File

@ -36,4 +36,7 @@ public class DlRepairTicketsReqVO extends DlRepairTickets {
/** 图片路径 */
private String image;
/** 操作类型默认是指派施工 --zpsg */
private String operateCode;
}

View File

@ -37,6 +37,17 @@
WHERE
main.deleted = 0
</select>
<select id="getByUserId" resultType="cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO">
SELECT
main.*,
sdd.label AS workerTypeStr
FROM
dl_repair_worker main
LEFT JOIN system_dict_data sdd ON sdd.dict_type = 'repair_work_type' AND main.work_type = sdd.`value`
WHERE
main.deleted = 0
AND main.user_id = #{userId}
</select>
</mapper>