Merge branch 'repair'

This commit is contained in:
Vinjor 2024-11-27 16:01:07 +08:00
commit 23c14b23ca
12 changed files with 180 additions and 47 deletions

View File

@ -18,6 +18,8 @@ public class RepairWaresRespVO extends RepairWares {
private String typeName;
/**类型名称*/
private String warehouseName;
/**计量单位名称*/
private String unitText;
/**关联子公司*/
List<String> corpIds = new ArrayList<>();

View File

@ -124,4 +124,7 @@ public class DlRepairSo extends TenantBaseDO {
*/
@TableField(exist = false)
private String licenseNumber;
/** 用户记录那些人可以看这条记录 */
private String userIds;
}

View File

@ -50,6 +50,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
/**
* 针对表dl_repair_so(采购单领料单)的数据库操作Service实现
@ -218,7 +219,17 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@Override
@DSTransactional
public void voidRepairSo(DlRepairSoReqVO repairSoReqVO) {
baseMapper.updateById(repairSoReqVO);
int update = baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
.set(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode())
.and(i ->
i.eq(DlRepairSo::getId, repairSoReqVO.getId())
.ne(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode())
.ne(DlRepairSo::getSoStatus, SoStatusEnum.PICKED.getCode())
.ne(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
));
if (update == 0) {
throw exception0(500, "该单据已有其他人操作");
}
// 下面的代码是因为这个接口还有地方在用
// 查主表
@ -325,11 +336,22 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@Override
@DSTransactional
public void confirmGet(String id, String image) {
// 更新主表状态 为已领料
DlRepairSo dlRepairSo = new DlRepairSo();
dlRepairSo.setId(id);
dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode());
baseMapper.updateById(dlRepairSo);
// 更新主表状态 为已领料 需要判断是否已经领料过了
int update = baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
.set(DlRepairSo::getSoStatus, SoStatusEnum.PICKED.getCode())
.and(i -> {
i.eq(DlRepairSo::getId, id)
.ne(DlRepairSo::getSoStatus, SoStatusEnum.PICKED.getCode())
.ne(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode());
})
);
if (update == 0) {
throw exception0(500, "该领料单已有其他人操作");
}
// DlRepairSo dlRepairSo = new DlRepairSo();
// dlRepairSo.setId(id);
// dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode());
// baseMapper.u
// 查最新的子表信息
DlRepairSo so = baseMapper.selectById(id);
@ -358,6 +380,14 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
remark += "确认领料" + String.join(";", nameAndCount);
// 记录日志
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.LL.getCode(), remark, image);
// 更新工单主表时间
if (ObjectUtil.isNotEmpty(so) && ObjectUtil.isNotEmpty(so.getTwId())){
DlTicketWares ticketWares = ticketWaresService.getById(so.getTwId());
if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())){
ticketsService.refreshUpdateTime(ticketWares.getTicketId());
}
}
}
/**
@ -371,10 +401,15 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@DSTransactional
public void confirmBack(String id, String image) {
// 更新主表
baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
int update = baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
.set(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
.eq(DlRepairSo::getId, id)
.and(i -> i.eq(DlRepairSo::getId, id)
.ne(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
.ne(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode()))
);
if (update == 0){
throw exception0(500, "该退料单已有其他人操作");
}
// 查主表
DlRepairSo newSo = baseMapper.selectById(id);
// 通知仓库
@ -394,6 +429,14 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
remark += "确认退料" + String.join(",", nameAndCount);
// 记录日志
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.TL.getCode(), remark, image);
// 更新工单主表时间
if (ObjectUtil.isNotEmpty(newSo) && ObjectUtil.isNotEmpty(newSo.getTwId())){
DlTicketWares ticketWares = ticketWaresService.getById(newSo.getTwId());
if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())){
ticketsService.refreshUpdateTime(ticketWares.getTicketId());
}
}
}
/**
@ -531,7 +574,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
AppWaresGroupVO waresGroupVO = new AppWaresGroupVO();
waresGroupVO.setSoiRespVOList(nullList);
waresGroupVO.setGroupName("未知分组");
waresGroupVO.setNums(nullList.size());
waresGroupVO.setTypeNums(nullList.size());
waresGroupVO.setNums(nullList.stream().mapToInt(DlRepairSoi::getGoodsCount).sum());
waresGroupList.add(waresGroupVO);
}
//过滤出有分类的进行分组
@ -541,7 +585,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
waresGroupVO.setSoiRespVOList(groupListMap.get(key));
waresGroupVO.setGroupName(groupListMap.get(key).get(0).getTypeName());
waresGroupVO.setGroupId(key);
waresGroupVO.setNums(groupListMap.get(key).size());
waresGroupVO.setTypeNums(groupListMap.get(key).size());
waresGroupVO.setNums(groupListMap.get(key).stream().mapToInt(DlRepairSoi::getGoodsCount).sum());
waresGroupList.add(waresGroupVO);
}
}

View File

@ -262,4 +262,13 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @param id id
**/
CustomerAndCarVO getCusAndCarById(String id);
/**
* 用于刷新工单的更新时间
*
* @author 小李
* @date 10:31 2024/11/27
* @param id 工单ID
**/
void refreshUpdateTime(String id);
}

