问题修复
This commit is contained in:
parent
db5b90b0b4
commit
6aa4a5eae7
|
|
@ -9,6 +9,7 @@ import org.apache.poi.ss.util.RegionUtil;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -314,11 +315,11 @@ public class PoiOutPage {
|
||||||
row.setHeightInPoints(30);
|
row.setHeightInPoints(30);
|
||||||
HSSFCell cell1 = row.createCell(0);
|
HSSFCell cell1 = row.createCell(0);
|
||||||
cell1.setCellStyle(headerStyleNoSide);
|
cell1.setCellStyle(headerStyleNoSide);
|
||||||
cell1.setCellValue("主管:");
|
cell1.setCellValue("专责:");
|
||||||
|
|
||||||
HSSFCell cell2 = row.createCell(4);
|
HSSFCell cell2 = row.createCell(4);
|
||||||
cell2.setCellStyle(headerStyleNoSide);
|
cell2.setCellStyle(headerStyleNoSide);
|
||||||
cell2.setCellValue("审核:");
|
cell2.setCellValue("班长审核:");
|
||||||
|
|
||||||
HSSFCell cell3 = row.createCell(8);
|
HSSFCell cell3 = row.createCell(8);
|
||||||
cell3.setCellStyle(headerStyleNoSide);
|
cell3.setCellStyle(headerStyleNoSide);
|
||||||
|
|
@ -801,7 +802,8 @@ public class PoiOutPage {
|
||||||
int totalCostColumnIndex = list.size() - 3;
|
int totalCostColumnIndex = list.size() - 3;
|
||||||
HSSFCell cell1 = row.createCell(totalCostColumnIndex);
|
HSSFCell cell1 = row.createCell(totalCostColumnIndex);
|
||||||
cell1.setCellStyle(headerStyle);
|
cell1.setCellStyle(headerStyle);
|
||||||
cell1.setCellValue(String.format("%.2f", totalCost));
|
DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
|
||||||
|
cell1.setCellValue(decimalFormat.format(totalCost.doubleValue()));
|
||||||
// 设置边框样式,覆盖整个合并区域
|
// 设置边框样式,覆盖整个合并区域
|
||||||
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 1, rowNum - 1, list.size() - 3, list.size() - 2); // 修改为包含至少两个单元格
|
CellRangeAddress cellRange2 = new CellRangeAddress(rowNum - 1, rowNum - 1, list.size() - 3, list.size() - 2); // 修改为包含至少两个单元格
|
||||||
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet);
|
RegionUtil.setBorderTop(BorderStyle.THIN, cellRange2, sheet);
|
||||||
|
|
@ -813,7 +815,7 @@ public class PoiOutPage {
|
||||||
int totalCostColumnIndexTwo = list.size() - 2;
|
int totalCostColumnIndexTwo = list.size() - 2;
|
||||||
HSSFCell cell2 = row.createCell(totalCostColumnIndexTwo);
|
HSSFCell cell2 = row.createCell(totalCostColumnIndexTwo);
|
||||||
cell2.setCellStyle(headerStyle);
|
cell2.setCellStyle(headerStyle);
|
||||||
cell2.setCellValue(String.format("%.2f", totalCostReal));
|
cell2.setCellValue(decimalFormat.format(totalCostReal.doubleValue()));
|
||||||
|
|
||||||
|
|
||||||
int totalCostColumnIndexThree = list.size() - 1;
|
int totalCostColumnIndexThree = list.size() - 1;
|
||||||
|
|
@ -1025,25 +1027,35 @@ public class PoiOutPage {
|
||||||
// 第一行:结算单位
|
// 第一行:结算单位
|
||||||
HSSFRow row1 = sheet.createRow(rowNum++);
|
HSSFRow row1 = sheet.createRow(rowNum++);
|
||||||
row1.setHeightInPoints(30);
|
row1.setHeightInPoints(30);
|
||||||
|
|
||||||
|
// 创建对齐样式 - 保留原有标题样式的其他属性
|
||||||
|
HSSFCellStyle rightAlignedStyle = sheet.getWorkbook().createCellStyle();
|
||||||
|
rightAlignedStyle.cloneStyleFrom(titleStyle);
|
||||||
|
rightAlignedStyle.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
|
||||||
|
HSSFCellStyle leftAlignedStyle = sheet.getWorkbook().createCellStyle();
|
||||||
|
leftAlignedStyle.cloneStyleFrom(titleStyle);
|
||||||
|
leftAlignedStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
|
||||||
// bug修复:修改合并单元格区域,确保包含两个或以上单元格
|
// bug修复:修改合并单元格区域,确保包含两个或以上单元格
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算单位: 占8
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 结算单位: 占8
|
||||||
HSSFCell cell1 = row1.createCell(0);
|
HSSFCell cell1 = row1.createCell(0);
|
||||||
cell1.setCellStyle(titleStyle);
|
cell1.setCellStyle(rightAlignedStyle);
|
||||||
cell1.setCellValue("领用单位:");
|
cell1.setCellValue("领用单位:");
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 7))); // unitName 占剩余的22
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 7))); // unitName 占剩余的22
|
||||||
HSSFCell cell2 = row1.createCell(2);
|
HSSFCell cell2 = row1.createCell(2);
|
||||||
cell2.setCellStyle(titleStyle);
|
cell2.setCellStyle(leftAlignedStyle);
|
||||||
cell2.setCellValue(unitName);
|
cell2.setCellValue(unitName);
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 6), (short) (nColumn - 5))); // 月结月份: 占8
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 6), (short) (nColumn - 5))); // 月结月份: 占8
|
||||||
HSSFCell cellMonth = row1.createCell(6);
|
HSSFCell cellMonth = row1.createCell(6);
|
||||||
cellMonth.setCellStyle(titleStyle);
|
cellMonth.setCellStyle(rightAlignedStyle);
|
||||||
cellMonth.setCellValue("月结月份:");
|
cellMonth.setCellValue("月结月份:");
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 4), (short) (nColumn - 1))); // 月份值 占剩余的22
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 4), (short) (nColumn - 1))); // 月份值 占剩余的22
|
||||||
HSSFCell cellMonthTwo = row1.createCell(8);
|
HSSFCell cellMonthTwo = row1.createCell(8);
|
||||||
cellMonthTwo.setCellStyle(titleStyle);
|
cellMonthTwo.setCellStyle(leftAlignedStyle);
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM");
|
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM");
|
||||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy年M月");
|
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy年M月");
|
||||||
|
|
@ -1059,24 +1071,24 @@ public class PoiOutPage {
|
||||||
row2.setHeightInPoints(30);
|
row2.setHeightInPoints(30);
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 工程名称: 占8
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 1)); // 工程名称: 占8
|
||||||
HSSFCell cell3 = row2.createCell(0);
|
HSSFCell cell3 = row2.createCell(0);
|
||||||
cell3.setCellStyle(titleStyle);
|
cell3.setCellStyle(rightAlignedStyle);
|
||||||
cell3.setCellValue("工程名称:");
|
cell3.setCellValue("工程名称:");
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 7))); // projectName 占剩余的22
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 2, (short) (nColumn - 7))); // projectName 占剩余的22
|
||||||
HSSFCell cell4 = row2.createCell(2);
|
HSSFCell cell4 = row2.createCell(2);
|
||||||
cell4.setCellStyle(titleStyle);
|
cell4.setCellStyle(leftAlignedStyle);
|
||||||
cell4.setCellValue(projectName);
|
cell4.setCellValue(projectName);
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 6), (short) (nColumn - 5))); // 费用承担方: 占8
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 6), (short) (nColumn - 5))); // 费用承担方: 占8
|
||||||
HSSFCell cell5 = row2.createCell(6);
|
HSSFCell cell5 = row2.createCell(6);
|
||||||
cell5.setCellStyle(titleStyle);
|
cell5.setCellStyle(rightAlignedStyle);
|
||||||
cell5.setCellValue("费用承担方:");
|
cell5.setCellValue("费用承担方:");
|
||||||
|
|
||||||
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 4), (short) (nColumn - 1))); // 费用承担方值 占剩余的22
|
sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, (short) (nColumn - 4), (short) (nColumn - 1))); // 费用承担方值 占剩余的22
|
||||||
HSSFCell cell6 = row2.createCell(8);
|
HSSFCell cell6 = row2.createCell(8);
|
||||||
// 创建红色字体样式
|
// 创建红色字体样式
|
||||||
HSSFCellStyle redStyle = sheet.getWorkbook().createCellStyle();
|
HSSFCellStyle redStyle = sheet.getWorkbook().createCellStyle();
|
||||||
redStyle.cloneStyleFrom(titleStyle); // 复制原有样式
|
redStyle.cloneStyleFrom(leftAlignedStyle); // 复制原有样式
|
||||||
HSSFFont font = sheet.getWorkbook().createFont();
|
HSSFFont font = sheet.getWorkbook().createFont();
|
||||||
font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); // 设置字体颜色为红色
|
font.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex()); // 设置字体颜色为红色
|
||||||
font.setFontHeightInPoints((short) 12);
|
font.setFontHeightInPoints((short) 12);
|
||||||
|
|
@ -1084,9 +1096,9 @@ public class PoiOutPage {
|
||||||
|
|
||||||
cell6.setCellStyle(redStyle); // 应用红色字体样式
|
cell6.setCellStyle(redStyle); // 应用红色字体样式
|
||||||
if(type==1){
|
if(type==1){
|
||||||
cell6.setCellValue("01(项目)");
|
cell6.setCellValue("01");
|
||||||
}else{
|
}else{
|
||||||
cell6.setCellValue("03(分包)");
|
cell6.setCellValue("03");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1362,7 +1374,42 @@ public class PoiOutPage {
|
||||||
integerStyle.cloneStyleFrom(contentStyle);
|
integerStyle.cloneStyleFrom(contentStyle);
|
||||||
integerStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
|
integerStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
|
||||||
cell.setCellStyle(integerStyle);
|
cell.setCellStyle(integerStyle);
|
||||||
} else {
|
}
|
||||||
|
// 如果是天数栏,设置整数格式(假设天数列为第5列,索引4,根据实际情况调整)
|
||||||
|
else if (j == 4 || j == 8) {
|
||||||
|
HSSFCellStyle integerStyle = sheet.getWorkbook().createCellStyle();
|
||||||
|
integerStyle.cloneStyleFrom(contentStyle);
|
||||||
|
integerStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0"));
|
||||||
|
cell.setCellStyle(integerStyle);
|
||||||
|
|
||||||
|
// 处理天数数据,四舍五入取整
|
||||||
|
if (data != null && isNumeric(data)) {
|
||||||
|
double value = Double.parseDouble(data.toString());
|
||||||
|
cell.setCellValue((int)Math.round(value)); // 四舍五入为整数
|
||||||
|
} else {
|
||||||
|
cell.setCellValue("");
|
||||||
|
}
|
||||||
|
continue; // 已手动设置值,跳过后续setCellData调用
|
||||||
|
}
|
||||||
|
// 如果是金额列(j == 10),设置千位符格式
|
||||||
|
else if (j == 10) {
|
||||||
|
HSSFCellStyle numberStyle = sheet.getWorkbook().createCellStyle();
|
||||||
|
numberStyle.cloneStyleFrom(contentStyle);
|
||||||
|
// 设置千位符格式,保留两位小数
|
||||||
|
DataFormat format = sheet.getWorkbook().createDataFormat();
|
||||||
|
numberStyle.setDataFormat(format.getFormat("#,##0.00"));
|
||||||
|
cell.setCellStyle(numberStyle);
|
||||||
|
|
||||||
|
// 处理金额数据
|
||||||
|
if (data != null && isNumeric(data)) {
|
||||||
|
double value = Double.parseDouble(data.toString());
|
||||||
|
cell.setCellValue(value);
|
||||||
|
} else {
|
||||||
|
cell.setCellValue("");
|
||||||
|
}
|
||||||
|
continue; // 已手动设置值,跳过后续setCellData调用
|
||||||
|
}
|
||||||
|
else {
|
||||||
cell.setCellStyle(contentStyle);
|
cell.setCellStyle(contentStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,6 @@ public class SecondLotConfig {
|
||||||
private String updateTime;
|
private String updateTime;
|
||||||
// 部门id
|
// 部门id
|
||||||
private Long deptId;
|
private Long deptId;
|
||||||
|
|
||||||
|
private Long parentId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,4 +148,6 @@ public class SecondaryWarehouse {
|
||||||
*/
|
*/
|
||||||
private Integer teamGroupId;
|
private Integer teamGroupId;
|
||||||
|
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.sgzb.material.mapper;
|
||||||
import com.bonus.sgzb.base.api.domain.MaMachine;
|
import com.bonus.sgzb.base.api.domain.MaMachine;
|
||||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.sgzb.material.domain.*;
|
import com.bonus.sgzb.material.domain.*;
|
||||||
|
import com.bonus.sgzb.system.api.domain.SysDept;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
@ -102,4 +103,6 @@ public interface SecondaryWarehouseMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
TeamLeaseInfo getParentIdByMaIdAndTypeId(TeamLeaseInfo teamLeaseInfo);
|
TeamLeaseInfo getParentIdByMaIdAndTypeId(TeamLeaseInfo teamLeaseInfo);
|
||||||
|
|
||||||
|
SysDept selectDeptById(Long deptId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.bonus.sgzb.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.sgzb.material.domain.*;
|
import com.bonus.sgzb.material.domain.*;
|
||||||
import com.bonus.sgzb.material.mapper.SecondaryWarehouseMapper;
|
import com.bonus.sgzb.material.mapper.SecondaryWarehouseMapper;
|
||||||
import com.bonus.sgzb.material.service.SecondaryWarehouseService;
|
import com.bonus.sgzb.material.service.SecondaryWarehouseService;
|
||||||
|
import com.bonus.sgzb.system.api.domain.SysDept;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -96,6 +97,12 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
|
||||||
public List<SecondLotConfig> listConfig(SecondLotConfig bean) {
|
public List<SecondLotConfig> listConfig(SecondLotConfig bean) {
|
||||||
if (!SecurityUtils.getLoginUser().getRoles().contains("admin") && !SecurityUtils.getLoginUser().getRoles().contains("sysadmin")) {
|
if (!SecurityUtils.getLoginUser().getRoles().contains("admin") && !SecurityUtils.getLoginUser().getRoles().contains("sysadmin")) {
|
||||||
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
|
||||||
|
//查询祖级以便获取上级部门id
|
||||||
|
SysDept dept = mapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
if (dept != null && StringUtils.isNotBlank(dept.getAncestors()) && StringUtils.countMatches(dept.getAncestors(), ",") == 2) {
|
||||||
|
bean.setDeptId(dept.getParentId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mapper.listConfig(bean);
|
return mapper.listConfig(bean);
|
||||||
}
|
}
|
||||||
|
|
@ -104,6 +111,12 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
|
||||||
public List<TeamGroup> listTeamGroup(TeamGroup bean) {
|
public List<TeamGroup> listTeamGroup(TeamGroup bean) {
|
||||||
if (!SecurityUtils.getLoginUser().getRoles().contains("admin") && !SecurityUtils.getLoginUser().getRoles().contains("sysadmin")) {
|
if (!SecurityUtils.getLoginUser().getRoles().contains("admin") && !SecurityUtils.getLoginUser().getRoles().contains("sysadmin")) {
|
||||||
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
|
||||||
|
//查询祖级以便获取上级部门id
|
||||||
|
SysDept dept = mapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
if (dept != null && StringUtils.isNotBlank(dept.getAncestors()) && StringUtils.countMatches(dept.getAncestors(), ",") == 2) {
|
||||||
|
bean.setDeptId(dept.getParentId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return mapper.listTeamGroup(bean);
|
return mapper.listTeamGroup(bean);
|
||||||
}
|
}
|
||||||
|
|
@ -266,6 +279,11 @@ public class SecondaryWarehouseServiceImpl implements SecondaryWarehouseService
|
||||||
bean.setLeaseType(1);
|
bean.setLeaseType(1);
|
||||||
if (!SecurityUtils.getLoginUser().getRoles().contains("admin") && !SecurityUtils.getLoginUser().getRoles().contains("sysadmin")) {
|
if (!SecurityUtils.getLoginUser().getRoles().contains("admin") && !SecurityUtils.getLoginUser().getRoles().contains("sysadmin")) {
|
||||||
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
//查询祖级以便获取上级部门id
|
||||||
|
SysDept dept = mapper.selectDeptById(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||||
|
if (dept != null && StringUtils.isNotBlank(dept.getAncestors()) && StringUtils.countMatches(dept.getAncestors(), ",") == 2) {
|
||||||
|
bean.setDeptId(dept.getParentId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<SecondaryWarehouse> list = mapper.getList(bean);
|
List<SecondaryWarehouse> list = mapper.getList(bean);
|
||||||
for (SecondaryWarehouse secondaryWarehouse : list) {
|
for (SecondaryWarehouse secondaryWarehouse : list) {
|
||||||
|
|
|
||||||
|
|
@ -682,6 +682,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and type_id = #{typeId}
|
and type_id = #{typeId}
|
||||||
order by create_time desc limit 1
|
order by create_time desc limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDeptById" resultType="com.bonus.sgzb.system.api.domain.SysDept">
|
||||||
|
select parent_id as parentId,ancestors from sys_dept where dept_id = #{deptId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="addConfig">
|
<insert id="addConfig">
|
||||||
insert into second_lot_config (name,unit_id,creater,create_time)
|
insert into second_lot_config (name,unit_id,creater,create_time)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue