This commit is contained in:
Vinjor 2024-10-25 18:12:22 +08:00
commit 47f55f5ce1
6 changed files with 255 additions and 147 deletions

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.supplier.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO;
@ -9,8 +8,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
/**
* 供应商 Service 接口
*
@ -28,6 +25,15 @@ public interface BaseSupplierService extends IService<BaseSupplier> {
**/
void saveBaseSupplier(BaseSupplierSaveReqVO saveReqVO);
/**
* 生成采购单选择供应商
* @author PQZ
* @date 17:43 2024/10/25
* @param supplierName 供应商名称
* @return java.lang.String
**/
String appSaveSupplier(String supplierName);
/**
* 删除供应商信息
*

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.supplier.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplier;
import cn.iocoder.yudao.module.supplier.entity.BaseSupplierAccount;
import cn.iocoder.yudao.module.supplier.mapper.BaseSupplierMapper;
@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.supplier.service.BaseSupplierService;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO;
import cn.iocoder.yudao.module.supplier.vo.BaseSupplierSaveReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -51,6 +52,30 @@ public class BaseSupplierServiceImpl extends ServiceImpl<BaseSupplierMapper, Bas
baseSupplierAccountService.saveBaseSupplierAccount(baseSupplier.getId(),saveReqVO.getAccountList());
}
/**
* 生成采购单选择供应商
*
* @param supplierName 供应商名称
* @return java.lang.String
* @author PQZ
* @date 17:43 2024/10/25
**/
@Override
public String appSaveSupplier(String supplierName) {
LambdaQueryWrapper<BaseSupplier> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BaseDO::getDeleted,0).eq(BaseSupplier::getName,supplierName);
List<BaseSupplier> list = list(lambdaQueryWrapper);
if (!list.isEmpty()){
//存在供应商
return list.get(0).getId();
} else {
BaseSupplier supplier = new BaseSupplier();
supplier.setName(supplierName);
save(supplier);
return supplier.getId();
}
}
/**
* 删除供应商信息

View File

@ -47,8 +47,8 @@ public class DlRepairSoController {
* 采购单/领料单新增分页
*
* @param repairSoReqVO 查询对象
* @param pageNo 页码
* @param pageSize 条数
* @param pageNo 页码
* @param pageSize 条数
* @author 小李
* @date 18:14 2024/9/14
**/
@ -64,10 +64,10 @@ public class DlRepairSoController {
/**
* 采购单/领料单 作废
*
* @param repairSoReqVO 作废对象
* @author 小李
* @date 11:12 2024/9/18
* @param repairSoReqVO 作废对象
**/
**/
@PostMapping("/void")
@Operation(summary = "采购单/领料单 作废")
public CommonResult<?> voidRepairSo(@RequestBody DlRepairSoReqVO repairSoReqVO) {
@ -78,26 +78,26 @@ public class DlRepairSoController {
/**
* 采购单/领料单 查看
*
* @param id 主键
* @author 小李
* @date 9:34 2024/9/22
* @param id 主键
**/
**/
@GetMapping("/get")
@Operation(summary = "采购单/领料单 查看")
public CommonResult<?> getRepairSoById(@RequestParam("id") String id){
public CommonResult<?> getRepairSoById(@RequestParam("id") String id) {
return success(dlRepairSoService.getRepairSoById(id));
}
/**
* 员工确认领料
*
* @param id 单据ID 领料单主表
* @author 小李
* @date 11:58 2024/10/21
* @param id 单据ID 领料单主表
**/
**/
@GetMapping("/confirmGet")
@Operation(summary = "员工确认领料")
public CommonResult<?> confirmGet(@RequestParam("id") String id){
public CommonResult<?> confirmGet(@RequestParam("id") String id) {
dlRepairSoService.confirmGet(id);
return CommonResult.ok();
}
@ -105,15 +105,31 @@ public class DlRepairSoController {
/**
* 员工确认退料
*
* @param id 退料单主表ID
* @author 小李
* @date 19:41 2024/10/21
* @param id 退料单主表ID
**/
**/
@GetMapping("/confirmBack")
@Operation(summary = "员工确认退料")
public CommonResult<?> confirmBack(@RequestParam("id") String id){
public CommonResult<?> confirmBack(@RequestParam("id") String id) {
dlRepairSoService.confirmBack(id);
return CommonResult.ok();
}
/**
* 采购入库
*
* @param repairSoReqVO DlRepairSoReqVO实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
* @author PQZ
* @date 10:43 2024/10/25
**/
@PostMapping("/inWare")
@Operation(summary = "采购入库")
public CommonResult<?> inWare(@RequestBody DlRepairSoReqVO repairSoReqVO) {
dlRepairSoService.inWare(repairSoReqVO);
return CommonResult.ok();
}
}

View File

@ -18,6 +18,7 @@ import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService;
import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoiService;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO;
import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO;
import cn.iocoder.yudao.module.supplier.service.BaseSupplierService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -36,6 +37,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -91,6 +93,8 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
private RepairWorkerService repairWorkerService;
@Resource
private AdminUserApi userApi;
@Resource
private BaseSupplierService supplierService;
/**
* 采购单/领料单 新增
@ -103,6 +107,16 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
@Override
public void createRepairSo(DlRepairSoRespVO repairSoRespVO) {
repairSoRespVO.setSoTime(new Date());
//保存供应商
if (repairSoRespVO.getSupplierId() == null){
//采购单中录入供应商或无供应商情况
if (StringUtils.isNotEmpty(repairSoRespVO.getSupplierName())){
//没有选择直接录入的情况
String supplierId = supplierService.appSaveSupplier(repairSoRespVO.getSupplierName());
//为供应商id赋值
repairSoRespVO.setSupplierId(supplierId);
}
}
// 取当前登录用户的门店信息
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
repairSoRespVO.setDeptId(deptId);

View File

@ -775,46 +775,51 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
.setSql("now_repair_name = adviser_name")
.eq(DlRepairTickets::getId, respVO.getId())
);
// todo 这儿有点问题先搁置
/*
如果同一个配件申请了多次按理应该在工单中合在一起
但如果同一个配件在申请多次的情况下打的折扣不一样就不能合在一起
我怎么知道工单中的配件是那一次申请的
两个方案让工单的配件关联申请表或者让配件申请表记录打的折扣
*/
// // 先查满足条件的申请表
// ArrayList<String> status = new ArrayList<>();
// status.add("01"); // 待审核
// status.add("05"); // 已驳回
// // 查工单所有已通过的配件申请单
// List<DlTicketWares> list = ticketWaresService.list(new LambdaQueryWrapper<DlTicketWares>().and(item -> {
// item.eq(DlTicketWares::getTicketId, respVO.getId())
// .notIn(DlTicketWares::getStatus, status);
// }));
// // 查配件申请表的所有已领取数量小于申请数量的子表信息
// List<String> ids = list.stream().map(DlTicketWares::getId).collect(Collectors.toList());
// List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
// item.in(DlTwItem::getTwId, ids)
// .apply("wares_already_count < wares_count");
// }));
// if (CollectionUtil.isNotEmpty(twItems)) {
// // 更新工单子表主要是把已领料的字段同步给工单配件的数量字段
// // 查询工单子表三个查询条件属于那个工单属于配件类型属于需要改变的即申请表的已领取数量小于申请数量的
// List<String> waresId = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toList());
// List<DlRepairTitem> items = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
// item.eq(DlRepairTitem::getTicketId, respVO.getId())
// .eq(DlRepairTitem::getItemType, "02")
// .in(DlRepairTitem::getPartId, waresId);
// }));
// // 同一个配件可能申请过多次属于是一个工单配件可能是对应多个申请表配件
// items.stream().map(item -> {
// DlRepairTitem titem = new DlRepairTitem();
// titem.setId(item.getId());
// List<DlTwItem> wares = twItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList());
// int sum = wares.stream().mapToInt(DlTwItem::getWaresAlreadyCount).sum();
//
// })
// }
// 先查满足条件的申请表
ArrayList<String> status = new ArrayList<>();
status.add("01"); // 待审核
status.add("05"); // 已驳回
// 查工单所有已通过的配件申请单
List<DlTicketWares> list = ticketWaresService.list(new LambdaQueryWrapper<DlTicketWares>().and(item -> {
item.eq(DlTicketWares::getTicketId, respVO.getId())
.notIn(DlTicketWares::getStatus, status);
}));
// 查配件申请表的所有已领取数量小于申请数量的子表信息
List<String> ids = list.stream().map(DlTicketWares::getId).collect(Collectors.toList());
List<DlTwItem> twItems = twItemService.list(new LambdaQueryWrapper<DlTwItem>().and(item -> {
item.in(DlTwItem::getTwId, ids)
.apply("wares_already_count < wares_count");
}));
if (CollectionUtil.isNotEmpty(twItems)) {
// 更新工单子表主要是把已领料的字段同步给工单配件的数量字段
// 查询工单子表三个查询条件属于那个工单属于配件类型属于需要改变的即申请表的已领取数量小于申请数量的
Set<String> waresId = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toSet());
List<DlRepairTitem> items = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(item -> {
item.eq(DlRepairTitem::getTicketId, respVO.getId())
.eq(DlRepairTitem::getItemType, "02")
.in(DlRepairTitem::getPartId, waresId);
}));
// 同一个配件可能申请过多次属于是一个工单配件可能是对应多个申请表配件
List<DlRepairTitem> updateItems = items.stream().map(item -> {
DlRepairTitem titem = new DlRepairTitem();
titem.setId(item.getId());
List<DlTwItem> wares = twItems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).collect(Collectors.toList());
int sum = wares.stream().mapToInt(DlTwItem::getWaresAlreadyCount).sum();
titem.setItemCount(sum);
BigDecimal discount = item.getItemDiscount() == null ? BigDecimal.ONE : item.getItemDiscount();
titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(sum)).multiply(discount));
return titem;
}).collect(Collectors.toList());
// 更新维修工单子表
titemService.updateBatchById(updateItems);
// 重新计算维修工单
boolean flag = computeTicket(respVO.getId());
if (!flag){
throw exception0(500, "系统异常");
}
}
// 通知服务顾问
DlRepairTickets tickets = baseMapper.selectById(respVO.getId());

View File

@ -150,11 +150,11 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
String userRoleCode = repairTicketsService.getUserRole();
List<DlTicketWares> result = new ArrayList<>();
//维修业务管理员总检服务顾问均可以进行审批
if (userRoleCode.equals(RepairRoleEnum.ADMIN.getCode())|| userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())||userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())){
if (userRoleCode.equals(RepairRoleEnum.ADMIN.getCode()) || userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode()) || userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())) {
LambdaQueryWrapper<DlTicketWares> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DlTicketWares::getTicketId,reqVO.getTicketId());
if (null != reqVO.getStatus()){
lambdaQueryWrapper.eq(DlTicketWares::getStatus,reqVO.getStatus());
lambdaQueryWrapper.eq(DlTicketWares::getTicketId, reqVO.getTicketId());
if (null != reqVO.getStatus()) {
lambdaQueryWrapper.eq(DlTicketWares::getStatus, reqVO.getStatus());
}
result = list(lambdaQueryWrapper);
}
@ -194,7 +194,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
// 通过角色信息查有这个角色的人
List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());
// 发通知
if (CollectionUtil.isNotEmpty(ids)){
if (CollectionUtil.isNotEmpty(ids)) {
ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要审核"));
}
}
@ -241,18 +241,18 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
// 如果是通过并且是领料就还需要把配件信息加入到工单中
if (ObjectUtil.isNotEmpty(status) && status.equals("02") && type.equals("01")) {
// 更新维修工单
if(null== repairItemList || repairItemList.isEmpty()){
if (null == repairItemList || repairItemList.isEmpty()) {
repairItemList = new ArrayList<>();
//配件没传去库里面查需要的配件
LambdaQueryWrapper<DlTwItem> queryWrapper= new LambdaQueryWrapper<DlTwItem>()
.eq(DlTwItem::getTwId,mainId);
LambdaQueryWrapper<DlTwItem> queryWrapper = new LambdaQueryWrapper<DlTwItem>()
.eq(DlTwItem::getTwId, mainId);
List<DlTwItem> applyList = twItemService.list(queryWrapper);
if(!applyList.isEmpty()){
if (!applyList.isEmpty()) {
//查配件库
List<RepairWares> waresList = repairWaresService.listByIds(applyList.stream().map(DlTwItem::getWaresId).collect(Collectors.toList()));
Map<String,RepairWares> waresMap =waresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
Map<String, RepairWares> waresMap = waresList.stream().collect(Collectors.toMap(RepairWares::getId, Function.identity()));
//组装工单子表数据
for (DlTwItem item:applyList){
for (DlTwItem item : applyList) {
DlRepairTitem repairTitem = new DlRepairTitem();
repairTitem.setTicketId(ticketMainId);
repairTitem.setItemCount(item.getWaresCount());
@ -270,25 +270,53 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
}
}
}
// 计算配件的总价
BigDecimal reduce = repairItemList.stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
repairTicketsService.update(new LambdaUpdateWrapper<DlRepairTickets>()
// 工单子项总数量增加上配件的数量
.setSql("count = count + " + repairItemList.size())
// 工单配件总价
.setSql("part_price = part_price + " + reduce)
// 工单总价
.setSql("total_price = total_price + " + reduce)
// 参考成本
.setSql("cost = cost + " + reduce)
// 参考毛利
.setSql("profit = profit + " + reduce)
// 领料状态
.set(DlRepairTickets::getPartStatus, "02")
.eq(DlRepairTickets::getId, ticketMainId)
);
// 更新维修工单子表
repairItemList.forEach(item -> {
// 这里是重新计算维修工单中的配件相关的信息写了一个公共的重新计算工单的方法替换掉
// // 计算配件的总价
// BigDecimal reduce = repairItemList.stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
// repairTicketsService.update(new LambdaUpdateWrapper<DlRepairTickets>()
// // 工单子项总数量增加上配件的数量
// .setSql("count = count + " + repairItemList.size())
// // 工单配件总价
// .setSql("part_price = part_price + " + reduce)
// // 工单总价
// .setSql("total_price = total_price + " + reduce)
// // 参考成本
// .setSql("cost = cost + " + reduce)
// // 参考毛利
// .setSql("profit = profit + " + reduce)
// // 领料状态
// .set(DlRepairTickets::getPartStatus, "02")
// .eq(DlRepairTickets::getId, ticketMainId)
// );
// 更新维修工单子表----需要合并相同的配件故修改
// 先查维修工单的子表中的配件相关的信息
List<DlRepairTitem> oldTitem = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> i.eq(DlRepairTitem::getTicketId, ticketMainId).eq(DlRepairTitem::getItemType, "02")));
// 过滤出新申请的配件里面有没有已经存在于工单子表的
List<String> waresIds = oldTitem.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList());
List<DlRepairTitem> already = repairItemList.stream().filter(item -> waresIds.contains(item.getPartId())).collect(Collectors.toList());
// 更新已经存在的配件
if (CollectionUtil.isNotEmpty(already)) {
List<DlRepairTitem> updateItems = new ArrayList<>();
already.forEach(item -> {
DlRepairTitem titem = oldTitem.stream().filter(i -> i.getPartId().equals(item.getPartId())).findFirst().orElse(null);
if (titem != null) {
DlRepairTitem newItem = new DlRepairTitem();
newItem.setId(titem.getId());
newItem.setItemCount(titem.getItemCount() + item.getItemCount());
// 如果设置了折扣就用没有就是1
BigDecimal itemDiscount = titem.getItemDiscount() == null ? new BigDecimal(1) : titem.getItemDiscount();
// titem取价格newItem取数量
newItem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(newItem.getItemCount())).multiply(itemDiscount));
updateItems.add(newItem);
}
});
if (CollectionUtil.isNotEmpty(updateItems)) {
repairTitemService.updateBatchById(updateItems);
}
}
// 新增维修工单中没有的配件
List<DlRepairTitem> newItems = repairItemList.stream().filter(item -> !waresIds.contains(item.getPartId())).collect(Collectors.toList());
newItems.forEach(item -> {
// 主表id
item.setTicketId(ticketMainId);
// 类型为配件
@ -296,62 +324,76 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
// 状态为未领料
item.setItemStatus(TicketsItemStatusEnum.WAITING_RECEIVE.getCode());
});
repairTitemService.saveBatch(repairItemList);
repairTitemService.saveBatch(newItems);
// 重新计算工单
boolean flag = repairTicketsService.computeTicket(ticketMainId);
if (!flag) {
throw exception0(500, "系统异常");
}
// 发送通过的消息给仓库
RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode());
List<Long> ids = permissionApi.getUserIdByRoleId(roleInfo.getId());
if (CollectionUtil.isNotEmpty(ids)){
if (CollectionUtil.isNotEmpty(ids)) {
ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要处理"));
}
} else if (ObjectUtil.isNotEmpty(respVO.getStatus()) && respVO.getStatus().equals("02") && respVO.getType().equals("02")) {
// 如果通过退料也需要更新
// 更新维修工单
// 计算配件的总价
BigDecimal reduce = respVO.getWares().stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
repairTicketsService.update(new LambdaUpdateWrapper<DlRepairTickets>()
// 工单子项总数量增加上配件的数量
.setSql("count = count - " + respVO.getWares().size())
// 工单配件总价
.setSql("part_price = part_price - " + reduce)
// 工单总价
.setSql("total_price = total_price - " + reduce)
// 参考成本
.setSql("cost = cost - " + reduce)
// 参考毛利
.setSql("profit = profit - " + reduce)
// 领料状态
.set(DlRepairTickets::getPartStatus, "02")
.eq(DlRepairTickets::getId, respVO.getTicketId())
);
// 维修工单子表对应的数据更新
// 先查数据出来
List<DlRepairTitem> list = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
i.eq(DlRepairTitem::getTicketId, respVO.getTicketId())
.in(DlRepairTitem::getPartId, respVO.getWares().stream().map(DlRepairTitem::getPartId).collect(Collectors.toList()));
}));
list.forEach(item -> {
respVO.getWares().stream().filter(i -> i.getPartId().equals(item.getPartId())).findFirst().ifPresent(i -> {
// 如果只是退部分就减少数量
if (!i.getItemCount().equals(item.getItemCount())) {
repairTitemService.update(new LambdaUpdateWrapper<DlRepairTitem>()
.setSql("item_count = item_count - " + i.getItemCount())
.setSql("item_money = item_money - " + i.getItemMoney())
.and(x -> {
x.eq(DlRepairTitem::getTicketId, respVO.getTicketId()).eq(DlRepairTitem::getPartId, item.getPartId());
})
);
} else {
// 如果是全部退了就直接删掉数据
repairTitemService.removeById(item.getId());
}
});
});
}
// 如果是驳回通知维修工
if (status.equals("05")){
// 发送没有通过的消息给员工
DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
repairWorkerService.sentMessage(ticketWares.getRepairId(), "您的配件申请单被驳回了");
}
// 下面的代码为退料申请单通过的代码但没有退料申请单可以注掉但防止有问题所以先不删除
// } else if (ObjectUtil.isNotEmpty(respVO.getStatus()) && respVO.getStatus().equals("02") && respVO.getType().equals("02")) {
// // 如果通过退料也需要更新
// // 更新维修工单
// // 计算配件的总价
// BigDecimal reduce = respVO.getWares().stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
// repairTicketsService.update(new LambdaUpdateWrapper<DlRepairTickets>()
// // 工单子项总数量增加上配件的数量
// .setSql("count = count - " + respVO.getWares().size())
// // 工单配件总价
// .setSql("part_price = part_price - " + reduce)
// // 工单总价
// .setSql("total_price = total_price - " + reduce)
// // 参考成本
// .setSql("cost = cost - " + reduce)
// // 参考毛利
// .setSql("profit = profit - " + reduce)
// // 领料状态
// .set(DlRepairTickets::getPartStatus, "02")
// .eq(DlRepairTickets::getId, respVO.getTicketId())
// );
// // 维修工单子表对应的数据更新
// // 先查数据出来
// List<DlRepairTitem> list = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
// i.eq(DlRepairTitem::getTicketId, respVO.getTicketId())
// .in(DlRepairTitem::getPartId, respVO.getWares().stream().map(DlRepairTitem::getPartId).collect(Collectors.toList()));
// }));
// list.forEach(item -> {
// respVO.getWares().stream().filter(i -> i.getPartId().equals(item.getPartId())).findFirst().ifPresent(i -> {
// // 如果只是退部分就减少数量
// if (!i.getItemCount().equals(item.getItemCount())) {
// repairTitemService.update(new LambdaUpdateWrapper<DlRepairTitem>()
// .setSql("item_count = item_count - " + i.getItemCount())
// .setSql("item_money = item_money - " + i.getItemMoney())
// .and(x -> {
// x.eq(DlRepairTitem::getTicketId, respVO.getTicketId()).eq(DlRepairTitem::getPartId, item.getPartId());
// })
// );
// } else {
// // 如果是全部退了就直接删掉数据
// repairTitemService.removeById(item.getId());
// }
// });
// });
//
// // 发送没有通过的消息给员工
// DlTicketWares ticketWares = baseMapper.selectById(respVO.getId());
// repairWorkerService.sentMessage(ticketWares.getRepairId(), "您的配件申请单被驳回了");
// }
}
/**
@ -412,7 +454,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
同理通知领料的数量可能与实际需要的数量不一致需要重新计算状态
*/
// 先查老数据领料才需要更新
if (type.equals("02")){
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 -> {
@ -492,7 +534,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
respVO.setAdviserId(Long.valueOf(tickets.getAdviserId()));
respVO.setAdviserName(tickets.getAdviserName());
this.save(respVO);
if(!respVO.getItems().isEmpty()){
if (!respVO.getItems().isEmpty()) {
List<DlTwItem> list = respVO.getItems().stream().map(dlTwItem -> dlTwItem.setTwId(respVO.getId())).collect(Collectors.toList());
twItemService.saveBatch(list);
}
@ -509,8 +551,8 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
public Map<String, Integer> getWorkerTodo() {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
LambdaQueryWrapper<DlTicketWares> queryWrapper = new LambdaQueryWrapper<DlTicketWares>()
.eq(DlTicketWares::getRepairId,loginUser.getId())
.eq(DlTicketWares::getType,"01");
.eq(DlTicketWares::getRepairId, loginUser.getId())
.eq(DlTicketWares::getType, "01");
List<DlTicketWares> list = this.list(queryWrapper);
Map<String, Integer> rtnMap = new HashMap<>();
//所有提交的
@ -520,23 +562,23 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
//未通过的
Integer noAllowNum = 0;
//待确认领料单
Integer waitingReceiveNum = dlRepairSoMapper.selectCountNum("02",loginUser.getId(), SoStatusEnum.TO_BE_PICKED.getCode());
Integer waitingReceiveNum = dlRepairSoMapper.selectCountNum("02", loginUser.getId(), SoStatusEnum.TO_BE_PICKED.getCode());
//待确认退料单
Integer waitingBackNum = dlRepairSoMapper.selectCountNum("04",loginUser.getId(), SoStatusEnum.TO_BE_RETURNED.getCode());
for (DlTicketWares wares:list){
if("02".equals(wares.getStatus())){
Integer waitingBackNum = dlRepairSoMapper.selectCountNum("04", loginUser.getId(), SoStatusEnum.TO_BE_RETURNED.getCode());
for (DlTicketWares wares : list) {
if ("02".equals(wares.getStatus())) {
//已通过
allowNum++;
}else if("05".equals(wares.getStatus())){
} else if ("05".equals(wares.getStatus())) {
//被驳回
noAllowNum++;
}
}
rtnMap.put("submitNum",submitNum);
rtnMap.put("allowNum",allowNum);
rtnMap.put("noAllowNum",noAllowNum);
rtnMap.put("waitingReceiveNum",waitingReceiveNum);
rtnMap.put("waitingBackNum",waitingBackNum);
rtnMap.put("submitNum", submitNum);
rtnMap.put("allowNum", allowNum);
rtnMap.put("noAllowNum", noAllowNum);
rtnMap.put("waitingReceiveNum", waitingReceiveNum);
rtnMap.put("waitingBackNum", waitingBackNum);
return rtnMap;
}