View File

@ -443,6 +443,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
List<DictDataRespDTO> recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE);
Map<String, String> typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel));
result.setRecords(records.stream().peek(item -> item.setType(typeMap.get(item.getType()))).collect(Collectors.toList()));
// 更新主表时间
refreshUpdateTime(id);
return result;
}
@ -506,6 +510,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
repairOrderInfoService.updateById(repairOrderInfo);
// 记录日志
repairRecordsService.saveRepairRecord(one.getGoodsId(), null, RecordTypeEnum.JS.getCode(), "线下支付结算", null);
// 更新工单主表时间
refreshUpdateTime(repairTicketsRespVO.getId());
}
/**
@ -603,6 +610,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Override
@DSTransactional
public void print(HttpServletResponse response, String id) {
// 更新工单时间
refreshUpdateTime(id);
// 开始之前先计算一次工单
boolean flag = computeTicket(id);
if (!flag) {
@ -1027,6 +1038,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(worker.getWorkType())).findFirst().orElse(null);
String message = String.format("您的爱车%s已由%s %s接单了", tickets.getCarNo(), (dictDataRespDTO != null ? dictDataRespDTO.getLabel() : "维修工"), worker.getUserName());
repairWorkerService.sentMessageToCus(id, message, false);
// 更新工单主表时间
refreshUpdateTime(id);
}
/**
@ -1071,6 +1085,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
//最后记录操作日志--指派施工
repairRecordsService.saveRepairRecord(reqVO.getId(), null, code, remark, null);
}
// 更新工单主表时间
refreshUpdateTime(reqVO.getId());
}
/**
@ -1231,6 +1248,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
);
repairWorkerService.sentMessageToCus(tickets.getId(), newMessage, false);
}
// 更新工单主表时间
refreshUpdateTime(respVO.getId());
}
private String createMessage(String who, String no, String projectName, String type, String finishType, String nextName) {
@ -1281,6 +1301,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
dlRepairTickets.setId(id);
dlRepairTickets.setPartShow(show);
baseMapper.updateById(dlRepairTickets);
refreshUpdateTime(id);
}
/**
@ -1354,6 +1376,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", tickets.getRepairType());
String message = String.format("您的爱车%s已%s完成", tickets.getCarNo(), (repairType != null ? repairType.getLabel() : "维修保养"));
repairWorkerService.sentMessageToCus(tickets.getId(), message, true);
// 更新工单主表状态
refreshUpdateTime(respVO.getId());
}
/**
@ -1445,6 +1470,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 记录日志
repairRecordsService.saveRepairRecord(respVO.getId(), null, RecordTypeEnum.JSGD.getCode(), respVO.getRemark(), respVO.getImage());
// 更新工单时间
refreshUpdateTime(respVO.getId());
}
/**
@ -1554,6 +1582,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
String recordStr = noticeCusVO.getName()
+ "通知客户取车:" + message;
repairRecordsService.saveRepairRecord(noticeCusVO.getId(), null, RecordTypeEnum.TZQC.getCode(), recordStr, null);
// 更新工单主表时间
refreshUpdateTime(noticeCusVO.getId());
}
/**
@ -1662,6 +1693,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
repairOrderInfoService.updateById(orderInfo);
Long time2 = System.currentTimeMillis();
System.out.println("时间差:"+(time2-time1));
// 更新主表时间
refreshUpdateTime(ticketId);
return true;
}
@ -1839,6 +1873,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 记录日志
repairRecordsService.saveRepairRecord(respVO.getId(), null, RecordTypeEnum.JC.getCode(), respVO.getRemark(), respVO.getImage());
refreshUpdateTime(respVO.getId());
}
/**
@ -1862,6 +1898,23 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
customerAndCarVO.setCarInfo(BeanUtil.toBean(carMain, CarMainReqVO.class));
return customerAndCarVO;
}
/**
* 用于刷新工单的更新时间
*
* @author 小李
* @date 10:31 2024/11/27
* @param id 工单ID
**/
@Override
public void refreshUpdateTime(String id){
if (ObjectUtil.isNotEmpty(id)){
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getUpdateTime, LocalDateTime.now())
.eq(DlRepairTickets::getId, id)
);
}
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.tickets.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
import cn.iocoder.yudao.module.tickets.mapper.DlRepairTitemMapper;
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
@ -70,6 +71,10 @@ public class DlRepairTitemServiceImpl extends ServiceImpl<DlRepairTitemMapper, D
*/
@Override
public DlRepairTitem updateRepairAndSale(DlRepairTitem dlRepairTitem) {
// 刷新主表时间
if (ObjectUtil.isNotEmpty(dlRepairTitem.getTicketId())){
repairTicketsService.refreshUpdateTime(dlRepairTitem.getTicketId());
}
baseMapper.updateRepairAndSale(dlRepairTitem);
return dlRepairTitem;
}
@ -156,6 +161,8 @@ public class DlRepairTitemServiceImpl extends ServiceImpl<DlRepairTitemMapper, D
**/
@Override
public List<DlRepairTitemRespVO> getProjList(String ticketId,String isOpen) {
// 更新工单主表时间
repairTicketsService.refreshUpdateTime(ticketId);
return dlRepairTitemMapper.selectProjList(ticketId,isOpen);
}
}

