diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java index 17e5119..0235e18 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java @@ -9,6 +9,8 @@ import lombok.EqualsAndHashCode; import org.springblade.core.mp.base.BaseEntity; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.util.Date; @@ -58,6 +60,12 @@ public class TestEntity extends BaseEntity { @ApiModelProperty("考试结束时间") private Date testEndTime; +// @NotNull +// @Min(value = 0, message = "及格分必须大于等于0") +// @Max(value = 100, message = "及格分必须小于等于100") +// @ApiModelProperty("及格分") +// private Integer passingScore; + @NotNull @Size(max = 255, message = "考试地点字段长度不能超过255") @ApiModelProperty("考试地点") @@ -77,7 +85,6 @@ public class TestEntity extends BaseEntity { @ApiModelProperty("参考人员") private String peopleName; - @Size(max = 1000, message = "考试图片字段长度不能超过1000") @ApiModelProperty("考试图片") private String imgPath; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java new file mode 100644 index 0000000..abb312d --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailImgVO.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.safeproduct.vo; + +import cn.afterturn.easypoi.entity.ImageEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "演练记录表VO类") +public class RehearsalRecordDetailImgVO extends RehearsalRecordDetailVO{ + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java new file mode 100644 index 0000000..2a7c8bf --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailStrVO.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +@ApiModel(value = "演练记录表VO类") +public class RehearsalRecordDetailStrVO extends RehearsalRecordDetailVO{ + + @ApiModelProperty("图片列表") + private List images; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java index e1d414f..545065f 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/RehearsalRecordDetailVO.java @@ -55,9 +55,6 @@ public class RehearsalRecordDetailVO { @ApiModelProperty("演练科目") private String subject; - @ApiModelProperty("图片列表") - private List images; - @ApiModelProperty("年份") private String year; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java index 518ebb5..7d89726 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreSumVO.java @@ -13,12 +13,14 @@ import lombok.Data; public class TestScoreSumVO { @ApiModelProperty("应考人数") - private Integer peopleNum=0; + private Integer peopleNum = 0; @ApiModelProperty("实考人数") - private Integer actualPeopleNum=0; + private Integer actualPeopleNum = 0; @ApiModelProperty("及格率") - private Double percentage=0.0; + private Double percentage = 0.0; + @ApiModelProperty("及格分") + private Integer passingScore; } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java index 15564c3..3bdfb4a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/service/impl/AlarmSaveServiceImpl.java @@ -6,6 +6,7 @@ import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.service.AlarmConfigService; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.config.vo.AlarmHandleMarkVo; import com.hnac.hzims.message.entity.MessagePushRecordEntity; @@ -21,6 +22,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -35,6 +37,8 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { private final AlarmService alarmService; + private final AlarmHandleService handleService; + private final AlarmConfigService alarmConfigService; private final IStationClient stationClient; @@ -49,41 +53,55 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { @Override public Boolean save(List alarms) { // 步骤1.查询告警数据对应站点 - R> result = stationClient.querySatationByCodes(alarms.stream().map(AlarmEntity::getStationId).collect(Collectors.toList())); - if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + R> stations = stationClient.querySatationByCodes(alarms.stream().map(AlarmEntity::getStationId).collect(Collectors.toList())); + if(!stations.isSuccess() || CollectionUtil.isEmpty(stations.getData())){ log.error("alarm_query_station_is_null : {}",alarms.stream().map(AlarmEntity::getAlarmId).collect(Collectors.toList())); return false; } + // 步骤2.查询当天处理的告警 + List handlers = handleService.sameDayContent(); + // 步骤3.查询延后未完成的告警 + List delays = handleService.incompleteContent(); + // 步骤4.近5分钟内告警 Set keys = stringRedisTemplate.keys("hzims:queue:filter:alarm" + "*"); - // 步骤2.遍历保存告警数据 + // 步骤5.遍历保存告警数据 alarms.forEach(alarm->{ - List stations = result.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(stations)){ + // 未匹配到站点 + Optional optional = stations.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).findFirst(); + if(!optional.isPresent()){ return; } - // 根据最近5分钟的数据,做去重 + // 告警已处理 + if(handlers.contains(alarm.getAlarmContext())){ + return; + } + // 告警已延后处理 + if(delays.contains(alarm.getAlarmContext())){ + return; + } + // 近5分钟内告警重复 for (String key : keys) { String value = stringRedisTemplate.opsForValue().get(key); - if (value.equals(stations.get(0).getName()+alarm.getAlarmContext())){ + if (value.equals(optional.get().getName()+alarm.getAlarmContext())){ return; } } - // fpd告警拼接 + // fpd告警拼接站点名称 if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){ - alarm.setAlarmContext(stations.get(0).getName() + "." + alarm.getAlarmContext()); + alarm.setAlarmContext(optional.get().getName() + "." + alarm.getAlarmContext()); } - // 步骤3.站点参数设置 - alarm.setCreateDept(stations.get(0).getCreateDept()); - alarm.setStationName(stations.get(0).getName()); - alarm.setTenantId(stations.get(0).getTenantId()); + // 站点参数设置 + alarm.setCreateDept(optional.get().getCreateDept()); + alarm.setStationName(optional.get().getName()); + alarm.setTenantId(optional.get().getTenantId()); alarm.setStatus(0); - // 步骤4.根据站点查询配置标识 + // 根据站点查询配置标识 AlarmHandleMarkVo mark = alarmConfigService.mark(alarm.getStationId(),alarm.getAlarmSource(),alarm.getAlarmType()); if(ObjectUtil.isEmpty(mark)){ log.error("alarm_obtain_mark_is_null : {}",alarm.getAlarmId()); return; } - // 步骤5.告警处理标识赋值 + // 告警处理标识赋值 alarm.setIsRightTabulation(mark.getIsRightTabulation()); alarm.setIsBroadcast(mark.getIsBroadcast()); alarm.setIsMask(mark.getIsMask()); @@ -92,16 +110,16 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { alarm.setIsSmallBell(mark.getIsSmallBell()); alarm.setIsShortMessage(mark.getIsShortMessage()); alarm.setIsWxMessage(mark.getIsWxMessage()); - // 步骤6.保存当日告警数据 + // 保存告警 boolean isSave = alarmService.save(alarm); if(!isSave){ log.error("alarm_save_fail : {}",alarm.getAlarmId()); return; } String key="hzims:queue:filter:alarm"+alarm.getAlarmId(); - stringRedisTemplate.opsForValue().set(key,stations.get(0).getName()+alarm.getAlarmContext()); + stringRedisTemplate.opsForValue().set(key,optional.get().getName()+alarm.getAlarmContext()); stringRedisTemplate.expire(key,5, TimeUnit.MINUTES); - // 步骤7.发生数据至redis告警队列 + // 发送告警数据进行消息推送队列 stringRedisTemplate.opsForList().rightPush("hzims:queue:alarm", JSON.toJSONString(alarm)); }); return true; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java index e196455..f4af51c 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmHandleService.java @@ -25,4 +25,8 @@ public interface AlarmHandleService extends BaseService { List handleUser(); List handles(); + + List sameDayContent(); + + List incompleteContent(); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java index 7fd7cb4..b53128a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmHandleServiceImpl.java @@ -170,4 +170,22 @@ public class AlarmHandleServiceImpl extends BaseServiceImpl sameDayContent() { + return null; + } + + /** + * 查询未到延后期限告警的内容 + * @return + */ + @Override + public List incompleteContent() { + return null; + } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index 2b769ec..1e3838e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -3,15 +3,15 @@ package com.hnac.hzims.alarm.show.service.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.alarm.config.service.AlarmConfigService; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.entity.AlarmEntity; +import com.hnac.hzims.alarm.config.service.AlarmConfigService; +import com.hnac.hzims.alarm.config.vo.AlarmCountVo; +import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.alarm.show.mapper.AlarmMapper; import com.hnac.hzims.alarm.show.service.AlarmHandleService; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.alarm.source.service.MessageService; -import com.hnac.hzims.alarm.config.vo.AlarmCountVo; -import com.hnac.hzims.alarm.config.vo.ChildAlarmCountVo; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmVideoBandingEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; @@ -20,10 +20,8 @@ import com.hnac.hzims.message.dto.MailMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; -import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; -import com.hnac.hzinfo.sdk.v5.project.ProjectClient; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java index 3bcf351..f9661f6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RemoteParamVO.java @@ -21,7 +21,7 @@ public class RemoteParamVO implements Serializable { private String remoteName; @JSONField(name = "device_id") - private String deviceCode; + private String deviceId; @JSONField(name = "device_name") private String deviceName; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java index ae78443..14cdc89 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java @@ -82,7 +82,8 @@ public class RehearsalController extends BladeController { @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "rehearsalStatus", value = "演练状态", dataType = "query", paramType = "string") }) @ApiOperation(value = "演练计划分页") @ApiOperationSupport(order = 5) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java index 57ef4ba..7eda44c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -91,7 +91,8 @@ public class TrainController extends BladeController { @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "trainStatus", value = "培训计划状态", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划分页") @ApiOperationSupport(order = 5) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml index a9ca3f6..19ef188 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml @@ -87,6 +87,9 @@ AND scheduled_end_time <= #{param.endTime} + + AND train_status = #{param.trainStatus} + ORDER BY create_time DESC diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java index 1714714..9cd63ef 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -275,7 +275,8 @@ public class RehearsalPlanServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); String unit = String.valueOf(param.get("unit")); String startTime = String.valueOf(param.get("scheduledStartTime")); - String endTime = String.valueOf((param.get("scheduledEndTime"))); + String endTime = String.valueOf(param.get("scheduledEndTime")); + String rehearsalStatus = String.valueOf(param.get("rehearsalStatus")); if (!unit.equals("null") && !unit.equals("")) { queryWrapper.lambda().like(RehearsalPlanEntity::getUnit, unit); } @@ -285,6 +286,9 @@ public class RehearsalPlanServiceImpl extends ServiceImpl list = new ArrayList<>(); - if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getImgPath())) { - String[] imgArr = rehearsalRecordDetailVO.getImgPath().split(","); - for (String img : imgArr) { - ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + - BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); - list.add(imageEntity); - } - } else { - // 添加空的ImageEntity,防止数据填入时显示"{{" - list.add(new ImageEntity()); - } - rehearsalRecordDetailVO.setImages(list); // 记录:换行符使用\r\n String standardRecord = rehearsalRecordDetailVO.getRecord().replaceAll("\n", "\r\n"); rehearsalRecordDetailVO.setRecord(standardRecord); @@ -183,7 +172,28 @@ public class RehearsalRecordServiceImpl extends ServiceImpl params = BaseUtil.obj2Map(rehearsalRecordDetailVO); + // 图片 + Map params; + if (StringUtils.isNotEmpty(rehearsalRecordDetailVO.getImgPath())) { + List list = new ArrayList<>(); + RehearsalRecordDetailImgVO imgVO = new RehearsalRecordDetailImgVO(); + BeanUtils.copyProperties(rehearsalRecordDetailVO, imgVO); + String[] imgArr = rehearsalRecordDetailVO.getImgPath().split(","); + for (String img : imgArr) { + ImageEntity imageEntity = new ImageEntity(BaseUtil.imgToByte(savePath + + BaseUtil.downloadFileByUrl(img, savePath)), 180, 150); + list.add(imageEntity); + } + imgVO.setImages(list); + params = BaseUtil.obj2Map(imgVO); + } else { + List list = new ArrayList<>(); + list.add(""); + RehearsalRecordDetailStrVO strVO = new RehearsalRecordDetailStrVO(); + BeanUtils.copyProperties(rehearsalRecordDetailVO, strVO); + strVO.setImages(list); + params = BaseUtil.obj2Map(strVO); + } String templateFile = "template/演练记录表" + SafeProductConstant.DOCX_SUFFIX; String wordPath = savePath + "/演练记录表" + SafeProductConstant.DOCX_SUFFIX; String pdfPath = savePath + "/演练记录表" + SafeProductConstant.PDF_SUFFIX; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java index 6145b38..a075bb2 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java @@ -126,6 +126,7 @@ public class TestScoreServiceImpl extends ServiceImpl iterator = p.getRuns().iterator(); - while (iterator.hasNext()) { - XWPFRun r = iterator.next(); - String text = r.getText(0); + for (int index = 0; index < p.getRuns().size(); index++) { + XWPFRun run = p.getRuns().get(index); + String text = run.getText(0); if (findText.equals(text)) { - r.setText("", 0); // 清除原有文本 - XWPFParagraph paragraph = r.getParagraph(); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject jsonObject = jsonArray.getJSONObject(i); - String name = jsonObject.getString("name"); - String url = jsonObject.getString("url"); - url = URLEncoder.encode(url, "UTF-8"); - String id = paragraph.getDocument().getPackagePart().addExternalRelationship(url, XWPFRelation.HYPERLINK.getRelation()).getId(); - CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); - cLink.setId(id); - CTText ctText = CTText.Factory.newInstance(); - ctText.setStringValue(name); - CTR ctr = CTR.Factory.newInstance(); - ctr.setTArray(new CTText[]{ctText}); - cLink.setRArray(new CTR[]{ctr}); - if (i tableList = xwpfDocument.getTables(); + if (tableList.size() > 0) { + // 循环表格 + for (XWPFTable table : tableList) { + // 获取表格所有行数 + List rows = table.getRows(); + // 第五行到倒数第三行为需合并区域 + for (int row = 5; row < rows.size() - 2;) { + XWPFTableCell startCell = rows.get(row).getCell(0); + String startText = startCell.getText(); + int index = row + 1; + for (; index < rows.size(); index++) { + XWPFTableCell endCell = rows.get(index).getCell(0); + String endText = endCell.getText(); + if (!startText.equals(endText)) { + break; + } + } + mergeCellsVertically(table, 0, row, index - 1); + row = index; + } + } + } + } + + private static void insertJsonArrayIntoParagraph(JSONArray jsonArray, XWPFParagraph paragraph) throws IOException { + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + String name = jsonObject.getString("name"); + String url = jsonObject.getString("url"); + // URL编码格式化 + String encodeName = URLEncoder.encode(name, "UTF-8").replaceAll("\\+", "%20"); + String prefixString = url.substring(0, url.lastIndexOf("/") + 1); + String encodeUrl = prefixString + encodeName; + String id = paragraph.getDocument().getPackagePart().addExternalRelationship(encodeUrl, + XWPFRelation.HYPERLINK.getRelation()).getId(); + CTHyperlink cLink = paragraph.getCTP().addNewHyperlink(); + cLink.setId(id); + CTText ctText = CTText.Factory.newInstance(); + ctText.setStringValue(name); + CTR ctr = CTR.Factory.newInstance(); + ctr.setTArray(new CTText[]{ctText}); + cLink.setRArray(new CTR[]{ctr}); + if (i < jsonArray.length() - 1) { + paragraph.createRun().addBreak(); + } + } + } + + /** * 卫生自查表格式处理 * @param xwpfDocument word文件类 */ diff --git a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql index b1296e1..3730612 100644 --- a/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/2.0.1.sql @@ -40,4 +40,8 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='卫生自查模板详情表'; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='卫生自查模板详情表'; + +-- 添加考试及格分字段 +ALTER TABLE hzims_test + ADD COLUMN passing_score int(10) NOT NULL DEFAULT 60 COMMENT '考试及格分'; \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/resources/template/演练记录表.docx b/hzims-service/safeproduct/src/main/resources/template/演练记录表.docx index c83a99c..38209f5 100644 Binary files a/hzims-service/safeproduct/src/main/resources/template/演练记录表.docx and b/hzims-service/safeproduct/src/main/resources/template/演练记录表.docx differ