| | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.aizuda.bpm.engine.entity.FlwTask; |
| | | import com.aizuda.bpm.mybatisplus.mapper.FlwTaskMapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | List<TContract> list = contractService.lambdaQuery().in(TContract::getId, dto.getIds()).list(); |
| | | List<String> res = new ArrayList<>(); |
| | | for (TContract contract : list) { |
| | | String url = generateContract(contract); |
| | | res.add(url); |
| | | } |
| | | |
| | | return R.ok(res); |
| | | } |
| | | |
| | | private String generateContract(TContract contract) { |
| | | String templateFileName = "1_yzj_租赁合同_个人.docx"; |
| | | TBill firstBill = billService.lambdaQuery().eq(TBill::getContractId, contract.getId()) |
| | | TBill firstBill = null; |
| | | TTenant tenant = null; |
| | | THouse tHouse = null; |
| | | TCheckAcceptRecord tCheckAcceptRecord = null; |
| | | if (StringUtils.isNotEmpty(contract.getId())){ |
| | | firstBill = billService.lambdaQuery().eq(TBill::getContractId, contract.getId()) |
| | | .orderByDesc(TBill::getStartTime).last("limit 1").one(); |
| | | TTenant tenant = tenantService.getById(contract.getTenantId()); |
| | | THouse tHouse = houseService.getById(contract.getHouseId()); |
| | | tenant = tenantService.getById(contract.getTenantId()); |
| | | tHouse = houseService.getById(contract.getHouseId()); |
| | | // 验收时间 |
| | | tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery() |
| | | .eq(TCheckAcceptRecord::getContractId, contract.getId()) |
| | | .last("limit 1").one(); |
| | | } |
| | | |
| | | |
| | | |
| | | Map<String, Object> templateParam = new HashMap<>(5); |
| | | templateParam.put("${contractNumber}", contract.getContractNumber()); |
| | | templateParam.put("${partyOneName}", contract.getPartyOneName()); |
| | |
| | | templateParam.put("${partyOnePhone}", contract.getPartyOnePhone()); |
| | | templateParam.put("${partyTwoPerson}", contract.getPartyTwoPerson()); |
| | | templateParam.put("${partyTwoPhone}", contract.getPartyTwoPhone()); |
| | | // 验收时间 |
| | | TCheckAcceptRecord tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery().eq(TCheckAcceptRecord::getContractId, contract.getId()).last("limit 1").one(); |
| | | |
| | | if (tCheckAcceptRecord!=null &&tCheckAcceptRecord.getCheckTime()!=null ){ |
| | | templateParam.put("${checkTime}", DateUtils.localDateTimeToStringYear(tCheckAcceptRecord.getCheckTime())); |
| | | }else{ |
| | | templateParam.put("${checkTime}", ""); |
| | | |
| | | } |
| | | String url = wordUtil.generatePdf("/usr/local/project/file/", templateFileName, templateParam, "租赁合同", "/usr/local/project/file/"); |
| | | res.add(url); |
| | | return wordUtil.generatePdf("/usr/local/project/file/", templateFileName, templateParam, "租赁合同", "/usr/local/project/file/"); |
| | | } |
| | | |
| | | return R.ok(res); |
| | | /** |
| | | * 生成预览版合同附件 |
| | | */ |
| | | @ApiOperation(value = "生成预览版合同附件") |
| | | @PostMapping("/generateContractPreview") |
| | | public R<String> generateContractPreview(@RequestBody TContractDTO dto) |
| | | { |
| | | TContract contract = new TContract(); |
| | | BeanUtil.copyProperties(dto,contract); |
| | | return R.ok(generateContract(contract)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 导出 |
| | | */ |