修改bug

This commit is contained in:
guoshengxiong 2025-08-14 14:45:23 +08:00
parent 3663e7d5d2
commit 933b8012be
15 changed files with 258 additions and 68 deletions

View File

@ -60,6 +60,7 @@ public class ProjectEnterpriseController {
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "cbsProjectType", value = "项目类型(字典)", paramType = "body", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "isCountMainEnterprise", value = "1是总包", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "enterpriseIds", value = "单位idList", paramType = "body", required = false, dataType = "String"),
})
@PostMapping(value = "/list")
public Result<IPage<EnterpriseInfo>> queryPageList(@RequestBody Map<String, Object> map) {

View File

@ -21,6 +21,7 @@ import com.zhgd.xmgl.modules.worker.mapper.UserEnterpriseMapper;
import com.zhgd.xmgl.modules.xz.entity.XzProjectOrg;
import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.MapUtil;
import com.zhgd.xmgl.util.MessageUtil;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -67,6 +68,11 @@ public class ProjectEnterpriseServiceImpl extends ServiceImpl<ProjectEnterpriseM
return null;
}
List<String> enterpriseIds = Stream.of(StringUtils.split(userEnterprise.getEnterpriseId(), ",")).collect(Collectors.toList());
List<String> queryEnterpriseIds = MapUtil.getList(map, "enterpriseIds", String.class);
if (CollUtil.isNotEmpty(queryEnterpriseIds)) {
enterpriseIds = enterpriseIds.stream().filter(queryEnterpriseIds::contains).collect(Collectors.toList());
}
enterpriseIds.add("0");
map.put("enterpriseIds", enterpriseIds);
}
List<EnterpriseInfo> list = projectEnterpriseMapper.selectProjectEnterprisePage(page, map);

View File

@ -122,11 +122,15 @@ public class QualityRegion implements Serializable {
private List<QualityRegion> children;
@TableField(exist = false)
@ApiModelProperty(value = "最外面的设置的责任单位")
private List<EnterpriseInfo> enterpriseInfos;
@TableField(exist = false)
@ApiModelProperty(value = "最外面的设置的责任人")
private List<SystemUser> systemUsers;
@TableField(exist = false)
@ApiModelProperty(value = "最外面的设置的AI设备")
private List<AiAnalyseHardWareRecord> aiAnalyseHardWareRecords;
@TableField(exist = false)

View File

@ -454,11 +454,10 @@ public class QualityRegionServiceImpl extends ServiceImpl<QualityRegionMapper, Q
pageSize = Integer.MAX_VALUE;
}
List<QualityRegionVo> list = this.treeList(paramMap);
List<QualityRegionVo> vos = BeanUtil.copyToList(ListUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(list)), "id", "parentRegion", "children"), QualityRegionVo.class);
IPage<QualityRegionVo> p = new Page<>();
int i = cn.hutool.core.util.PageUtil.getStart(pageNo - 1, pageSize);
p.setTotal(vos.size());
p.setRecords(CollUtil.sub(vos, i, i + pageSize));
p.setTotal(list.size());
p.setRecords(CollUtil.sub(list, i, i + pageSize));
p.setCurrent(pageNo);
p.setSize(pageSize);
return p;

View File

