问题修复
This commit is contained in:
parent
e198b4d002
commit
937143dd0b
|
|
@ -16,7 +16,8 @@ import com.github.pagehelper.PageHelper;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -108,6 +109,39 @@ public class InventoryCountController {
|
|||
});
|
||||
ExportParams exportParams = new ExportParams("工程领退及差缺台账", "工程领退及差缺台账", ExcelType.XSSF);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, ProjectMaterialLedger.class, list);
|
||||
|
||||
// 手动合并工程名称列相同值的单元格
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
int firstRow = sheet.getFirstRowNum() + 1; // 跳过标题行
|
||||
int lastRow = sheet.getLastRowNum();
|
||||
|
||||
if (lastRow > firstRow) {
|
||||
String currentProName = "";
|
||||
int mergeStartRow = firstRow;
|
||||
|
||||
for (int i = firstRow; i <= lastRow; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
if (row != null) {
|
||||
Cell cell = row.getCell(0); // 假设工程名称在第1列
|
||||
if (cell != null) {
|
||||
String proName = cell.getStringCellValue();
|
||||
if (!proName.equals(currentProName)) {
|
||||
// 如果不是第一行,且当前项目名称与上一个不同,则合并之前的单元格
|
||||
if (i > firstRow && mergeStartRow < i - 1) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(mergeStartRow, i - 1, 0, 0));
|
||||
}
|
||||
currentProName = proName;
|
||||
mergeStartRow = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 合并最后一组相同项目名称的单元格
|
||||
if (mergeStartRow < lastRow) {
|
||||
sheet.addMergedRegion(new CellRangeAddress(mergeStartRow, lastRow, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("content-disposition", "attachment;fileName=" + URLEncoder.encode("工程领退及差缺台账" + ".xlsx", "UTF-8"));
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
|
|||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author : 阮世耀
|
||||
* @version : 1.0
|
||||
|
|
@ -25,7 +27,7 @@ public class ProjectMaterialLedger {
|
|||
/**
|
||||
* 工程名称
|
||||
*/
|
||||
@Excel(name = "工程名称", width = 70)
|
||||
@Excel(name = "工程名称", width = 70,needMerge = true)
|
||||
private String proName;
|
||||
|
||||
/**
|
||||
|
|
@ -71,12 +73,25 @@ public class ProjectMaterialLedger {
|
|||
@Excel(name = "利库量", width = 16)
|
||||
private Double totalLk = 0.00;
|
||||
|
||||
/**
|
||||
* 采购单价
|
||||
*/
|
||||
@Excel(name = "单价", width = 16)
|
||||
private Double price= 0.00;
|
||||
|
||||
/**
|
||||
* 出库量--出库
|
||||
*/
|
||||
@Excel(name = "出库量", width = 16)
|
||||
private Double totalCk = 0.00;
|
||||
|
||||
|
||||
/**
|
||||
* 总价格
|
||||
*/
|
||||
@Excel(name = "总价", width = 16)
|
||||
private Double totalPrice= 0.00;
|
||||
|
||||
/**
|
||||
* 退货量--退库
|
||||
*/
|
||||
|
|
@ -89,6 +104,12 @@ public class ProjectMaterialLedger {
|
|||
@Excel(name = "差缺量", width = 16)
|
||||
private Double totalDiff = 0.00;
|
||||
|
||||
/**
|
||||
* 差缺总价格
|
||||
*/
|
||||
@Excel(name = "差缺总价", width = 16)
|
||||
private Double totalDiffPrice= 0.00;
|
||||
|
||||
/**
|
||||
* 差缺状态 1-缺货 2-不缺货
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -83,5 +83,10 @@ public class PurchaseVo extends ParentVo {
|
|||
*/
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
*0-暂存,1-提交
|
||||
*/
|
||||
|
||||
private Integer editStatus;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ public class InventoryCountVo {
|
|||
/**是否预警 1.库存等于0 2.库存大于0*/
|
||||
private String isWarn;
|
||||
|
||||
/**
|
||||
* 总数量
|
||||
*/
|
||||
private int totalNum;
|
||||
|
||||
@Data
|
||||
public static class DataView {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ public class InventoryCountServiceImpl implements InventoryCountService{
|
|||
|
||||
}
|
||||
|
||||
return result;
|
||||
return result.stream()
|
||||
.sorted(Comparator.comparing(ProjectMaterialLedger::getProId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -134,7 +136,8 @@ public class InventoryCountServiceImpl implements InventoryCountService{
|
|||
ledger.setTotalBack(returnRecord.getTotalBack() != null ? returnRecord.getTotalBack() : 0.00);
|
||||
ledger.setTotalCk(outRecord != null ? outRecord.getTotalCk() : 0.00);
|
||||
ledger.setNeedNum(outRecord != null ? outRecord.getNeedNum() : 0.00);
|
||||
|
||||
//设置价格
|
||||
ledger.setPrice(outRecord != null ? outRecord.getPrice() : 0.00);
|
||||
// 3.设置工程信息
|
||||
ledger.setProId(outRecord != null ? outRecord.getProId() : returnRecord.getProId());
|
||||
ledger.setProName(outRecord != null ? outRecord.getProName() : returnRecord.getProName());
|
||||
|
|
@ -149,6 +152,10 @@ public class InventoryCountServiceImpl implements InventoryCountService{
|
|||
|
||||
// 计算差缺量 = 出库数量 - 退料数量
|
||||
ledger.setTotalDiff(ledger.getTotalCk() - ledger.getTotalBack());
|
||||
ledger.setTotalPrice(Double.parseDouble(String.format("%.2f", ledger.getTotalCk() * ledger.getPrice())));
|
||||
double totalDiffPrice = Double.parseDouble(String.format("%.2f", ledger.getTotalDiff() * ledger.getPrice()));
|
||||
ledger.setTotalDiffPrice(totalDiffPrice == 0 ? 0.0 : totalDiffPrice);
|
||||
|
||||
|
||||
// 5.设置差缺状态
|
||||
if (ledger.getTotalDiff() > 0) {
|
||||
|
|
|
|||
|
|
@ -179,4 +179,4 @@
|
|||
and mt.name like concat('%',#{modelModel},'%')
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -11,13 +11,17 @@
|
|||
SUM(o.cg_num) AS totalCg,
|
||||
SUM(o.lk_num) AS totalLk,
|
||||
SUM(o.need_num) AS needNum, -- 需求数量
|
||||
SUM(o.cg_num + o.lk_num) as totalCk -- 总出库数量
|
||||
SUM(o.cg_num + o.lk_num) as totalCk, -- 总出库数量
|
||||
sct.price as price
|
||||
FROM
|
||||
st_plan_out_details o
|
||||
JOIN
|
||||
st_plan_out spo ON o.out_id = spo.id -- 关联出库表
|
||||
JOIN
|
||||
bm_project p ON spo.pro_id = p.ID -- 关联工程表
|
||||
|
||||
left join st_contract_type sct on o.model_id = sct.model_id
|
||||
|
||||
where
|
||||
1=1
|
||||
<if test="keyWord != null and keyWord != ''">
|
||||
|
|
@ -72,8 +76,10 @@
|
|||
smt.unit_name AS unit,
|
||||
smt.storage_num AS num,
|
||||
smt.dbf_num AS dbfNum,
|
||||
(IFNULL(smt.storage_num, 0) + IFNULL(smt.dbf_num, 0)) AS totalNum,
|
||||
smt2.name AS `name`,
|
||||
smt3.name AS `type`
|
||||
|
||||
FROM st_ma_type smt
|
||||
LEFT JOIN st_ma_type smt2 ON smt.parent_id = smt2.id
|
||||
LEFT JOIN st_ma_type smt3 ON smt2.parent_id = smt3.id
|
||||
|
|
@ -272,4 +278,4 @@
|
|||
and sba.`code` LIKE CONCAT('%',#{planCode},'%')
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
|
||||
<select id="getProPurchaseList" resultType="com.bonus.aqgqj.business.backstage.entity.PurchaseVo">
|
||||
select count(1) planNum,pro.name proName,bc.`NAME` as companyName,SUM(spa.need_num) needNum , SUM(ck_num) ckNum,sum(lk_num) lkNum ,
|
||||
spa.project_id proId,
|
||||
spa.project_id proId,spa.edit_status editStatus,
|
||||
if(SUM(ck_num)+sum(lk_num)=0,'未发货',
|
||||
if(SUM(spa.need_num)-SUM(ck_num)-sum(lk_num)>0,'部分发货','全部发货'))
|
||||
status ,(if(SUM(spa.need_num)-SUM(ck_num)-sum(lk_num)>0,SUM(spa.need_num)-SUM(ck_num)-sum(lk_num),0) )dfhNum,( SUM(ck_num)+sum(lk_num)) fhNum,
|
||||
|
|
@ -280,4 +280,4 @@
|
|||
from st_slt_details
|
||||
where plan_id=#{planId}
|
||||
</select>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue