导入合同

This commit is contained in:
pengjie 2023-09-12 18:56:46 +08:00
parent 4f00d7ec4b
commit 2681b21961
4 changed files with 127 additions and 13 deletions

View File

@ -108,7 +108,7 @@ public class GovEnterpriseScoreDetailController {
// wrapper.eq(EnterpriseScoreDetail::getSubItem, enterpriseScoreDetail.getSubItem());
// }
// return Result.success(enterpriseScoreDetailService.list(wrapper));
List<String> item = enterpriseScoreDetailService.getItem(enterpriseScoreDetail.getScoreId());
List<String> item = enterpriseScoreDetailService.getType(enterpriseScoreDetail.getScoreId());
QueryWrapper<EnterpriseScoreDetail> queryWrapper = QueryGenerator.initQueryWrapper(enterpriseScoreDetail);
List<EnterpriseScoreDetail> list = enterpriseScoreDetailService.list(queryWrapper);
Map<String, Object> resultMap = new HashMap<>();

View File

@ -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.<Engineering>lambdaQuery().eq(Engineering::getEngineeringSn, engineeringSn)).getProjectSn();
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> 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<InvestmentPayment> investmentPaymentList = new ArrayList<>();
List<InvestmentContractDto> 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("文件导入失败!");
}
}

View File

@ -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;
/**
* 申请单位

View File

@ -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;
}