pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-admin/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TContractController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
pom.xml
@@ -86,20 +86,6 @@ <version>${commons.io.version}</version> </dependency> <!-- excel工具 --> <!-- Apache POI核心依赖 --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> </dependency> <!-- velocity代码生成使用模板 --> <dependency> <groupId>org.apache.velocity</groupId> ruoyi-admin/pom.xml
@@ -136,23 +136,6 @@ <version>1.2.78</version> </dependency> <!-- easypoi --> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-base</artifactId> <version>4.3.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-web</artifactId> <version>4.3.0</version> </dependency> <dependency> <groupId>cn.afterturn</groupId> <artifactId>easypoi-annotation</artifactId> <version>4.3.0</version> </dependency> <!-- 阿里云短信 --> <dependency> <groupId>com.aliyun</groupId> @@ -160,6 +143,19 @@ <version>2.0.10</version> </dependency> <!-- excel工具 --> <!-- Apache POI核心依赖 --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> </dependency> </dependencies> <build> ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -1,16 +1,25 @@ package com.ruoyi.web.controller.api; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ImportParams; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.constant.DictConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.model.LoginUserApplet; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.ProcessCategoryEnum; import com.ruoyi.common.utils.CodeGenerateUtils; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.WebUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.bo.ProcessStartBO; import com.ruoyi.system.dto.RevokeDTO; import com.ruoyi.system.dto.SignContractDTO; import com.ruoyi.system.model.TContract; @@ -22,14 +31,31 @@ import com.ruoyi.system.service.*; import com.ruoyi.system.vo.TContractAppletVO; import com.ruoyi.system.vo.TContractVO; import com.ruoyi.web.controller.tool.ImportExcelUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import java.time.LocalDateTime; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; /** * <p> @@ -118,5 +144,90 @@ res.setHouse(house); return R.ok(res); } @ApiOperation(value = "合同导入模板下载") @GetMapping("/import-template") public void importTemplate() { List<TContract> contractList = new ArrayList<>(); Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), TContract.class, contractList); HttpServletResponse response = WebUtils.response(); ServletOutputStream outputStream = null; try { String fileName = URLEncoder.encode("合同导入模板.xls", "utf-8"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); outputStream = response.getOutputStream(); workbook.write(outputStream); } catch (IOException e) { e.printStackTrace(); System.out.println("合同导入模板下载失败!"); } finally { try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } @ApiOperation(value = "合同导入") @PostMapping("/importContracts") @ApiImplicitParam(paramType = "form", name = "file", value = "文件对象", required = true, dataType = "__file") public R<String> importContracts(@RequestPart("file") MultipartFile file) { ImportParams params = new ImportParams(); params.setTitleRows(1);//标题行数 params.setHeadRows(1); //表头行数 try { InputStream inputStream = file.getInputStream(); List<TContract> contractList = ExcelImportUtil.importExcel(inputStream, TContract.class, params); List<String> errors = new ArrayList<>(); for (TContract tContract : contractList) { try{ contractService.save(tContract); if(tContract.getStatus().equals("2")){ //发起合同新增审批 ProcessStartBO processStartBO = new ProcessStartBO(); processStartBO.setCategory(ProcessCategoryEnum.CATEGORY1.getValue().toString()); processStartBO.setModuleName("合同新增审批"); processStartBO.setName(tContract.getContractName()); //需要显示发起申请人所在单位 processStartBO.setRemark(""); Map<String, Object> variable = new HashMap<>(); variable.put("projectId", tContract.getId()); processStartBO.setVariable(variable); //开启工作流程 Boolean start = stateProcessTemplateService.start(processStartBO); } if(tContract.getStatus().equals("9")){ // 进入签订审批流程 ProcessStartBO processStartBO = new ProcessStartBO(); processStartBO.setCategory(ProcessCategoryEnum.CATEGORY2.getValue().toString()); processStartBO.setModuleName("合同签订审批"); processStartBO.setName(tContract.getContractName()); processStartBO.setRemark(""); Map<String, Object> variable = new HashMap<>(); variable.put("projectId", tContract.getId()); processStartBO.setVariable(variable); //开启工作流程 stateProcessTemplateService.startApplet(processStartBO); } }catch (Exception e){ errors.add("合同名称:[" + tContract.getContractName() + "],导入错误,忽略导入。"); } } Integer errorLines = 0; Integer successLines = 0; errorLines += errors.size(); successLines += (contractList.size() - errorLines); R<String> stringApiResult = ImportExcelUtil.importReturnMsg(errorLines, successLines, errors); return stringApiResult; } catch (Exception e) { System.out.println("合同导入失败!" + e.getMessage()); } return R.ok(); } } ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -118,7 +118,7 @@ "/applet/changepwd", "/captchaImage","/getCode","/loginCode", "/operations/getBySingleNum/**", "/user/getUserInfoByNumber/**", "/wxLogin/**", "/wxLogin/**","/t-contract/import-template","/t-contract/importContracts", "/open/**","/cos/get/**" ).permitAll() // 静态资源,可匿名访问 ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java
@@ -1,5 +1,6 @@ package com.ruoyi.system.model; import cn.afterturn.easypoi.excel.annotation.Excel; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -32,48 +33,60 @@ @TableId(value = "id", type = IdType.ASSIGN_ID) private String id; @Excel(name = "合同编号") @ApiModelProperty(value = "合同编号") @TableField("contract_number") private String contractNumber; @Excel(name = "合同名称") @ApiModelProperty(value = "合同名称") @TableField("contract_name") private String contractName; @Excel(name = "生效日期", format = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "开始时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("start_time") private LocalDateTime startTime; @Excel(name = "终止日期", format = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "结束时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("end_time") private LocalDateTime endTime; @Excel(name = "每月租金") @ApiModelProperty(value = "每月租金") @TableField("month_rent") private BigDecimal monthRent; @Excel(name = "押金") @ApiModelProperty(value = "押金") @TableField("deposit") private BigDecimal deposit; @Excel(name = "租金支付方式 1=月付 2=季付 3=年付") @ApiModelProperty(value = "租金支付方式 月付 季付 年付") @TableField("pay_type") private String payType; @Excel(name = "开始计费日期", format = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "开始计费时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("start_pay_time") private LocalDateTime startPayTime; @ApiModelProperty(value = "每月租金") @TableField("month_rent") private BigDecimal monthRent; @ApiModelProperty(value = "押金") @TableField("deposit") private BigDecimal deposit; @Excel(name = "合计年租金") @ApiModelProperty(value = "合计年租金") @TableField("total_year") private BigDecimal totalYear; @Excel(name = "房屋用途") @ApiModelProperty(value = "房屋使用范围") @TableField("house_use_scope") private String houseUseScope; @ApiModelProperty(value = "变动后递增或递减之后的每月租金 前端忽略") @TableField("change_rent") private BigDecimal changeRent; @ApiModelProperty(value = "租金支付方式 月付 季付 年付") @TableField("pay_type") private String payType; @ApiModelProperty(value = "账单第一次支付日期 合同生效日期+10天 (不是真正的支付日期)生成第一次帐单后存值") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("first_pay_time") private LocalDateTime firstPayTime; @Excel(name = "变动时间", format = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "变动时间 根据周期改变 前端忽略") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("change_time") @@ -86,39 +99,31 @@ @ApiModelProperty(value = "押金是否随租金递增递减 true=是 false=否") @TableField("isIncreasing_deposit") private Boolean isIncreasingDeposit; @Excel(name = "违约金比例") @ApiModelProperty(value = "违约金比例") @TableField("proportion") private BigDecimal proportion; @ApiModelProperty(value = "房屋id") @TableField("house_id") private String houseId; @Excel(name = "甲方名称") @ApiModelProperty(value = "甲方名称") @TableField("party_one_name") private String partyOneName; @Excel(name = "甲方联系人") @ApiModelProperty(value = "甲方联系人") @TableField("party_one_person") private String partyOnePerson; @Excel(name = "甲方联系方式") @ApiModelProperty(value = "甲方联系方式") @TableField("party_one_phone") private String partyOnePhone; @ApiModelProperty(value = "租户id") @TableField("tenant_id") private String tenantId; @Excel(name = "乙方名称") @ApiModelProperty(value = "乙方名称") @TableField("party_two_name") private String partyTwoName; @Excel(name = "乙方联系人") @ApiModelProperty(value = "乙方联系人") @TableField("party_two_person") private String partyTwoPerson; @Excel(name = "乙方联系方式") @ApiModelProperty(value = "乙方联系方式") @TableField("party_two_phone") private String partyTwoPhone; @@ -126,7 +131,7 @@ @ApiModelProperty(value = "合同附件,多个逗号拼接") @TableField("contract_file") private String contractFile; @Excel(name = "概况补充") @ApiModelProperty(value = "备注") @TableField("remark") private String remark; @@ -141,6 +146,7 @@ * 7 待结算 * 8 已结算 */ @Excel(name = "合同状态 1=待提交 2=待审批 3=未签订 4=已签订 5=已驳回 6=已终止 7=待结算 8=已结算 9 = 签订待审核") @ApiModelProperty(value = "合同状态 1=待提交 2=待审批 3=未签订 4=已签订 5=已驳回 6=已终止 7=待结算 8=已结算 9 = 签订待审核") @TableField("status") private String status; @@ -148,6 +154,7 @@ /** * 签订时间 */ @Excel(name = "签订时间", format = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "签订时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("sign_time") @@ -162,15 +169,16 @@ @ApiModelProperty(value = "租户确认合同电子签名") @TableField("signature") private String signature; @Excel(name = "签订时间") @ApiModelProperty(value = "终止合同备注说明") @TableField("terminate_remark") private String terminateRemark; @ApiModelProperty(value = "合计年租金") @TableField("total_year") private BigDecimal totalYear; @ApiModelProperty(value = "房屋名称") @TableField(exist = false) private String houseName; @ApiModelProperty(value = "租户名称") @TableField(exist = false) private String tenantName; @ApiModelProperty(value = "房屋地址") @TableField(exist = false) private String houseAddress; @@ -178,14 +186,18 @@ @TableField(exist = false) private String instanceId; @ApiModelProperty(value = "房屋使用范围") @TableField("house_use_scope") private String houseUseScope; @ApiModelProperty(value = "终止日期-前端传的") @TableField("terminate_time") private LocalDateTime terminateTime; @Excel(name = "房屋id") @ApiModelProperty(value = "房屋id") @TableField("house_id") private String houseId; @Excel(name = "租户id") @ApiModelProperty(value = "租户id") @TableField("tenant_id") private String tenantId; @Excel(name = "所属营业部id") @ApiModelProperty(value = "营业部id") @TableField("business_dept_id") private String businessDeptId;