修改bug
This commit is contained in:
parent
58d316bcb9
commit
0cf0c64722
17
pom.xml
17
pom.xml
@ -416,6 +416,23 @@
|
||||
<artifactId>easypoi-web</artifactId>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<!--pdf-->
|
||||
<dependency>
|
||||
<groupId>com.documents4j</groupId>
|
||||
<artifactId>documents4j-local</artifactId>
|
||||
<version>1.1.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.documents4j</groupId>
|
||||
<artifactId>documents4j-transformer-msoffice-word</artifactId>
|
||||
<version>1.1.12</version>
|
||||
</dependency>
|
||||
<!-- documents4j 转 pdf -->
|
||||
<dependency>
|
||||
<groupId>com.documents4j</groupId>
|
||||
<artifactId>documents4j-transformer-msoffice-excel</artifactId>
|
||||
<version>1.1.12</version>
|
||||
</dependency>
|
||||
<!--注意:word中要使用循环等标签必须单独导入以下依赖-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
|
||||
@ -3,28 +3,41 @@ package com.zhgd.xmgl.modules.ocr.controller;
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.gexin.fastjson.JSONObject;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.modules.ocr.entity.OcrBuildLog;
|
||||
import com.zhgd.xmgl.modules.ocr.entity.dto.OcrBuildLogDto;
|
||||
import com.zhgd.xmgl.modules.ocr.entity.vo.OcrBuildLogForMonthVo;
|
||||
import com.zhgd.xmgl.modules.ocr.entity.vo.OcrBuildLogVo;
|
||||
import com.zhgd.xmgl.modules.ocr.service.IOcrBuildLogService;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.simpleframework.xml.core.Validate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -159,5 +172,88 @@ public class OcrBuildLogController {
|
||||
return Result.success(vos);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "OCR施工日志模板下载", notes = "OCR施工日志模板下载")
|
||||
@GetMapping("/downloadTemplate")
|
||||
public void downloadTemplate(HttpServletResponse response) {
|
||||
try (OutputStream out = response.getOutputStream();
|
||||
InputStream fis = new ClassPathResource("word/ocr施工日志模版.docx").getInputStream()) {
|
||||
|
||||
// 设置正确的 Content-Type
|
||||
response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
// 设置文件名(URL编码)
|
||||
String fileName = URLEncoder.encode("施工日志模版.docx", "UTF-8").replace("+", "%20");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
|
||||
IOUtils.copy(fis, out);
|
||||
} catch (Exception e) {
|
||||
log.error("下载模板失败:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "导出zip文件", notes = "导出zip文件", httpMethod = "POST")
|
||||
@ApiImplicitParam(name = "idList", value = "idList", paramType = "body", required = true, dataType = "String")
|
||||
@PostMapping("exportZip")
|
||||
public void exportZip(HttpServletResponse response, @ApiIgnore @RequestBody HashMap<String, Object> param) throws IOException {
|
||||
try (OutputStream out = response.getOutputStream();) {
|
||||
String wordDir = PathUtil.getBasePath() + "/temp/" + DateUtil.today() + "/" + IdUtil.randomUUID() + "/导出OCR施工日志ZIP/word";
|
||||
FileUtil.mkdir(wordDir);
|
||||
List<String> idList = MapUtil.getList(param, "idList", String.class);
|
||||
List<OcrBuildLogVo> logVos = ocrBuildLogService.queryList(new MapBuilder<String, Object>()
|
||||
.put("idList", idList)
|
||||
.build());
|
||||
String dir = new File(wordDir).getParent();
|
||||
for (OcrBuildLogVo logVo : logVos) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (StrUtil.isNotBlank(logVo.getWeatherJson())) {
|
||||
JSONObject jsonObject = JSON.parseObject(logVo.getWeatherJson());
|
||||
map.put("win_speed", jsonObject.getString("win_speed"));
|
||||
map.put("wea", jsonObject.getString("wea"));
|
||||
map.put("tem_day", jsonObject.getString("tem_day"));
|
||||
}
|
||||
map.put("constructionUnitIds", logVo.getConstructionUnitIds());
|
||||
map.put("constructionAreaNames", logVo.getConstructionAreaNames());
|
||||
map.put("constructionUnitNames", logVo.getConstructionUnitNames());
|
||||
map.put("constructionWorkerNames", logVo.getConstructionWorkerNames());
|
||||
map.put("supervisionUnitNames", logVo.getSupervisionUnitNames());
|
||||
map.put("supervisionPersonnelNames", logVo.getSupervisionPersonnelNames());
|
||||
map.put("type", logVo.getType());
|
||||
map.put("uploaderName", logVo.getUploaderName());
|
||||
map.put("id", logVo.getId());
|
||||
map.put("date", DateUtil.formatDate(logVo.getDate()));
|
||||
map.put("weatherJson", logVo.getWeatherJson());
|
||||
map.put("constructionAreaIds", logVo.getConstructionAreaIds());
|
||||
map.put("constructionWorkerIds", logVo.getConstructionWorkerIds());
|
||||
map.put("supervisionUnitIds", logVo.getSupervisionUnitIds());
|
||||
map.put("supervisionPersonnelIds", logVo.getSupervisionPersonnelIds());
|
||||
map.put("constructionTask", logVo.getConstructionTask());
|
||||
map.put("constructionMachinery", logVo.getConstructionMachinery());
|
||||
map.put("attendance", logVo.getAttendance());
|
||||
map.put("designChangeMaterial", logVo.getDesignChangeMaterial());
|
||||
map.put("safetyBriefingMaterial", logVo.getSafetyBriefingMaterial());
|
||||
map.put("technicalBriefingMaterial", logVo.getTechnicalBriefingMaterial());
|
||||
map.put("createTime", logVo.getCreateTime());
|
||||
map.put("updateTime", logVo.getUpdateTime());
|
||||
map.put("projectSn", logVo.getProjectSn());
|
||||
map.put("uploaderId", logVo.getUploaderId());
|
||||
String url = Fileutils.getExportTemplateFile("word/ocr施工日志导出模版.docx").getAbsolutePath();
|
||||
File wordFile = new File(wordDir, logVo.getConstructionAreaNames() + DateUtil.formatDate(logVo.getDate()) + ".docx");
|
||||
EasyPoiUtil.exportNewLineWord(map, url, wordFile);
|
||||
EasyPoiUtil.wordToPdfExport(wordFile, new File(dir, logVo.getConstructionAreaNames() + DateUtil.formatDate(logVo.getDate()) + ".pdf").getAbsolutePath());
|
||||
}
|
||||
FileUtil.del(wordDir);
|
||||
ZipUtil.zip(dir);
|
||||
response.setContentType("application/json");
|
||||
response.setHeader("Content-disposition", "attachment; filename=" +
|
||||
URLEncoder.encode(new File(dir + ".zip").getName(), "UTF-8"));
|
||||
InputStream fis = new FileInputStream(dir + ".zip");
|
||||
org.apache.poi.util.IOUtils.copy(fis, out);
|
||||
out.flush();
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
throw new OpenAlertException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,14 @@
|
||||
,su.real_name as uploader_name
|
||||
from ocr_build_log t
|
||||
left join system_user su on su.user_id=t.uploader_id
|
||||
where 1=1
|
||||
<if test="param.idList != null and param.idList.size() != 0">
|
||||
and t.id in
|
||||
<foreach item="item" index="index" collection="param.idList"
|
||||
open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
)t
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
@ -270,6 +270,7 @@ 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) {
|
||||
@ -306,6 +307,7 @@ 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>()
|
||||
@ -382,7 +384,7 @@ public class RiskListSourceController {
|
||||
QrConfig config = new QrConfig(qrSize, qrSize);
|
||||
config.setMargin(1); // 设置边距
|
||||
BufferedImage qrImage = QrCodeUtil.generate(
|
||||
regionV2Vo.getId() + "",
|
||||
httpPrefix + regionV2Vo.getId(),
|
||||
config
|
||||
);
|
||||
|
||||
|
||||
@ -446,4 +446,41 @@ public class WorkerDailyAttendanceStatisticsV2Controller {
|
||||
}
|
||||
}
|
||||
|
||||
@OperLog(operModul = "员工每日的考勤统计记录v2管理", operType = "", operDesc = "考勤总览")
|
||||
@ApiOperation(value = "考勤总览", notes = "考勤总览", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "enterpriseTypeId", value = "企业类型id", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "enterpriseId", value = "所属企业id", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "teamId", value = "班组ID", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "startMonth", value = "开始时间,格式2020-08(startMonth和endMonth或startDate和endDate至少传其中一组)", dataType = "String", paramType = "body", required = true),
|
||||
@ApiImplicitParam(name = "endMonth", value = "结束时间,格式2020-08", dataType = "String", paramType = "body", required = true),
|
||||
@ApiImplicitParam(name = "startDate", value = "开始时间,yyyy-MM-dd", paramType = "body", dataType = "String", required = true),
|
||||
@ApiImplicitParam(name = "endDate", value = "结束时间,yyyy-MM-dd", paramType = "body", dataType = "String", required = true),
|
||||
})
|
||||
@PostMapping(value = "/countWorkerDailyAttendanceStatisticsV2")
|
||||
public Result<CountWorkerDailyAttendanceStatisticsV2Vo> countWorkerDailyAttendanceStatisticsV2(@RequestBody Map<String, Object> param) {
|
||||
return Result.success(workerDailyAttendanceStatisticsV2Service.countWorkerDailyAttendanceStatisticsV2(param));
|
||||
}
|
||||
|
||||
@OperLog(operModul = "员工每日的考勤统计记录v2管理", operType = "", operDesc = "每月/日出勤/在职人数统计")
|
||||
@ApiOperation(value = "每月/日出勤/在职人数统计", notes = "每月/日出勤/在职人数统计", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "enterpriseTypeId", value = "企业类型id", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "enterpriseId", value = "所属企业id", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "teamId", value = "班组ID", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "departmentId", value = "部门ID", paramType = "body", required = false, dataType = "String"),
|
||||
@ApiImplicitParam(name = "startMonth", value = "开始时间,格式2020-08(startMonth和endMonth或startDate和endDate至少传其中一组)", dataType = "String", paramType = "body", required = true),
|
||||
@ApiImplicitParam(name = "endMonth", value = "结束时间,格式2020-08", dataType = "String", paramType = "body", required = true),
|
||||
@ApiImplicitParam(name = "startDate", value = "开始时间,yyyy-MM-dd", paramType = "body", dataType = "String", required = true),
|
||||
@ApiImplicitParam(name = "endDate", value = "结束时间,yyyy-MM-dd", paramType = "body", dataType = "String", required = true),
|
||||
})
|
||||
@PostMapping(value = "/countWorkerDailyAttendanceStatisticsV2ByDate")
|
||||
public Result<ChartDataVo> countWorkerDailyAttendanceStatisticsV2ByDate(@RequestBody Map<String, Object> param) {
|
||||
return Result.success(workerDailyAttendanceStatisticsV2Service.countWorkerDailyAttendanceStatisticsV2ByDate(param));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -39,4 +39,99 @@
|
||||
)t
|
||||
where t.id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="countWorkerDailyAttendanceStatisticsV2"
|
||||
resultType="com.zhgd.xmgl.modules.worker.entity.vo.CountWorkerDailyAttendanceStatisticsV2Vo">
|
||||
select
|
||||
t.*
|
||||
,ifnull(round(t.total_in_service_num/t.total_attendance_num*100,2),0) as attendance_rate_avg
|
||||
from (
|
||||
select
|
||||
count(*) as total_in_service_num
|
||||
,ifnull(sum(t.is_attendance),0) as total_attendance_num
|
||||
from worker_daily_attendance_statistics_v2 t
|
||||
JOIN worker_info a on t.person_sn=a.person_sn
|
||||
JOIN team_info b ON a.team_id = b.id and a.person_type = 1
|
||||
JOIN department_info c ON a.department_id = c.id and a.person_type = 2
|
||||
JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1
|
||||
JOIN enterprise_info en ON en.id = a.enterprise_id
|
||||
INNER JOIN project_enterprise pe ON a.id = pe.enterprise_id and pe.project_sn=t.project_sn
|
||||
where t.project_sn=#{projectSn}
|
||||
<if test="enterpriseTypeId != null and enterpriseTypeId != ''">
|
||||
and pe.enterprise_type_id = #{enterpriseTypeId}
|
||||
</if>
|
||||
<if test="enterpriseId != null and enterpriseId != ''">
|
||||
and b.enterprise_id = #{enterpriseId}
|
||||
</if>
|
||||
<if test="teamId != null and teamId != ''">
|
||||
and a.team_id=#{teamId}
|
||||
</if>
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
and a.department_id=#{departmentId}
|
||||
</if>
|
||||
<if test="startMonth != null and startMonth != ''">
|
||||
and t.attendance_date <![CDATA[>=]]> concat(#{startMonth},'-01 00:00:00')
|
||||
</if>
|
||||
<if test="endMonth != null and endMonth != ''">
|
||||
and t.attendance_date <![CDATA[<=]]> concat(#{endMonth},'-31 23:59:59')
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and t.attendance_date >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and t.attendance_date <![CDATA[<=]]> concat(#{endDate},' 23:59:59')
|
||||
</if>
|
||||
)t
|
||||
</select>
|
||||
|
||||
<select id="countWorkerDailyAttendanceStatisticsV2ByDate"
|
||||
resultType="com.zhgd.xmgl.modules.worker.entity.bo.CountWorkerDailyAttendanceStatisticsV2ByDateBo">
|
||||
select
|
||||
t.*
|
||||
,ifnull(round(t.total_in_service_num/t.total_attendance_num*100,2),0) as attendance_rate_avg
|
||||
from (
|
||||
select
|
||||
<if test="startMonth != null and startMonth != ''">
|
||||
date_format(t.attendance_date, '%Y-%m') as x_name
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
date_format(t.attendance_date, '%Y-%m-%d') as x_name
|
||||
</if>
|
||||
,count(*) as total_in_service_num
|
||||
,ifnull(sum(t.is_attendance),0) as total_attendance_num
|
||||
from worker_daily_attendance_statistics_v2 t
|
||||
JOIN worker_info a on t.person_sn=a.person_sn
|
||||
JOIN team_info b ON a.team_id = b.id and a.person_type = 1
|
||||
JOIN department_info c ON a.department_id = c.id and a.person_type = 2
|
||||
JOIN worker_type wt ON b.worker_type_id = wt.id and a.person_type = 1
|
||||
JOIN enterprise_info en ON en.id = a.enterprise_id
|
||||
INNER JOIN project_enterprise pe ON a.id = pe.enterprise_id and pe.project_sn=t.project_sn
|
||||
where t.project_sn=#{projectSn}
|
||||
<if test="enterpriseTypeId != null and enterpriseTypeId != ''">
|
||||
and pe.enterprise_type_id = #{enterpriseTypeId}
|
||||
</if>
|
||||
<if test="enterpriseId != null and enterpriseId != ''">
|
||||
and b.enterprise_id = #{enterpriseId}
|
||||
</if>
|
||||
<if test="teamId != null and teamId != ''">
|
||||
and a.team_id=#{teamId}
|
||||
</if>
|
||||
<if test="departmentId != null and departmentId != ''">
|
||||
and a.department_id=#{departmentId}
|
||||
</if>
|
||||
<if test="startMonth != null and startMonth != ''">
|
||||
and t.attendance_date <![CDATA[>=]]> concat(#{startMonth},'-01 00:00:00')
|
||||
</if>
|
||||
<if test="endMonth != null and endMonth != ''">
|
||||
and t.attendance_date <![CDATA[<=]]> concat(#{endMonth},'-31 23:59:59')
|
||||
</if>
|
||||
<if test="startDate != null and startDate != ''">
|
||||
and t.attendance_date >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and t.attendance_date <![CDATA[<=]]> concat(#{endDate},' 23:59:59')
|
||||
</if>
|
||||
group by x_name
|
||||
)t
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -171,7 +171,7 @@ public class XzSecurityDangerFieldController {
|
||||
String sn = MapUtils.getString(param, "sn");
|
||||
List<XzSecurityDangerFieldConfigVo> configVos = xzSecurityDangerFieldConfigService.queryList(param);
|
||||
List<XzSecurityDangerFieldVo> list = xzSecurityDangerFieldService.queryList(param);
|
||||
if (Objects.equals(companyProjectType, 2) && (CollUtil.isEmpty(list) || Objects.equals(CollUtil.getFirst(configVos).getEnableProject(), 0))) {
|
||||
if (Objects.equals(companyProjectType, 2) && CollUtil.isEmpty(list)) {
|
||||
//项目不存在,查询企业配置
|
||||
list = getCompanyConfig(param, sn);
|
||||
for (XzSecurityDangerFieldVo fieldVo : list) {
|
||||
|
||||
@ -63,16 +63,6 @@ public class XzSecurityDangerReviewVerify implements Serializable {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 复查配置项目端是否开启,1开启,0不开启
|
||||
*/
|
||||
@ApiModelProperty(value = "复查配置项目端是否开启,1开启,0不开启")
|
||||
private java.lang.Integer enableProjectForReview;
|
||||
/**
|
||||
* 核验配置项目端是否开启,1开启,0不开启
|
||||
*/
|
||||
@ApiModelProperty(value = "核验配置项目端是否开启,1开启,0不开启")
|
||||
private java.lang.Integer enableProjectForVerify;
|
||||
@ApiModelProperty("1开启复查0不开启复查")
|
||||
private Integer enableReview;
|
||||
@ApiModelProperty("1开启核验0不开启核验")
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
package com.zhgd.xmgl.modules.xz.security.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.base.Objects;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.system.query.QueryGenerator;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerField;
|
||||
@ -14,11 +18,13 @@ import com.zhgd.xmgl.modules.xz.security.mapper.XzSecurityDangerFieldMapper;
|
||||
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityDangerFieldService;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 安全隐患检查字段设置
|
||||
@ -36,14 +42,14 @@ public class XzSecurityDangerFieldServiceImpl extends ServiceImpl<XzSecurityDang
|
||||
QueryWrapper<XzSecurityDangerFieldVo> queryWrapper = this.getQueryWrapper(param);
|
||||
Page<XzSecurityDangerFieldVo> page = PageUtil.getPage(param);
|
||||
IPage<XzSecurityDangerFieldVo> pageList = baseMapper.queryList(page, queryWrapper, param);
|
||||
pageList.setRecords(this.dealList(pageList.getRecords()));
|
||||
pageList.setRecords(this.dealList(pageList.getRecords(), param));
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<XzSecurityDangerFieldVo> queryList(HashMap<String, Object> param) {
|
||||
QueryWrapper<XzSecurityDangerFieldVo> queryWrapper = getQueryWrapper(param);
|
||||
return dealList(baseMapper.queryList(queryWrapper, param));
|
||||
return dealList(baseMapper.queryList(queryWrapper, param), param);
|
||||
}
|
||||
|
||||
private QueryWrapper<XzSecurityDangerFieldVo> getQueryWrapper(HashMap<String, Object> param) {
|
||||
@ -52,7 +58,19 @@ public class XzSecurityDangerFieldServiceImpl extends ServiceImpl<XzSecurityDang
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
private List<XzSecurityDangerFieldVo> dealList(List<XzSecurityDangerFieldVo> list) {
|
||||
private List<XzSecurityDangerFieldVo> dealList(List<XzSecurityDangerFieldVo> list, HashMap<String, Object> param) {
|
||||
Integer recordType = MapUtils.getInteger(param, "recordType");
|
||||
Integer companyProjectType = MapUtils.getInteger(param, "companyProjectType");
|
||||
String sn = MapUtils.getString(param, "sn");
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
//空就初始化值
|
||||
List<XzSecurityDangerFieldVo> fieldVos = JSON.parseArray(ResourceUtil.readUtf8Str("init/data/xzSecurityDangerField.json"), XzSecurityDangerFieldVo.class);
|
||||
list = fieldVos.stream().filter(vo -> Objects.equal(vo.getRecordType(), recordType)).collect(Collectors.toList());
|
||||
for (XzSecurityDangerFieldVo vo : list) {
|
||||
vo.setSn(sn);
|
||||
vo.setCompanyProjectType(companyProjectType);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@ -130,27 +130,9 @@ public class XzSecurityDangerReviewVerifyServiceImpl extends ServiceImpl<XzSecur
|
||||
Integer companyProjectType = MapUtils.getInteger(param, "companyProjectType");
|
||||
String sn = MapUtils.getString(param, "sn");
|
||||
List<XzSecurityDangerReviewVerifyVo> list = this.queryList(param);
|
||||
if (Objects.equals(companyProjectType, 2)) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
//项目没数据
|
||||
list = getCompanyConfig(param, sn);
|
||||
} else {
|
||||
XzSecurityDangerReviewVerifyVo vo = CollUtil.getFirst(list);
|
||||
if (Objects.equals(vo.getEnableProjectForReview(), 0) || Objects.equals(vo.getEnableProjectForVerify(), 0)) {
|
||||
List<XzSecurityDangerReviewVerifyVo> companyConfigs = getCompanyConfig(param, sn);
|
||||
if (CollUtil.isNotEmpty(companyConfigs)) {
|
||||
XzSecurityDangerReviewVerifyVo verifyVo = companyConfigs.get(0);
|
||||
if (Objects.equals(vo.getEnableProjectForReview(), 0)) {
|
||||
vo.setReviewRoleName(verifyVo.getReviewRoleName());
|
||||
vo.setEnableReview(verifyVo.getEnableReview());
|
||||
}
|
||||
if (Objects.equals(vo.getEnableProjectForReview(), 0)) {
|
||||
vo.setVerifyRoleName(verifyVo.getVerifyRoleName());
|
||||
vo.setEnableVerify(verifyVo.getEnableVerify());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Objects.equals(companyProjectType, 2) && CollUtil.isEmpty(list)) {
|
||||
//项目没数据
|
||||
list = getCompanyConfig(param, sn);
|
||||
}
|
||||
XzSecurityDangerReviewVerifyVo vo = CollUtil.getFirst(list);
|
||||
if (Objects.isNull(vo)) {
|
||||
@ -158,8 +140,6 @@ public class XzSecurityDangerReviewVerifyServiceImpl extends ServiceImpl<XzSecur
|
||||
vo = new XzSecurityDangerReviewVerifyVo();
|
||||
vo.setReviewRoleName(null);
|
||||
vo.setVerifyRoleName(null);
|
||||
vo.setEnableProjectForReview(0);
|
||||
vo.setEnableProjectForVerify(0);
|
||||
vo.setEnableReview(1);
|
||||
vo.setEnableVerify(1);
|
||||
}
|
||||
|
||||
330
src/main/java/com/zhgd/xmgl/util/EasyPoiUtil.java
Normal file
330
src/main/java/com/zhgd/xmgl/util/EasyPoiUtil.java
Normal file
@ -0,0 +1,330 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.afterturn.easypoi.entity.ImageEntity;
|
||||
import cn.afterturn.easypoi.word.WordExportUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.documents4j.api.DocumentType;
|
||||
import com.documents4j.api.IConverter;
|
||||
import com.documents4j.job.LocalConverter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class EasyPoiUtil {
|
||||
|
||||
/**
|
||||
* 导出word
|
||||
*
|
||||
* @param response
|
||||
* @param params
|
||||
* @param file
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void exportNewLineWord(HttpServletResponse response, Map<String, Object> params, File file) {
|
||||
try {
|
||||
XWPFDocument doc = WordExportUtil.exportWord07(URLDecoder.decode(file.getPath(), "UTF-8"), params);
|
||||
WordUtils.addBreakInCell(doc.getParagraphs());
|
||||
//设置响应体内容类型
|
||||
response.setContentType("application/octet-stream");
|
||||
//添加响应头
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("下载试卷.docx", "UTF-8"));
|
||||
//暴露新添加的响应头
|
||||
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
//将word文档流输出到输出流中
|
||||
doc.write(response.getOutputStream());
|
||||
//关闭流
|
||||
doc.close();
|
||||
} catch (Exception e) {
|
||||
log.error("exportNewLineWord:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模板导出word
|
||||
*
|
||||
* @param map 数据
|
||||
* @param tempUrl 模板地址
|
||||
* @param outputFile 临时模板文件
|
||||
*/
|
||||
public static void exportWord(Map<String, Object> map, String tempUrl, File outputFile) {
|
||||
try {
|
||||
XWPFDocument doc = WordExportUtil.exportWord07(tempUrl, map);
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
doc.write(fos);
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
log.error("exportWord:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模板导出word会换行的
|
||||
*
|
||||
* @param map 参数map
|
||||
* @param tempUrl 模板url
|
||||
* @param outputFile 导出位置
|
||||
*/
|
||||
public static void exportNewLineWord(Map<String, Object> map, String tempUrl, File outputFile) {
|
||||
try {
|
||||
XWPFDocument doc = WordExportUtil.exportWord07(tempUrl, map);
|
||||
//文本换行
|
||||
WordUtils.addBreakInCell(doc.getParagraphs());
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
doc.write(fos);
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
log.error("exportNewLineWord:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* word转pdf导出
|
||||
*
|
||||
* @param response
|
||||
* @param wordFile word文档文件
|
||||
*/
|
||||
public static void wordToPdfExport(HttpServletResponse response, File wordFile) {
|
||||
response.setContentType("application/pdf");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=name.pdf");
|
||||
// 获取当前系统名称
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
// 根据系统选择执行方法
|
||||
if (osName.contains("win")) {
|
||||
try (InputStream docxInputStream = new FileInputStream(wordFile);
|
||||
OutputStream pdfOutputStream = response.getOutputStream()
|
||||
// OutputStream pdfOutputStream = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\管道焊接记录.pdf")
|
||||
) {
|
||||
|
||||
IConverter converter = LocalConverter.builder().build();
|
||||
converter
|
||||
.convert(docxInputStream)
|
||||
.as(DocumentType.DOCX)
|
||||
.to(pdfOutputStream)
|
||||
.as(DocumentType.PDF)
|
||||
.execute();
|
||||
|
||||
// 通常不需要在这里调用 flush(),因为 execute()方法可能已经完成了它,但如果遇到特定问题,可以尝试调用它
|
||||
// pdfOutputStream.flush();
|
||||
|
||||
} catch (Exception e) {
|
||||
// 设置适当的 HTTP 状态码和错误消息
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
// 可以在这里记录错误或向客户端发送错误消息(但注意,响应流可能已关闭)
|
||||
log.error("", e);
|
||||
} finally {
|
||||
// 清理临时文件
|
||||
if (!wordFile.delete()) {
|
||||
wordFile.deleteOnExit();
|
||||
}
|
||||
}
|
||||
} else if (osName.contains("nux") || osName.contains("nix")) {
|
||||
File pdfFile = new File(wordFile.getParent(), StringUtils.substringBeforeLast(wordFile.getName(), ".") + ".pdf");
|
||||
log.info("linux环境开始导出pdf,源文件:{},目标文件:{}", wordFile.getAbsolutePath(), pdfFile.getAbsolutePath());
|
||||
linuxWordToPdf(pdfFile, wordFile);
|
||||
try {
|
||||
FileUtil.writeToStream(pdfFile, response.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
log.error("word导出pdf出错");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* word转pdf导出
|
||||
*
|
||||
* @param wordFile word文档文件
|
||||
*/
|
||||
public static void wordToPdfExport(File wordFile) {
|
||||
wordToPdfExport(wordFile, StrUtil.subBefore(wordFile.getAbsolutePath(), ".", true) + ".pdf");
|
||||
}
|
||||
|
||||
/**
|
||||
* word转pdf导出
|
||||
*
|
||||
* @param wordFile word文档文件
|
||||
* @param outputFilePath
|
||||
*/
|
||||
public static void wordToPdfExport(File wordFile, String outputFilePath) {
|
||||
// 获取当前系统名称
|
||||
String osName = System.getProperty("os.name").toLowerCase();
|
||||
// 根据系统选择执行方法
|
||||
if (osName.contains("win")) {
|
||||
try (InputStream docxInputStream = new FileInputStream(wordFile);
|
||||
OutputStream pdfOutputStream = new FileOutputStream(outputFilePath)
|
||||
// OutputStream pdfOutputStream = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\管道焊接记录.pdf")
|
||||
) {
|
||||
|
||||
IConverter converter = LocalConverter.builder().build();
|
||||
converter
|
||||
.convert(docxInputStream)
|
||||
.as(DocumentType.DOCX)
|
||||
.to(pdfOutputStream)
|
||||
.as(DocumentType.PDF)
|
||||
.execute();
|
||||
|
||||
// 通常不需要在这里调用 flush(),因为 execute()方法可能已经完成了它,但如果遇到特定问题,可以尝试调用它
|
||||
// pdfOutputStream.flush();
|
||||
|
||||
} catch (Exception e) {
|
||||
// 可以在这里记录错误或向客户端发送错误消息(但注意,响应流可能已关闭)
|
||||
log.error("", e);
|
||||
} finally {
|
||||
// 清理临时文件
|
||||
if (!wordFile.delete()) {
|
||||
wordFile.deleteOnExit();
|
||||
}
|
||||
}
|
||||
} else if (osName.contains("nux") || osName.contains("nix")) {
|
||||
try {
|
||||
File pdfFile = new File(wordFile.getParent(), StringUtils.substringBeforeLast(wordFile.getName(), ".") + ".pdf");
|
||||
log.info("linux环境开始导出pdf,源文件:{},目标文件:{}", wordFile.getAbsolutePath(), pdfFile.getAbsolutePath());
|
||||
linuxWordToPdf(pdfFile, wordFile);
|
||||
} catch (Exception e) {
|
||||
log.error("word导出pdf出错");
|
||||
} finally {
|
||||
// 清理临时文件
|
||||
if (!wordFile.delete()) {
|
||||
wordFile.deleteOnExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* linux系统word转pdf
|
||||
* * 使用LibreOffice转换。系统需安装LibreOffice
|
||||
* * 转换命令 libreoffice --invisible --convert-to pdf --outdir output_dir source_path
|
||||
* * 转换后的pdf文件名使用的是源文件的名称,所以如果要指定输出文件名称,就需把源文件名称改成想要输出的名称
|
||||
*
|
||||
* @param pdfFile 转换后的pdf文件
|
||||
* @param wordFile word源文件
|
||||
*/
|
||||
private static void linuxWordToPdf(File pdfFile, File wordFile) {
|
||||
// 获取word文件的绝对路径
|
||||
String sourcePath = wordFile.getAbsolutePath();
|
||||
// 获取pdf文件存放文件夹的绝对路径
|
||||
String outDir = pdfFile.getAbsolutePath().substring(0, pdfFile.getAbsolutePath().lastIndexOf(File.separator));
|
||||
|
||||
// 构建LibreOffice的命令行工具命令
|
||||
List<String> cmd = new ArrayList<>();
|
||||
cmd.add("libreoffice");
|
||||
cmd.add("--invisible");
|
||||
cmd.add("--convert-to");
|
||||
cmd.add("pdf");
|
||||
cmd.add("--outdir");
|
||||
cmd.add(outDir);
|
||||
cmd.add(sourcePath);
|
||||
log.info(cmd.toString());
|
||||
// 执行转换命令
|
||||
try {
|
||||
executeLinuxCmd(cmd);
|
||||
} catch (Exception e) {
|
||||
log.error("linuxWordToPdf linux环境word转换为pdf时出现异常:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令行
|
||||
*
|
||||
* @param cmd 命令行
|
||||
* @return
|
||||
*/
|
||||
// private static boolean executeLinuxCmd(List<String> cmd) {
|
||||
// try {
|
||||
// Process process = Runtime.getRuntime().exec(cmd.toArray(new String[cmd.size()]));
|
||||
// process.waitFor();
|
||||
// InputStream in = process.getInputStream();
|
||||
// BufferedReader read = new BufferedReader(new InputStreamReader(in));
|
||||
// String result = read.readLine();
|
||||
// log.info("executeLinuxCmd 执行Linux命令INFO:" + result);
|
||||
// } catch (InterruptedException e) {
|
||||
// log.error("executeLinuxCmd 执行Linux命令异常:", e);
|
||||
// Thread.currentThread().interrupt();
|
||||
// return false;
|
||||
// } catch (IOException e) {
|
||||
// log.error("获取系统命令执行环境异常", e);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
private static boolean executeLinuxCmd(List<String> cmd) {
|
||||
try {
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
|
||||
// 合并标准输出和错误输出
|
||||
processBuilder.redirectErrorStream(true);
|
||||
Process process = processBuilder.start();
|
||||
|
||||
// 读取命令输出
|
||||
InputStream in = process.getInputStream();
|
||||
BufferedReader read = new BufferedReader(new InputStreamReader(in));
|
||||
String line;
|
||||
while ((line = read.readLine()) != null) {
|
||||
log.info("executeLinuxCmd 执行Linux命令INFO: " + line);
|
||||
}
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
if (exitCode != 0) {
|
||||
log.error("executeLinuxCmd 命令执行失败,退出码: " + exitCode);
|
||||
return false;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error("executeLinuxCmd 执行Linux命令异常:", e);
|
||||
Thread.currentThread().interrupt();
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
log.error("获取系统命令执行环境异常", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片格式化,Word导出图片格式
|
||||
*
|
||||
* @param imgPath 图片路径
|
||||
*/
|
||||
public static ImageEntity imgFormatting(String imgPath, int width, int height) {
|
||||
//设置图片
|
||||
ImageEntity image = new ImageEntity(imgPath, width, height);
|
||||
//表格外添加简单图片
|
||||
image.setType(ImageEntity.URL);
|
||||
image.setRowspan(ImageEntity.EMBED);
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* excel转pdf
|
||||
*
|
||||
* @param excelPath
|
||||
* @return
|
||||
*/
|
||||
public static void excelToPdf(String excelPath) {
|
||||
File inputWord = new File(excelPath);
|
||||
try (InputStream docxInputStream = new FileInputStream(inputWord);
|
||||
OutputStream outputStream = new FileOutputStream(StrUtil.subBefore(excelPath, ".", true) + ".pdf")) {
|
||||
IConverter converter = LocalConverter.builder().build();
|
||||
String fileTyle = excelPath.substring(excelPath.lastIndexOf("."), excelPath.length());//获取文件类型
|
||||
if (".xls".equals(fileTyle)) {
|
||||
converter.convert(docxInputStream).as(DocumentType.XLS).to(outputStream).as(DocumentType.PDF).execute();
|
||||
} else if (".xlsx".equals(fileTyle)) {
|
||||
converter.convert(docxInputStream).as(DocumentType.XLSX).to(outputStream).as(DocumentType.PDF).execute();
|
||||
}
|
||||
docxInputStream.close();
|
||||
outputStream.close();
|
||||
inputWord.delete();
|
||||
System.out.println("pdf转换成功");
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
157
src/main/java/com/zhgd/xmgl/util/WordUtils.java
Normal file
157
src/main/java/com/zhgd/xmgl/util/WordUtils.java
Normal file
@ -0,0 +1,157 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import cn.afterturn.easypoi.word.WordExportUtil;
|
||||
import cn.afterturn.easypoi.word.parse.ParseWord07;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryEntry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WordUtils {
|
||||
|
||||
/**
|
||||
* word下载
|
||||
*
|
||||
* @param fileName 下载时的文件名称
|
||||
* @param response
|
||||
* @param doc
|
||||
*/
|
||||
private static void downLoadWord(String fileName, HttpServletResponse response, XWPFDocument doc) throws IOException {
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("content-Type", "application/msword");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".docx", "UTF-8"));
|
||||
doc.write(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* word下载
|
||||
*
|
||||
* @param fileName 下载时的文件名称
|
||||
* @param response
|
||||
*/
|
||||
private static void downLoadWord(String fileName, HttpServletResponse response, POIFSFileSystem poifsFileSystem) throws IOException {
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("content-Type", "application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".docx", "UTF-8"));
|
||||
poifsFileSystem.writeFilesystem(response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* html转word
|
||||
*
|
||||
* @param response
|
||||
* @param html
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void html2Word(HttpServletResponse response, String html) throws IOException {
|
||||
// String html = FileUtil.readString("C:\\Users\\Administrator\\Desktop\\t\\文档.html", StandardCharsets.UTF_8 );
|
||||
byte by[] = html.getBytes("UTF-8");
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(by);
|
||||
POIFSFileSystem poifsFileSystem = new POIFSFileSystem();
|
||||
DirectoryEntry directoryEntry = poifsFileSystem.getRoot();
|
||||
directoryEntry.createDocument("WordDocument", byteArrayInputStream);
|
||||
WordUtils.downLoadWord("导出word", response, poifsFileSystem);
|
||||
}
|
||||
|
||||
/**
|
||||
* word模板导出
|
||||
*
|
||||
* @param map
|
||||
* @param templatePath
|
||||
* @param fileName
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void WordTemplateExport(Map<String, Object> map, String templatePath, String fileName, HttpServletResponse response) throws Exception {
|
||||
XWPFDocument doc = WordExportUtil.exportWord07(templatePath, map);
|
||||
downLoadWord(fileName, response, doc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* word模板导出多页
|
||||
*
|
||||
* @param list
|
||||
* @param templatePath
|
||||
* @param fileName
|
||||
* @param response
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void WordTemplateExportMorePage(List<Map<String, Object>> list, String templatePath, String fileName, HttpServletResponse response) throws Exception {
|
||||
XWPFDocument doc = new ParseWord07().parseWord(templatePath, list);
|
||||
downLoadWord(fileName, response, doc);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本换行
|
||||
*/
|
||||
public static void addBreakInCell(List<XWPFParagraph> paragraphs) {
|
||||
for (XWPFParagraph p : paragraphs) {
|
||||
for (XWPFRun run : p.getRuns()) {//XWPFRun对象定义具有一组公共属性的文本区域
|
||||
if (run.getText(0) != null && run.getText(0).contains("\n")) {
|
||||
String[] lines = run.getText(0).split("\n");
|
||||
if (lines.length > 0) {
|
||||
run.setText(lines[0], 0); // set first line into XWPFRun
|
||||
for (int i = 1; i < lines.length; i++) {
|
||||
// add break and insert new text
|
||||
run.addBreak();//中断
|
||||
// run.addCarriageReturn();//回车符,但是不起作用
|
||||
run.setText(lines[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本换行
|
||||
*/
|
||||
public static void addBreakInCellForExam(List<XWPFParagraph> paragraphs) {
|
||||
for (XWPFParagraph p : paragraphs) {
|
||||
List<XWPFRun> runs = p.getRuns();
|
||||
if (runs.size() > 0) {
|
||||
XWPFRun run = runs.get(0);
|
||||
String text = run.getText(0); // 获取完整文本
|
||||
if (text != null && text.contains("\n")) {
|
||||
String[] lines = text.split("\n");
|
||||
if (lines.length > 0) {
|
||||
// 设置第一行文本
|
||||
run.setText(lines[0], 0);
|
||||
run.addBreak(); // 添加换行符
|
||||
// 为剩余行创建新的 XWPFRun
|
||||
for (int j = 1; j < lines.length; j++) {
|
||||
XWPFRun newRun = p.insertNewRun(j); // 插入新的 XWPFRun
|
||||
newRun.setText(lines[j]); // 设置新行的文本
|
||||
// 复制原始 XWPFRun 的样式到新的 XWPFRun
|
||||
newRun.setBold(run.isBold());
|
||||
newRun.setItalic(run.isItalic());
|
||||
newRun.setFontSize(10);
|
||||
newRun.setFontFamily("宋体");
|
||||
if (j != lines.length - 1) {
|
||||
newRun.addBreak();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
379
src/main/resources/init/data/xzSecurityDangerField.json
Normal file
379
src/main/resources/init/data/xzSecurityDangerField.json
Normal file
@ -0,0 +1,379 @@
|
||||
[
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "fileUrl",
|
||||
"originalFieldName": "上传附件",
|
||||
"displayFieldName": "上传附件",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 0,
|
||||
"sort": 7
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "imageUrl",
|
||||
"originalFieldName": "上传图片",
|
||||
"displayFieldName": "上传图片",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 6
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "enterpriseIds",
|
||||
"originalFieldName": "分包单位",
|
||||
"displayFieldName": "分包单位",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 5
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "inspectTime",
|
||||
"originalFieldName": "检查时间",
|
||||
"displayFieldName": "检查时间",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 4
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "dangerDesc",
|
||||
"originalFieldName": "补充说明",
|
||||
"displayFieldName": "补充说明",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 3
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "addedDescription",
|
||||
"originalFieldName": "事件描述",
|
||||
"displayFieldName": "事件描述",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 2
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "dangerItemId",
|
||||
"originalFieldName": "排查分类",
|
||||
"displayFieldName": "排查分类",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 1
|
||||
},
|
||||
{
|
||||
"recordType": 2,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "regionIds",
|
||||
"originalFieldName": "检查部位",
|
||||
"displayFieldName": "责任区域",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 0
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "dutyMajor",
|
||||
"originalFieldName": "责任专业",
|
||||
"displayFieldName": "责任专业",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 0,
|
||||
"isPinned": 0,
|
||||
"sort": 20
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "rectifyAfterImage",
|
||||
"originalFieldName": "整改后图片",
|
||||
"displayFieldName": "整改后图片",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 19
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "status",
|
||||
"originalFieldName": "现场整改",
|
||||
"displayFieldName": "现场整改",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 18
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "fileUrl",
|
||||
"originalFieldName": "上传附件",
|
||||
"displayFieldName": "上传附件",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 0,
|
||||
"sort": 17
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "imageUrl",
|
||||
"originalFieldName": "隐患图片",
|
||||
"displayFieldName": "隐患图片",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 16
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "verifyManIds",
|
||||
"originalFieldName": "核验人",
|
||||
"displayFieldName": "核验人",
|
||||
"defaultDataType": 1,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 15
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "reviewIds",
|
||||
"originalFieldName": "复查人",
|
||||
"displayFieldName": "复查人",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 14
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "changeId",
|
||||
"originalFieldName": "整改人",
|
||||
"displayFieldName": "整改人",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 13
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "changeLimitTime",
|
||||
"originalFieldName": "整改时限",
|
||||
"displayFieldName": "整改时限",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 12
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "enterpriseIds",
|
||||
"originalFieldName": "分包单位",
|
||||
"displayFieldName": "分包单位",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 11
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "inspectTime",
|
||||
"originalFieldName": "检查时间",
|
||||
"displayFieldName": "检查时间",
|
||||
"defaultDataType": 1,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 10
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "urgentLevel",
|
||||
"originalFieldName": "紧急程度",
|
||||
"displayFieldName": "紧急程度",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 0,
|
||||
"sort": 9
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "priorityNameDic",
|
||||
"originalFieldName": "问题等级二",
|
||||
"displayFieldName": "问题等级二",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 0,
|
||||
"isPinned": 0,
|
||||
"sort": 8
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "level",
|
||||
"originalFieldName": "问题等级",
|
||||
"displayFieldName": "问题等级",
|
||||
"defaultDataType": 1,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 7
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "addedDescription",
|
||||
"originalFieldName": "事件描述",
|
||||
"displayFieldName": "事件描述",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 0,
|
||||
"sort": 6
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "remark",
|
||||
"originalFieldName": "整改要求",
|
||||
"displayFieldName": "整改要求",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 0,
|
||||
"sort": 5
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "dangerDesc",
|
||||
"originalFieldName": "补充说明",
|
||||
"displayFieldName": "补充说明",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 0,
|
||||
"sort": 4
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "dangerItemId",
|
||||
"originalFieldName": "问题分类",
|
||||
"displayFieldName": "问题分类",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 3
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "dangerItemId",
|
||||
"originalFieldName": "问题描述",
|
||||
"displayFieldName": "问题描述",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 2
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "detailPlace",
|
||||
"originalFieldName": "详细部位",
|
||||
"displayFieldName": "详细部位",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 0,
|
||||
"isEnabled": 0,
|
||||
"isPinned": 0,
|
||||
"sort": 1
|
||||
},
|
||||
{
|
||||
"recordType": 1,
|
||||
"sn": "2e07f0e2569c43fb835ae2082d1d314f",
|
||||
"companyProjectType": 1,
|
||||
"fieldName": "regionIds",
|
||||
"originalFieldName": "责任区域",
|
||||
"displayFieldName": "责任区域",
|
||||
"defaultDataType": null,
|
||||
"isRequired": 1,
|
||||
"isEnabled": 1,
|
||||
"isPinned": 1,
|
||||
"sort": 0
|
||||
}
|
||||
]
|
||||
28
src/main/resources/word/ocr施工日志导出模版.docx
Normal file
28
src/main/resources/word/ocr施工日志导出模版.docx
Normal file
@ -0,0 +1,28 @@
|
||||
施工日志
|
||||
|
||||
日期:
|
||||
{{date}}
|
||||
风力:
|
||||
{{win_speed}}
|
||||
气温:
|
||||
{{tem_day}}
|
||||
天气:
|
||||
{{wea}}
|
||||
施工区域:
|
||||
{{constructionAreaNames}}
|
||||
施工单位:
|
||||
{{constructionUnitNames}}
|
||||
施工员:
|
||||
{{constructionWorkerNames}}
|
||||
监理单位:
|
||||
{{supervisionUnitNames}}
|
||||
监理人员:
|
||||
{{supervisionPersonnelNames}}
|
||||
施工任务:
|
||||
{{constructionTask}}
|
||||
施工机械:
|
||||
{{constructionMachinery}}
|
||||
出勤情况:
|
||||
{{attendance}}
|
||||
施工员签名:
|
||||
备注:1.施工员根据当日实施的施工任务、施工机械、出勤情况,如实填写《施工日志》;2.《施工日志》每周定期交项目部资料员归档。
|
||||
28
src/main/resources/word/ocr施工日志模版.docx
Normal file
28
src/main/resources/word/ocr施工日志模版.docx
Normal file
@ -0,0 +1,28 @@
|
||||
施工日志
|
||||
|
||||
日期:
|
||||
|
||||
风力:
|
||||
|
||||
气温:
|
||||
|
||||
天气:
|
||||
|
||||
施工区域:
|
||||
|
||||
施工单位:
|
||||
|
||||
施工员:
|
||||
|
||||
监理单位:
|
||||
|
||||
监理人员:
|
||||
|
||||
施工任务:
|
||||
|
||||
施工机械:
|
||||
|
||||
出勤情况:
|
||||
|
||||
施工员签名:
|
||||
备注:1.施工员根据当日实施的施工任务、施工机械、出勤情况,如实填写《施工日志》;2.《施工日志》每周定期交项目部资料员归档。
|
||||
Loading…
x
Reference in New Issue
Block a user