This commit is contained in:
Vinjor 2024-11-04 18:11:01 +08:00
commit 36e140f7f1
8 changed files with 86 additions and 153 deletions

View File

@ -68,7 +68,13 @@ public enum RecordTypeEnum {
/**
* 接单
*/
jd("jd","接单");
jd("jd","接单"),
/** 作废工单 */
ZFGG("zfgg", "作废工单"),
/** 删除工单 */
SCGG("scgg", "删除工单");
/**
* code

View File

@ -97,8 +97,8 @@ public class DlRepairSoController {
**/
@GetMapping("/confirmGet")
@Operation(summary = "员工确认领料")
public CommonResult<?> confirmGet(@RequestParam("id") String id) {
dlRepairSoService.confirmGet(id);
public CommonResult<?> confirmGet(@RequestParam("id") String id, @RequestParam(value = "image", required = false) String image) {
dlRepairSoService.confirmGet(id, image);
return CommonResult.ok();
}
@ -111,8 +111,8 @@ public class DlRepairSoController {
**/
@GetMapping("/confirmBack")
@Operation(summary = "员工确认退料")
public CommonResult<?> confirmBack(@RequestParam("id") String id) {
dlRepairSoService.confirmBack(id);
public CommonResult<?> confirmBack(@RequestParam("id") String id, @RequestParam(value = "image", required = false) String image) {
dlRepairSoService.confirmBack(id, image);
return CommonResult.ok();
}

View File

@ -58,7 +58,7 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
* @author 小李
* @date 11:58 2024/10/21
**/
void confirmGet(String id);
void confirmGet(String id, String image);
/**
* 员工确认退料
@ -67,7 +67,7 @@ public interface DlRepairSoService extends IService<DlRepairSo> {
* @author 小李
* @date 19:41 2024/10/21
**/
void confirmBack(String id);
void confirmBack(String id, String image);
/**
* 采购入库

View File

@ -3,9 +3,11 @@ package cn.iocoder.yudao.module.stockOperate.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.RecordTypeEnum;
import cn.iocoder.yudao.common.RepairErrorCodeConstants;
import cn.iocoder.yudao.common.SoStatusEnum;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.service.CompanyService;
@ -99,6 +101,10 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@Lazy
private RepairWaresService repairWaresService;
@Resource
@Lazy
private RepairRecordsService recordsService;
/**
* 采购单/领料单 新增
*
@ -309,53 +315,15 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
**/
@Override
@DSTransactional
public void confirmGet(String id) {
// 查子表
List<DlRepairSoi> sois = repairSoiService
.list(new LambdaQueryWrapper<DlRepairSoi>()
.eq(DlRepairSoi::getSoId, id)
);
// 查库存---生成领料单的时候更新了
// List<RepairWares> wares = waresService
// .list(new LambdaQueryWrapper<RepairWares>()
// .in(RepairWares::getId, sois.stream()
// .map(DlRepairSoi::getGoodsId)
// .collect(Collectors.toList())
// ));
// // 更新库存
// List<RepairWares> newWares = wares.stream().map(item -> {
// RepairWares ware = new RepairWares();
// ware.setId(item.getId());
// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> {
// ware.setStock(item.getStock().subtract(BigDecimal.valueOf(i.getGoodsCount())));
// });
// return ware;
// }).collect(Collectors.toList());
// waresService.updateBatchById(newWares);
public void confirmGet(String id, String image) {
// 更新主表状态 为已领料
DlRepairSo dlRepairSo = new DlRepairSo();
dlRepairSo.setId(id);
dlRepairSo.setSoStatus(SoStatusEnum.PICKED.getCode());
baseMapper.updateById(dlRepairSo);
// 更新申请表的数据----生成领料单的时候更新了
// // 查申请表的子表对应的配件信息
// List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
// item.eq(DlTwItem::getTwId, so.getTwId())
// .in(DlTwItem::getWaresId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
// }));
// // 更新子表
// List<DlTwItem> newTwItems = twItems.stream().map(item -> {
// DlTwItem dlTwItem = new DlTwItem();
// dlTwItem.setId(item.getId());
// dlTwItem.setWaresAlreadyCount(ObjectUtil.isNotEmpty(item.getWaresAlreadyCount()) ? item.getWaresAlreadyCount() + item.getWaresCouldCount() : item.getWaresCouldCount());
// dlTwItem.setWaresStatus(dlTwItem.getWaresAlreadyCount().equals(item.getWaresCount()) ? "01" : item.getWaresStatus());
// return dlTwItem;
// }).collect(Collectors.toList());
// twItemService.updateBatchById(newTwItems);
// 查最新的子表信息
DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper<DlRepairSo>().eq(DlRepairSo::getId, id));
DlRepairSo so = baseMapper.selectById(id);
List<DlTwItem> list = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
// 判断是部分完成还是全部完成
DlTicketWares dlTicketWares = new DlTicketWares();
@ -365,10 +333,22 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
// 更新主表的状态
ticketWaresService.updateById(dlTicketWares);
// 查主表记录
DlRepairSo newSo = baseMapper.selectById(id);
// 通知仓库
repairWorkerService.sentMessage(Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认领料单:" + newSo.getSoNo());
repairWorkerService.sentMessage(Long.valueOf(so.getCreator()), so.getUserName() + "已确认领料单:" + so.getSoNo());
// 记录日志
// 查配件申请表
DlTicketWares byId = ticketWaresService.getById(so.getTwId());
// 取当前操作人的名称
String remark = SecurityFrameworkUtils.getLoginUserNickname();
// 构建备注
/*
领了什么配件领了多少个
*/
List<String> nameAndCount = list.stream().map(item -> item.getWaresName() + "(" + item.getWaresCount() + ")").collect(Collectors.toList());
remark += "确认领料" + String.join(",", nameAndCount);
// 记录日志
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.LL.getCode(), remark, image);
}
/**
@ -380,105 +360,31 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
**/
@Override
@DSTransactional
public void confirmBack(String id) {
public void confirmBack(String id, String image) {
// 更新主表
baseMapper.update(new LambdaUpdateWrapper<DlRepairSo>()
.set(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode())
.eq(DlRepairSo::getId, id)
);
// 更新配件申请表----生成退料单的时候更新了
// DlRepairSo so = baseMapper.selectOne(new LambdaQueryWrapper<DlRepairSo>().eq(DlRepairSo::getId, id));
// // 查配件退料表子表
// List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, so.getId()));
// // 查申请表子表
// List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
// // 得到需要更新的数据
// List<DlTwItem> newTwItems = twItems.stream().map(item -> {
// DlTwItem dlTwItem = new DlTwItem();
// dlTwItem.setId(item.getId());
// sois.stream().filter(i -> i.getGoodsId().equals(item.getWaresId())).findFirst().ifPresent(i -> {
// dlTwItem.setWaresBackCount(
// ObjectUtil.isNotEmpty(item.getWaresBackCount())
// ? item.getWaresCount() + item.getWaresBackCount()
// : i.getGoodsCount());
// // 如果退料数就是领料申请数那就是全退了
// if (i.getGoodsCount().equals(dlTwItem.getWaresCount())) {
// dlTwItem.setWaresStatus("03");
// }
// });
// return dlTwItem;
// }).collect(Collectors.toList());
// twItemService.updateBatchById(newTwItems);
// // 更新库存
// // 查库存
// List<RepairWares> wares = waresService.list(new LambdaQueryWrapper<RepairWares>().in(RepairWares::getId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())));
// // 构建新数据
// List<RepairWares> newWares = wares.stream().map(item -> {
// RepairWares ware = new RepairWares();
// ware.setId(item.getId());
// sois.stream().filter(i -> i.getGoodsId().equals(item.getId())).findFirst().ifPresent(i -> {
// ware.setStock(item.getStock().add(BigDecimal.valueOf(i.getGoodsCount())));
// });
// return ware;
// }).collect(Collectors.toList());
// waresService.updateBatchById(newWares);
// 更新维修工单----最后完成工单的时候来更新
// // 查配件退料表子表
// List<DlRepairSoi> sois = repairSoiService.list(new LambdaQueryWrapper<DlRepairSoi>().eq(DlRepairSoi::getSoId, so.getId()));
// // 查申请表主表
// DlTicketWares ticketWares = ticketWaresService.getOne(new LambdaQueryWrapper<DlTicketWares>().eq(DlTicketWares::getId, so.getTwId()));
// // 查维修工单子表为配件的数据
// List<DlRepairTitem> titems = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
// item.eq(DlRepairTitem::getTicketId, ticketWares.getTicketId())
// .eq(DlRepairTitem::getItemType, "02")
// .in(DlRepairTitem::getPartId, sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()));
// }));
// // 构建新数据更新维修工单子表
// List<DlRepairTitem> newTitems = titems.stream().map(item -> {
// DlRepairTitem titem = new DlRepairTitem();
// titem.setId(item.getId());
// sois.stream().filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst().ifPresent(i -> {
// titem.setItemCount(item.getItemCount() - i.getGoodsCount());
// BigDecimal itemDiscount = ObjectUtil.isNotEmpty(item.getItemDiscount()) ? item.getItemDiscount() : BigDecimal.ONE;
// titem.setItemMoney(new BigDecimal(titem.getItemCount()).multiply(item.getItemPrice()).multiply(itemDiscount));
// });
// return titem;
// }).collect(Collectors.toList());
// // 分开全部退料了的和没有全部退料的数据
// List<DlRepairTitem> delTitems = newTitems.stream().filter(item -> item.getItemCount() == 0).collect(Collectors.toList());
// if (CollectionUtil.isEmpty(delTitems)) {
// titemService.updateBatchById(newTitems);
// } else {
// titemService.removeBatchByIds(delTitems);
// List<DlRepairTitem> updateTitems = newTitems.stream().filter(item -> !delTitems.contains(item)).collect(Collectors.toList());
// if (CollectionUtil.isEmpty(updateTitems)) {
// titemService.updateBatchById(updateTitems);
// }
//
// }
// // 更新维修工单
// DlRepairTickets tickets = ticketsService.getOne(new LambdaQueryWrapper<DlRepairTickets>().eq(DlRepairTickets::getId, ticketWares.getTicketId()));
// // 查最新的子表信息
// List<DlRepairTitem> list = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().in(DlRepairTitem::getTicketId, tickets.getId()));
// // 计算工单总子项工单配件总价工单总价
// DlRepairTickets newTickets = new DlRepairTickets();
// newTickets.setId(tickets.getId());
// newTickets.setCount(list.stream().mapToInt(DlRepairTitem::getItemCount).sum());
// newTickets.setPartPrice(list.stream()
// .filter(item -> item.getItemType().equals("02"))
// .map(DlRepairTitem::getItemMoney)
// .reduce(BigDecimal.ZERO, BigDecimal::add));
// BigDecimal projectPrice = tickets.getProjectPrice() == null ? BigDecimal.ZERO : tickets.getProjectPrice();
// BigDecimal otherPrice = tickets.getOtherPrice() != null ? tickets.getOtherPrice() : BigDecimal.ZERO;
// BigDecimal partPrice = newTickets.getPartPrice() == null ? BigDecimal.ZERO : newTickets.getPartPrice();
// newTickets.setTotalPrice(projectPrice.add(partPrice).add(otherPrice));
// ticketsService.updateById(newTickets);
// 查主表
DlRepairSo newSo = baseMapper.selectById(id);
// 通知仓库
repairWorkerService.sentMessage(Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认退料单:" + newSo.getSoNo());
// 记录日志
// 查子表信息
List<DlTwItem> list = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, newSo.getTwId()));
// 查申请表
DlTicketWares byId = ticketWaresService.getById(newSo.getTwId());
// 取当前操作人的名称
String remark = SecurityFrameworkUtils.getLoginUserNickname();
// 构建备注
/*
退了什么配件退了多少个
*/
List<String> nameAndCount = list.stream().map(item -> item.getWaresName() + "(" + item.getWaresCount() + ")").collect(Collectors.toList());
remark += "确认退料" + String.join(",", nameAndCount);
// 记录日志
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.TL.getCode(), remark, image);
}
/**

View File

@ -200,8 +200,10 @@ public class DlRepairTicketsController {
**/
@GetMapping("/take")
@Operation(summary = "接单")
public CommonResult<?> updateTake(@RequestParam("id") String id) {
dlRepairTicketsService.updateTake(id);
public CommonResult<?> updateTake(@RequestParam("id") String id,
@RequestParam(value="image",required = false) String image,
@RequestParam(value="remark",required = false) String remark) {
dlRepairTicketsService.updateTake(id,image);
return CommonResult.ok();
}

View File

@ -131,7 +131,7 @@ public class DlTicketWaresController {
/**
* 员工确认领料
*
* 弃用
* @author 小李
* @date 22:07 2024/10/16
* @param respVO 请求对象
@ -145,7 +145,7 @@ public class DlTicketWaresController {
/**
* 仓库确认退料
*
* 弃用
* @author 小李
* @date 22:03 2024/10/17
* @param respVO 请求对象

View File

@ -108,7 +108,7 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @date 11:48 2024/10/14
* @param id 工单ID
**/
void updateTake(String id);
void updateTake(String id,String image);
/**
* 指派员工通知施工

View File

@ -5,9 +5,8 @@ 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.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
@ -383,14 +382,27 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
/**
* 维修工单表 作废
* 传对象是因为需要有作废备注
*
* @param repairTicketsReqVO 工单对象
* @author 小李
* @date 19:46 2024/9/22
**/
@Override
@DSTransactional
public void setTicketsVoid(DlRepairTicketsReqVO repairTicketsReqVO) {
baseMapper.updateById(repairTicketsReqVO);
// 作废维修工单
DlRepairTickets tickets = new DlRepairTickets();
tickets.setId(repairTicketsReqVO.getId());
if (ObjectUtil.isNotEmpty(repairTicketsReqVO.getRemark())){
tickets.setRemark(repairTicketsReqVO.getRemark());
}
tickets.setTicketsStatus("03");
baseMapper.updateById(tickets);
// 删除订单
repairOrderInfoService.remove(new LambdaQueryWrapper<RepairOrderInfo>().eq(RepairOrderInfo::getGoodsId, repairTicketsReqVO.getId()));
// 记录日志
repairRecordsService.saveRepairRecord(repairTicketsReqVO.getId(), null, RecordTypeEnum.ZFGG.getCode(), repairTicketsReqVO.getRemark(), null);
}
/**
@ -413,6 +425,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
repairOrderInfo.setPayType(repairTicketsRespVO.getPayType());
repairOrderInfoService.updateById(repairOrderInfo);
// 更新工单
// 在这里把工单的状态更新为已完成
repairTicketsRespVO.setIsFinish("1");
baseMapper.updateById(repairTicketsRespVO);
}
@ -910,7 +924,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
* @date 11:48 2024/10/14
**/
@Override
public void updateTake(String id) {
public void updateTake(String id,String image) {
// 改变时看看是否已经被接了
int update = baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getTicketsWorkStatus, TicketsWorkStatusEnum.RECEIVED.getCode())
@ -922,7 +936,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
throw exception0(500, "工单已被其他人接单了");
}
//最后记录操作日志--接单
repairRecordsService.saveRepairRecord(id, null, RecordTypeEnum.jd.getCode(), "接单", null);
repairRecordsService.saveRepairRecord(id, null, RecordTypeEnum.jd.getCode(), "接单", image);
}
/**
@ -1115,11 +1129,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 维修服务顾问
if (userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())) {
repairTicketsReqVO.setNowRepairId(loginUserId);
repairTicketsReqVO.setIsFinish("1");
// 因为完成状态需要在交车之后所以注掉这个
// repairTicketsReqVO.setIsFinish("1");
} else if (userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())) {
// 总检
repairTicketsReqVO.setNowRepairId(loginUserId);
repairTicketsReqVO.setIsFinish("0");
// 因为完成状态需要在交车之后所以注掉这个
// repairTicketsReqVO.setIsFinish("0");
} else {
return null;
}
@ -1141,7 +1157,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
repairRecordsService.saveRepairRecord(respVO.getId(), null, RecordTypeEnum.ZJ.getCode(), respVO.getRemark(), respVO.getImage());
// 更新工单
baseMapper.update(new LambdaUpdateWrapper<DlRepairTickets>()
.set(DlRepairTickets::getIsFinish, "1")
// 因为完成状态需要在交车之后所以注掉这个
// .set(DlRepairTickets::getIsFinish, "1")
.setSql("now_repair_id = adviser_id")
.setSql("now_repair_name = adviser_name")
.eq(DlRepairTickets::getId, respVO.getId())
@ -1546,6 +1563,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
baseMapper.deleteById(id);
// 删除工单子表
titemService.remove(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, id));
// 记录操作日志
repairRecordsService.saveRepairRecord(id, null, RecordTypeEnum.SCGG.getCode(), null, null);
}
}