申请配件单、审核配件单逻辑改造完成
This commit is contained in:
parent
cd258a589c
commit
4797d5d1c9
@ -62,7 +62,7 @@ public class DlTicketWaresController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增、修改
|
* 维修工新增配件申请单
|
||||||
*
|
*
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 12:14 2024/10/15
|
* @date 12:14 2024/10/15
|
||||||
|
@ -2,17 +2,13 @@ package cn.iocoder.yudao.module.tickets.entity;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工单配件申请/退回子表
|
* 工单配件申请单配件明细表
|
||||||
*
|
*
|
||||||
* @author 小李
|
* @author 小李
|
||||||
* @date 11:49 2024/10/15
|
* @date 11:49 2024/10/15
|
||||||
@ -43,6 +39,12 @@ public class DlTwItem extends TenantBaseDO {
|
|||||||
|
|
||||||
/** 配件状态:使用字典yes_no,1通过,0没通过 */
|
/** 配件状态:使用字典yes_no,1通过,0没通过 */
|
||||||
private String waresStatus;
|
private String waresStatus;
|
||||||
|
/** 配件添加人id */
|
||||||
|
private Long addUserId;
|
||||||
|
/** 配件添加人姓名 */
|
||||||
|
private String addUserName;
|
||||||
|
/** 是否仓管添加的(0否|1是) */
|
||||||
|
private Boolean ifHouseAdd;
|
||||||
|
|
||||||
/** 审核人ID(system_users的ID) */
|
/** 审核人ID(system_users的ID) */
|
||||||
private Long handleId;
|
private Long handleId;
|
||||||
|
@ -223,6 +223,10 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
twItem.setTwId(ticketWares.getId());
|
twItem.setTwId(ticketWares.getId());
|
||||||
twItem.setWaresStatus("");
|
twItem.setWaresStatus("");
|
||||||
twItem.setWaresAlreadyCount(0);
|
twItem.setWaresAlreadyCount(0);
|
||||||
|
//非仓管添加
|
||||||
|
twItem.setIfHouseAdd(false);
|
||||||
|
twItem.setAddUserId(customerMain.getUserId());
|
||||||
|
twItem.setAddUserName(customerMain.getCusName());
|
||||||
return twItem;
|
return twItem;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
if (CollectionUtil.isEmpty(list)) {
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
@ -289,7 +293,6 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
List<DlTwItem> twItems = twItemService.listByIds(twItemIds);
|
List<DlTwItem> twItems = twItemService.listByIds(twItemIds);
|
||||||
// 取所有的配件信息
|
// 取所有的配件信息
|
||||||
List<String> wareIds = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toList());
|
List<String> wareIds = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toList());
|
||||||
List<RepairWares> repairWares = repairWaresService.listByIds(wareIds);
|
|
||||||
// 更新配件申请表子表
|
// 更新配件申请表子表
|
||||||
List<DlTwItem> newTwitems = twItemIds.stream().map(item -> {
|
List<DlTwItem> newTwitems = twItemIds.stream().map(item -> {
|
||||||
DlTwItem twItem = new DlTwItem();
|
DlTwItem twItem = new DlTwItem();
|
||||||
@ -307,68 +310,70 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
|||||||
if (isStatus) {
|
if (isStatus) {
|
||||||
baseMapper.update(new LambdaUpdateWrapper<DlTicketWares>().set(DlTicketWares::getStatus, "02").eq(DlTicketWares::getId, respVO.getId()));
|
baseMapper.update(new LambdaUpdateWrapper<DlTicketWares>().set(DlTicketWares::getStatus, "02").eq(DlTicketWares::getId, respVO.getId()));
|
||||||
}
|
}
|
||||||
// 更新维修工单子表
|
/* 审核配件申请单暂时不操作工单子表 */
|
||||||
if (status.equals("01")) {
|
// // 更新维修工单子表
|
||||||
DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
|
// List<RepairWares> repairWares = repairWaresService.listByIds(wareIds);
|
||||||
List<DlRepairTitem> titems = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
// if (status.equals("01")) {
|
||||||
i.in(DlRepairTitem::getTicketId, ticketWares.getTicketId())
|
// DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
|
||||||
.eq(DlRepairTitem::getItemType, "02");
|
// List<DlRepairTitem> titems = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
||||||
}));
|
// i.in(DlRepairTitem::getTicketId, ticketWares.getTicketId())
|
||||||
// 要修改的
|
// .eq(DlRepairTitem::getItemType, "02");
|
||||||
List<DlRepairTitem> updateTitems = titems.stream().filter(item -> wareIds.contains(item.getPartId())).collect(Collectors.toList());
|
// }));
|
||||||
// 修改
|
// // 要修改的
|
||||||
if (CollectionUtil.isNotEmpty(updateTitems)) {
|
// List<DlRepairTitem> updateTitems = titems.stream().filter(item -> wareIds.contains(item.getPartId())).collect(Collectors.toList());
|
||||||
List<DlRepairTitem> newTitems = updateTitems.stream().map(item -> {
|
// // 修改
|
||||||
DlRepairTitem titem = new DlRepairTitem();
|
// if (CollectionUtil.isNotEmpty(updateTitems)) {
|
||||||
titem.setId(item.getId());
|
// List<DlRepairTitem> newTitems = updateTitems.stream().map(item -> {
|
||||||
DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).findFirst().orElse(null);
|
// DlRepairTitem titem = new DlRepairTitem();
|
||||||
if (twItem != null) {
|
// titem.setId(item.getId());
|
||||||
titem.setItemCount(item.getItemCount() + twItem.getWaresCount());
|
// DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).findFirst().orElse(null);
|
||||||
titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(item.getItemDiscount()));
|
// if (twItem != null) {
|
||||||
}
|
// titem.setItemCount(item.getItemCount() + twItem.getWaresCount());
|
||||||
return titem;
|
// titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(item.getItemDiscount()));
|
||||||
}).collect(Collectors.toList());
|
// }
|
||||||
repairTitemService.updateBatchById(newTitems);
|
// return titem;
|
||||||
}
|
// }).collect(Collectors.toList());
|
||||||
// 要新增的
|
// repairTitemService.updateBatchById(newTitems);
|
||||||
if (updateTitems.size() < wareIds.size()) {
|
// }
|
||||||
List<String> titemIds = updateTitems.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList());
|
// // 要新增的
|
||||||
List<RepairWares> newWares = repairWares.stream().filter(item -> !titemIds.contains(item.getId())).collect(Collectors.toList());
|
// if (updateTitems.size() < wareIds.size()) {
|
||||||
// 新增
|
// List<String> titemIds = updateTitems.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList());
|
||||||
List<DlRepairTitem> newTitems = newWares.stream().map(item -> {
|
// List<RepairWares> newWares = repairWares.stream().filter(item -> !titemIds.contains(item.getId())).collect(Collectors.toList());
|
||||||
DlRepairTitem titem = new DlRepairTitem();
|
// // 新增
|
||||||
titem.setTicketId(ticketWares.getTicketId());
|
// List<DlRepairTitem> newTitems = newWares.stream().map(item -> {
|
||||||
titem.setItemType("02");
|
// DlRepairTitem titem = new DlRepairTitem();
|
||||||
titem.setItemName(item.getName());
|
// titem.setTicketId(ticketWares.getTicketId());
|
||||||
DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null);
|
// titem.setItemType("02");
|
||||||
titem.setItemCount(twItem != null ? twItem.getWaresCount() : 0);
|
// titem.setItemName(item.getName());
|
||||||
titem.setItemUnit(item.getUnit());
|
// DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null);
|
||||||
titem.setItemPrice((item.getPrice() != null) ? item.getPrice() : BigDecimal.ZERO);
|
// titem.setItemCount(twItem != null ? twItem.getWaresCount() : 0);
|
||||||
titem.setItemDiscount(BigDecimal.ONE);
|
// titem.setItemUnit(item.getUnit());
|
||||||
titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount()));
|
// titem.setItemPrice((item.getPrice() != null) ? item.getPrice() : BigDecimal.ZERO);
|
||||||
titem.setRepairIds(String.valueOf(ticketWares.getRepairId()));
|
// titem.setItemDiscount(BigDecimal.ONE);
|
||||||
titem.setRepairNames(ticketWares.getRepairName());
|
// titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount()));
|
||||||
titem.setSaleId(ticketWares.getAdviserId());
|
// titem.setRepairIds(String.valueOf(ticketWares.getRepairId()));
|
||||||
titem.setSaleName(ticketWares.getAdviserName());
|
// titem.setRepairNames(ticketWares.getRepairName());
|
||||||
titem.setPartId(item.getId());
|
// titem.setSaleId(ticketWares.getAdviserId());
|
||||||
titem.setItemStatus("04");
|
// titem.setSaleName(ticketWares.getAdviserName());
|
||||||
titem.setRemark(twItem != null ? twItem.getRemark() : null);
|
// titem.setPartId(item.getId());
|
||||||
return titem;
|
// titem.setItemStatus("04");
|
||||||
}).collect(Collectors.toList());
|
// titem.setRemark(twItem != null ? twItem.getRemark() : null);
|
||||||
repairTitemService.saveBatch(newTitems);
|
// return titem;
|
||||||
}
|
// }).collect(Collectors.toList());
|
||||||
// 更新维修工单主表
|
// repairTitemService.saveBatch(newTitems);
|
||||||
boolean flag = repairTicketsService.computeTicket(ticketWares.getTicketId());
|
// }
|
||||||
if (!flag) {
|
// // 更新维修工单主表
|
||||||
throw exception0(500, "重新计算工单错误");
|
// boolean flag = repairTicketsService.computeTicket(ticketWares.getTicketId());
|
||||||
}
|
// if (!flag) {
|
||||||
// 发送通过的消息给仓库
|
// throw exception0(500, "重新计算工单错误");
|
||||||
RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode());
|
// }
|
||||||
List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());
|
// // 发送通过的消息给仓库
|
||||||
if (CollectionUtil.isNotEmpty(ids)) {
|
// RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode());
|
||||||
ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要处理"));
|
// List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());
|
||||||
}
|
// if (CollectionUtil.isNotEmpty(ids)) {
|
||||||
}
|
// ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要处理"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// 通知维修工
|
// 通知维修工
|
||||||
DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
|
DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
|
||||||
repairWorkerService.sentMessage(ticketWares.getRepairId(), "您有新的配件申请单" + (status.equals("01") ? "审批通过了" : "被驳回了"));
|
repairWorkerService.sentMessage(ticketWares.getRepairId(), "您有新的配件申请单" + (status.equals("01") ? "审批通过了" : "被驳回了"));
|
||||||
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.tickets.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.project.entity.RepairWares;
|
import cn.iocoder.yudao.module.project.entity.RepairWares;
|
||||||
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||||
@ -101,6 +103,7 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
|
|||||||
**/
|
**/
|
||||||
@Override
|
@Override
|
||||||
public void addTwi(AddTwiVO addTwiVO){
|
public void addTwi(AddTwiVO addTwiVO){
|
||||||
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
// 构建子表数据
|
// 构建子表数据
|
||||||
if (CollectionUtil.isEmpty(addTwiVO.getItems())){
|
if (CollectionUtil.isEmpty(addTwiVO.getItems())){
|
||||||
throw exception0(500, "请选择配件");
|
throw exception0(500, "请选择配件");
|
||||||
@ -125,6 +128,9 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
|
|||||||
twItem.setWaresId(item.getId());
|
twItem.setWaresId(item.getId());
|
||||||
twItem.setWaresName(item.getName());
|
twItem.setWaresName(item.getName());
|
||||||
twItem.setWaresCount(item.getCount());
|
twItem.setWaresCount(item.getCount());
|
||||||
|
twItem.setAddUserId(loginUser.getId());
|
||||||
|
twItem.setAddUserName(loginUser.getInfo().get("nickname"));
|
||||||
|
twItem.setIfHouseAdd(false);
|
||||||
twItem.setWaresAlreadyCount(0);
|
twItem.setWaresAlreadyCount(0);
|
||||||
twItem.setWaresStatus("");
|
twItem.setWaresStatus("");
|
||||||
twItem.setRemark(item.getRemark());
|
twItem.setRemark(item.getRemark());
|
||||||
@ -152,6 +158,9 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
|
|||||||
twItem.setWaresId(item.getId());
|
twItem.setWaresId(item.getId());
|
||||||
twItem.setWaresName(item.getName());
|
twItem.setWaresName(item.getName());
|
||||||
twItem.setWaresCount(item.getCount());
|
twItem.setWaresCount(item.getCount());
|
||||||
|
twItem.setAddUserId(loginUser.getId());
|
||||||
|
twItem.setAddUserName(loginUser.getInfo().get("nickname"));
|
||||||
|
twItem.setIfHouseAdd(false);
|
||||||
twItem.setWaresAlreadyCount(0);
|
twItem.setWaresAlreadyCount(0);
|
||||||
twItem.setWaresStatus("");
|
twItem.setWaresStatus("");
|
||||||
twItem.setRemark(item.getRemark());
|
twItem.setRemark(item.getRemark());
|
||||||
|
Loading…
Reference in New Issue
Block a user