打印工单

This commit is contained in:
xiaofajia 2024-10-29 21:30:39 +08:00
parent 33b2b79663
commit 138c709c9a
3 changed files with 78 additions and 6 deletions

View File

@ -187,4 +187,28 @@ public class DlRepairTickets extends TenantBaseDO {
/** 配件是否可见(yes_no1可见,0:不可见) */
private String partShow;
/** 已行里程 */
private String mileageTraveled;
/** 三包单位 */
private String threePackUnits;
/** 保险名称 */
private String insuranceName;
/** 管理费 */
private BigDecimal managerMoney;
/** 救援费 */
private BigDecimal rescueMoney;
/** 三包费 */
private BigDecimal threePackMoney;
/** 定损费 */
private BigDecimal confirmFaultMoney;
/** 结算备注 */
private String billingRemark;
}

View File

@ -474,7 +474,13 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
* @date 14:00 2024/10/12
**/
@Override
@DSTransactional
public void print(HttpServletResponse response, String id) {
// 开始之前先计算一次工单
boolean flag = computeTicket(id);
if (!flag){
throw exception0(500, "系统异常");
}
// 预备工作
// 先把这个工单和工单的所有子表信息取出来备用
DlRepairTickets tickets = baseMapper.selectById(id);
@ -653,7 +659,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 其他费用 维修工单的其他子项的费用
params.put("otherCost", ObjectUtil.isNotEmpty(tickets.getOtherPrice()) ? tickets.getOtherPrice() : 0.00);
// 材料工时优惠 材料优惠+工时优惠
params.put("matlabourFavorable", matFavorable.add(labourFavorable));
params.put("matlabourFavorable", "0.00");
// todo 目前取不到管理费救援费三包费定损费结算备注这个是因为和工单备注用的同一个客户签字
// 取不到的先默认为0或未知
@ -1221,24 +1227,42 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
}
/**
* 重新计算工单的一些数值
* 重新计算工单的一些数值子表也要重新计算
*
* @param ticketId 工单ID
* @author 小李
* @date 15:47 2024/10/24
**/
@Override
@DSTransactional
public boolean computeTicket(String ticketId) {
// 查子表
List<DlRepairTitem> list = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, ticketId));
// 计算
// 计算子表
if (CollectionUtil.isEmpty(list)){
throw exception0(500, "没有项目、配件或其他");
}
List<DlRepairTitem> updateItems = list.stream().map(item -> {
DlRepairTitem titem = new DlRepairTitem();
titem.setId(item.getId());
// 取出折扣
BigDecimal discount = item.getItemDiscount() == null ? new BigDecimal("1") : item.getItemDiscount();
titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(discount));
return titem;
}).collect(Collectors.toList());
// 更新
titemService.updateBatchById(updateItems);
// 计算主表
// 查新的子表信息
List<DlRepairTitem> newList = titemService.list(new LambdaQueryWrapper<DlRepairTitem>().eq(DlRepairTitem::getTicketId, ticketId));
DlRepairTickets tickets = new DlRepairTickets();
// 计算子项总数
int count = list.stream().mapToInt(DlRepairTitem::getItemCount).sum();
int count = newList.stream().mapToInt(DlRepairTitem::getItemCount).sum();
tickets.setId(ticketId);
tickets.setCount(count);
// 分类计算各自的总价和最终工单总价
Map<String, List<DlRepairTitem>> map = list.stream().collect(Collectors.groupingBy(DlRepairTitem::getItemType));
Map<String, List<DlRepairTitem>> map = newList.stream().collect(Collectors.groupingBy(DlRepairTitem::getItemType));
// 01项目02配件03其他
tickets.setTotalPrice(BigDecimal.ZERO);
map.forEach((k, v) -> {

View File

@ -46,6 +46,14 @@
<result property="nowRepairId" column="now_repair_id" />
<result property="nowRepairName" column="now_repair_name" />
<result property="partShow" column="part_show" />
<result property="mileageTraveled" column="mileage_traveled" />
<result property="threePackUnits" column="three_pack_units" />
<result property="insuranceName" column="insurance_name" />
<result property="managerMoney" column="manager_money" />
<result property="rescueMoney" column="rescue_money" />
<result property="threePackMoney" column="three_pack_money" />
<result property="confirmFaultMoney" column="confirm_fault_money" />
<result property="billingRemark" column="billing_remark" />
</resultMap>
<resultMap id="APPBaseResultMap" type="cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO">
@ -90,6 +98,14 @@
<result property="nowRepairId" column="now_repair_id" />
<result property="nowRepairName" column="now_repair_name" />
<result property="partShow" column="part_show" />
<result property="mileageTraveled" column="mileage_traveled" />
<result property="threePackUnits" column="three_pack_units" />
<result property="insuranceName" column="insurance_name" />
<result property="managerMoney" column="manager_money" />
<result property="rescueMoney" column="rescue_money" />
<result property="threePackMoney" column="three_pack_money" />
<result property="confirmFaultMoney" column="confirm_fault_money" />
<result property="billingRemark" column="billing_remark" />
<association property="booking" javaType="cn.iocoder.yudao.module.booking.entity.DlRepairBooking" select="selectBookingById" column="id"/>
<collection property="itemList" column="id" ofType="cn.iocoder.yudao.module.tickets.entity.DlRepairTitem" select="selectItemList" />
</resultMap>
@ -135,7 +151,15 @@
is_finish,
now_repair_id,
now_repair_name,
part_show
part_show,
mileage_traveled,
three_pack_units,
insurance_name,
manager_money,
rescue_money,
three_pack_money,
confirm_fault_money,
billing_remark
from dl_repair_tickets drt
where drt.deleted = '0'
</sql>