Compare commits
2 Commits
baf972df52
...
33b2b79663
Author | SHA1 | Date | |
---|---|---|---|
|
33b2b79663 | ||
|
4c35c69ad7 |
@ -21,5 +21,7 @@ public class RepairCons {
|
||||
/**数据字典常量-repair_unit-*/
|
||||
public static final String DICT_REPAIR_WORK_TYPE = "repair_work_type";
|
||||
/** 数据字典常量-repair_part_disposal */
|
||||
public static final String REPAIR_PART_DISPOSAL = "repair_part_disposal";
|
||||
public static final String DICT_REPAIR_PART_DISPOSAL = "repair_part_disposal";
|
||||
/** 数据字典常量-repair_pay_type */
|
||||
public static final String DICT_REPAIR_PAY_TYPE = "repair_pay_type";
|
||||
}
|
||||
|
@ -205,6 +205,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
|
||||
// 门店信息
|
||||
Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
|
||||
DeptRespDTO dept = deptApi.getDept(deptId);
|
||||
@ -510,7 +512,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
params.put("mileage", "未知");
|
||||
// 旧件处理
|
||||
// 获取字典数据
|
||||
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList(REPAIR_PART_DISPOSAL);
|
||||
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList(DICT_REPAIR_PART_DISPOSAL);
|
||||
// 找到对应的处理方式
|
||||
DictDataRespDTO dictDataRespDTO = dataList.stream().filter(item -> item.getValue().equals(tickets.getPartDisposal())).findFirst().orElse(null);
|
||||
params.put("oldhandle", Objects.requireNonNull(dictDataRespDTO).getLabel());
|
||||
@ -548,10 +550,14 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
project.put("repItem", item.getItemName());
|
||||
project.put("repPrice", item.getItemPrice());
|
||||
project.put("repCount", item.getItemCount());
|
||||
project.put("repDiscount", item.getItemDiscount() == null ? "无折扣" : item.getItemDiscount());
|
||||
// todo 工时费
|
||||
BigDecimal itemDiscount = item.getItemDiscount();
|
||||
if (ObjectUtil.isEmpty(item.getItemDiscount())) {
|
||||
itemDiscount = new BigDecimal("1.00");
|
||||
}
|
||||
project.put("repDiscount", itemDiscount.equals(new BigDecimal("1.00")) ? "无折扣" : item.getItemDiscount());
|
||||
// 工时费 项目打折后的费用
|
||||
// 取不到先给0
|
||||
project.put("labourAmount", 0.00);
|
||||
project.put("labourAmount", item.getItemMoney());
|
||||
project.put("major", item.getRepairNames());
|
||||
project.put("repRemark", item.getRemark());
|
||||
if (ObjectUtil.isNotEmpty(item.getItemTypeId())) {
|
||||
@ -562,7 +568,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
});
|
||||
}
|
||||
configureBuilder.bind("projects", new HackLoopTableRenderPolicy());
|
||||
// todo 有问题,不渲染
|
||||
params.put("projects", projects);
|
||||
|
||||
/*
|
||||
@ -571,18 +576,38 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
// 取出维修工单子表的配件
|
||||
List<DlRepairTitem> waresList = titems.stream().filter(item -> item.getItemType().equals("02")).collect(Collectors.toList());
|
||||
List<Map<String, Object>> wares = new ArrayList<>();
|
||||
// 取出对应需要的其他表的数据备用
|
||||
List<DictDataRespDTO> unitDataList = dictDataApi.getDictDataList(DICT_REPAIR_UNIT);
|
||||
if (CollectionUtil.isNotEmpty(waresList)) {
|
||||
waresList.forEach(item -> {
|
||||
Map<String, Object> ware = new HashMap<>();
|
||||
ware.put("matRort", wares.size() + 1);
|
||||
// todo 配件号
|
||||
ware.put("matNum", "");
|
||||
// 配件号
|
||||
// 先取配件
|
||||
RepairWares wareById = waresService.getOne(new LambdaQueryWrapper<RepairWares>().eq(RepairWares::getId, item.getPartId()));
|
||||
String matNum = "";
|
||||
if (ObjectUtil.isNotEmpty(wareById)) {
|
||||
matNum = wareById.getCode();
|
||||
}
|
||||
ware.put("matNum", matNum);
|
||||
ware.put("matName", item.getItemName());
|
||||
// todo 单位
|
||||
ware.put("matUnit", item.getItemUnit());
|
||||
// 单位
|
||||
// 先取单位字典
|
||||
String matUnit = "";
|
||||
if (CollectionUtil.isNotEmpty(unitDataList) && ObjectUtil.isNotEmpty(item.getItemUnit())) {
|
||||
DictDataRespDTO unit = unitDataList.stream().filter(i -> i.getValue().equals(item.getItemUnit())).findFirst().orElse(null);
|
||||
if (unit != null) {
|
||||
matUnit = unit.getLabel();
|
||||
}
|
||||
}
|
||||
ware.put("matUnit", matUnit);
|
||||
ware.put("matPrice", item.getItemPrice());
|
||||
ware.put("matCount", item.getItemCount());
|
||||
ware.put("matDiscount", item.getItemDiscount() == null ? "无折扣" : item.getItemDiscount());
|
||||
BigDecimal itemDiscount = item.getItemDiscount();
|
||||
if (ObjectUtil.isEmpty(item.getItemDiscount())) {
|
||||
itemDiscount = new BigDecimal("1.00");
|
||||
}
|
||||
ware.put("matDiscount", itemDiscount.equals(new BigDecimal("1.00")) ? "无折扣" : item.getItemDiscount());
|
||||
ware.put("matAmount", item.getItemMoney());
|
||||
ware.put("matRemark", item.getRemark());
|
||||
if (ObjectUtil.isNotEmpty(item.getItemTypeId())) {
|
||||
@ -593,7 +618,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
});
|
||||
}
|
||||
configureBuilder.bind("wares", new HackLoopTableRenderPolicy());
|
||||
// todo 同样是不渲染
|
||||
params.put("wares", wares);
|
||||
// 小计
|
||||
params.put("matTotalAmount", tickets.getPartPrice());
|
||||
@ -601,14 +625,15 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
/*
|
||||
4、其他信息
|
||||
*/
|
||||
// 目前能取到:材料费、材料费优惠、总费用、应收费、大写、工单备注
|
||||
// 目前能取到:材料费、材料费优惠、总费用、应收费、大写、工单备注、工时费、工时费优惠、其他费、材料工时优惠
|
||||
// 计算配件没打折的总金额
|
||||
BigDecimal matCost = waresList.stream()
|
||||
.map(item -> item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
params.put("matCost", matCost);
|
||||
// 没打折的金额减去打折后的总金额得到优惠了多少钱
|
||||
params.put("matFavorable", matCost.subtract(tickets.getPartPrice()));
|
||||
BigDecimal matFavorable = matCost.subtract(ObjectUtil.isNotEmpty(tickets.getPartPrice()) ? tickets.getPartPrice() : BigDecimal.ZERO);
|
||||
params.put("matFavorable", matFavorable);
|
||||
// 计算没打折的工单总价
|
||||
BigDecimal matTotalCost = titems.stream().map(item -> item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount()))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
params.put("matTotalCost", matTotalCost);
|
||||
@ -619,13 +644,20 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
params.put("bigAllCost", bigAllCost);
|
||||
// 这个备注现在是工单备注
|
||||
params.put("paperRemark", tickets.getRemark());
|
||||
// todo 目前取不到:管理费、工时费、工时费优惠、其他费、材料工时优惠、救援费、三包费、定损费、付款情况、结算备注(这个是因为和工单备注用的同一个)、客户签字
|
||||
// 项目没打折的总价
|
||||
BigDecimal labourCost = projectList.stream().map(item -> item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount()))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
params.put("labourCost", labourCost);
|
||||
// 项目没打折的总价减打折后的总价就是优惠
|
||||
BigDecimal labourFavorable = labourCost.subtract(ObjectUtil.isNotEmpty(tickets.getProjectPrice()) ? tickets.getProjectPrice() : BigDecimal.ZERO);
|
||||
params.put("labourFavorable", labourFavorable);
|
||||
// 其他费用 维修工单的其他子项的费用
|
||||
params.put("otherCost", ObjectUtil.isNotEmpty(tickets.getOtherPrice()) ? tickets.getOtherPrice() : 0.00);
|
||||
// 材料工时优惠 材料优惠+工时优惠
|
||||
params.put("matlabourFavorable", matFavorable.add(labourFavorable));
|
||||
|
||||
// todo 目前取不到:管理费、救援费、三包费、定损费、结算备注(这个是因为和工单备注用的同一个)、客户签字
|
||||
// 取不到的先默认为0或未知
|
||||
params.put("manageCost", 0.00);
|
||||
params.put("labourCost", 0.00);
|
||||
params.put("labourFavorable", 0.00);
|
||||
params.put("otherCost", 0.00);
|
||||
params.put("matlabourFavorable", 0.00);
|
||||
params.put("rescueCost", 0.00);
|
||||
params.put("tripleCost", 0.00);
|
||||
params.put("lossCost", 0.00);
|
||||
@ -634,16 +666,30 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
/*
|
||||
5、最后结尾
|
||||
*/
|
||||
// 目前能取到:服务顾问、联系电话、结算日期
|
||||
// 目前能取到:服务顾问、联系电话、结算日期、付款情况
|
||||
params.put("serviceConsultant", tickets.getAdviserName());
|
||||
AdminUserRespDTO adviser = adminUserApi.getUser(Long.valueOf(tickets.getAdviserId()));
|
||||
if (ObjectUtil.isNotEmpty(adviser) && ObjectUtil.isNotEmpty(adviser.getMobile())) {
|
||||
params.put("serviceTelephone", adviser.getMobile());
|
||||
}
|
||||
RepairOrderInfo orderInfo = repairOrderInfoService.getOne(new LambdaQueryWrapper<RepairOrderInfo>().eq(RepairOrderInfo::getGoodsId, tickets.getId()));
|
||||
if (ObjectUtil.isNotEmpty(orderInfo) && ObjectUtil.isNotEmpty(orderInfo.getPayTime())) {
|
||||
params.put("settleDate", date.format(orderInfo.getPayTime()));
|
||||
if (ObjectUtil.isNotEmpty(orderInfo)) {
|
||||
if (ObjectUtil.isNotEmpty(orderInfo.getPayTime())) {
|
||||
params.put("settleDate", date.format(orderInfo.getPayTime()));
|
||||
}
|
||||
// 付款情况
|
||||
// 先取支付字典
|
||||
List<DictDataRespDTO> payTypes = dictDataApi.getDictDataList(DICT_REPAIR_PAY_TYPE);
|
||||
String costCondition = "未支付";
|
||||
if (ObjectUtil.isNotEmpty(payTypes) && ObjectUtil.isNotEmpty(orderInfo.getPayType())) {
|
||||
DictDataRespDTO payType = payTypes.stream().filter(item -> item.getValue().equals(orderInfo.getPayType())).findFirst().orElse(null);
|
||||
if (payType != null) {
|
||||
costCondition = payType.getLabel();
|
||||
}
|
||||
}
|
||||
params.put("costCondition", costCondition);
|
||||
}
|
||||
|
||||
// todo 目前取不到:单位、开户行、地址、账号
|
||||
// 取不到的先给未知
|
||||
params.put("corporation", "未知");
|
||||
@ -653,7 +699,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
|
||||
Configure config = configureBuilder.build();
|
||||
try {
|
||||
InputStream inputStream = XWPFTemplate.class.getResourceAsStream("/templates/gdmb.docx");
|
||||
InputStream inputStream = XWPFTemplate.class.getResourceAsStream("/templates/ticketTemplate.docx");
|
||||
XWPFTemplate template = XWPFTemplate.compile(inputStream, config);
|
||||
template.render(params);
|
||||
FileOutputStream fos = new FileOutputStream(tmpPath);
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user