View File

@ -243,6 +243,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
if (CollectionUtil.isNotEmpty(ids)) {
ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要审核"));
}
// 更新工单主表时间
if (ObjectUtil.isNotEmpty(respVO.getTicketId())){
repairTicketsService.refreshUpdateTime(respVO.getTicketId());
}
}
/**
@ -255,6 +260,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
@Override
@DSTransactional
public void removeTicketWares(String id) {
// 更新工单主表时间
DlTicketWares ticketWares = baseMapper.selectById(id);
if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())){
repairTicketsService.refreshUpdateTime(ticketWares.getTicketId());
}
// 删除主表
baseMapper.deleteById(id);
// 删除子表
@ -498,34 +508,18 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
// 更新库存
repairWaresService.updateBatchById(newWares);
}
// /*
// 同理通知领料的数量可能与实际需要的数量不一致需要重新计算状态
// */
// // 先查老数据领料才需要更新
// if (type.equals("02")) {
// List<DlTwItem> oldData = twItemService.list(new LambdaQueryWrapper<DlTwItem>().in(DlTwItem::getId, respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList())));
// // 构造新数据
// List<DlTwItem> newData = oldData.stream().map(item -> {
// DlTwItem dlTwItem = new DlTwItem();
// dlTwItem.setId(item.getId());
// respVO.getRepairSois().stream()
// .filter(i -> i.getGoodsId().equals(item.getWaresId()))
// .findFirst()
// .ifPresent(repairSoi -> {
// dlTwItem.setWaresCouldCount(repairSoi.getGoodsCount());
// dlTwItem.setWaresStatus(repairSoi.getGoodsCount().equals(item.getWaresCount()) ? "04" : item.getWaresStatus());
// });
// return dlTwItem;
// }).collect(Collectors.toList());
// twItemService.updateBatchById(newData);
// }
//插入记录
//最后记录操作日志--创建工单
repairRecordsService.saveRepairRecord(respVO.getTicketId(), null, "02".equals(type) ? RecordTypeEnum.TZLL.getCode() : RecordTypeEnum.TZTL.getCode(),
("02".equals(type) ? "通知领料" : "通知退料") + ",配件明细:" + remarkStr, null);
("02".equals(type) ? "通知领料" : "通知退料") + ",配件明细:" + remarkStr, respVO.getImages());
// 通知维修工
// 查维修工的userId
repairWorkerService.sentMessage(respVO.getRepairId(), type.equals("02") ? "您有新的领料单需要确认" : "您有新的退料单需要确认");
// 刷新工单主表时间
if (ObjectUtil.isNotEmpty(respVO.getTicketId())){
repairTicketsService.refreshUpdateTime(respVO.getTicketId());
}
}
/**
@ -590,6 +584,10 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
twItemService.saveBatch(list);
}
// 更新工单主表时间
if (ObjectUtil.isNotEmpty(respVO.getTicketId())){
repairTicketsService.refreshUpdateTime(respVO.getTicketId());
}
}
/**

View File

@ -199,7 +199,8 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
}
}).collect(Collectors.toList()));
waresGroupVO.setGroupName("未知分组");
waresGroupVO.setNums(nullList.size());
waresGroupVO.setTypeNums(nullList.size());
waresGroupVO.setNums(nullList.stream().mapToInt(DlTwItem::getWaresCount).sum());
waresGroupVO.setAllowNum(numArray[0]);
waresGroupVO.setNoNum(numArray[1]);
waresGroupVO.setWaitingNum(numArray[2]);
@ -229,7 +230,8 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
}).collect(Collectors.toList()));
waresGroupVO.setGroupName(groupListMap.get(key).get(0).getTypeName());
waresGroupVO.setGroupId(key);
waresGroupVO.setNums(groupListMap.get(key).size());
waresGroupVO.setTypeNums(groupListMap.get(key).size());
waresGroupVO.setNums(groupListMap.get(key).stream().mapToInt(DlTwItem::getWaresCount).sum());
waresGroupVO.setAllowNum(numArray[0]);
waresGroupVO.setNoNum(numArray[1]);
waresGroupVO.setWaitingNum(numArray[2]);

View File

@ -17,6 +17,8 @@ public class AppWaresGroupVO {
private String groupId;
/** 分组名称(分类名称) */
private String groupName;
/** 配件总类型数量 */
private Integer typeNums;
/** 配件总数量 */
private Integer nums;
/** 总价 */

