bug fixed

This commit is contained in:
Timer
2026-03-16 20:31:00 +08:00
parent 2bfa643373
commit 56da3dc9ff
2 changed files with 60 additions and 55 deletions

View File

@ -327,13 +327,13 @@ public class DataController {
fileIds = fileIds.replace(",","','");
wherestr += " and (id in ('"+fileIds+"') or filename like '%"+fileName+"%') ";
}
if(request.getParameter("masterId")!=null && !request.getParameter("masterId").isEmpty()){
String masterId = request.getParameter("masterId");
masterId = masterId.replace(",","','");
wherestr += " and masterid in ('"+masterId+"')";
}else if(request.getParameter("equipmentId") == null){
wherestr += " and masterid in ('')";
}
// if(request.getParameter("masterId")!=null && !request.getParameter("masterId").isEmpty()){
// String masterId = request.getParameter("masterId");
// masterId = masterId.replace(",","','");
// wherestr += " and masterid in ('"+masterId+"')";
// }else if(request.getParameter("equipmentId") == null){
// wherestr += " and masterid in ('')";
// }
if(request.getParameter("equipmentId")!=null && !request.getParameter("equipmentId").isEmpty()){
String fileIds = this.equipmentFileService.getFileIds(request.getParameter("equipmentId"));
fileIds = fileIds.replace(",","','");

View File

@ -46,6 +46,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xmlpull.v1.XmlPullParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import javax.xml.parsers.DocumentBuilderFactory;
@ -70,6 +72,7 @@ import static org.apache.poi.ss.usermodel.CellType.FORMULA;
@Service("rptCreateService")
//@Service
public class RptCreateServiceImpl implements RptCreateService {
private static final Logger logger = LoggerFactory.getLogger(RptCreateServiceImpl.class);
@Resource
private RptCreateDao rptCreateDao;
@Resource
@ -393,7 +396,7 @@ public class RptCreateServiceImpl implements RptCreateService {
}
}
Row row2 = sheet.getRow(row);
HSSFCell cell = (HSSFCell) row2.getCell(column);
Cell cell = row2.getCell(column);
return list;
}
@ -846,21 +849,26 @@ public class RptCreateServiceImpl implements RptCreateService {
// 设定Excel文件所在路径
String excelFileName = filelist.get(0).getAbspath();
// 读取Excel文件内容
HSSFWorkbook workbook = null;
Workbook workbook = null;
FileInputStream inputStream = null;
byte[] bytes_m = commonFileService.getInputStreamBytes(FileNameSpaceEnum.RptInfoSetFile.getNameSpace(), path);
// Check if bytes_m is null or empty
if (bytes_m == null || bytes_m.length == 0) {
logger.error("Excel file is empty or not found: " + path);
return null;
}
// 直接从本地文件创建Workbook, 从输入流创建Workbook
InputStream ins = new ByteArrayInputStream(bytes_m);
// 构建Workbook对象, 只读Workbook对象
// 构建Workbook对象, 只读Workbook对象 - use WorkbookFactory to support both .xls and .xlsx
try {
workbook = new HSSFWorkbook(ins);
workbook = WorkbookFactory.create(ins);
} catch (IOException e) {
logger.error("Failed to create workbook from file: " + path, e);
e.printStackTrace();
}
String endtype = ".xls";
String endtype = path.toLowerCase().endsWith(".xlsx") ? ".xlsx" : ".xls";
// 生成一个样式,用在表格数据
HSSFCellStyle listStyle = null;
if (endtype.equals(".xls")) {
CellStyle listStyle = null;
listStyle = workbook.createCellStyle();
// 设置这些样式
listStyle.setBorderBottom(BorderStyle.THIN);
@ -871,10 +879,8 @@ public class RptCreateServiceImpl implements RptCreateService {
listStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
//listStyle.setWrapText(false);//不自动换行
//listStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));//设置格式
}
// 生成一个样式,用在表格数据 修改过的数据
HSSFCellStyle listStyle2 = null;
if (endtype.equals(".xls")) {
CellStyle listStyle2 = null;
listStyle2 = workbook.createCellStyle();
// 设置这些样式
listStyle2.setBorderBottom(BorderStyle.THIN);
@ -885,7 +891,6 @@ public class RptCreateServiceImpl implements RptCreateService {
listStyle2.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
listStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
listStyle2.setFillForegroundColor(IndexedColors.GREEN.getIndex());
}
List<RptSpSet> rptSpSetlist = this.rptSpSetService.selectListByWhere(" where pid='" + rptInfoSet.getId() + "' and (active !='" + CommString.Active_False_CH + "' or active is null) order by morder asc");
if (rptSpSetlist != null && rptSpSetlist.size() > 0) {
for (int s = 0; s < rptSpSetlist.size(); s++) {
@ -993,10 +998,10 @@ public class RptCreateServiceImpl implements RptCreateService {
if (spname != null && spname.equals(RptSpSet.RptSpSet_Type_Confirm)) { //接班人 类型
for (int ws = 0; ws < workbook.getNumberOfSheets(); ws++) {//获取每个Sheet表
if (workbook.getSheetName(ws).equals(rptSpSetlist.get(s).getSheet())) {
HSSFSheet sheet = workbook.getSheetAt(ws);
HSSFRow row = sheet.getRow(posy - 1);
Sheet sheet = workbook.getSheetAt(ws);
Row row = sheet.getRow(posy - 1);
if (row != null) {
HSSFCell cell_d = row.getCell(posx - 1);
Cell cell_d = row.getCell(posx - 1);
if (cell_d != null) {
//插入日志表
RptLog rptLog = new RptLog();
@ -1029,10 +1034,10 @@ public class RptCreateServiceImpl implements RptCreateService {
} else if (spname != null && spname.equals(RptSpSet.RptSpSet_Type_Rptdt)) {//日期 类型
for (int ws = 0; ws < workbook.getNumberOfSheets(); ws++) {//获取每个Sheet表
if (workbook.getSheetName(ws).equals(rptSpSetlist.get(s).getSheet())) {
HSSFSheet sheet = workbook.getSheetAt(ws);
HSSFRow row = sheet.getRow(posy - 1);
Sheet sheet = workbook.getSheetAt(ws);
Row row = sheet.getRow(posy - 1);
if (row != null) {
HSSFCell cell_d = row.getCell(posx - 1);
Cell cell_d = row.getCell(posx - 1);
if (cell_d != null) {
try {
cell_d.setCellStyle(cell_d.getCellStyle());
@ -1058,10 +1063,10 @@ public class RptCreateServiceImpl implements RptCreateService {
} else if (spname != null && spname.equals(RptSpSet.RptSpSet_Type_BanZhang)) {//值班班长 类型
for (int ws = 0; ws < workbook.getNumberOfSheets(); ws++) {//获取每个Sheet表
if (workbook.getSheetName(ws).equals(rptSpSetlist.get(s).getSheet())) {
HSSFSheet sheet = workbook.getSheetAt(ws);
HSSFRow row = sheet.getRow(posy - 1);
Sheet sheet = workbook.getSheetAt(ws);
Row row = sheet.getRow(posy - 1);
if (row != null) {
HSSFCell cell_d = row.getCell(posx - 1);
Cell cell_d = row.getCell(posx - 1);
if (cell_d != null) {
//插入日志表
RptLog rptLog = new RptLog();
@ -1094,10 +1099,10 @@ public class RptCreateServiceImpl implements RptCreateService {
} else if (spname != null && spname.equals(RptSpSet.RptSpSet_Type_ZuYuan)) { //值班组员 类型
for (int ws = 0; ws < workbook.getNumberOfSheets(); ws++) {//获取每个Sheet表
if (workbook.getSheetName(ws).equals(rptSpSetlist.get(s).getSheet())) {
HSSFSheet sheet = workbook.getSheetAt(ws);
HSSFRow row = sheet.getRow(posy - 1);
Sheet sheet = workbook.getSheetAt(ws);
Row row = sheet.getRow(posy - 1);
if (row != null) {
HSSFCell cell_d = row.getCell(posx - 1);
Cell cell_d = row.getCell(posx - 1);
if (cell_d != null) {
//插入日志表
RptLog rptLog = new RptLog();
@ -1134,12 +1139,12 @@ public class RptCreateServiceImpl implements RptCreateService {
for (int r = 0; r < rpttemplist.size(); r++) {
for (int ws = 0; ws < workbook.getNumberOfSheets(); ws++) {//获取每个Sheet表
if (workbook.getSheetName(ws).equals(rptSpSetlist.get(s).getSheet())) {
HSSFSheet sheet = workbook.getSheetAt(ws);
HSSFRow row = sheet.getRow(rpttemplist.get(r).getColposy() - 1);
Sheet sheet = workbook.getSheetAt(ws);
Row row = sheet.getRow(rpttemplist.get(r).getColposy() - 1);
if (row != null) {
Cell cell_d = row.getCell(rpttemplist.get(r).getColposx() - 1);
if (cell_d != null) {
HSSFCellStyle cellStyle = row.getCell(rpttemplist.get(r).getColposx() - 1).getCellStyle();
CellStyle cellStyle = row.getCell(rpttemplist.get(r).getColposx() - 1).getCellStyle();
// HSSFCellStyle cellStyle_r = row.getCell(rpttemplist.get(r).getColposx() - 1).getCellStyle();
try {
/**
@ -1286,9 +1291,9 @@ public class RptCreateServiceImpl implements RptCreateService {
*/
List<RptLog> list = rptLogService.selectListByWhere("where creat_id = '" + rptCreate.getId() + "'");
for (RptLog rptLog : list) {
HSSFSheet sheet = workbook.getSheet(rptLog.getSheet());
Sheet sheet = workbook.getSheet(rptLog.getSheet());
if (rptLog.getPosyE() != null && !rptLog.getPosyE().equals("") && sheet != null) {
HSSFRow row = sheet.getRow(Integer.parseInt(rptLog.getPosyE()) - 1);
Row row = sheet.getRow(Integer.parseInt(rptLog.getPosyE()) - 1);
if (row != null) {
Cell cell_d = row.getCell(Integer.parseInt(rptLog.getPosxE()) - 1);
if (cell_d != null) {