打印工单

This commit is contained in:
xiaofajia 2024-10-30 11:26:27 +08:00
parent 0548422b4b
commit db87951161
3 changed files with 114 additions and 20 deletions

View File

@ -334,5 +334,19 @@ public class DlRepairTicketsController {
dlRepairTicketsService.addItems(respVO);
return CommonResult.ok();
}
/**
* 修改工单主表只是主表
*
* @author 小李
* @date 10:25 2024/10/30
* @param respVO 请求对象
**/
@PostMapping("/updateTicket")
@Operation(summary = "修改工单主表,只是主表")
public CommonResult<?> updateTicket(@RequestBody DlRepairTicketsRespVO respVO) {
dlRepairTicketsService.updateTicket(respVO);
return CommonResult.ok();
}
}

View File

@ -217,4 +217,13 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @date 16:35 2024/10/26
**/
void autoInspection();
/**
* 修改工单主表只是主表
*
* @author 小李
* @date 10:25 2024/10/30
* @param respVO 请求对象
**/
void updateTicket(DlRepairTicketsRespVO respVO);
}

View File

@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.*;
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairRecordsService;
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
@ -13,6 +15,8 @@ import cn.iocoder.yudao.module.base.vo.RepairRecordsPageReqVO;
import cn.iocoder.yudao.module.base.vo.RepairRecordsRespVO;
import cn.iocoder.yudao.module.booking.entity.DlRepairBooking;
import cn.iocoder.yudao.module.booking.service.DlRepairBookingService;
import cn.iocoder.yudao.module.company.entity.Company;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.conf.entity.BaseType;
import cn.iocoder.yudao.module.conf.service.BaseTypeService;
import cn.iocoder.yudao.module.custom.entity.*;
@ -170,6 +174,10 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Lazy
private BaseTypeService baseTypeService;
@Resource
@Lazy
private CompanyService companyService;
/**
* 维修工单表 新增
*
@ -513,9 +521,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
params.put("plate", tickets.getCarNo());
params.put("frameNumber", tickets.getCarVin());
params.put("billingTime", time.format(tickets.getCreateTime()));
// todo 已行里程
// 取不到先给未知
params.put("mileage", "未知");
// 已行里程
params.put("mileage", tickets.getMileageTraveled());
// 旧件处理
// 获取字典数据
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList(DICT_REPAIR_PART_DISPOSAL);
@ -526,10 +533,9 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 车辆其他信息发动机号码三包单位保险名称车型
CarMain carMain = carMainService.getById(tickets.getCarId());
params.put("engineNumber", carMain.getEngineNumber());
// todo 三包单位保险名称
// 取不到先给未知
params.put("tripleUnit", "未知");
params.put("insuranceName", "未知");
// 三包单位保险名称
params.put("tripleUnit", tickets.getThreePackUnits());
params.put("insuranceName", tickets.getInsuranceName());
// 先查车辆对应的品牌
String brandAndModel = "";
if (ObjectUtil.isNotEmpty(carMain.getCarBrand())) {
@ -642,6 +648,16 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
params.put("matFavorable", matFavorable);
// 计算没打折的工单总价
BigDecimal matTotalCost = titems.stream().map(item -> item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount()))).reduce(BigDecimal.ZERO, BigDecimal::add);
// 加上特殊费用
// 管理费
BigDecimal managerMoney = ObjectUtil.isNotEmpty(tickets.getManagerMoney()) ? tickets.getManagerMoney() : new BigDecimal("0");
// 救援费
BigDecimal rescueMoney = ObjectUtil.isNotEmpty(tickets.getRescueMoney()) ? tickets.getRescueMoney() : new BigDecimal("0");
// 三包费
BigDecimal threePackMoney = ObjectUtil.isNotEmpty(tickets.getThreePackMoney()) ? tickets.getThreePackMoney() : new BigDecimal("0");
// 定损费
BigDecimal confirmFaultMoney = ObjectUtil.isNotEmpty(tickets.getConfirmFaultMoney()) ? tickets.getConfirmFaultMoney() : new BigDecimal("0");
matTotalCost = matTotalCost.add(managerMoney).add(rescueMoney).add(threePackMoney).add(confirmFaultMoney);
params.put("matTotalCost", matTotalCost);
// 应收费目前是工单的打折后的总价
params.put("allCost", tickets.getTotalPrice());
@ -661,14 +677,12 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 材料工时优惠 材料优惠+工时优惠
params.put("matlabourFavorable", "0.00");
// todo 目前取不到管理费救援费三包费定损费结算备注这个是因为和工单备注用的同一个客户签字
// 取不到的先默认为0或未知
params.put("manageCost", 0.00);
params.put("rescueCost", 0.00);
params.put("tripleCost", 0.00);
params.put("lossCost", 0.00);
params.put("costCondition", "未知");
params.put("costRemark", "未知");
// 管理费救援费三包费定损费结算备注这个是因为和工单备注用的同一个todo 客户签字
params.put("manageCost", ObjectUtil.isNotEmpty(tickets.getManagerMoney()) ? tickets.getManagerMoney() : "0.00") ;
params.put("rescueCost", ObjectUtil.isNotEmpty(tickets.getRescueMoney()) ? tickets.getRescueMoney() : "0.00");
params.put("tripleCost", ObjectUtil.isNotEmpty(tickets.getThreePackMoney()) ? tickets.getThreePackMoney() : "0.00");
params.put("lossCost", ObjectUtil.isNotEmpty(tickets.getConfirmFaultMoney()) ? tickets.getConfirmFaultMoney() : "0.00");
params.put("costRemark", tickets.getBillingRemark());
/*
5最后结尾
*/
@ -696,12 +710,35 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
params.put("costCondition", costCondition);
}
// todo 目前取不到单位开户行地址账号
// 单位开户行地址账号
// 取当前租户的公司们
Long tenantId = tickets.getTenantId();
List<Company> companies = companyService.list(new LambdaQueryWrapper<Company>().in(Company::getTenantId, tenantId));
// 得到属于当前业务的公司
Company company = companies.stream().filter(item -> {
String[] service = item.getServiceCodes().split(",");
for (String s : service) {
if (s.equals("weixiu")) {
return true;
}
}
return false;
}).findFirst().orElse(null);
String corporation = "";
String bank = "";
String bankAddress = "";
String account = "";
if (company != null){
corporation = company.getCorpName();
bankAddress = company.getAddress();
}
// 取不到的先给未知
params.put("corporation", "未知");
params.put("bank", "未知");
params.put("bankAddress", "未知");
params.put("account", "未知");
params.put("corporation", corporation);
// todo
params.put("bank", bank);
params.put("bankAddress", bankAddress);
// todo
params.put("account", account);
Configure config = configureBuilder.build();
try {
@ -1276,6 +1313,20 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
tickets.setOtherPrice(reduce);
}
});
// 工单总价还需要变把其他新加的费用也需要算上
// 查主表
DlRepairTickets oldTicket = baseMapper.selectById(ticketId);
// 管理费
BigDecimal managerMoney = ObjectUtil.isNotEmpty(oldTicket.getManagerMoney()) ? oldTicket.getManagerMoney() : new BigDecimal("0");
// 救援费
BigDecimal rescueMoney = ObjectUtil.isNotEmpty(oldTicket.getRescueMoney()) ? oldTicket.getRescueMoney() : new BigDecimal("0");
// 三包费
BigDecimal threePackMoney = ObjectUtil.isNotEmpty(oldTicket.getThreePackMoney()) ? oldTicket.getThreePackMoney() : new BigDecimal("0");
// 定损费
BigDecimal confirmFaultMoney = ObjectUtil.isNotEmpty(oldTicket.getConfirmFaultMoney()) ? oldTicket.getConfirmFaultMoney() : new BigDecimal("0");
tickets.setTotalPrice(tickets.getTotalPrice().add(managerMoney).add(rescueMoney).add(threePackMoney).add(confirmFaultMoney));
return baseMapper.updateById(tickets) > 0;
}
@ -1392,6 +1443,26 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
repairRecordsService.saveRepairRecord(item.getId(), null, RecordTypeEnum.ZJ.getCode(), "该工单由系统自动总检完成", null);
});
}
/**
* 修改工单主表只是主表
*
* @author 小李
* @date 10:25 2024/10/30
* @param respVO 请求对象
**/
@Override
@DSTransactional
public void updateTicket(DlRepairTicketsRespVO respVO){
// 更新主表
baseMapper.updateById(respVO);
// 重新计算
boolean flag = computeTicket(respVO.getId());
if (!flag){
throw exception0(500, "系统异常");
}
}
}