材料站过滤不展示协议单位,结算管理
This commit is contained in:
parent
e6c43863d3
commit
594c725e02
|
|
@ -1,5 +1,8 @@
|
||||||
package com.bonus.material.settlement.controller;
|
package com.bonus.material.settlement.controller;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
@ -37,6 +40,7 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.poi.hssf.usermodel.*;
|
import org.apache.poi.hssf.usermodel.*;
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
|
@ -55,6 +59,8 @@ import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.page.TableDataInfo;
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结算信息Controller
|
* 结算信息Controller
|
||||||
|
|
@ -1541,6 +1547,7 @@ public class SltAgreementInfoController extends BaseController {
|
||||||
if (vo != null && !ObjectUtil.isEmpty(vo)) {
|
if (vo != null && !ObjectUtil.isEmpty(vo)) {
|
||||||
vo.setAgreementId(info.getAgreementId());
|
vo.setAgreementId(info.getAgreementId());
|
||||||
vo.setAgreementCode(info.getAgreementCode());
|
vo.setAgreementCode(info.getAgreementCode());
|
||||||
|
vo.setSettlementType(settlementType);
|
||||||
dataList.add(vo);
|
dataList.add(vo);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -1656,4 +1663,214 @@ public class SltAgreementInfoController extends BaseController {
|
||||||
log.error("导出区间费用汇总失败", e);
|
log.error("导出区间费用汇总失败", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一键批量导出未结算报表(zip)
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "一键批量导出未结算报表")
|
||||||
|
@PreventRepeatSubmit
|
||||||
|
@SysLog(title = "结算信息", businessType = OperaType.EXPORT, logType = 1,module = "结算管理->一键批量导出未结算报表")
|
||||||
|
@PostMapping("/exportUnsettled")
|
||||||
|
public void exportUnsettled(HttpServletResponse response, @RequestBody List<SltAgreementInfo> list) throws Exception {
|
||||||
|
// 创建临时文件夹
|
||||||
|
String tempDir = System.getProperty("java.io.tmpdir") + File.separator + UUID.randomUUID();
|
||||||
|
new File(tempDir).mkdirs();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for(SltAgreementInfo info : list){
|
||||||
|
if(info.getAgreementId() == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//根据协议id获取结算单位和结算工程
|
||||||
|
SltAgreementInfo agreementInfo = sltAgreementInfoMapper.getUnitAndProjectByAgreementId(info.getAgreementId());
|
||||||
|
// 生成文件名
|
||||||
|
String fileName = "";
|
||||||
|
String unitName = "";
|
||||||
|
String projectName = "";
|
||||||
|
unitName = agreementInfo.getUnitName();
|
||||||
|
projectName = agreementInfo.getProjectName();
|
||||||
|
|
||||||
|
//租赁费用明细
|
||||||
|
BigDecimal totalCostLease = BigDecimal.valueOf(0.00);
|
||||||
|
List<SltAgreementInfo> leaseList = new ArrayList<>();
|
||||||
|
leaseList = sltAgreementInfoMapper.getLeaseList(info);
|
||||||
|
|
||||||
|
for (SltAgreementInfo bean : leaseList) {
|
||||||
|
if (null == bean.getLeasePrice()) {
|
||||||
|
bean.setLeasePrice(BigDecimal.valueOf(0.00));
|
||||||
|
}
|
||||||
|
if (null == bean.getNum()) {
|
||||||
|
bean.setNum(BigDecimal.valueOf(0L));
|
||||||
|
}
|
||||||
|
if (null == bean.getLeaseDays()) {
|
||||||
|
bean.setLeaseDay(0L);
|
||||||
|
}
|
||||||
|
BigDecimal leasePrice = bean.getLeasePrice();
|
||||||
|
BigDecimal num = bean.getNum();
|
||||||
|
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
|
||||||
|
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays);
|
||||||
|
if(costs!=null){
|
||||||
|
totalCostLease = totalCostLease.add(costs);
|
||||||
|
}
|
||||||
|
bean.setCosts(costs);
|
||||||
|
}
|
||||||
|
List<SltLeaseInfo> lease = Convert.toList(SltLeaseInfo.class, leaseList);
|
||||||
|
|
||||||
|
//丢失费用明细
|
||||||
|
BigDecimal totalCostLose = BigDecimal.valueOf(0.00);
|
||||||
|
List<SltAgreementInfo> loseList = new ArrayList<>();
|
||||||
|
|
||||||
|
loseList = sltAgreementInfoMapper.getLoseList(info);
|
||||||
|
|
||||||
|
for (SltAgreementInfo bean : loseList) {
|
||||||
|
if (null == bean.getBuyPrice()) {
|
||||||
|
bean.setBuyPrice(BigDecimal.valueOf(0.00));
|
||||||
|
}
|
||||||
|
if (null == bean.getNum()) {
|
||||||
|
bean.setNum(BigDecimal.valueOf(0L));
|
||||||
|
}
|
||||||
|
BigDecimal buyPrice = bean.getBuyPrice();
|
||||||
|
BigDecimal num = bean.getNum();
|
||||||
|
// 原价 x 数量
|
||||||
|
BigDecimal costs = buyPrice.multiply(num);
|
||||||
|
if(costs!=null){
|
||||||
|
totalCostLose = totalCostLose.add(costs);
|
||||||
|
}
|
||||||
|
//计算租赁费用
|
||||||
|
bean.setCosts(costs);
|
||||||
|
}
|
||||||
|
List<SltLeaseInfo> lose = Convert.toList(SltLeaseInfo.class, loseList);
|
||||||
|
|
||||||
|
//维修费用明细
|
||||||
|
BigDecimal totalCostRepair = BigDecimal.valueOf(0.00);
|
||||||
|
List<SltAgreementInfo> repairList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
List<TmTask> taskRepairList = taskMapper.getTaskIdList(info);
|
||||||
|
if (null != taskRepairList && !taskRepairList.isEmpty()) {
|
||||||
|
repairList = sltAgreementInfoMapper.getRepairDetailsList(info, taskRepairList);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SltAgreementInfo bean : repairList) {
|
||||||
|
if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) {
|
||||||
|
totalCostRepair = totalCostRepair.add(bean.getCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<SltLeaseInfo> repair = Convert.toList(SltLeaseInfo.class, repairList);
|
||||||
|
|
||||||
|
//报废费用明细
|
||||||
|
BigDecimal totalCostScrap = BigDecimal.valueOf(0.00);
|
||||||
|
List<SltAgreementInfo> scrapList = new ArrayList<>();
|
||||||
|
|
||||||
|
List<TmTask> taskScrapList = taskMapper.getTaskIdList(info);
|
||||||
|
if (null != taskScrapList && !taskScrapList.isEmpty()) {
|
||||||
|
scrapList = sltAgreementInfoMapper.getScrapDetailsList(info, taskScrapList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (SltAgreementInfo bean : scrapList) {
|
||||||
|
if (bean.getCosts()!=null && (bean.getPartType().equals("收费"))) {
|
||||||
|
totalCostScrap = totalCostScrap.add(bean.getCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<SltLeaseInfo> scrap = Convert.toList(SltLeaseInfo.class, scrapList);
|
||||||
|
|
||||||
|
//减免费用明细
|
||||||
|
BigDecimal totalCostReduction = BigDecimal.valueOf(0.00);
|
||||||
|
List<SltAgreementReduce> reductionList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (info.getAgreementId() != null){
|
||||||
|
SltAgreementReduce bean =new SltAgreementReduce();
|
||||||
|
bean.setAgreementId(info.getAgreementId());
|
||||||
|
reductionList = sltAgreementRecudceMapper.getReductionList(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SltAgreementReduce reduction : reductionList) {
|
||||||
|
if(reduction.getLeaseMoney()!=null){
|
||||||
|
totalCostReduction = totalCostReduction.add(reduction.getLeaseMoney());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<SltLeaseInfo> reduction = Convert.toList(SltLeaseInfo.class, reductionList);
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String, Object>> resultsLease = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> resultsLose = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> resultsRepair = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> resultsScrap = new ArrayList<>();
|
||||||
|
List<Map<String, Object>> resultsReduction = new ArrayList<>();
|
||||||
|
if (lease!= null) {
|
||||||
|
for (SltLeaseInfo bean : lease) {
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 1, 1);
|
||||||
|
resultsLease.add(maps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lose!= null) {
|
||||||
|
for (SltLeaseInfo bean : lose) {
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 2, 1);
|
||||||
|
resultsLose.add(maps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (repair!= null) {
|
||||||
|
for (SltLeaseInfo bean : repair) {
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 3, 1);
|
||||||
|
resultsRepair.add(maps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scrap!= null) {
|
||||||
|
for (SltLeaseInfo bean : scrap) {
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 4, 1);
|
||||||
|
resultsScrap.add(maps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reduction!= null) {
|
||||||
|
for (SltLeaseInfo bean : reduction) {
|
||||||
|
Map<String, Object> maps = outReceiveDetailsBeanToMap(bean, 5, 1);
|
||||||
|
resultsReduction.add(maps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> headersLease = receiveDetailsHeader(1,1);
|
||||||
|
List<String> headersLose = receiveDetailsHeader(2,1);
|
||||||
|
List<String> headersRepair = receiveDetailsHeader(3,1);
|
||||||
|
List<String> headersScrap = receiveDetailsHeader(4,1);
|
||||||
|
List<String> headersReduction = receiveDetailsHeader(5,1);
|
||||||
|
|
||||||
|
fileName = agreementInfo.getAgreementCode() + "-" + unitName + "-" + projectName ;
|
||||||
|
// 导出单个Excel文件
|
||||||
|
String filePath = tempDir + File.separator + fileName;
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(filePath)) {
|
||||||
|
HSSFWorkbook workbook = PoiOutPage.excelForcheckAll(resultsLease,resultsLose,resultsRepair,resultsScrap,resultsReduction, headersLease,headersLose,headersRepair,headersScrap,headersReduction, "结算明细",projectName,unitName,totalCostLease,totalCostLose,totalCostRepair,totalCostScrap,totalCostReduction);
|
||||||
|
workbook.write(fos);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// 创建压缩包
|
||||||
|
String zipFileName = "结算单_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".zip";
|
||||||
|
response.setContentType("application/zip");
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(zipFileName, "UTF-8"));
|
||||||
|
|
||||||
|
try (ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream())) {
|
||||||
|
File[] files = new File(tempDir).listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
zipOut.putNextEntry(new ZipEntry(file.getName()));
|
||||||
|
try (FileInputStream fis = new FileInputStream(file)) {
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len;
|
||||||
|
while ((len = fis.read(buffer)) > 0) {
|
||||||
|
zipOut.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zipOut.closeEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("一键批量导出未结算报表失败", e);
|
||||||
|
} finally {
|
||||||
|
// 删除临时文件
|
||||||
|
FileUtils.deleteDirectory(new File(tempDir));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -310,4 +310,6 @@ public interface SltAgreementInfoMapper {
|
||||||
* @param bean 协议ID
|
* @param bean 协议ID
|
||||||
*/
|
*/
|
||||||
List<SltAgreementInfo> getRepairCodeList(SltAgreementInfo bean);
|
List<SltAgreementInfo> getRepairCodeList(SltAgreementInfo bean);
|
||||||
|
|
||||||
|
SltAgreementInfo getUnitAndProjectByAgreementId(Long agreementId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,4 +171,5 @@ public interface ISltAgreementInfoService {
|
||||||
|
|
||||||
|
|
||||||
List<SltAgreementInfo> getRepairCodeList(SltAgreementInfo bean);
|
List<SltAgreementInfo> getRepairCodeList(SltAgreementInfo bean);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1347,7 +1347,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
AND sai.back_id IS NULL
|
AND sai.back_id IS NULL
|
||||||
AND bp.external_id IS NOT NULL
|
AND bp.external_id IS NOT NULL
|
||||||
AND bu.type_id = 36
|
AND bu.type_id = 36
|
||||||
and sd.dept_id not in (342,345,347,348,101)
|
and sd.dept_id not in (342,345,347,348,101,344)
|
||||||
and bp.pro_id not in (3414,1192,3321,3595)
|
and bp.pro_id not in (3414,1192,3321,3595)
|
||||||
and bp.pro_center IS NOT NULL
|
and bp.pro_center IS NOT NULL
|
||||||
<if test="impUnitName != null and impUnitName != ''">
|
<if test="impUnitName != null and impUnitName != ''">
|
||||||
|
|
@ -1421,7 +1421,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
sai.`status` = '0'
|
sai.`status` = '0'
|
||||||
AND sai.end_time IS NULL
|
AND sai.end_time IS NULL
|
||||||
AND sai.back_id IS NULL
|
AND sai.back_id IS NULL
|
||||||
and sd.dept_id not in (342,345,347,348,101)
|
and sd.dept_id not in (342,345,347,348,101,344)
|
||||||
and bp.pro_id not in (3414,1192,3321,3595)
|
and bp.pro_id not in (3414,1192,3321,3595)
|
||||||
<if test="impUnitName != null and impUnitName != ''">
|
<if test="impUnitName != null and impUnitName != ''">
|
||||||
AND sd.dept_name like concat('%',#{impUnitName},'%')
|
AND sd.dept_name like concat('%',#{impUnitName},'%')
|
||||||
|
|
@ -1516,7 +1516,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
AND sai.back_id IS NULL
|
AND sai.back_id IS NULL
|
||||||
AND bu.unit_name is not null
|
AND bu.unit_name is not null
|
||||||
AND bp.external_id is not NULL
|
AND bp.external_id is not NULL
|
||||||
and sd.dept_id not in (342,345,347,348,101)
|
and sd.dept_id not in (342,345,347,348,101,344)
|
||||||
and bp.pro_id not in (3414,1192,3321,3595)
|
and bp.pro_id not in (3414,1192,3321,3595)
|
||||||
and bp.pro_center IS NOT NULL
|
and bp.pro_center IS NOT NULL
|
||||||
<if test="impUnitName != null and impUnitName != ''">
|
<if test="impUnitName != null and impUnitName != ''">
|
||||||
|
|
@ -1605,7 +1605,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
LEFT JOIN sys_dept sd ON sd.dept_id = bp.imp_unit
|
||||||
WHERE
|
WHERE
|
||||||
sd.dept_name IS NOT NULL
|
sd.dept_name IS NOT NULL
|
||||||
and sd.dept_id not in (342,345,347,348,101)
|
and sd.dept_id not in (342,345,347,348,101,344)
|
||||||
<if test="impUnitName != null and impUnitName != ''">
|
<if test="impUnitName != null and impUnitName != ''">
|
||||||
AND sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
|
AND sd.dept_name LIKE CONCAT('%', #{impUnitName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -1766,7 +1766,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
AND sai.back_id IS NULL
|
AND sai.back_id IS NULL
|
||||||
AND bu.unit_name is not null
|
AND bu.unit_name is not null
|
||||||
AND bp.external_id is not NULL
|
AND bp.external_id is not NULL
|
||||||
and sd.dept_id not in (342,345,347,348,101)
|
and sd.dept_id not in (342,345,347,348,101,344)
|
||||||
and bp.pro_id not in (3414,1192,3321,3595)
|
and bp.pro_id not in (3414,1192,3321,3595)
|
||||||
<if test="impUnitName != null and impUnitName != ''">
|
<if test="impUnitName != null and impUnitName != ''">
|
||||||
AND sd.dept_name = #{impUnitName}
|
AND sd.dept_name = #{impUnitName}
|
||||||
|
|
|
||||||
|
|
@ -1195,6 +1195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
FROM bm_agreement_info bai
|
FROM bm_agreement_info bai
|
||||||
INNER JOIN slt_agreement_info sai ON bai.agreement_id = sai.agreement_id
|
INNER JOIN slt_agreement_info sai ON bai.agreement_id = sai.agreement_id
|
||||||
WHERE sai.is_slt = 0
|
WHERE sai.is_slt = 0
|
||||||
|
and bai.is_show != 0
|
||||||
)
|
)
|
||||||
<!-- SELECT DISTINCT bp.pro_id as proId-->
|
<!-- SELECT DISTINCT bp.pro_id as proId-->
|
||||||
<!-- FROM bm_project bp-->
|
<!-- FROM bm_project bp-->
|
||||||
|
|
|
||||||
|
|
@ -593,6 +593,7 @@
|
||||||
LEFT JOIN sys_workflow_config swc ON swn.id = swc.node_id
|
LEFT JOIN sys_workflow_config swc ON swn.id = swc.node_id
|
||||||
LEFT JOIN sys_workflow_record_history swrs ON swr.id = swrs.record_id
|
LEFT JOIN sys_workflow_record_history swrs ON swr.id = swrs.record_id
|
||||||
where 1=1
|
where 1=1
|
||||||
|
and swr.task_type = 19
|
||||||
<if test="deptId != null">and bp.imp_unit = #{deptId}</if>
|
<if test="deptId != null">and bp.imp_unit = #{deptId}</if>
|
||||||
<if test="code != null and code != ''">and lai.code = #{code}</if>
|
<if test="code != null and code != ''">and lai.code = #{code}</if>
|
||||||
<if test="taskId != null ">and lai.task_id = #{taskId}</if>
|
<if test="taskId != null ">and lai.task_id = #{taskId}</if>
|
||||||
|
|
|
||||||
|
|
@ -1456,4 +1456,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where
|
where
|
||||||
sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType}
|
sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="getUnitAndProjectByAgreementId" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
SELECT
|
||||||
|
bai.unit_id as unitId,
|
||||||
|
bai.project_id as projectId,
|
||||||
|
bu.unit_name as unitName,
|
||||||
|
bp.pro_name as projectName,
|
||||||
|
bai.agreement_code as agreementCode
|
||||||
|
FROM
|
||||||
|
bm_agreement_info bai
|
||||||
|
LEFT JOIN bm_unit bu on bu.unit_id = bai.unit_id
|
||||||
|
LEFT JOIN bm_project bp on bp.pro_id = bai.project_id
|
||||||
|
where bai.agreement_id = #{agreementId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue