修改员工确认领料、退料
This commit is contained in:
parent
4436bb236f
commit
6a761fb4b3
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
* 采购入库
|
||||
|
@ -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,51 +315,13 @@ 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));
|
||||
List<DlTwItem> list = twItemService.list(new LambdaQueryWrapper<DlTwItem>().eq(DlTwItem::getTwId, so.getTwId()));
|
||||
@ -369,6 +337,12 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
DlRepairSo newSo = baseMapper.selectById(id);
|
||||
// 通知仓库
|
||||
repairWorkerService.sentMessage(Long.valueOf(newSo.getCreator()), newSo.getUserName() + "已确认领料单:" + newSo.getSoNo());
|
||||
|
||||
// 记录日志
|
||||
// 查配件申请表
|
||||
DlTicketWares byId = ticketWaresService.getById(so.getTwId());
|
||||
// 记录日志
|
||||
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.LL.getCode(), null, image);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -380,105 +354,21 @@ 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());
|
||||
// 记录日志
|
||||
// 查申请表
|
||||
DlTicketWares byId = ticketWaresService.getById(newSo.getTwId());
|
||||
// 记录日志
|
||||
recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.TL.getCode(), null, image);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user