View File

@ -33,4 +33,7 @@ public class DlTicketWaresRespVO extends DlTicketWares {
/** 更新配件库子表价格 */
private List<RepairWares> repairWaresList;
/** 通知领料时上传的图片 */
private String images;
}

View File

@ -13,12 +13,14 @@
drw.*,
dbt.`name` AS typeName,
dbw.`name` AS warehouseName,
sdd.label AS unit_text,
GROUP_CONCAT( bc.corp_name ) AS corpNames
FROM
dl_repair_wares drw
LEFT JOIN base_company bc ON FIND_IN_SET( bc.id, drw.corp_id ) > 0
LEFT JOIN dl_base_type dbt ON drw.type = dbt.id AND dbt.deleted = 0
LEFT JOIN dl_base_warehouse dbw ON drw.warehouse = dbw.id AND dbw.deleted = 0
LEFT JOIN system_dict_data sdd ON drw.unit = sdd.value AND sdd.dict_type='repair_unit'
<where>
drw.deleted = 0
<if test="entity.name != null and entity.name != ''">
@ -49,10 +51,12 @@
</select>
<select id="selectAllType" resultType="java.util.Map">
SELECT
tmp.type as id,
tmp.type AS id,
dbt.`name`
FROM
( SELECT DISTINCT type FROM dl_repair_wares ) tmp
LEFT JOIN dl_base_type dbt ON tmp.type = dbt.id
WHERE tmp.type is not null AND tmp.type !=''
ORDER BY dbt.create_time DESC
</select>
</mapper>

View File

@ -26,6 +26,7 @@
<result property="updater" column="updater" jdbcType="VARCHAR"/>
<result property="twId" column="tw_id" />
<result property="licenseNumber" column="license_number" />
<result property="userIds" column="user_ids" />
</resultMap>
<sql id="Base_SQL">
@ -50,7 +51,8 @@
so.update_time,
so.updater,
so.tw_id,
dtw.license_number
dtw.license_number,
so.user_ids
from dl_repair_so so
LEFT JOIN dl_ticket_wares dtw ON so.tw_id = dtw.id
where so.deleted = '0'
@ -83,11 +85,14 @@
and (so.so_no like concat('%', #{map.soNo}, '%') or so.remark like concat('%', #{map.soNo}, '%'))
</if>
<if test="map.userId != null and map.userId != ''">
and (so.user_id = #{map.userId})
and (so.user_id = #{map.userId} or find_in_set(#{map.userId}, so.user_ids) > 0)
</if>
<if test="map.mainId != null and map.mainId != ''">
and so.main_id = #{map.mainId}
</if>
<if test="map.twId != null and map.twId != ''">
and so.tw_id = #{map.twId}
</if>
order by so.create_time desc
</select>
<select id="selectCountNum" resultType="java.lang.Integer">