@ -43,6 +43,7 @@ import org.apache.poi.util.IOUtils;
import org.simpleframework.xml.core.Validate;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -92,6 +93,8 @@ public class RiskListSourceController {
@Lazy
@Autowired
private IRiskListSourceResponsibilityRegionService riskListSourceResponsibilityRegionService;
@Value("${riskListSourceRegionQrCode:}")
private String riskListSourceRegionQrCode;
/**
* 分页列表查询
@ -270,7 +273,6 @@ public class RiskListSourceController {
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "Integer"),
@ApiImplicitParam(name = "regionIds", value = "区域ids多个,分割)", paramType = "body", required = false, dataType = "Integer"),
@ApiImplicitParam(name = "httpPrefix", value = "http的前缀", paramType = "body", required = false, dataType = "String"),
})
@PostMapping(value = "/downloadRegionQrCode")
public void downloadRegionQrCode(HttpServletResponse response, @RequestBody HashMap<String, Object> param) {
@ -307,7 +309,6 @@ public class RiskListSourceController {
* @param dir
*/
private void generateRegionQrCode(HashMap<String, Object> param, String dir) {
String httpPrefix = MapUtils.getString(param, "httpPrefix");
String projectSn = MapUtils.getString(param, "projectSn");
List<String> regionIds = StrUtil.split(MapUtils.getString(param, "regionIds"), ",");
List<QualityRegionVo> regionV2Vos = qualityRegionService.queryList(new MapBuilder<String, Object>()
@ -384,7 +385,7 @@ public class RiskListSourceController {
QrConfig config = new QrConfig(qrSize, qrSize);
config.setMargin(1); // 设置边距
BufferedImage qrImage = QrCodeUtil.generate(
httpPrefix + regionV2Vo.getId(),
riskListSourceRegionQrCode + regionV2Vo.getId(),
config
);

View File

@ -8,6 +8,7 @@ import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.stream.StreamUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -30,8 +31,10 @@ import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService;
import com.zhgd.xmgl.modules.worker.service.IWorkerDailyAttendanceStatisticsV2Service;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.EasyPoiUtil;
import com.zhgd.xmgl.util.ExcelUtils;
import com.zhgd.xmgl.util.Fileutils;
import com.zhgd.xmgl.util.PathUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -50,6 +53,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -274,6 +278,11 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
vo.setEnterpriseName(statisticsV2Vo.getEnterpriseName());
vo.setWorkerName(statisticsV2Vo.getWorkerName());
vo.setDeptName(statisticsV2Vo.getDeptName());
vo.setWorkerTypeName(statisticsV2Vo.getWorkerTypeName());
vo.setPhoneNumber(statisticsV2Vo.getPhoneNumber());
vo.setIdCard(statisticsV2Vo.getIdCard());
vo.setSex(statisticsV2Vo.getSex());
vo.setEnterDate(statisticsV2Vo.getEnterDate());
vo.setTotalHour(statisticsV2Vo.getHourVal());
vo.setDate(statisticsV2Vo.getAttendanceDate());
vo.setInTimeList(Optional.ofNullable(inOutMap.get(statisticsV2Vo.getPersonSn())).map(m -> m.get(1))
@ -483,13 +492,24 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
return Result.success(workerDailyAttendanceStatisticsV2Service.countWorkerDailyAttendanceStatisticsV2ByDate(param));
}
@ApiOperation(value = "查询考勤日报列表", notes = "查询考勤日报列表", httpMethod = "POST")
@ApiOperation(value = "分页查询考勤日报列表", notes = "分页查询考勤日报列表", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "attendanceDate", value = "考勤日期yyyy-MM-dd", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "pageNo", value = "第几页", paramType = "body", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", value = "每页显示条数", paramType = "body", required = true, dataType = "Integer"),
})
@PostMapping(value = "/getWorkerDailyAttendancesByDate")
public Result<IPage<WorkerDailyAttendancesByDateVo>> getWorkerDailyAttendancesByDate(@RequestBody HashMap<String, Object> param) {
@PostMapping(value = "/getWorkerDailyAttendancePageByDate")
public Result<IPage<WorkerDailyAttendancesByDateVo>> getWorkerDailyAttendancePageByDate(@RequestBody HashMap<String, Object> param) {
IPage<WorkerDailyAttendancesByDateVo> p = doGetWorkerDailyAttendancePageByDateVoIPage(param);
return Result.success(p);
}
/**
* @param param
* @return
*/
private IPage<WorkerDailyAttendancesByDateVo> doGetWorkerDailyAttendancePageByDateVoIPage(HashMap<String, Object> param) {
String projectSn = MapUtils.getString(param, "projectSn");
String attendanceDate = MapUtils.getString(param, "attendanceDate");
param.put("addTime_end", attendanceDate);
@ -506,7 +526,7 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
WorkerDailyAttendanceStatisticsV2Vo voDb = personSnMap.get(workerInfo.getPersonSn());
WorkerDailyAttendancesByDateVo vo = new WorkerDailyAttendancesByDateVo();
if (voDb != null) {
BeanUtil.copyProperties(vo, voDb);
BeanUtil.copyProperties(voDb, vo);
} else {
vo.setPersonType(workerInfo.getPersonType());
vo.setEnterpriseName(workerInfo.getEnterpriseName());
@ -521,6 +541,11 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
vo.setOvertimeHourVal(new BigDecimal("0"));
vo.setOvertimeDayVal(new BigDecimal("0"));
vo.setInserviceType(workerInfo.getInserviceType());
vo.setWorkerTypeName(workerInfo.getTypeName());
vo.setPhoneNumber(workerInfo.getPhoneNumber());
vo.setIdCard(workerInfo.getIdCard());
vo.setSex(workerInfo.getSex());
vo.setEnterDate(workerInfo.getEnterDate());
}
List<WorkerAttendance> attendances = personSn2AttendancesMap.get(workerInfo.getPersonSn());
if (Objects.equals(vo.getIsAttendance(), 1) && CollUtil.isNotEmpty(attendances)) {
@ -532,6 +557,7 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
vo.setFirstTimeAm(firstTimeAm);
String endTimePm = attendances.stream().filter(w -> DateUtil.compare(DateUtil.parseDateTime(w.getCreateTime()), DateUtil.parseDateTime(attendanceDate + " 12:00:00")) >= 0).max(Comparator.comparing(WorkerAttendance::getCreateTime)).map(WorkerAttendance::getCreateTime).orElse(null);
vo.setEndTimePm(endTimePm);
vo.setAttendanceList(attendances);
}
vos.add(vo);
}
@ -540,7 +566,7 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
p.setRecords(vos);
p.setCurrent(workerInfoList.getCurrent());
p.setSize(workerInfoList.getSize());
return Result.success(p);
return p;
}
@ApiOperation(value = "统计考勤日报", notes = "统计考勤日报", httpMethod = "POST")
@ -571,59 +597,88 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "downloadType", value = "1上下午打卡2进出场打卡", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "startDate", value = "开始日期yyyy-MM-dd", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期yyyy-MM-dd", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/exportWorkerDailyAttendancesStaticsByDateXls")
public void exportXls(HttpServletResponse response, @RequestBody HashMap<String, Object> param) {
// String templateUrl = null;
// try {
// String sn = MapUtils.getString(param, "sn");
//// String libraryId = MapUtils.getString(param, "libraryId");
// List<String> detailIdList = JSON.parseArray(JSON.toJSONString(param.get("detailIdList")), String.class);
// // Step.1 组装查询条件
// param.put("pageNo", 1);
// param.put("pageSize", -1);
// List<Map<String, Object>> listMap = new ArrayList<>();
// Map<String, Object> firstSheetMap = new HashMap<>();
// List<RiskListDetail> details = riskListDetailService.list(new LambdaQueryWrapper<RiskListDetail>()
//// .eq(RiskListDetail::getLibraryId, libraryId)
// .in(RiskListDetail::getId, detailIdList)
// );
// Map<String, DictionaryItem> factorTypeMap = dictionaryItemService.getDictList("risk_factor_type", null).stream().collect(Collectors.toMap(DictionaryItem::getData, Function.identity(), (o1, o2) -> o1));
// Map<Long, RiskListPotentialAccidentType> accidentTypeMap = riskListPotentialAccidentTypeService.list(new LambdaQueryWrapper<RiskListPotentialAccidentType>()
// .eq(RiskListPotentialAccidentType::getSn, sn)).stream().collect(Collectors.toMap(RiskListPotentialAccidentType::getId, Function.identity(), (o1, o2) -> o1));
// for (RiskListDetail detail : details) {
// Map<String, Object> map = new HashMap<>();
// map.put("riskDescription", detail.getRiskDescription());
// map.put("accidentType", Optional.ofNullable(accidentTypeMap.get(detail.getAccidentTypeId())).map(RiskListPotentialAccidentType::getType).orElse(""));
// map.put("riskFactorType", Optional.ofNullable(factorTypeMap.get(detail.getRiskFactorType())).map(DictionaryItem::getName).orElse(""));
// List<String> levels = Arrays.asList("重大风险", "较大风险", "一般风险", "低风险");
// map.put("riskLevel", Optional.ofNullable(detail.getRiskLevel()).map(m -> levels.get(m - 1)).orElse(""));
// map.put("engineeringMeasure", detail.getEngineeringMeasure());
// map.put("managementMeasure", detail.getManagementMeasure());
// map.put("personalProtection", detail.getPersonalProtection());
// map.put("emergencyMeasure", detail.getEmergencyMeasure());
// map.put("educationalMeasure", detail.getEducationalMeasure());
// listMap.add(map);
// }
// //将项目清单集合添加到map中
// firstSheetMap.put("listMap", listMap);
// Map<Integer, Map<String, Object>> root = new HashMap<>(4);
// root.put(0, firstSheetMap);
// putOtherSheets(sn, root);
// templateUrl = Fileutils.getExportTemplateFile("excel/风险清单详情导出模板.xlsx").getAbsolutePath();
//// templateUrl = new File("C:\\Users\\Administrator\\IdeaProjects\\wisdomisite-with-flowjar\\tmp\\风险清单详情导出模板.xlsx").getAbsolutePath();
// TemplateExportParams params = new TemplateExportParams(templateUrl, root.keySet().toArray(new Integer[]{}));
// Workbook workbook = ExcelExportUtil.exportExcel(root, params);
// //设置下拉
// ExcelUtils.downLoadExcel("风险清单详情导出模板.xlsx", response, workbook);
// } catch (IOException e) {
// log.error("", e);
// throw new OpenAlertException("系统错误");
// } finally {
// if (templateUrl != null) {
// FileUtil.deleteFile(templateUrl);
// }
// }
public void exportWorkerDailyAttendancesStaticsByDateXls(HttpServletResponse response, @RequestBody HashMap<String, Object> param) {
String templateUrl = null;
try {
String projectSn = MapUtils.getString(param, "projectSn");
String startDate = MapUtils.getString(param, "startDate");
String endDate = MapUtils.getString(param, "endDate");
Integer downloadType = MapUtils.getInteger(param, "downloadType");
// Step.1 组装查询条件
param.put("pageNo", 1);
param.put("pageSize", -1);
List<DateTime> dateTimes = DateUtil.rangeToList(DateUtil.parseDate(startDate), DateUtil.parseDate(endDate), DateField.DAY_OF_YEAR);
Map<Integer, Map<String, Object>> root = new HashMap<>();
int j = 0;
String tempSheetName;
if (Objects.equals(downloadType, 1)) {
tempSheetName = "考勤日报-出勤导出模版(上午下午).xlsx";
} else {
tempSheetName = "考勤日报-出勤导出模版(进场出场).xlsx";
}
for (DateTime dateTime : dateTimes) {
param.put("attendanceDate", DateUtil.formatDate(dateTime));
List<WorkerDailyAttendancesByDateVo> records = doGetWorkerDailyAttendancePageByDateVoIPage(param).getRecords();
Map<String, Object> sheetMap = new HashMap<>();
List<Map<String, Object>> listMap = new ArrayList<>();
for (WorkerDailyAttendancesByDateVo vo : records) {
Map<String, Object> map = new HashMap<>();
map.put("firstInTimeYes", StrUtil.isNotBlank(vo.getFirstInTime()) ? "" : "×");
map.put("firstInTime", vo.getFirstInTime());
map.put("endOutTimeYes", StrUtil.isNotBlank(vo.getEndOutTime()) ? "" : "×");
map.put("endOutTime", vo.getEndOutTime());
map.put("firstTimeAmYes", StrUtil.isNotBlank(vo.getFirstTimeAm()) ? "" : "×");
map.put("firstTimeAm", vo.getFirstTimeAm());
map.put("endTimePmYes", StrUtil.isNotBlank(vo.getEndTimePm()) ? "" : "×");
map.put("endTimePm", vo.getEndTimePm());
map.put("personType", vo.getPersonType());
map.put("enterpriseName", vo.getEnterpriseName());
map.put("workerName", vo.getWorkerName());
map.put("deptName", vo.getDeptName());
map.put("projectSn", vo.getProjectSn());
map.put("personSn", vo.getPersonSn());
map.put("attendanceDate", vo.getAttendanceDate());
map.put("hourVal", vo.getHourVal());
map.put("dayVal", vo.getDayVal());
map.put("isAttendance", vo.getIsAttendance());
map.put("overtimeHourVal", vo.getOvertimeHourVal());
map.put("overtimeDayVal", vo.getOvertimeDayVal());
map.put("inserviceType", vo.getInserviceType());
AtomicInteger i = new AtomicInteger(1);
map.put("attendanceList", Objects.nonNull(vo.getAttendanceList()) ? vo.getAttendanceList().stream().map(a -> {
return i.getAndIncrement() + ".(" + (Objects.equals(a.getPassType(), 1) ? "进场" : "出场") + a.getCreateTime() + ")";
}).collect(Collectors.joining("\n")) : "");
map.put("workerTypeName", vo.getWorkerTypeName());
map.put("phoneNumber", vo.getPhoneNumber());
map.put("idCard", vo.getIdCard());
map.put("sex", Objects.equals(vo.getSex(), 1) ? "" : "");
map.put("enterDate", vo.getEnterDate());
listMap.add(map);
}
sheetMap.put("date", DateUtil.formatDate(dateTime));
sheetMap.put("listMap", listMap);
root.put(j++, sheetMap);
}
templateUrl = Fileutils.getExportTemplateFile("excel/" + tempSheetName).getAbsolutePath();
String outputTemplateFilePath = PathUtil.getBasePath() + "/temp/" + IdUtil.randomUUID() + ".xlsx";
EasyPoiUtil.cloneSheetMultipleTimes(templateUrl, outputTemplateFilePath, "1", dateTimes.size() - 1);
TemplateExportParams params = new TemplateExportParams(outputTemplateFilePath, true);
params.setSheetName(dateTimes.stream().map(DateUtil::formatDate).collect(Collectors.toList()).toArray(new String[]{}));
Workbook workbook = ExcelExportUtil.exportExcel(root, params);
//设置下拉
ExcelUtils.downLoadExcel(tempSheetName, response, workbook);
} catch (IOException e) {
log.error("", e);
throw new OpenAlertException("系统错误");
} finally {
if (templateUrl != null) {
FileUtil.deleteFile(templateUrl);
}
}
}
}

View File

@ -31,6 +31,31 @@ public class ExceptionHourStatisticsListVo {
*/
@ApiModelProperty(value = "班组/部门")
private String deptName;
/**
* 工种名称
*/
@ApiModelProperty(value = "工种名称")
private String workerTypeName;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private java.lang.String phoneNumber;
/**
* 身份证号
*/
@ApiModelProperty(value = "身份证号")
private java.lang.String idCard;
/**
* 性别
*/
@ApiModelProperty(value = "性别1男2女")
private java.lang.Integer sex;
/**
* 进场日期
*/
@ApiModelProperty(value = "进场日期")
private java.lang.String enterDate;
/**
* 合计工时(h)
*/

View File

@ -28,5 +28,30 @@ public class WorkerDailyAttendanceStatisticsV2Vo extends WorkerDailyAttendanceSt
*/
@ApiModelProperty(value = "班组/部门")
private String deptName;
/**
* 工种名称
*/
@ApiModelProperty(value = "工种名称")
private String workerTypeName;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号")
private java.lang.String phoneNumber;
/**
* 身份证号
*/
@ApiModelProperty(value = "身份证号")
private java.lang.String idCard;
/**
* 性别
*/
@ApiModelProperty(value = "性别1男2女")
private java.lang.Integer sex;
/**
* 进场日期
*/
@ApiModelProperty(value = "进场日期")
private java.lang.String enterDate;
}

View File

@ -1,8 +1,11 @@
package com.zhgd.xmgl.modules.worker.entity.vo;
import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class WorkerDailyAttendancesByDateVo extends WorkerDailyAttendanceStatisticsV2Vo {
/**
@ -25,4 +28,10 @@ public class WorkerDailyAttendancesByDateVo extends WorkerDailyAttendanceStatist
*/
@ApiModelProperty(value = "下午打卡(未次)")
private String endTimePm;
/**
* 考勤记录明细
*/
@ApiModelProperty(value = "考勤记录明细")
private List<WorkerAttendance> attendanceList;
}

View File

@ -10,6 +10,11 @@
,c.department_name
,en.enterprise_name
,if(a.person_type=1,b.team_name,c.department_name) as dept_name
,wt.type_name as worker_type_name
,a.phone_number
,a.id_card
,a.sex
,a.enter_date
from worker_daily_attendance_statistics_v2 t
JOIN worker_info a on t.person_sn=a.person_sn
LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1

View File

@ -7,8 +7,10 @@ import cn.hutool.core.util.StrUtil;
import com.documents4j.api.DocumentType;
import com.documents4j.api.IConverter;
import com.documents4j.job.LocalConverter;
import com.zhgd.jeecg.common.execption.OpenAlertException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import javax.servlet.http.HttpServletResponse;
@ -21,6 +23,55 @@ import java.util.Map;
@Slf4j
public class EasyPoiUtil {
public static void main(String[] args) {
File file = new File("C:\\Users\\Administrator\\Desktop\\t\\测试1.xlsx");
// FileInputStream fis;
try {
// fis = new FileInputStream(file);
// XSSFWorkbook wb = new XSSFWorkbook(fis);
// XSSFSheet sheet = wb.getSheet("test1");
// String name = sheet.getSheetName();
// String test2 = "test2";
// XSSFSheet sheet2 = wb.cloneSheet(0, test2);
// wb.setSheetOrder(test2, 1);
String outputFile = "C:\\Users\\Administrator\\Desktop\\t\\测试2.xlsx";
FileOutputStream fos = new FileOutputStream(outputFile);
// wb.write(fos);
// fis.close();
// fos.close();
// wb.close();
cloneSheetMultipleTimes(file.getAbsolutePath(), outputFile, "test1", 5);
} catch (IOException e) {
e.printStackTrace();
}
// System.out.println("结束");
}
/**
* 克隆Excel的一个Sheet多份并导出新文件
*
* @param sourceFilePath 源Excel文件路径
* @param outputFilePath 输出Excel文件路径
* @param sheetName
* @param copyCount 要复制的份数 (不包括原始Sheet)
* @throws IOException 如果文件操作失败
*/
public static void cloneSheetMultipleTimes(String sourceFilePath, String outputFilePath, String sheetName, int copyCount) throws IOException {
try (FileInputStream fis = new FileInputStream(sourceFilePath);
XSSFWorkbook wb = new XSSFWorkbook(fis);
FileOutputStream fos = new FileOutputStream(outputFilePath);) {
int sheetIndex = wb.getSheetIndex(sheetName);
if (sheetIndex == -1) {
throw new OpenAlertException("sheetName错误");
}
for (int i = 0; i < copyCount; i++) {
wb.cloneSheet(sheetIndex, sheetName + "-" + (i + 1));
wb.setSheetOrder(sheetName + "-" + (i + 1), sheetIndex + i + 1);
}
wb.write(fos);
}
}
/**
* 导出word

View File

@ -1,8 +1,11 @@
package com.zhgd.xmgl.util;
import com.gexin.fastjson.JSON;
import com.gexin.fastjson.TypeReference;
import jodd.util.StringUtil;
import org.apache.commons.collections.MapUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -18,18 +21,22 @@ public class MapUtil {
* @return 包含指定类型元素的List如果key不存在或类型不匹配返回空List
*/
public static <T> List<T> getList(Map<String, Object> map, String key, Class<T> clazz) {
// 1. 检查参数
if (map == null || key == null || clazz == null) {
return null;
return Collections.emptyList();
}
// 2. 获取Map中的值
Object value = map.get(key);
if (value == null) {
return null;
return Collections.emptyList();
}
return com.gexin.fastjson.JSON.parseObject(com.gexin.fastjson.JSON.toJSONString(value), new com.gexin.fastjson.TypeReference<List<T>>() {
// 特殊处理 String 类型
if (clazz == String.class) {
return (List<T>) JSON.parseArray(JSON.toJSONString(value), String.class);
}
return JSON.parseObject(JSON.toJSONString(value),
new TypeReference<List<T>>() {
});
}

View File

@ -105,3 +105,5 @@ udp.port=51236
#上传的图片的url前缀
upload.image.url.prefix=http://192.168.34.221:9111/image/
supplierResubmitApplicationUrl=http://192.168.34.175:88/#/workspace/contractorApply
#管控清单危险源的区域二维码的前缀
riskListSourceRegionQrCode=http://localhost:8088/app/#/pages/projectEnd/safeSame/riskGradingControlList/riskGradingControlList?id=