From 2681b219611c4e148863eae2b5d4af0dd9ede037 Mon Sep 17 00:00:00 2001 From: pengjie <17373303529@163.com> Date: Tue, 12 Sep 2023 18:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=90=88=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GovEnterpriseScoreDetailController.java | 2 +- .../GovInvestmentContractController.java | 85 ++++++++++++++++++- .../safety/entity/InvestmentContract.java | 16 ++-- .../safety/vo/InvestmentContractDto.java | 37 ++++++++ 4 files changed, 127 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/zhgd/xmgl/modules/safety/vo/InvestmentContractDto.java diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovEnterpriseScoreDetailController.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovEnterpriseScoreDetailController.java index a28af19..8852ce5 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovEnterpriseScoreDetailController.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovEnterpriseScoreDetailController.java @@ -108,7 +108,7 @@ public class GovEnterpriseScoreDetailController { // wrapper.eq(EnterpriseScoreDetail::getSubItem, enterpriseScoreDetail.getSubItem()); // } // return Result.success(enterpriseScoreDetailService.list(wrapper)); - List item = enterpriseScoreDetailService.getItem(enterpriseScoreDetail.getScoreId()); + List item = enterpriseScoreDetailService.getType(enterpriseScoreDetail.getScoreId()); QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(enterpriseScoreDetail); List list = enterpriseScoreDetailService.list(queryWrapper); Map resultMap = new HashMap<>(); diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovInvestmentContractController.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovInvestmentContractController.java index 53ac3fd..cae868f 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovInvestmentContractController.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/government/GovInvestmentContractController.java @@ -2,28 +2,42 @@ package com.zhgd.xmgl.modules.basicdata.controller.government; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zhgd.annotation.OperLog; import com.zhgd.jeecg.common.api.vo.Result; import com.zhgd.jeecg.common.system.query.QueryGenerator; import com.zhgd.jeecg.common.util.PageUtil; +import com.zhgd.xmgl.modules.basicdata.entity.Engineering; +import com.zhgd.xmgl.modules.basicdata.service.IEngineeringService; import com.zhgd.xmgl.modules.safety.dto.InvestmentEntPageDto; import com.zhgd.xmgl.modules.safety.dto.InvestmentProPageDto; import com.zhgd.xmgl.modules.safety.entity.InvestmentContract; +import com.zhgd.xmgl.modules.safety.entity.InvestmentPayment; import com.zhgd.xmgl.modules.safety.service.IInvestmentContractService; +import com.zhgd.xmgl.modules.safety.service.IInvestmentPaymentService; +import com.zhgd.xmgl.modules.safety.vo.InvestmentContractDto; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; import springfox.documentation.annotations.ApiIgnore; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -44,6 +58,12 @@ public class GovInvestmentContractController { @Autowired private IInvestmentContractService investmentContractService; + @Autowired + private IInvestmentPaymentService investmentPaymentService; + + @Autowired + private IEngineeringService engineeringService; + /** * 分页列表查询 * @@ -222,4 +242,61 @@ public class GovInvestmentContractController { } return result; } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @ApiOperation(value = "通过excel导入合同以及支付信息", notes = "通过excel导入合同以及支付信息", httpMethod = "POST") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + String engineeringSn = request.getParameter("engineeringSn"); + String projectSn = engineeringService.getOne(Wrappers.lambdaQuery().eq(Engineering::getEngineeringSn, engineeringSn)).getProjectSn(); + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + for (Map.Entry entity : fileMap.entrySet()) { + MultipartFile file = entity.getValue();// 获取上传文件对象 + ImportParams params = new ImportParams(); +// params.setTitleRows(1); +// params.setHeadRows(1); +// params.setNeedSave(true); + try { + Long id = null; + List investmentPaymentList = new ArrayList<>(); + List investmentContractDtoList = ExcelImportUtil.importExcel(file.getInputStream(), InvestmentContractDto.class, params); + for (InvestmentContractDto investmentContractDto : investmentContractDtoList) { + if (StringUtils.isNotBlank(investmentContractDto.getType())) { + InvestmentContract investmentContract = new InvestmentContract(); + BeanUtils.copyProperties(investmentContractDto, investmentContract); + investmentContract.setProjectSn(projectSn); + investmentContract.setEngineeringSn(engineeringSn); + investmentContractService.save(investmentContract); + id = investmentContract.getId(); + } + InvestmentPayment investmentPayment = new InvestmentPayment(); + BeanUtils.copyProperties(investmentContractDto, investmentPayment); + investmentPayment.setProjectSn(projectSn); + investmentPayment.setEngineeringSn(engineeringSn); + investmentPayment.setContractId(id); + investmentPayment.setPayRatio(new BigDecimal(investmentPayment.getPayRatio()).multiply(new BigDecimal(100)).toString()); + investmentPaymentList.add(investmentPayment); + } + investmentPaymentService.saveBatch(investmentPaymentList); + return Result.ok("文件导入成功!数据行数:" + investmentContractDtoList.size()); + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error("文件导入失败!"); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.ok("文件导入失败!"); + } } diff --git a/src/main/java/com/zhgd/xmgl/modules/safety/entity/InvestmentContract.java b/src/main/java/com/zhgd/xmgl/modules/safety/entity/InvestmentContract.java index 767989c..4c314a5 100644 --- a/src/main/java/com/zhgd/xmgl/modules/safety/entity/InvestmentContract.java +++ b/src/main/java/com/zhgd/xmgl/modules/safety/entity/InvestmentContract.java @@ -40,24 +40,24 @@ public class InvestmentContract implements Serializable { @ApiModelProperty(value = "费用类型") private String type; /** - * 合同金额 + * 合同金额(元) */ - @Excel(name = "合同金额", width = 15) - @ApiModelProperty(value = "合同金额") + @Excel(name = "合同金额(元)", width = 15) + @ApiModelProperty(value = "合同金额(元)") private BigDecimal contractAmount; /** - * 结算金额 + * 结算金额(元) */ - @Excel(name = "结算金额", width = 15) - @ApiModelProperty(value = "结算金额") + @Excel(name = "结算金额(元)", width = 15) + @ApiModelProperty(value = "结算金额(元)") private BigDecimal settlementAmount; /** - * 结算定额日期 + * 结算定案日期 */ @TableField(exist = false) @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd") - @ApiModelProperty(value = "结算定额日期") + @ApiModelProperty(value = "结算定案日期") private Date settlementTime; /** * 申请单位 diff --git a/src/main/java/com/zhgd/xmgl/modules/safety/vo/InvestmentContractDto.java b/src/main/java/com/zhgd/xmgl/modules/safety/vo/InvestmentContractDto.java new file mode 100644 index 0000000..26e6d0a --- /dev/null +++ b/src/main/java/com/zhgd/xmgl/modules/safety/vo/InvestmentContractDto.java @@ -0,0 +1,37 @@ +package com.zhgd.xmgl.modules.safety.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.zhgd.xmgl.modules.safety.entity.InvestmentContract; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +public class InvestmentContractDto extends InvestmentContract { + + @Excel(name = "累计拨付金额(万元)", width = 15) + @ApiModelProperty(value = "累计拨付金额(万元)") + private BigDecimal totalAmount; + + @Excel(name = "付款金额(万元)", width = 15) + @ApiModelProperty(value = "付款金额(万元)") + private BigDecimal payAmount; + + @Excel(name = "付款日期", width = 20, format = "yyyy-MM-dd") + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty(value = "付款日期") + private Date payTime; + + @Excel(name = "未支付工程款(万元)", width = 15) + @ApiModelProperty(value = "未支付工程款(万元)") + private BigDecimal unPayAmount; + + @Excel(name = "支付百分比(%)", width = 15) + @ApiModelProperty(value = "支付百分比(%)") + private String payRatio; +}