租赁协议
This commit is contained in:
		
							parent
							
								
									cbeb16ca28
								
							
						
					
					
						commit
						6b218f8d3d
					
				| 
						 | 
					@ -12,6 +12,8 @@ import io.swagger.annotations.ApiOperation;
 | 
				
			||||||
import org.springframework.web.bind.annotation.*;
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.annotation.Resource;
 | 
					import javax.annotation.Resource;
 | 
				
			||||||
 | 
					import java.net.URL;
 | 
				
			||||||
 | 
					import java.net.URLDecoder;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -36,6 +38,9 @@ public class BmContractController extends BaseController {
 | 
				
			||||||
    @ApiOperation(value = "合同新增")
 | 
					    @ApiOperation(value = "合同新增")
 | 
				
			||||||
    @PostMapping("/add")
 | 
					    @PostMapping("/add")
 | 
				
			||||||
    public AjaxResult add(@RequestBody BmContract bmContract) {
 | 
					    public AjaxResult add(@RequestBody BmContract bmContract) {
 | 
				
			||||||
 | 
					        String decode = URLDecoder.decode(bmContract.getContent());
 | 
				
			||||||
 | 
					        decode = decode.replace("$", "$");
 | 
				
			||||||
 | 
					        bmContract.setContent(decode);
 | 
				
			||||||
        Integer i = bmContractService.add(bmContract);
 | 
					        Integer i = bmContractService.add(bmContract);
 | 
				
			||||||
        if (i > 0){
 | 
					        if (i > 0){
 | 
				
			||||||
            return AjaxResult.success("新增成功");
 | 
					            return AjaxResult.success("新增成功");
 | 
				
			||||||
| 
						 | 
					@ -46,6 +51,9 @@ public class BmContractController extends BaseController {
 | 
				
			||||||
    @ApiOperation(value = "合同修改")
 | 
					    @ApiOperation(value = "合同修改")
 | 
				
			||||||
    @PostMapping("/edit")
 | 
					    @PostMapping("/edit")
 | 
				
			||||||
    public AjaxResult edit(@RequestBody BmContract bmContract) {
 | 
					    public AjaxResult edit(@RequestBody BmContract bmContract) {
 | 
				
			||||||
 | 
					        String decode = URLDecoder.decode(bmContract.getContent());
 | 
				
			||||||
 | 
					        decode = decode.replace("$", "$");
 | 
				
			||||||
 | 
					        bmContract.setContent(decode);
 | 
				
			||||||
        Integer i = bmContractService.edit(bmContract);
 | 
					        Integer i = bmContractService.edit(bmContract);
 | 
				
			||||||
        if (i > 0){
 | 
					        if (i > 0){
 | 
				
			||||||
            return AjaxResult.success("修改成功");
 | 
					            return AjaxResult.success("修改成功");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ public class BmContractServiceImpl implements BmContractService {
 | 
				
			||||||
        bmContract.setStatus(0);
 | 
					        bmContract.setStatus(0);
 | 
				
			||||||
        Integer add = bmContractMapper.add(bmContract);
 | 
					        Integer add = bmContractMapper.add(bmContract);
 | 
				
			||||||
        if (add > 0) {
 | 
					        if (add > 0) {
 | 
				
			||||||
            if (bmContract.getBmFileInfoList().size() > 0) {
 | 
					            if (bmContract.getBmFileInfoList() != null && bmContract.getBmFileInfoList().size() > 0) {
 | 
				
			||||||
                for (BmFileInfo bmFileInfo : bmContract.getBmFileInfoList()) {
 | 
					                for (BmFileInfo bmFileInfo : bmContract.getBmFileInfoList()) {
 | 
				
			||||||
                    bmFileInfo.setModelId(Long.valueOf(bmContract.getId()));
 | 
					                    bmFileInfo.setModelId(Long.valueOf(bmContract.getId()));
 | 
				
			||||||
                    bmFileInfo.setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT);
 | 
					                    bmFileInfo.setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT);
 | 
				
			||||||
| 
						 | 
					@ -69,7 +69,7 @@ public class BmContractServiceImpl implements BmContractService {
 | 
				
			||||||
        bmContract.setOwnerCom(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
 | 
					        bmContract.setOwnerCom(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
 | 
				
			||||||
        Integer edit = bmContractMapper.edit(bmContract);
 | 
					        Integer edit = bmContractMapper.edit(bmContract);
 | 
				
			||||||
        if (edit > 0) {
 | 
					        if (edit > 0) {
 | 
				
			||||||
            if (bmContract.getBmFileInfoList().size() > 0) {
 | 
					            if (bmContract.getBmFileInfoList() != null && bmContract.getBmFileInfoList().size() > 0) {
 | 
				
			||||||
                BmFileInfo fileInfo = new BmFileInfo();
 | 
					                BmFileInfo fileInfo = new BmFileInfo();
 | 
				
			||||||
                fileInfo.setModelId(Long.valueOf(bmContract.getId())).setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT).setFileType(0L);
 | 
					                fileInfo.setModelId(Long.valueOf(bmContract.getId())).setTaskType(MaterialConstants.APPENDICES_OF_CONTRACT).setFileType(0L);
 | 
				
			||||||
                bmFileInfoMapper.deleteBmFileInfo(fileInfo);
 | 
					                bmFileInfoMapper.deleteBmFileInfo(fileInfo);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,6 +41,7 @@ import java.io.ByteArrayInputStream;
 | 
				
			||||||
import java.io.ByteArrayOutputStream;
 | 
					import java.io.ByteArrayOutputStream;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.io.InputStream;
 | 
					import java.io.InputStream;
 | 
				
			||||||
 | 
					import java.net.MalformedURLException;
 | 
				
			||||||
import java.net.URL;
 | 
					import java.net.URL;
 | 
				
			||||||
import java.text.ParseException;
 | 
					import java.text.ParseException;
 | 
				
			||||||
import java.text.SimpleDateFormat;
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
| 
						 | 
					@ -176,9 +177,9 @@ public class OrderController extends BaseController {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @ApiOperation(value = "租赁协议(查看)")
 | 
					   /* @ApiOperation(value = "租赁协议(查看)")
 | 
				
			||||||
    @GetMapping("/leaseAgreement")
 | 
					    @GetMapping("/leaseAgreement")
 | 
				
			||||||
    public AjaxResult getleaseAgreement(String orderId, Map<String, String> replacements) throws IOException, ParseException {
 | 
					    public AjaxResult leaseAgreement(String orderId, Map<String, String> replacements) throws IOException, ParseException {
 | 
				
			||||||
        OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
 | 
					        OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
 | 
				
			||||||
        List<OrderDetailDto> orderDetailsByOrderId = orderMapper.selectOrderDetailsByOderId(orderId);
 | 
					        List<OrderDetailDto> orderDetailsByOrderId = orderMapper.selectOrderDetailsByOderId(orderId);
 | 
				
			||||||
        BmContract bmContract = new BmContract();
 | 
					        BmContract bmContract = new BmContract();
 | 
				
			||||||
| 
						 | 
					@ -242,10 +243,72 @@ public class OrderController extends BaseController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        MultipartFile file = new MockMultipartFile("contract", "contract.docx", MediaType.APPLICATION_OCTET_STREAM_VALUE, wordBytes);
 | 
					        MultipartFile file = new MockMultipartFile("contract", "contract.docx", MediaType.APPLICATION_OCTET_STREAM_VALUE, wordBytes);
 | 
				
			||||||
        return sysFileService.upload(file);
 | 
					        return sysFileService.upload(file);
 | 
				
			||||||
    }
 | 
					    }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   /* @ApiOperation(value = "购物车协议(查看)")
 | 
				
			||||||
 | 
					    @GetMapping("/bookCarAgreement")
 | 
				
			||||||
 | 
					    public AjaxResult bookCarAgreement(OrderInfoDto orderInfoDto, Map<String, String> replacements) throws ParseException, IOException {
 | 
				
			||||||
 | 
					        if (orderInfoDto != null) {
 | 
				
			||||||
 | 
					            BmContract bmContract = new BmContract();
 | 
				
			||||||
 | 
					            bmContract.setStatus(1);
 | 
				
			||||||
 | 
					            List<BmContract> list = bmContractService.list(bmContract);
 | 
				
			||||||
 | 
					            String wordUrl = list.get(0).getBmFileInfoList().get(0).getFileUrl();
 | 
				
			||||||
 | 
					            InputStream inputStream = new URL(wordUrl).openStream();
 | 
				
			||||||
 | 
					            XWPFDocument document = new XWPFDocument(inputStream);
 | 
				
			||||||
 | 
					            SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
 | 
				
			||||||
 | 
					            SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
				
			||||||
 | 
					            //装备所属公司
 | 
				
			||||||
 | 
					            replacements.put("${czcompanyName}", orderInfoDto.getCzcompanyName());
 | 
				
			||||||
 | 
					            //承租方所属公司
 | 
				
			||||||
 | 
					            replacements.put("${companyName}", orderInfoDto.getCompanyName());
 | 
				
			||||||
 | 
					            //订单金额
 | 
				
			||||||
 | 
					            replacements.put("${cost}", orderInfoDto.getCost().toString());
 | 
				
			||||||
 | 
					            //订单详情
 | 
				
			||||||
 | 
					            StrBuilder orderDetail = new StrBuilder();
 | 
				
			||||||
 | 
					            List<OrderDetailDto> detailsList = orderInfoDto.getDetailsList();
 | 
				
			||||||
 | 
					            for (OrderDetailDto orderDetailDto : detailsList) {
 | 
				
			||||||
 | 
					                Date rentBeginTime = inputFormat.parse(orderDetailDto.getRentBeginTime().toString());
 | 
				
			||||||
 | 
					                String beginTime = outputFormat.format(rentBeginTime);
 | 
				
			||||||
 | 
					                Date rentEndTime = inputFormat.parse(orderDetailDto.getRentEndTime().toString());
 | 
				
			||||||
 | 
					                String endTime = outputFormat.format(rentEndTime);
 | 
				
			||||||
 | 
					                // 添加每一行的内容
 | 
				
			||||||
 | 
					                orderDetail.append("\n");
 | 
				
			||||||
 | 
					                orderDetail.append("机具名称:").append(orderDetailDto.getDeviceName()).append("\n")
 | 
				
			||||||
 | 
					                        .append("租期:").append(beginTime).append(" 至 ").append(endTime).append("\n")
 | 
				
			||||||
 | 
					                        .append("天数:").append(orderDetailDto.getDays()).append("天").append("\n")
 | 
				
			||||||
 | 
					                        .append("租金:").append(orderDetailDto.getDayLeasePrice()).append("元/天").append("\n")
 | 
				
			||||||
 | 
					                        .append("数量:").append(orderDetailDto.getNum()).append("个").append("\n");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            replacements.put("${orderTable}", orderDetail.toString());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            for (IBodyElement element : document.getBodyElements()) {
 | 
				
			||||||
 | 
					                if (element instanceof XWPFParagraph) {
 | 
				
			||||||
 | 
					                    XWPFParagraph paragraph = (XWPFParagraph) element;
 | 
				
			||||||
 | 
					                    for (XWPFRun run : paragraph.getRuns()) {
 | 
				
			||||||
 | 
					                        String text = run.getText(0);
 | 
				
			||||||
 | 
					                        if (text != null) {
 | 
				
			||||||
 | 
					                            for (Map.Entry<String, String> entry : replacements.entrySet()) {
 | 
				
			||||||
 | 
					                                text = text.replace(entry.getKey(), entry.getValue());
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            run.setText(text, 0);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 | 
				
			||||||
 | 
					            document.write(outputStream);
 | 
				
			||||||
 | 
					            byte[] wordBytes = outputStream.toByteArray();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            MultipartFile file = new MockMultipartFile("bookCar", "bookCar.docx", MediaType.APPLICATION_OCTET_STREAM_VALUE, wordBytes);
 | 
				
			||||||
 | 
					            return sysFileService.upload(file);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return AjaxResult.error("参数错误");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /*  @ApiOperation(value = "租赁协议(查看)")
 | 
					    @ApiOperation(value = "租赁协议(查看)")
 | 
				
			||||||
    @GetMapping("/leaseAgreement")
 | 
					    @GetMapping("/leaseAgreement")
 | 
				
			||||||
    public AjaxResult getleaseAgreement(String orderId, Map<String, String> replacements) throws ParseException {
 | 
					    public AjaxResult getleaseAgreement(String orderId, Map<String, String> replacements) throws ParseException {
 | 
				
			||||||
        OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
 | 
					        OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
 | 
				
			||||||
| 
						 | 
					@ -272,7 +335,7 @@ public class OrderController extends BaseController {
 | 
				
			||||||
            String beginTime = outputFormat.format(rentBeginTime);
 | 
					            String beginTime = outputFormat.format(rentBeginTime);
 | 
				
			||||||
            Date rentEndTime = inputFormat.parse(orderDetailDto.getRentEndTime().toString());
 | 
					            Date rentEndTime = inputFormat.parse(orderDetailDto.getRentEndTime().toString());
 | 
				
			||||||
            String endTime = outputFormat.format(rentEndTime);
 | 
					            String endTime = outputFormat.format(rentEndTime);
 | 
				
			||||||
            orderDetail += "<p>机具名称:" + orderDetailDto.getDeviceName() + "<br>租期:" + beginTime + "至" + endTime + "<br>天数:" + orderDetailDto.getDays() + "天 <br>租金:" + orderDetailDto.getDayLeasePrice() + "元/天<br>数量:" + orderDetailDto.getNum() + "</p>";
 | 
					            orderDetail += "<p><br>机具名称:" + orderDetailDto.getDeviceName() + "<br>租期:" + beginTime + "至" + endTime + "<br>天数:" + orderDetailDto.getDays() + "天 <br>租金:" + orderDetailDto.getDayLeasePrice() + "元/天<br>数量:" + orderDetailDto.getNum() + "</p>";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        replacements.put("orderTable", orderDetail);
 | 
					        replacements.put("orderTable", orderDetail);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -286,16 +349,16 @@ public class OrderController extends BaseController {
 | 
				
			||||||
        StrSubstitutor sub = new StrSubstitutor(replacements);
 | 
					        StrSubstitutor sub = new StrSubstitutor(replacements);
 | 
				
			||||||
        String result = sub.replace(content);
 | 
					        String result = sub.replace(content);
 | 
				
			||||||
        return AjaxResult.success(result);
 | 
					        return AjaxResult.success(result);
 | 
				
			||||||
    }*/
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /*  @ApiOperation(value = "购物车协议(查看)")
 | 
					    @ApiOperation(value = "购物车协议(查看)")
 | 
				
			||||||
    @GetMapping("/bookCarAgreement")
 | 
					    @GetMapping("/bookCarAgreement")
 | 
				
			||||||
    public AjaxResult getbookCarAgreement(OrderInfoDto orderInfoDto, Map<String, Object> replacements) throws ParseException {
 | 
					    public AjaxResult getbookCarAgreement(OrderInfoDto orderInfoDto, Map<String, Object> replacements) throws ParseException, IOException {
 | 
				
			||||||
        if (orderInfoDto != null) {
 | 
					        if (orderInfoDto != null) {
 | 
				
			||||||
            SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
 | 
					            SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
 | 
				
			||||||
            SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
					            SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 | 
				
			||||||
            //装备所属公司
 | 
					            //装备所属公司
 | 
				
			||||||
            replacements.put("czcompanyName", orderInfoDto.getCzcompanyName());
 | 
					            replacements.put("czCompanyName", orderInfoDto.getCzcompanyName());
 | 
				
			||||||
            //承租方所属公司
 | 
					            //承租方所属公司
 | 
				
			||||||
            replacements.put("companyName", orderInfoDto.getCompanyName());
 | 
					            replacements.put("companyName", orderInfoDto.getCompanyName());
 | 
				
			||||||
            //订单金额
 | 
					            //订单金额
 | 
				
			||||||
| 
						 | 
					@ -308,7 +371,7 @@ public class OrderController extends BaseController {
 | 
				
			||||||
                String beginTime = outputFormat.format(rentBeginTime);
 | 
					                String beginTime = outputFormat.format(rentBeginTime);
 | 
				
			||||||
                Date rentEndTime = inputFormat.parse(orderDetailDto.getRentEndTime().toString());
 | 
					                Date rentEndTime = inputFormat.parse(orderDetailDto.getRentEndTime().toString());
 | 
				
			||||||
                String endTime = outputFormat.format(rentEndTime);
 | 
					                String endTime = outputFormat.format(rentEndTime);
 | 
				
			||||||
                orderDetail += "<p>机具名称:" + orderDetailDto.getDeviceName() + "<br>租期:" + beginTime + "至" + endTime + "<br>天数:" + orderDetailDto.getDays() + "天 <br>租金:" + orderDetailDto.getDayLeasePrice() + "元/天<br>数量:" + orderDetailDto.getNum() + "</p>";
 | 
					                orderDetail += "<p><br>机具名称:" + orderDetailDto.getDeviceName() + "<br>租期:" + beginTime + "至" + endTime + "<br>天数:" + orderDetailDto.getDays() + "天 <br>租金:" + orderDetailDto.getDayLeasePrice() + "元/天<br>数量:" + orderDetailDto.getNum() + "</p>";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            replacements.put("orderTable", orderDetail);
 | 
					            replacements.put("orderTable", orderDetail);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -322,5 +385,5 @@ public class OrderController extends BaseController {
 | 
				
			||||||
        StrSubstitutor sub = new StrSubstitutor(replacements);
 | 
					        StrSubstitutor sub = new StrSubstitutor(replacements);
 | 
				
			||||||
        String result = sub.replace(content);
 | 
					        String result = sub.replace(content);
 | 
				
			||||||
        return AjaxResult.success(result);
 | 
					        return AjaxResult.success(result);
 | 
				
			||||||
    }*/
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue