配件领退优化1/2
This commit is contained in:
parent
4ad6d6835b
commit
a268b43f14
@ -48,7 +48,7 @@ public class DlTwItem extends TenantBaseDO {
|
||||
private Integer waresCount;
|
||||
|
||||
/**
|
||||
* 配件状态(01:已领料,02:未领料,03:已退料 tw_item_status)
|
||||
* 配件状态(01:已领料,02:未领料,03:已退料,04可确认领料,可确认退料 tw_item_status)
|
||||
*/
|
||||
private String waresStatus;
|
||||
|
||||
@ -57,4 +57,10 @@ public class DlTwItem extends TenantBaseDO {
|
||||
|
||||
/** 客户是否可见(字典yes_no);已存在于系统中(是:1,否:0) */
|
||||
private String isShow;
|
||||
|
||||
/** 可领取数量 */
|
||||
private Integer waresCouldCount;
|
||||
|
||||
/** 已领料数量 */
|
||||
private Integer waresAlreadyCount;
|
||||
}
|
@ -259,8 +259,11 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
DlRepairTickets dlRepairTickets = baseMapper.selectById(id);
|
||||
DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class);
|
||||
//查车辆
|
||||
if (ObjectUtil.isNotEmpty(dlRepairTickets.getCarId())){
|
||||
CarMainRespVO carInfo = carMainService.queryCarById(dlRepairTickets.getCarId());
|
||||
result.setCarInfo(carInfo);
|
||||
}
|
||||
|
||||
//查用户信息
|
||||
CustomerMain customerInfo = customerService.getCustomerById(dlRepairTickets.getUserId());
|
||||
result.setCustomerInfo(customerInfo);
|
||||
|
@ -35,6 +35,7 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
@ -76,15 +77,16 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
@Resource
|
||||
@Lazy
|
||||
private RepairWaresService repairWaresService;
|
||||
|
||||
@Resource
|
||||
private RepairWorkerService workerService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param reqVO 请求对象
|
||||
* @author 小李
|
||||
* @date 12:01 2024/10/15
|
||||
* @param reqVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
public IPage<DlTicketWares> getPage(DlTicketWaresReqVO reqVO, Page<DlTicketWares> page) {
|
||||
@ -123,9 +125,9 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
/**
|
||||
* 新增、修改
|
||||
*
|
||||
* @param respVO 请求对象
|
||||
* @author 小李
|
||||
* @date 12:14 2024/10/15
|
||||
* @param respVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
@DSTransactional
|
||||
@ -147,9 +149,9 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param id id
|
||||
* @author 小李
|
||||
* @date 12:21 2024/10/15
|
||||
* @param id id
|
||||
**/
|
||||
@Override
|
||||
@DSTransactional
|
||||
@ -163,9 +165,9 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
/**
|
||||
* 审核
|
||||
*
|
||||
* @param respVO 请求对象
|
||||
* @author 小李
|
||||
* @date 21:15 2024/10/15
|
||||
* @param respVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
@DSTransactional
|
||||
@ -254,43 +256,84 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
/**
|
||||
* 仓库通知领料
|
||||
*
|
||||
* @param respVO 请求对象
|
||||
* @author 小李
|
||||
* @date 20:45 2024/10/16
|
||||
* @param respVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
@DSTransactional
|
||||
public void passTicketWares(DlTicketWaresRespVO respVO) {
|
||||
// 查工单子表中的配件信息
|
||||
List<DlRepairTitem> list = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>()
|
||||
.eq(DlRepairTitem::getTicketId, respVO.getTicketId())
|
||||
List<DlRepairTitem> list = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
||||
i.eq(DlRepairTitem::getTicketId, respVO.getTicketId())
|
||||
.in(DlRepairTitem::getPartId, respVO.getRepairSois()
|
||||
.stream()
|
||||
.map(DlRepairSoi::getGoodsId)
|
||||
.collect(Collectors.toList())));
|
||||
.collect(Collectors.toList()));
|
||||
})
|
||||
);
|
||||
// 计算总价 (通知领料的数量可能和请求的不一样,所以需要这样计算)
|
||||
BigDecimal reduce = list.stream()
|
||||
/*
|
||||
item:维修工单子表中的每一个配件
|
||||
map中是找到与item对应的领料单子表的配件,记soi
|
||||
将item的价格设置给soi的价格
|
||||
*/
|
||||
.map(item -> {
|
||||
DlRepairSoi repairSoi = respVO.getRepairSois().stream()
|
||||
.filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst()
|
||||
.orElse(null);
|
||||
if (repairSoi != null) {
|
||||
repairSoi.setGoodsPrice(item.getItemPrice());
|
||||
}
|
||||
return repairSoi;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
// 计算soi的价格
|
||||
.map(i -> new BigDecimal(i.getGoodsCount()).multiply(i.getGoodsPrice()))
|
||||
// 计算总价
|
||||
BigDecimal reduce = list.stream().map(DlRepairTitem::getItemMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
respVO.getRepairSo().setItemCount(list.size());
|
||||
respVO.getRepairSo().setTotalPrice(reduce);
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// 生成领料单
|
||||
respVO.getRepairSo().setTotalPrice(reduce);
|
||||
respVO.getRepairSo().setItemCount(list.size());
|
||||
repairSoService.save(respVO.getRepairSo());
|
||||
// 生成领料单子表
|
||||
respVO.getRepairSois().forEach(item -> {
|
||||
item.setSoId(respVO.getRepairSo().getId());
|
||||
DlRepairTitem titem = list.stream().filter(i -> i.getPartId().equals(item.getGoodsId())).collect(Collectors.toList()).get(0);
|
||||
item.setGoodsPrice(titem.getItemPrice());
|
||||
});
|
||||
repairSoiService.saveBatch(respVO.getRepairSois());
|
||||
// 更新领料申请子表
|
||||
twItemService.updateBatchById(respVO.getItems());
|
||||
// 更新配件申请子表
|
||||
/*
|
||||
同理,通知领料的数量可能与实际需要的数量不一致,需要重新计算状态
|
||||
*/
|
||||
// 先查老数据
|
||||
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 -> {
|
||||
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);
|
||||
|
||||
// 通知维修工
|
||||
// 查维修工的userId
|
||||
repairWorkerService.sentMessage(respVO.getRepairId(), "您有新的领料单需要确认");
|
||||
}
|
||||
|
||||
/**
|
||||
* 员工确认领料
|
||||
*
|
||||
* @param respVO 请求对象
|
||||
* @author 小李
|
||||
* @date 22:07 2024/10/16
|
||||
* @param respVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
@DSTransactional
|
||||
@ -315,9 +358,9 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
/**
|
||||
* 仓库确认退料
|
||||
*
|
||||
* @param respVO 请求对象
|
||||
* @author 小李
|
||||
* @date 22:03 2024/10/17
|
||||
* @param respVO 请求对象
|
||||
**/
|
||||
@Override
|
||||
public void passBackTicketWares(DlTicketWaresRespVO respVO) {
|
||||
|
@ -6,11 +6,13 @@ import cn.iocoder.yudao.module.project.entity.RepairWares;
|
||||
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
||||
import cn.iocoder.yudao.module.tickets.entity.DlTwItem;
|
||||
import cn.iocoder.yudao.module.tickets.mapper.DlTwItemMapper;
|
||||
import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService;
|
||||
import cn.iocoder.yudao.module.tickets.service.DlTwItemService;
|
||||
import cn.iocoder.yudao.module.tickets.vo.DlTwItemReqVO;
|
||||
import cn.iocoder.yudao.module.tickets.vo.DlTwItemRespVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -30,6 +32,10 @@ public class DlTwItemServiceImpl extends ServiceImpl<DlTwItemMapper, DlTwItem>
|
||||
@Resource
|
||||
private RepairWaresService repairWaresService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private DlTicketWaresService ticketWaresService;
|
||||
|
||||
/**
|
||||
* 根据主表查看全部
|
||||
*
|
||||
|
@ -206,11 +206,22 @@
|
||||
</if>
|
||||
<if test="map.userIds != null and map.userIds.size > 0 ">
|
||||
and (drt.tickets_status = '05')
|
||||
<choose>
|
||||
<when test="map.isFinish == '0'">
|
||||
and (drt.now_repair_id in
|
||||
<foreach collection="map.userIds" item="item" index="index" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
<when test="map.isFinish == '1'">
|
||||
and (
|
||||
<foreach item="item" collection="map.userIds" index="index" open="" separator="or" close="">
|
||||
find_in_set(#{item}, drti.repair_ids) > 0
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
</choose>
|
||||
</if>
|
||||
order by drt.create_time desc
|
||||
</select>
|
||||
|
@ -13,13 +13,15 @@
|
||||
<result property="waresStatus" column="wares_status" jdbcType="VARCHAR"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="isShow" column="is_show" />
|
||||
<result property="waresCouldCount" column="wares_could_count" />
|
||||
<result property="waresAlreadyCount" column="wares_already_count" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_SQL">
|
||||
select
|
||||
id,tw_id,wares_id,
|
||||
wares_name,wares_count,wares_status,remark,
|
||||
is_show
|
||||
is_show,wares_could_count, wares_already_count
|
||||
from dl_tw_item dti
|
||||
where dti.deleted = '0'
|
||||
</sql>
|
||||
|
Loading…
Reference in New Issue
Block a user