diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresRespVO.java index 7179757c..fbc89815 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresRespVO.java @@ -18,6 +18,8 @@ public class RepairWaresRespVO extends RepairWares { private String typeName; /**类型名称*/ private String warehouseName; + /**计量单位名称*/ + private String unitText; /**关联子公司*/ List corpIds = new ArrayList<>(); diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java index 7293b598..200b0673 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/entity/DlRepairSo.java @@ -124,4 +124,7 @@ public class DlRepairSo extends TenantBaseDO { */ @TableField(exist = false) private String licenseNumber; + + /** 用户记录那些人可以看这条记录 */ + private String userIds; } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index 2d3c7f4d..7607bf79 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -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实现 @@ -128,7 +129,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl() + .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, "该单据已有其他人操作"); + } // 下面的代码是因为这个接口还有地方在用 // 查主表 @@ -248,11 +259,11 @@ public class DlRepairSoServiceImpl extends ServiceImpl i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(repairSoiByTwItem -> { - if (so.getSoType().equals("02")){ + if (so.getSoType().equals("02")) { dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() - repairSoiByTwItem.getGoodsCount()); // 不操作配件申请表子表的状态 // dlTwItem.setWaresStatus("02"); - }else { + } else { dlTwItem.setWaresAlreadyCount(item.getWaresAlreadyCount() + repairSoiByTwItem.getGoodsCount()); } }); @@ -263,7 +274,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl i.getGoodsId().equals(wares.getId())).findFirst().ifPresent(repairSoiByWares -> { - if (so.getSoType().equals("02")){ + if (so.getSoType().equals("02")) { wares.setStock(item.getStock().add(BigDecimal.valueOf(repairSoiByWares.getGoodsCount()))); } // 采购改了入库逻辑,不能在这里扣库存 @@ -325,11 +336,22 @@ public class DlRepairSoServiceImpl extends ServiceImpl() + .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() + int update = baseMapper.update(new LambdaUpdateWrapper() .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 wareMap = filterWare.stream().collect(Collectors.toMap(DlRepairSoi::getGoodsId, soi -> soi)); //采购配件按照按照原始配件库id分组,目的取出价格---不是用wareId,是用GoodsId,wareId是仓库 - Map itemsMap = pmsWaresList.stream().collect(Collectors.toMap(DlRepairSoi::getGoodsId,soi -> soi)); + Map itemsMap = pmsWaresList.stream().collect(Collectors.toMap(DlRepairSoi::getGoodsId, soi -> soi)); waresList.forEach(item -> { DlRepairSoi filterSoi = wareMap.get(item.getId()); DlRepairSoi itemSoi = itemsMap.get(item.getId()); @@ -526,22 +569,24 @@ public class DlRepairSoServiceImpl extends ServiceImpl waresGroupList = new ArrayList<>(); if (CollectionUtil.isNotEmpty(dlRepairSoiRespVOList)) { //先过滤出itenTypeId为null或空,或者itemTypeName为null或空的,为单独一个组 - List nullList = dlRepairSoiRespVOList.stream().filter(item-> StringUtils.isEmpty(item.getTypeId()) || StringUtils.isEmpty(item.getTypeName())).collect(Collectors.toList()); + List nullList = dlRepairSoiRespVOList.stream().filter(item -> StringUtils.isEmpty(item.getTypeId()) || StringUtils.isEmpty(item.getTypeName())).collect(Collectors.toList()); if (CollectionUtil.isNotEmpty(nullList)) { 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); } //过滤出有分类的进行分组 - Map> groupListMap = dlRepairSoiRespVOList.stream().filter(item->StringUtils.isNotEmpty(item.getTypeId()) && StringUtils.isNotEmpty(item.getTypeName())).collect(Collectors.groupingBy(DlRepairSoiRespVO::getTypeId)); - for (String key:groupListMap.keySet()){ + Map> groupListMap = dlRepairSoiRespVOList.stream().filter(item -> StringUtils.isNotEmpty(item.getTypeId()) && StringUtils.isNotEmpty(item.getTypeName())).collect(Collectors.groupingBy(DlRepairSoiRespVO::getTypeId)); + for (String key : groupListMap.keySet()) { AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); 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); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java index 3194be45..e4d2115f 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/DlRepairTicketsService.java @@ -262,4 +262,13 @@ public interface DlRepairTicketsService extends IService { * @param id id **/ CustomerAndCarVO getCusAndCarById(String id); + + /** + * 用于刷新工单的更新时间 + * + * @author 小李 + * @date 10:31 2024/11/27 + * @param id 工单ID + **/ + void refreshUpdateTime(String id); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 44bf316f..4c047ff9 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -443,6 +443,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE); Map 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 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() + .set(DlRepairTickets::getUpdateTime, LocalDateTime.now()) + .eq(DlRepairTickets::getId, id) + ); + } + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java index a15315ac..24f0f6b2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java @@ -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; @@ -56,7 +57,7 @@ public class DlRepairTitemServiceImpl extends ServiceImpl getProjectList(String ticketId){ - return baseMapper.selectList(new LambdaQueryWrapper().and(item -> { + return baseMapper.selectList(new LambdaQueryWrapper().and(item -> { item.eq(DlRepairTitem::getItemType, "01") .eq(DlRepairTitem::getTicketId, ticketId); })); @@ -70,6 +71,10 @@ public class DlRepairTitemServiceImpl extends ServiceImpl getProjList(String ticketId,String isOpen) { + // 更新工单主表时间 + repairTicketsService.refreshUpdateTime(ticketId); return dlRepairTitemMapper.selectProjList(ticketId,isOpen); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java index d1acbb02..2418d9ac 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java @@ -243,6 +243,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl repairWorkerService.sentMessage(id, "您有新的配件申请单需要审核")); } + + // 更新工单主表时间 + if (ObjectUtil.isNotEmpty(respVO.getTicketId())){ + repairTicketsService.refreshUpdateTime(respVO.getTicketId()); + } } /** @@ -255,6 +260,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl oldData = twItemService.list(new LambdaQueryWrapper().in(DlTwItem::getId, respVO.getItems().stream().map(DlTwItem::getId).collect(Collectors.toList()))); -// // 构造新数据 -// List 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 } }).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 }).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]); diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java index 9f3b04ce..82f185ac 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java @@ -17,6 +17,8 @@ public class AppWaresGroupVO { private String groupId; /** 分组名称(分类名称) */ private String groupName; + /** 配件总类型数量 */ + private Integer typeNums; /** 配件总数量 */ private Integer nums; /** 总价 */ diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java index 111abd9b..1e481867 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java @@ -33,4 +33,7 @@ public class DlTicketWaresRespVO extends DlTicketWares { /** 更新配件库子表价格 */ private List repairWaresList; + + /** 通知领料时上传的图片 */ + private String images; } diff --git a/dl-module-repair/src/main/resources/mapper/project/RepairWaresMapper.xml b/dl-module-repair/src/main/resources/mapper/project/RepairWaresMapper.xml index 89679d42..a298ea5e 100644 --- a/dl-module-repair/src/main/resources/mapper/project/RepairWaresMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/project/RepairWaresMapper.xml @@ -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' drw.deleted = 0 @@ -49,10 +51,12 @@ \ No newline at end of file diff --git a/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml b/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml index e3efa60c..93546bc3 100644 --- a/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoMapper.xml @@ -26,6 +26,7 @@ + @@ -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}, '%')) - and (so.user_id = #{map.userId}) + and (so.user_id = #{map.userId} or find_in_set(#{map.userId}, so.user_ids) > 0) and so.main_id = #{map.mainId} + + and so.tw_id = #{map.twId} + order by so.create_time desc