|
|
@ -3,8 +3,12 @@ package com.yxt.anrui.base.biz.commoncontract; |
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.base.api.basemodelszconfig.AppBaseModelSzconfigDetailsVo; |
|
|
|
import com.yxt.anrui.base.api.basetrailer.AppBaseTrailerDetailsVo; |
|
|
|
import com.yxt.anrui.base.api.commonappendix.CommonAppendix; |
|
|
|
import com.yxt.anrui.base.api.commoncontract.*; |
|
|
|
import com.yxt.anrui.base.biz.basemodelszconfig.BaseModelSzconfigService; |
|
|
|
import com.yxt.anrui.base.biz.basetrailer.BaseTrailerService; |
|
|
|
import com.yxt.anrui.base.biz.basevehiclebrand.BaseVehicleBrandService; |
|
|
|
import com.yxt.anrui.base.biz.basevehiclemodel.BaseVehicleModelService; |
|
|
|
import com.yxt.anrui.base.biz.commonappendix.CommonAppendixService; |
|
|
@ -13,6 +17,12 @@ import com.yxt.anrui.buscenter.api.busdeposit.BusDepositFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.busdepositvehicle.BusDepositVehicleFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.busorder.BusOrderFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.busorder.BusOrderVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busorderdiscount.AppBusOrderDiscountListVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busorderdiscount.BusOrderDiscountFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.busordermodel.AppBusOrderModelVo; |
|
|
|
import com.yxt.anrui.buscenter.api.busordermodel.BusOrderModelFeign; |
|
|
|
import com.yxt.anrui.buscenter.api.busordervehicle.BusOrderVehicleFeign; |
|
|
|
import com.yxt.anrui.crm.api.crmcustomer.CrmCustomerFeign; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormLinkFeign; |
|
|
|
import com.yxt.anrui.flowable.api.sysformlink.SysFormStateVo; |
|
|
|
import com.yxt.anrui.flowable.api.utils.procDefEnum; |
|
|
@ -25,6 +35,7 @@ import com.yxt.anrui.portal.api.sysstafforg.SysStaffOrgVo; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserFeign; |
|
|
|
import com.yxt.anrui.portal.api.sysuser.SysUserVo; |
|
|
|
import com.yxt.anrui.portal.config.DictCommonType; |
|
|
|
import com.yxt.common.base.config.component.DocPdfComponent; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.DateUtils; |
|
|
@ -34,12 +45,18 @@ import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.MessageFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.concurrent.Future; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -58,6 +75,15 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class CommonContractService extends MybatisBaseService<CommonContractMapper, CommonContract> { |
|
|
|
|
|
|
|
@Value("${templateUrl.uploadUrl}") |
|
|
|
private String uploadTemplateUrl; |
|
|
|
|
|
|
|
@Value("${templateUrl.prefixUrl}") |
|
|
|
private String prefixTemplateUrl; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DocPdfComponent docPdfComponent; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
@ -71,6 +97,12 @@ public class CommonContractService extends MybatisBaseService<CommonContractMapp |
|
|
|
@Autowired |
|
|
|
private BusOrderFeign busOrderFeign; |
|
|
|
@Autowired |
|
|
|
private BusOrderDiscountFeign busOrderDiscountFeign; |
|
|
|
@Autowired |
|
|
|
private BusOrderModelFeign busOrderModelFeign; |
|
|
|
@Autowired |
|
|
|
private BusOrderVehicleFeign busOrderVehicleFeign; |
|
|
|
@Autowired |
|
|
|
private BusDepositVehicleFeign busDepositVehicleFeign; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
@ -84,6 +116,12 @@ public class CommonContractService extends MybatisBaseService<CommonContractMapp |
|
|
|
private FlowableService flowableService; |
|
|
|
@Autowired |
|
|
|
private SysFormLinkFeign sysFormLinkFeign; |
|
|
|
@Autowired |
|
|
|
private CrmCustomerFeign crmCustomerFeign; |
|
|
|
@Autowired |
|
|
|
private BaseModelSzconfigService baseModelSzconfigService; |
|
|
|
@Autowired |
|
|
|
private BaseTrailerService baseTrailerService; |
|
|
|
|
|
|
|
private QueryWrapper<CommonContract> createQueryWrapper(CommonContractQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
@ -522,6 +560,266 @@ public class CommonContractService extends MybatisBaseService<CommonContractMapp |
|
|
|
return baseMapper.saveList(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打印项设置 |
|
|
|
* @param busSid |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<PrintItemVo> printItemSet(String busSid, String customerName) { |
|
|
|
CommonContractBuscenterVo contractBuscenterVo = baseMapper.selectByBusSid(busSid); |
|
|
|
PrintItemVo vo = new PrintItemVo(); |
|
|
|
BeanUtil.copyProperties(contractBuscenterVo, vo); |
|
|
|
vo.setCustomerName(customerName); |
|
|
|
return new ResultBean<PrintItemVo>().success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 打印项-确认 |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public ResultBean<List<PrintConfirmVo>> printConfirm(PrintConfirmDto dto) { |
|
|
|
Map<String, Object> map = new HashMap<String, Object>(); |
|
|
|
// 合同信息
|
|
|
|
CommonContract contract = fetchBySid(dto.getSid()); |
|
|
|
map.put("partyA", contract.getPartyA()); // 甲方
|
|
|
|
map.put("partyB", contract.getPartyB()); // 乙方
|
|
|
|
map.put("contractNo", contract.getContractNo()); // 合同编号
|
|
|
|
map.put("createDate", contract.getCreateDate()); // 签订时间
|
|
|
|
// 客户信息;
|
|
|
|
BusOrderVo order = busOrderFeign.fetchSid(dto.getBusSid()).getData(); |
|
|
|
map.put("customerName", order.getCustomerName()); // 联系电话
|
|
|
|
map.put("mobile", order.getMobile()); // 联系电话
|
|
|
|
map.put("IDNumber", order.getIDNumber()); // 身份证号
|
|
|
|
// 车型、主车信息
|
|
|
|
ResultBean<AppBusOrderModelVo> model = busOrderModelFeign.getAppBusOrderModelInfoBySid(dto.getBusSid()); |
|
|
|
map.put("modelName", model.getData().getModelName()); // 车型
|
|
|
|
map.put("modelConfig", model.getData().getModelotherConfig()); // 配置(只有订车有) ?待确认
|
|
|
|
map.put("mainVehicleNum", model.getData().getQuantity()); // 主车数量
|
|
|
|
map.put("mainVehicleSinglePrice", model.getData().getSingle_price()); // 单台成交价
|
|
|
|
ResultBean<String> vinNo = busOrderVehicleFeign.getVehicleVINNoByOrderSid(dto.getBusSid()); |
|
|
|
map.put("VINNo", vinNo.getData()); // 车架号
|
|
|
|
// 上装信息
|
|
|
|
AppBaseModelSzconfigDetailsVo szconfig = baseModelSzconfigService.getAppBaseModelSzconfigDetailsVo(model.getData().getSid()); |
|
|
|
map.put("topName", szconfig.getTopName()); // 上装
|
|
|
|
// 挂车信息
|
|
|
|
AppBaseTrailerDetailsVo trailer = baseTrailerService.getAppBaseTrailerDetailsVo(model.getData().getSid()); |
|
|
|
map.put("trailerName", trailer.getOtherConfig()); // 挂车
|
|
|
|
map.put("trailerNum", model.getData().getQuantity()); // 挂车数量 ?待确认
|
|
|
|
map.put("trailerSinglePrice", StringUtils.isBlank(trailer.getTrailerPrince()) ? "" : trailer.getTrailerPrince()); // 挂车单台成交价 ?待确认
|
|
|
|
// 优惠说明信息
|
|
|
|
ResultBean<List<AppBusOrderDiscountListVo>> discountList = busOrderDiscountFeign.getAppDiscountListVoByOrderSid(order.getOrderSid()); |
|
|
|
map.put("discountDetail", ""); // 优惠说明 ?待确认
|
|
|
|
if (discountList.getSuccess()) { |
|
|
|
map.put("discountDetail", discountList.getData().get(0).getDetail()); // 优惠说明 ?待确认
|
|
|
|
} |
|
|
|
// 保险说明信息
|
|
|
|
map.put("insuranceDetail", "首次在本店投保,第二、三年继续在本店续保。(不在公司投保的,不显示)"); // 保险说明 ?待确认
|
|
|
|
// 车辆交付地点
|
|
|
|
map.put("deliveryPlace", model.getData().getExpected_takecar_location()); |
|
|
|
|
|
|
|
List<PrintConfirmVo> list = new ArrayList<>(); |
|
|
|
try { |
|
|
|
ExecutorService executor = Executors.newFixedThreadPool(5); |
|
|
|
Future<String> future1 = executor.submit(() -> { |
|
|
|
return genCarSaleContract(dto, map, order); |
|
|
|
}); |
|
|
|
Future<String> future2 = executor.submit(() -> { |
|
|
|
return genVehicleRegistration(dto, map); |
|
|
|
}); |
|
|
|
Future<String> future3 = executor.submit(() -> { |
|
|
|
// 客户开票申请书(暂时先不考虑)
|
|
|
|
if (dto.getIsAdvanceInvoice() == 1) { |
|
|
|
return genAdvanceInvoice(dto, map); |
|
|
|
} else { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
}); |
|
|
|
Future<String> future4 = executor.submit(() -> { |
|
|
|
// 委托提车授权书
|
|
|
|
if (dto.getIsEntrustVehicle() == 1) { |
|
|
|
return genEntrustVehicle(dto, map); |
|
|
|
} else { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
}); |
|
|
|
Future<String> future5 = executor.submit(() -> { |
|
|
|
return genCarSaleContractBlank(dto, map, order); |
|
|
|
}); |
|
|
|
|
|
|
|
future1.get(); |
|
|
|
future2.get(); |
|
|
|
future3.get(); |
|
|
|
future4.get(); |
|
|
|
future5.get(); |
|
|
|
PrintConfirmVo printConfirmVo = null; |
|
|
|
if (StringUtils.isNotBlank(future1.get())) { |
|
|
|
printConfirmVo = new PrintConfirmVo(); |
|
|
|
// 待确认:现车或订车
|
|
|
|
// 现车
|
|
|
|
// printConfirmVo.setName(MessageFormat.format("《{0}》", ContractTemplateEnum.CARSALECONTRACTNEW.getName()));
|
|
|
|
// 订车
|
|
|
|
printConfirmVo.setName(MessageFormat.format("《{0}》", ContractTemplateEnum.CARSALECONTRACTBOOK.getName())); |
|
|
|
printConfirmVo.setDownloadUrl(future1.get()); |
|
|
|
list.add(printConfirmVo); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(future2.get())) { |
|
|
|
printConfirmVo = new PrintConfirmVo(); |
|
|
|
printConfirmVo.setName(MessageFormat.format("《{0}》", ContractTemplateEnum.VEHICLEREGISTRATION.getName())); |
|
|
|
printConfirmVo.setDownloadUrl(future2.get()); |
|
|
|
list.add(printConfirmVo); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(future3.get())) { |
|
|
|
printConfirmVo = new PrintConfirmVo(); |
|
|
|
printConfirmVo.setName(MessageFormat.format("《{0}》", ContractTemplateEnum.CUSTOMERINVOICINGAPPLICATION.getName())); |
|
|
|
printConfirmVo.setDownloadUrl(future3.get()); |
|
|
|
list.add(printConfirmVo); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(future4.get())) { |
|
|
|
printConfirmVo = new PrintConfirmVo(); |
|
|
|
printConfirmVo.setName(MessageFormat.format("《{0}》", ContractTemplateEnum.ENTRUSTPICKUPAUTHORIZATION.getName())); |
|
|
|
printConfirmVo.setDownloadUrl(future4.get()); |
|
|
|
list.add(printConfirmVo); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(future5.get())) { |
|
|
|
printConfirmVo = new PrintConfirmVo(); |
|
|
|
printConfirmVo.setName(MessageFormat.format("《{0}》", ContractTemplateEnum.CARSALECONTRACTNEWBLANK.getName())); |
|
|
|
printConfirmVo.setDownloadUrl(future5.get()); |
|
|
|
list.add(printConfirmVo); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return new ResultBean().fail().setMsg("生成文件失败"); |
|
|
|
} |
|
|
|
return new ResultBean().success().setData(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成 新车买卖合同(现车或订车) pdf |
|
|
|
* @param dto |
|
|
|
*/ |
|
|
|
private String genCarSaleContract(PrintConfirmDto dto, Map<String, Object> map, BusOrderVo order) { |
|
|
|
String url = ""; |
|
|
|
// 车辆税信息
|
|
|
|
map.put("taxSum", "1111"); // 车辆含税 ?待确认
|
|
|
|
map.put("taxSumUpper", "壹仟壹佰壹拾壹"); // 车辆含税(大写) ?待确认
|
|
|
|
// 乙方缴纳订金
|
|
|
|
map.put("deposit", order.getDeposit()); // 订金
|
|
|
|
map.put("useDeposit", "true"); // 判断是否展示括号中的内容 ?待确认:用本人交纳的虚拟订金的,需要显示订金后面括弧 中的说明
|
|
|
|
map.put("date", order.getCreateDate()); // 订金缴纳日期 ?待确认
|
|
|
|
map.put("deposit1", ""); // 总订金 ?待确认
|
|
|
|
map.put("deposit2", ""); // 用于缴纳的订金 ?待确认
|
|
|
|
|
|
|
|
// 目标路径 ? 待确认:如何区分现车和订车
|
|
|
|
// 现车
|
|
|
|
// String typeName = ContractTemplateEnum.CARSALECONTRACTNEW.getName();
|
|
|
|
// 订车
|
|
|
|
String typeName = ContractTemplateEnum.CARSALECONTRACTBOOK.getName(); |
|
|
|
String docName = typeName + "(" + order.getCustomerName() + ").doc"; |
|
|
|
Map<String, String> resultMap = docPdfComponent.createDocToPdf(map, typeName, docName); |
|
|
|
url = resultMap.get("prefixTemplateUrl"); |
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成 新车买卖合同(现车) (空)pdf |
|
|
|
* @param dto |
|
|
|
* @param map |
|
|
|
* @param order |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String genCarSaleContractBlank(PrintConfirmDto dto, Map<String, Object> map, BusOrderVo order) { |
|
|
|
String url = ""; |
|
|
|
String typeName = ""; |
|
|
|
String docName = ""; |
|
|
|
// 涉及高低开票的,需要打印两套合同,一套按照成交价打印(记账用),一套为价格空白的合同(开票用)
|
|
|
|
// 合同金额 ? 待确定
|
|
|
|
BigDecimal contractAmount = order.getContractAmount(); |
|
|
|
if (contractAmount == null) { |
|
|
|
// 待确定 ? 现车或订车
|
|
|
|
// 现车
|
|
|
|
typeName = ContractTemplateEnum.CARSALECONTRACTNEWBLANK.getName(); |
|
|
|
// 订车
|
|
|
|
typeName = ContractTemplateEnum.CARSALECONTRACTBOOKBLANK.getName(); |
|
|
|
docName = typeName + "(" + order.getCustomerName() + ").doc"; |
|
|
|
Map<String, String> map2 = docPdfComponent.createDocToPdf(map, typeName, docName); |
|
|
|
url += ", " + map2.get("prefixTemplateUrl"); |
|
|
|
} |
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成 客户开票申请书 pdf |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String genAdvanceInvoice(PrintConfirmDto dto, Map<String, Object> map) { |
|
|
|
String url = ""; |
|
|
|
// 列表?待确认
|
|
|
|
List<AdvanceInvoiceListVo> list = new ArrayList<>(); |
|
|
|
AdvanceInvoiceListVo vo = new AdvanceInvoiceListVo(); |
|
|
|
vo.setInvoiceName("开票名称"); |
|
|
|
vo.setInvoiceMoney("开票金额"); |
|
|
|
vo.setInvoiceType("发票类型"); |
|
|
|
vo.setVINNo("002234329"); |
|
|
|
list.add(vo); |
|
|
|
AdvanceInvoiceListVo vo1 = new AdvanceInvoiceListVo(); |
|
|
|
BeanUtil.copyProperties(vo, vo1); |
|
|
|
vo1.setVINNo("002324345"); |
|
|
|
list.add(vo1); |
|
|
|
map.put("list", list); // 列表
|
|
|
|
// 目标路径
|
|
|
|
String typeName = ContractTemplateEnum.CUSTOMERINVOICINGAPPLICATION.getName(); |
|
|
|
String docName = typeName + "(" + map.get("customerName") + ").doc"; |
|
|
|
Map<String, String> resultMap = docPdfComponent.createDocToPdf(map, typeName, docName); |
|
|
|
url = resultMap.get("prefixTemplateUrl"); |
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成 车辆登记合同 pdf |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String genVehicleRegistration(PrintConfirmDto dto, Map<String, Object> map) { |
|
|
|
String url = ""; |
|
|
|
// 列表?待确认
|
|
|
|
List<VehicleRegistrationListVo> list = new ArrayList<>(); |
|
|
|
VehicleRegistrationListVo vo = new VehicleRegistrationListVo(); |
|
|
|
vo.setBrandName("陕汽"); |
|
|
|
vo.setVINNo("002234329"); |
|
|
|
vo.setEngineNo("672342642232323"); |
|
|
|
list.add(vo); |
|
|
|
VehicleRegistrationListVo vo1 = new VehicleRegistrationListVo(); |
|
|
|
vo1.setBrandName("欧曼"); |
|
|
|
vo1.setVINNo("002324345"); |
|
|
|
vo1.setEngineNo("67234299923ad"); |
|
|
|
list.add(vo1); |
|
|
|
map.put("list", list); // 列表
|
|
|
|
// 目标路径
|
|
|
|
String typeName = ContractTemplateEnum.VEHICLEREGISTRATION.getName(); |
|
|
|
String docName = typeName + "(" + map.get("customerName") + ").doc"; |
|
|
|
Map<String, String> resultMap = docPdfComponent.createDocToPdf(map, typeName, docName); |
|
|
|
url = resultMap.get("prefixTemplateUrl"); |
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成 委托提车授权书 pdf |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String genEntrustVehicle(PrintConfirmDto dto, Map<String, Object> map) { |
|
|
|
String url = ""; |
|
|
|
// 目标路径
|
|
|
|
String typeName = ContractTemplateEnum.ENTRUSTPICKUPAUTHORIZATION.getName(); |
|
|
|
String docName = typeName + "(" + map.get("customerName") + ").doc"; |
|
|
|
Map<String, String> resultMap = docPdfComponent.createDocToPdf(map, typeName, docName); |
|
|
|
url = resultMap.get("prefixTemplateUrl"); |
|
|
|
return url; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<CommonContractVo> selByBusSid(String userSid, String busSid) { |
|
|
|
Map<String, String> map = generateContractNo(userSid); |
|
|
|
String staffSid = map.get("staffSid"); |
|
|
|