租赁协议查看
This commit is contained in:
parent
14502ba6ce
commit
48269d19a8
|
|
@ -106,6 +106,14 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Apache POI dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.2.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ public class BmContract {
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建时间")
|
@ApiModelProperty(value = "创建时间")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "修改时间")
|
@ApiModelProperty(value = "修改时间")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户id")
|
@ApiModelProperty(value = "用户id")
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,21 @@ import com.bonus.material.order.service.OrderService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.poi.xwpf.usermodel.IBodyElement;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
|
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:liang.chao
|
* @Author:liang.chao
|
||||||
|
|
@ -110,9 +121,9 @@ public class OrderController extends BaseController {
|
||||||
if (dtos.size() > 0 && CollectionUtil.isNotEmpty(dtos)) {
|
if (dtos.size() > 0 && CollectionUtil.isNotEmpty(dtos)) {
|
||||||
for (OrderDetailDto dto : dtos) {
|
for (OrderDetailDto dto : dtos) {
|
||||||
// if ("0".equals(dto.getManageType())) {
|
// if ("0".equals(dto.getManageType())) {
|
||||||
// 编码设备已取消的继续上架
|
// 编码设备已取消的继续上架
|
||||||
dto.setMaStatus(MaStatusEnum.LISTING.getCode().toString());
|
dto.setMaStatus(MaStatusEnum.LISTING.getCode().toString());
|
||||||
orderMapper.updateDeviceStatus(dto);
|
orderMapper.updateDeviceStatus(dto);
|
||||||
/* } else {
|
/* } else {
|
||||||
// 数量设备已退租的增加库存
|
// 数量设备已退租的增加库存
|
||||||
orderMapper.updateAddDevCount(dto);
|
orderMapper.updateAddDevCount(dto);
|
||||||
|
|
@ -141,4 +152,54 @@ public class OrderController extends BaseController {
|
||||||
return error("发起减免失败");
|
return error("发起减免失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "租赁协议(查看)")
|
||||||
|
@PostMapping("/leaseAgreement")
|
||||||
|
public ResponseEntity<String> getleaseAgreement(@RequestParam("file") MultipartFile file,
|
||||||
|
@RequestParam("orderId") String orderId,
|
||||||
|
@RequestParam Map<String, String> replacements) {
|
||||||
|
// 根据orderId获取订单信息
|
||||||
|
OrderInfoDto orderInfoDto = orderService.getAgreementByOrderId(orderId);
|
||||||
|
try (XWPFDocument document = new XWPFDocument(file.getInputStream())) {
|
||||||
|
// 准备替换的占位符及其对应值
|
||||||
|
//订单日期
|
||||||
|
replacements.put("${orderTime}", orderInfoDto.getOrderTime().toString());
|
||||||
|
//装备所属公司
|
||||||
|
replacements.put("${czcompanyName}", orderInfoDto.getCzcompanyName());
|
||||||
|
//承租方所属公司
|
||||||
|
replacements.put("${companyName}", orderInfoDto.getCompanyName());
|
||||||
|
//订单金额
|
||||||
|
replacements.put("${cost}", orderInfoDto.getCost().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 byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
document.write(byteArrayOutputStream);
|
||||||
|
|
||||||
|
// 将字节数组转换为字符串(仅用于演示,实际应提供文件下载)
|
||||||
|
String content = byteArrayOutputStream.toString("UTF-8");
|
||||||
|
// 注意:对于大文件,不建议将内容作为字符串返回。应提供下载链接或二进制文件响应。
|
||||||
|
|
||||||
|
return ResponseEntity.ok(content);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Error processing file");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,6 @@ public interface OrderMapper {
|
||||||
int deleteCostReliefs(@Param("orderId") Integer orderId);
|
int deleteCostReliefs(@Param("orderId") Integer orderId);
|
||||||
|
|
||||||
int insertCostReliefs(@Param("list") List<OrderDetailCostReliefDto> reliefList);
|
int insertCostReliefs(@Param("list") List<OrderDetailCostReliefDto> reliefList);
|
||||||
|
|
||||||
|
OrderInfoDto getAgreementByOrderId(String orderId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,6 @@ public interface OrderService {
|
||||||
OrderInfoDto getOrderDetailsById(OrderDetailDto dto) throws Exception;
|
OrderInfoDto getOrderDetailsById(OrderDetailDto dto) throws Exception;
|
||||||
|
|
||||||
Integer submitCostRelief(OrderInfoDto orderInfoDto);
|
Integer submitCostRelief(OrderInfoDto orderInfoDto);
|
||||||
|
|
||||||
|
OrderInfoDto getAgreementByOrderId(String orderId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,6 @@ public class OrderServiceImpl implements OrderService {
|
||||||
if (minOrderStatus.isPresent()) {
|
if (minOrderStatus.isPresent()) {
|
||||||
dto.setOrderStatus(minOrderStatus.get().getOrderStatus());
|
dto.setOrderStatus(minOrderStatus.get().getOrderStatus());
|
||||||
}
|
}
|
||||||
dto.setStartTime(list.get(0).getRentBeginTime());
|
|
||||||
dto.setEndTime(list.get(0).getRentEndTime());
|
|
||||||
//根据订单id去lease_repair_record表中查询是否已填写退租检修信息
|
//根据订单id去lease_repair_record表中查询是否已填写退租检修信息
|
||||||
int count = mapper.selectLeaseContent(String.valueOf(dto.getOrderId()));
|
int count = mapper.selectLeaseContent(String.valueOf(dto.getOrderId()));
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
|
@ -144,4 +142,9 @@ public class OrderServiceImpl implements OrderService {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderInfoDto getAgreementByOrderId(String orderId) {
|
||||||
|
return orderMapper.getAgreementByOrderId(orderId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -271,6 +271,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE
|
WHERE
|
||||||
mt.del_flag = 0 and hh.order_id = #{orderId}
|
mt.del_flag = 0 and hh.order_id = #{orderId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getAgreementByOrderId" resultType="com.bonus.material.order.domain.OrderInfoDto">
|
||||||
|
SELECT
|
||||||
|
moi.CODE AS CODE,
|
||||||
|
moi.order_time,
|
||||||
|
up.dept_name AS czcompanyName,
|
||||||
|
mdi.person_phone AS personPhone,
|
||||||
|
su.phonenumber AS phoneNumber,
|
||||||
|
moi.address,
|
||||||
|
moi.order_id,
|
||||||
|
sum( hh.costs ) cost,
|
||||||
|
dept.dept_name AS companyName
|
||||||
|
FROM
|
||||||
|
ma_order_details hh
|
||||||
|
LEFT JOIN ma_order_info moi ON moi.order_id = hh.order_id
|
||||||
|
LEFT JOIN ma_dev_info mdi ON hh.ma_id = mdi.ma_id
|
||||||
|
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
||||||
|
LEFT JOIN sys_user su ON su.user_id = moi.buyer_id
|
||||||
|
LEFT JOIN sys_dept dept ON dept.dept_id = moi.buyer_company
|
||||||
|
LEFT JOIN sys_dept up ON up.dept_id = mdi.own_co
|
||||||
|
WHERE
|
||||||
|
mt.del_flag = '0'
|
||||||
|
AND hh.order_id = #{orderId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<delete id="deleteCostReliefs">
|
<delete id="deleteCostReliefs">
|
||||||
delete from ma_order_details_relief
|
delete from ma_order_details_relief
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue