diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java index a938a80..ebb82d2 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/config/entity/AlarmEntity.java @@ -1,11 +1,14 @@ package com.hnac.hzims.alarm.config.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; @@ -68,6 +71,8 @@ public class AlarmEntity extends TenantEntity { private Integer alarmCount; @ApiModelProperty(value = "告警时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.sss") private Date alarmTime; @ApiModelProperty(value = "监测点") diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java index 2a49f48..04b7013 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/OperationalConstants.java @@ -4,7 +4,7 @@ import lombok.Getter; public class OperationalConstants { - public final static String APP_NAME = "hzims-operational"; + public final static String APP_NAME = "hzims-operational-ysj"; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/constants/FeedbackConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/constants/FeedbackConstant.java new file mode 100644 index 0000000..92b3c58 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/constants/FeedbackConstant.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.operational.feedback.constants; + +/** + * 应急抢修常量 + * @Author: ysj + */ +public interface FeedbackConstant { + + + /** + * 问题回复角色别名 + */ + String REPLY_ROLE_ALIAS = "feedback_reply"; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserFeedbackEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/entity/UserFeedbackEntity.java similarity index 52% rename from hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserFeedbackEntity.java rename to hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/entity/UserFeedbackEntity.java index 4e4e4e3..18c022c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/entity/UserFeedbackEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/entity/UserFeedbackEntity.java @@ -1,38 +1,56 @@ -package com.hnac.hzims.operational.main.entity; +package com.hnac.hzims.operational.feedback.entity; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import lombok.EqualsAndHashCode; import org.springblade.core.tenant.mp.TenantEntity; -import java.io.Serializable; +import java.util.Date; + /** - * Created by Sam Huang 2022/5/24 11:03 + * @author ysj */ +@EqualsAndHashCode(callSuper = true) @Data @TableName("hzims_user_feedback") -@ApiModel(value = "UserFeedbackEntity对象", description = "用户反馈表") -public class UserFeedbackEntity extends TenantEntity implements Serializable { - private static final long serialVersionUID = 1L; +@ApiModel(value = "用户反馈信息", description = "用户反馈记录表") +public class UserFeedbackEntity extends TenantEntity { - @ApiModelProperty(value = "联系电话") - private String phone; + private static final long serialVersionUID = 1L; @ApiModelProperty(value = "反馈内容") private String content; + @ApiModelProperty(value = "联系电话") + private String phone; + @ApiModelProperty(value = "附件名称") private String fileName; @ApiModelProperty(value = "附件地址") private String fileUrl; + @ApiModelProperty(value = "反馈人") + private Long feedbackUser; + + @ApiModelProperty(value = "反馈人姓名") + private String feedbackUserName; + + @ApiModelProperty(value = "反馈类型") + private String feedbackType; + @ApiModelProperty(value = "回复内容") private String replyContent; @ApiModelProperty(value = "回复人") private Long replyUser; + @ApiModelProperty(value = "回复时间") + private Date replyTime; + + @ApiModelProperty(value = "回复人姓名") + private String replyUserName; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/vo/FeedbackQueryVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/vo/FeedbackQueryVo.java new file mode 100644 index 0000000..a005165 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/feedback/vo/FeedbackQueryVo.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.operational.feedback.vo; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +@ApiModel(value = "用户反馈查询对象") +public class FeedbackQueryVo { + + @ApiModelProperty(value = "反馈开始时间") + private String startTime; + + @ApiModelProperty(value = "反馈结束时间") + private String endTime; + + @ApiModelProperty(value = "反馈信息") + private String content; + + @ApiModelProperty(value = "反馈类型") + private String feedbackType; + + @ApiModelProperty(value = "问题状态: 1-未回复 2-已回复") + private Integer status; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java index ce42a8f..4337c56 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/HomePageConstant.java @@ -88,6 +88,8 @@ public interface HomePageConstant { */ Integer HYDROPOWER_SERVETYPE = 2; + String HYDROPOWER_SERVETYPE_STRING = "2"; + /** * 站点接入方式 : 数据采集 */ diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java index a080158..f37ce48 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java @@ -50,7 +50,10 @@ public interface MainConstants { String LOAD_HYDROPOWER_UNIT_TARGET = "loadHydropowerUnitTarget"; // 近年发电量 + String LOAD_POWER_DATA_NEW = "loadPowerDataNew"; + String ELECTRICITY_GENERATION_RECENT_YEAR = "electricityGenerationRecentYear"; + // 風電儲能近年发电量 String WIND_POWER_GENERATION_RECENT_YEAR = "windPowerGenerationRecentYear"; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java index 9a82c8f..9875675 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java @@ -1,5 +1,6 @@ package com.hnac.hzims.safeproduct.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -18,4 +19,7 @@ public class HygieneTemplateEntity extends BaseEntity { @ApiModelProperty("模板名称") private String templateName; + + @TableField(exist = false) + private String createDeptName; } 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 7cc733b..97633b9 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 @@ -69,7 +69,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { // 未匹配到站点 Optional optional = stations.getData().stream().filter(o->o.getCode().equals(alarm.getStationId())).findFirst(); if(!optional.isPresent()){ - return; + return; } // 告警已处理 if(CollectionUtil.isNotEmpty(handlers) && handlers.contains(alarm.getAlarmContext())){ @@ -88,22 +88,22 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { } } } - // fpd告警拼接站点名称 + // fpd告警拼接 if(AlarmConstants.EARLY_WARNING.equals(alarm.getAlarmSource())){ alarm.setAlarmContext(optional.get().getName() + "." + alarm.getAlarmContext()); } - // 站点参数设置 + // 步骤3.站点参数设置 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()); @@ -112,7 +112,7 @@ 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()); @@ -121,7 +121,7 @@ public class AlarmSaveServiceImpl implements AlarmSaveService { String key="hzims:queue:filter:alarm"+alarm.getAlarmId(); 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/mqtt/DroolsMqttConsumer.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java index 25bea94..87acece 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/mqtt/DroolsMqttConsumer.java @@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.source.service.DroolsAlarmService; import com.hnac.hzims.alarm.monitor.service.AlarmSaveService; +import com.hnac.hzims.common.utils.DateUtil; import com.hnac.hzinfo.subscribe.SubscribeCallBack; import lombok.extern.slf4j.Slf4j; +import oracle.sql.DATE; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; import java.util.Map; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml index 0a0ff34..029edcc 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/mapper/AlarmHandleMapper.xml @@ -4,7 +4,7 @@ + - select * from hzims_user_feedback where IS_DELETED = 0 - - AND CONTENT like concat('%',#{req.content},'%') - - - AND STATUS = #{req.status} - - - AND CREATE_TIME = ]]> #{req.startTime} - - - AND CREATE_TIME #{req.endTime} - - - AND CREATE_USER = #{req.createUser} - - order by CREATE_TIME desc - - - diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IUserFeedbackService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IUserFeedbackService.java deleted file mode 100644 index b2f0d7f..0000000 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IUserFeedbackService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.hnac.hzims.operational.main.service; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.operational.main.dto.UserFeedbackDTO; -import com.hnac.hzims.operational.main.entity.UserFeedbackEntity; -import org.springblade.core.mp.base.BaseService; - -/** - * Created by Sam Huang 2022/5/24 11:18 - */ -public interface IUserFeedbackService extends BaseService { - - IPage pageNotDataScope(IPage page, UserFeedbackDTO req); - -} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java index 865f0e8..c66d6ff 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java @@ -1,8 +1,6 @@ package com.hnac.hzims.operational.main.service.impl; import com.google.common.collect.Lists; -import com.hnac.hzims.EquipmentConstants; -import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.operational.main.service.IAnalyseDataService; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserFeedbackServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserFeedbackServiceImpl.java deleted file mode 100644 index 4eb8507..0000000 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/UserFeedbackServiceImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.hnac.hzims.operational.main.service.impl; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.operational.main.dto.UserFeedbackDTO; -import com.hnac.hzims.operational.main.entity.UserFeedbackEntity; -import com.hnac.hzims.operational.main.mapper.UserFeedbackMapper; -import com.hnac.hzims.operational.main.service.IUserFeedbackService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springblade.core.mp.base.BaseServiceImpl; -import org.springframework.stereotype.Service; - -/** - * Created by Sam Huang 2022/5/24 11:19 - */ -@Service -@Slf4j -@AllArgsConstructor -public class UserFeedbackServiceImpl extends BaseServiceImpl implements IUserFeedbackService { - - - private final UserFeedbackMapper userFeedbackMapper; - - @Override - public IPage pageNotDataScope(IPage page, UserFeedbackDTO req) { - return userFeedbackMapper.pageNotDataScope(page, req); - } -} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java index c594b34..2d8a986 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/vo/UserFeedbackVo.java @@ -1,6 +1,6 @@ package com.hnac.hzims.operational.main.vo; -import com.hnac.hzims.operational.main.entity.UserFeedbackEntity; +import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java index 8282ab0..1588f88 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/wrapper/UserFeedbackWrapper.java @@ -1,6 +1,6 @@ package com.hnac.hzims.operational.main.wrapper; -import com.hnac.hzims.operational.main.entity.UserFeedbackEntity; +import com.hnac.hzims.operational.feedback.entity.UserFeedbackEntity; import com.hnac.hzims.operational.main.vo.UserFeedbackVo; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.utils.BeanUtil; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java index 17b18ec..9801a20 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/controller/RunMonthController.java @@ -23,6 +23,22 @@ public class RunMonthController { private final RunMonthService runMonthService; + + @GetMapping("/generate") + @ApiOperation(value = "生成站点月报",notes = "生成站点月报") + @ApiOperationSupport(order = 1) + public R generate(@RequestParam("mon") String mon, + @RequestParam("stationCode") String stationCode){ + return R.data(runMonthService.generate(mon,stationCode)); + } + + @GetMapping("/check") + @ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据") + @ApiOperationSupport(order = 2) + public R check(@RequestParam("stationCode") String stationCode){ + return R.data(runMonthService.check(stationCode)); + } + @GetMapping("/data") @ApiOperation(value = "查询站点月报数据",notes = "查询站点月报数据") @ApiOperationSupport(order = 3) @@ -33,7 +49,7 @@ public class RunMonthController { @GetMapping("/export") @ApiOperation(value = "导出站点运行月报",notes = "导出站点运行月报") - @ApiOperationSupport(order = 3) + @ApiOperationSupport(order = 4) public void export(@RequestParam("mon") String mon, @RequestParam("stationCode") String stationCode){ runMonthService.export(mon,stationCode); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonReportMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonReportMapper.java new file mode 100644 index 0000000..87a4eb6 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/mapper/RunMonReportMapper.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.operational.report.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.operational.report.entity.RunMonthEntity; + +/** + * @author ysj + * @date 2023/04/10 11:22:14 + * @version 4.0.0 + */ +public interface RunMonReportMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthReportService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthReportService.java new file mode 100644 index 0000000..68bca91 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthReportService.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.operational.report.service; + +import com.hnac.hzims.operational.report.entity.RunMonthEntity; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface RunMonthReportService extends BaseService { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java index aa172f4..bed8fde 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/RunMonthService.java @@ -11,4 +11,8 @@ public interface RunMonthService extends BaseService { RunMonthEntity data(String mon, String stationCode); void export(String mon, String stationCode); + + Boolean generate(String mon, String stationCode); + + Boolean check(String stationCode); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonReportServiceImpl.java new file mode 100644 index 0000000..8dda69a --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonReportServiceImpl.java @@ -0,0 +1,19 @@ +package com.hnac.hzims.operational.report.service.impl; + +import com.hnac.hzims.operational.report.entity.RunMonthEntity; +import com.hnac.hzims.operational.report.mapper.RunMonReportMapper; +import com.hnac.hzims.operational.report.service.RunMonthReportService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class RunMonReportServiceImpl extends BaseServiceImpl implements RunMonthReportService { + +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index 6e4a668..60c6d4d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -3,10 +3,40 @@ package com.hnac.hzims.operational.report.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.hnac.hzims.alarm.config.constants.AlarmConstants; +import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; +import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.entity.PlanGenerationEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; +import com.hnac.hzims.equipment.feign.IPlanGenertionClient; +import com.hnac.hzims.equipment.vo.RideDeviceVo; +import com.hnac.hzims.operational.main.constant.HomePageConstant; +import com.hnac.hzims.operational.main.service.IAnalyseDataService; import com.hnac.hzims.operational.report.entity.RunMonthEntity; import com.hnac.hzims.operational.report.mapper.RunMonthMapper; +import com.hnac.hzims.operational.report.service.RunMonthReportService; import com.hnac.hzims.operational.report.service.RunMonthService; import com.hnac.hzims.operational.report.vo.*; +import com.hnac.hzims.operational.station.entity.StationEntity; +import com.hnac.hzims.operational.station.service.IStationService; +import com.hnac.hzims.operational.station.vo.StationVO; +import com.hnac.hzinfo.datasearch.PointData; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; +import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO; +import com.hnac.hzinfo.datasearch.history.IHistoryDataSearchClient; +import com.hnac.hzinfo.datasearch.history.OriginalDataQuery; +import com.hnac.hzinfo.datasearch.soe.ISoeClient; +import com.hnac.hzinfo.datasearch.soe.domian.SoeData; +import com.hnac.hzinfo.datasearch.soe.domian.SoeQueryConditionByStation; +import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; +import com.hnac.hzinfo.sdk.core.response.HzPage; +import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; +import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO; +import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.poi.hssf.usermodel.HSSFFont; @@ -17,10 +47,9 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.tool.utils.BeanUtil; -import org.springblade.core.tool.utils.CollectionUtil; -import org.springblade.core.tool.utils.ObjectUtil; -import org.springblade.core.tool.utils.StringUtil; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.*; import org.springframework.stereotype.Service; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -31,19 +60,39 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; +import java.time.LocalDateTime; +import java.util.*; +import java.util.concurrent.*; import java.util.stream.Collectors; /** * @author ysj */ +@SuppressWarnings("ALL") @Service @AllArgsConstructor @Slf4j public class RunMonthServiceImpl extends BaseServiceImpl implements RunMonthService { + private final IStationService stationService; + + private final IAnalyseDataService dataService; + + private final RunMonthReportService runMonthReportService; + + private final ISoeClient soeClient; + + private final IEmInfoClient deivceClient; + + private final SoeDataClient soeDataClient; + + private final IPlanGenertionClient planClient; + + private final IHistoryDataSearchClient historyDataSearchClient; + + // 创建线程池 + private static final ExecutorService pool = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("generate-run-report-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + /** * 查询站点月报运行数据 * @param mon @@ -57,23 +106,34 @@ public class RunMonthServiceImpl extends BaseServiceImpl run = JSONObject.parseObject(entity.getRunData(),new TypeReference>(){}); - if(CollectionUtil.isEmpty(run)){ + List runs = JSONObject.parseObject(entity.getRunData(),new TypeReference>(){}); + if(CollectionUtil.isEmpty(runs)){ return data; } - double monSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerate).sum(); - double monSumPlan = run.stream().mapToDouble(RunDataVo::getPlan).sum(); + // 保留两位小数 + data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{ + // 月发电量 + run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + // 年发电量 + run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + return run; + }).collect(Collectors.toList()))); + + // 月发电量完成率 + double monSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerate).sum(); + double monSumPlan = runs.stream().mapToDouble(RunDataVo::getPlan).sum(); data.setMonSumGenerate(monSumGenerate); data.setMonSumPlan(monSumPlan); if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){ data.setMonRate(BigDecimal.valueOf(monSumGenerate / monSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue()); } - double yearSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerateYear).sum(); - double yearSumPlan = run.stream().mapToDouble(RunDataVo::getPlanYear).sum(); + // 年发电量完成率 + double yearSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerateYear).sum(); + double yearSumPlan = runs.stream().mapToDouble(RunDataVo::getPlanYear).sum(); data.setYearSumGenerate(yearSumGenerate); data.setYearSumPlan(yearSumPlan); if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){ @@ -82,7 +142,6 @@ public class RunMonthServiceImpl extends BaseServiceImpl runs = JSONObject.parseObject(data.getRunData(),new TypeReference>(){}); + if(CollectionUtil.isNotEmpty(runs)){ + // 保留两位小数 + data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{ + // 月发电量 + run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + // 年发电量 + run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue()); + return run; + }).collect(Collectors.toList()))); + } // 创建Excel文件 // 表头、sheet页、文件名 String headerName = data.getStationName() + "运行月报(" + mon + ")"; @@ -124,6 +194,483 @@ public class RunMonthServiceImpl extends BaseServiceImpllambdaQuery() + .eq(StationEntity::getDataOrigin, HomePageConstant.DATA_ORIGIN) + .eq(StationEntity::getType,HomePageConstant.HYDROPOWER) + .eq(StationEntity::getCode,stationCode) + ); + if(ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到站点信息!"); + } + // 查询站点设备 + List devices = deivceClient.rideDevices(Collections.singletonList(station.getRefDept())); + if(CollectionUtil.isEmpty(devices)){ + throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!"); + } + // 计划发电量 + List plans = planClient.getPlanGenerationByParam(Collections.singletonList(stationCode), null , DateUtil.format(new Date(),"yyyy")); + RunMonthEntity run = new RunMonthEntity(); + run.setTenantId(station.getTenantId()); + run.setCreateDept(station.getRefDept()); + run.setCreateUser(station.getCreateUser()); + run.setUpdateUser(station.getUpdateUser()); + run.setStationCode(station.getCode()); + run.setStationName(station.getName()); + run.setMonth(mon); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse(mon,"yyyy-MM")); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + calendar.add(Calendar.MONTH,1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + // 告警数据 + run.setAlarmData(this.alarmData(station.getCode(),start,end)); + List runDatas = new ArrayList<>(); + List curveEcharts = new ArrayList<>(); + for (RideDeviceVo device : devices){ + // 运行数据 + runDatas.add(this.runData(station.getCode(),device,plans,start,end)); + // 月度运行曲线 + curveEcharts.add(this.curveData(device,start,end)); + } + /*CountDownLatch countDownLatch = new CountDownLatch(devices.size()); + List runDatas = new CopyOnWriteArrayList<>(); + List curveEcharts = new CopyOnWriteArrayList<>(); + for (RideDeviceVo device : devices){ + pool.submit(()->{ + // 运行数据 + runDatas.add(this.runData(station.getCode(),device,plans,start,end)); + // 月度运行曲线 + curveEcharts.add(this.curveData(device,start,end)); + countDownLatch.countDown(); + }); + } + //所有模板数据获取完成后释放锁 + try { + countDownLatch.await(); + } catch (InterruptedException e) { + e.printStackTrace(); + Thread.currentThread().interrupt(); + }*/ + if(!CollectionUtil.isEmpty(runDatas)){ + run.setRunData(JSONObject.toJSONString(runDatas)); + } + if(!CollectionUtil.isEmpty(curveEcharts)){ + run.setCurveData(JSONObject.toJSONString(curveEcharts)); + } + // TODO 运行数据分析 + // TODO 运行建议及其他 + // 先删除原先月报数据 + this.deleteRunReport(mon,stationCode); + // 保存生成月报数据 + return runMonthReportService.save(run); + } + + /** + * 先删除原先月报数据 + * @param mon + * @param stationCode + */ + private void deleteRunReport(String mon, String stationCode) { + List runs = runMonthReportService.list(Wrappers.lambdaQuery() + .eq(RunMonthEntity::getMonth,mon) + .eq(RunMonthEntity::getStationCode,stationCode) + ); + if(CollectionUtil.isEmpty(runs)){ + return; + } + this.runMonthReportService.deleteLogic(runs.stream().map(RunMonthEntity::getId).collect(Collectors.toList())); + } + + /** + * 运行数据 + * @param devices + * @return + */ + private RunDataVo runData(String stationCode,RideDeviceVo device,List plans,String start,String end) { + RunDataVo run = new RunDataVo(); + run.setDeviceCode(device.getNumber()); + run.setDeviceName(device.getName()); + // 运行时长 + run.setRunHours(this.runHours(device,DateUtil.parse(start,DateUtil.PATTERN_DATETIME), DateUtil.parse(end,DateUtil.PATTERN_DATETIME))); + // 月发电量 + Double day = this.generates(0,device.getNumber(),device.getRide(),start,end); + if(ObjectUtil.isEmpty(day)){ + run.setGenerate(0.0); + }else{ + run.setGenerate(day/10000); + } + // 年发电量 + Double year = this.generates(1,device.getNumber(),device.getRide(),start,end); + if(ObjectUtil.isEmpty(day)){ + run.setGenerateYear(0.0); + }else{ + run.setGenerateYear(year/10000); + } + // 计划发电量 + run.setPlan(this.planGenerate(0,stationCode,plans)/10000); + // 年计划发电量 + run.setPlanYear(this.planGenerate(1,stationCode,plans)/10000); + return run; + } + + /** + * 实际发电量 + * @param type + * @param deviceCode + * @param ride + * @return + */ + private Double generates(int type,String deviceCode,double ride,String start,String end) { + if(type == 0){ + return Double.valueOf(dataService.periodTargetFloat(start,end,5,5,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER)); + } + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH)); + calendar.add(Calendar.DAY_OF_MONTH,-calendar.get(Calendar.DAY_OF_MONTH)); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY)); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + calendar.add(Calendar.DAY_OF_MONTH,1); + return Double.valueOf(dataService.periodTargetFloat(DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME),end,5,6,deviceCode,ride,HomePageConstant.HYDROPOWER_GENERATE_POWER)); + } + + /** + * 计划发电量 + * @param type + * @param stationCode + * @param plans + * @return + */ + private Double planGenerate(int type, String stationCode,List plans) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); + if(type == 0){ + calendar.add(Calendar.DAY_OF_MONTH,-1); + calendar.add(Calendar.HOUR_OF_DAY,-calendar.get(Calendar.HOUR_OF_DAY) + 1); + calendar.add(Calendar.MINUTE, -calendar.get(Calendar.MINUTE)); + calendar.add(Calendar.SECOND, -calendar.get(Calendar.SECOND)); + String time = DateUtil.format(calendar.getTime(),"yyyy-MM"); + return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time)) + .mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + } + String time = DateUtil.format(calendar.getTime(),"yyyy"); + return plans.stream().filter(plan -> plan.getStationId().equals(stationCode) && plan.getDateTime().contains(time)) + .mapToDouble(PlanGenerationEntity::getPlanGeneration).sum(); + } + + /** + * 获取运行数据 + * @param device + * @return + */ + private Double runHours(RideDeviceVo device,Date startDate,Date endDate) { + MultiAnalyzeCodePO analyze = new MultiAnalyzeCodePO(); + analyze.setDeviceCode(device.getNumber()); + analyze.setSignages(Collections.singletonList(HomePageConstant.ACTIVE_POWER)); + List signages = dataService.analyzeCodeBySignages(Collections.singletonList(analyze)); + if(CollectionUtil.isEmpty(signages)){ + return 0.0; + } + // 监测点 + String realId = signages.get(0).getRealId(); + if(StringUtils.isEmpty(realId)){ + return 0.0; + } + return this.getRunConvertData(realId,startDate,endDate); + } + + /** + * 获取时间范围内运行时长 + * @param realId + * @param startDate + * @param endDate + * @return + */ + private Double getRunConvertData(String realId, Date startDate, Date endDate) { + OriginalDataQuery originalDataQuery = new OriginalDataQuery(); + originalDataQuery.setRealId(realId); + originalDataQuery.setBeginTime(startDate); + originalDataQuery.setEndTime(endDate); + originalDataQuery.setLimit(100000); + originalDataQuery.setPage(1); + // 查询时间范围开关机监测点历史数据 + Result> result = historyDataSearchClient.getOriginalDataByRealIds(originalDataQuery); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData())){ + return 0.0; + } + // 开机运行时长 + long time = this.getRunTime(result.getData().getRecords(),startDate,endDate); + return BigDecimal.valueOf(time / (1000 * 60 * 60.00)).setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + + /** + * 获取运行时长 + * @param result + * @return + */ + private long getRunTime(List result,Date startDate,Date endDate) { + if(result.size() == 1){ + // 一直开机 + if(Double.parseDouble(result.get(0).getValue()) > 0){ + return endDate.getTime() - startDate.getTime(); + } + // 一直关机 + return 0; + } + long time=0; + // 遍历累计开机时长 + for(int i = 0; i< result.size() ; i++){ + // 记录为开机状态 就计算到下次关机的时间差 + if(Double.parseDouble(result.get(i).getValue()) <= 0){ + continue; + } + Date endTime,startTime = DateUtil.parse(result.get(i).getTime(), DateUtil.PATTERN_DATETIME); + // 遍历至最后一条数据,累计至当前时间 + if(i == result.size() - 1){ + endTime = endDate; + }else { + endTime = DateUtil.parse(result.get(i+1).getTime(), DateUtil.PATTERN_DATETIME); + } + time += endTime.getTime() - startTime.getTime(); + } + return time; + } + + /** + * 告警数据 + * @param code + * @return + */ + private String alarmData(String code,String start,String end) { + // HZ3000:故障告警 + List alarms = this.hz3000Alarm(code,start,end); + // FDP智能预警 + alarms.addAll(this.intelligentEarly(code,start,end)); + return JSONObject.toJSONString(alarms); + } + + /** + * 查询hz3000告警 + * @param code + */ + private List hz3000Alarm(String code,String start,String end) { + SoeQueryConditionByStation query = new SoeQueryConditionByStation(); + query.setStationIds(Collections.singletonList(code)); + query.setTypes(Collections.singletonList(AlarmHandleConstant.FAULT)); + query.setBeginTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER)); + query.setEndTime(LocalDateTime.parse(end,DateUtil.DATETIME_FORMATTER)); + query.setNeedPage(false); + Result> result = soeClient.getByStationsAndTime(query); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ + return new ArrayList<>(); + } + return result.getData().getRecords().stream().collect(Collectors.groupingBy(SoeData::getSoeExplain)).entrySet().stream().map(entry->{ + RunAlarmVo alarm = new RunAlarmVo(); + alarm.setAlarmTime(DateUtil.format(entry.getValue().stream().sorted(Comparator.comparing(SoeData::getTs)).collect(Collectors.toList()).get(0).getTs(),DateUtil.PATTERN_DATETIME)); + alarm.setDeviceName(entry.getValue().get(0).getDeviceName()); + alarm.setContent(entry.getKey()); + alarm.setType(String.valueOf(AlarmConstants.FAULT)); + alarm.setTypeName("故障"); + alarm.setCount(Math.max(entry.getValue().stream().filter(o->StringUtil.isNotBlank(o.getTraceCount())).mapToInt(soe->Integer.parseInt(soe.getTraceCount())).sum(), 1)); + return alarm; + }).collect(Collectors.toList()); + } + + /** + * 智能预警 + * @param code + * @param start + * @param end + * @return + */ + private List intelligentEarly(String code, String start, String end) { + StbAnalysisDTO param = new StbAnalysisDTO(); + param.setStartTime(LocalDateTime.parse(start,DateUtil.DATETIME_FORMATTER)); + param.setEndTime(LocalDateTime.parse(end, DateUtil.DATETIME_FORMATTER)); + param.setStations(Collections.singletonList(code)); + param.setNeedPage(false); + Result> result = soeDataClient.pageStbAnalysis(param); + if(!result.isSuccess() || ObjectUtil.isEmpty(result.getData()) || CollectionUtil.isEmpty(result.getData().getRecords())){ + return new ArrayList<>(); + } + return result.getData().getRecords().stream().collect(Collectors.groupingBy(StbAnalysisVO::getName)).entrySet().stream().map(entry->{ + RunAlarmVo alarm = new RunAlarmVo(); + alarm.setAlarmTime(entry.getValue().stream().sorted(Comparator.comparing(StbAnalysisVO::getTs)).collect(Collectors.toList()).get(0).getTs()); + alarm.setDeviceName(entry.getValue().get(0).getOrd()); + alarm.setContent(entry.getKey()); + alarm.setType(String.valueOf(AlarmConstants.EARLY)); + alarm.setTypeName("智能预警"); + alarm.setReason(entry.getValue().get(0).getFinfo()); + alarm.setMemo(entry.getValue().get(0).getInfo()); + alarm.setCount(entry.getValue().size()); + return alarm; + }).collect(Collectors.toList()); + } + + /** + * 运行曲线 + * @param devices + * @return + */ + private CurveEchartVo curveData(RideDeviceVo device,String start,String end) { + CurveEchartVo curveData = new CurveEchartVo(); + curveData.setDeviceCode(device.getNumber()); + curveData.setDeviceName(device.getName()); + // 负荷曲线 + curveData.setLoadCurve(this.curve(this.attribute(0),start,end, device.getNumber())); + // 轴承温度曲线 + curveData.setBearingTempCurve(this.curve(this.attribute(1),start,end, device.getNumber())); + // 定子温度曲线 + curveData.setStatorTempCurve(this.curve(this.attribute(2),start,end, device.getNumber())); + return curveData; + } + + /** + * 获取曲线数据 + * @param attributes + * @param deviceCode + * @return + * + * + */ + private List curve(List attributes,String start,String end, String deviceCode) { + List datas = dataService.periodTargetSignages(start,end,3,3,deviceCode,attributes.stream().map(AttributeVo::getSignage).collect(Collectors.toList())); + if(CollectionUtil.isEmpty(datas)){ + return new ArrayList<>(); + } + List analyseDatas = new ArrayList<>(); + Calendar day = Calendar.getInstance(); + datas.forEach(data->{ + if(CollectionUtil.isEmpty(data.getList())){ + return; + } + analyseDatas.addAll(data.getList().stream().peek(item->{ + item.setSignage(data.getSignage()); + Date date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + day.setTime(date); + item.setTs(String.valueOf(day.get(Calendar.DAY_OF_MONTH))); + }).collect(Collectors.toList())); + }); + if(CollectionUtil.isEmpty(analyseDatas)){ + return new ArrayList<>(); + } + Map> map = analyseDatas.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)); + return map.entrySet().stream().map(entry->{ + EchartVo echart = new EchartVo(); + echart.setTime(Integer.valueOf(entry.getKey())); + echart.setValues(entry.getValue().stream().map(value->{ + EchartValueVo echartValue = new EchartValueVo(); + echartValue.setAttribute(value.getSignage()); + echartValue.setAttributeName(attributes.stream().filter(o->o.getSignage().equals(value.getSignage())).collect(Collectors.toList()).get(0).getSignageName()); + if(StringUtil.isEmpty(value.getVal())){ + echartValue.setValue(0.0); + }else{ + echartValue.setValue(Double.parseDouble(value.getVal())); + } + return echartValue; + }).collect(Collectors.toList())); + return echart; + }).sorted(Comparator.comparing(EchartVo::getTime)).collect(Collectors.toList()); + } + + /** + * 曲线属性获取 + * @param attributeType + * @return + */ + private List attribute(int attributeType) { + List attributes = new ArrayList<>(); + switch (attributeType){ + case 0: + AttributeVo attribute = new AttributeVo(); + attribute.setSignage(HomePageConstant.ACTIVE_POWER); + attribute.setSignageName("负荷"); + attributes.add(attribute); + break; + case 1: + + AttributeVo upper_temp = new AttributeVo(); + upper_temp.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_TEMP); + upper_temp.setSignageName("上导轴承瓦温1"); + attributes.add(upper_temp); + AttributeVo oil_tem = new AttributeVo(); + oil_tem.setSignage(HomePageConstant.UPPER_GUIDE_BEARING_OIL_GROOVE_TEMP); + oil_tem.setSignageName("上导轴承油槽温度"); + attributes.add(oil_tem); + AttributeVo thrust_tem = new AttributeVo(); + thrust_tem.setSignage(HomePageConstant.THRUST_BEARING_TEMP); + thrust_tem.setSignageName("推力轴瓦温度1"); + attributes.add(thrust_tem); + AttributeVo lower_tem = new AttributeVo(); + lower_tem.setSignage(HomePageConstant.LOWER_GUIDE_BEARING_TEMP); + lower_tem.setSignageName("下导轴承瓦温1"); + attributes.add(lower_tem); + AttributeVo tank_tem = new AttributeVo(); + tank_tem.setSignage(HomePageConstant.LOWER_GUIDE_OIL_TANK_TEMP); + tank_tem.setSignageName("下导油槽温度"); + attributes.add(tank_tem); + AttributeVo tile_tem = new AttributeVo(); + tile_tem.setSignage(HomePageConstant.WATER_GUIDE_TILE_TEMP); + tile_tem.setSignageName("水导瓦温"); + attributes.add(tile_tem); + AttributeVo water_tem = new AttributeVo(); + water_tem.setSignage(HomePageConstant.WATER_GUIDE_OIL_TANK_TEMP); + water_tem.setSignageName("水导油槽温度"); + attributes.add(water_tem); + break; + case 2: + AttributeVo A_tem = new AttributeVo(); + A_tem.setSignage(HomePageConstant.A_PHASE_IRON_CORE_TEMP); + A_tem.setSignageName("A相铁芯温度1"); + attributes.add(A_tem); + + AttributeVo B_tem = new AttributeVo(); + B_tem.setSignage(HomePageConstant.B_PHASE_IRON_CORE_TEMP); + B_tem.setSignageName("B相铁芯温度1"); + attributes.add(B_tem); + + AttributeVo C_tem = new AttributeVo(); + C_tem.setSignage(HomePageConstant.C_PHASE_IRON_CORE_TEMP); + C_tem.setSignageName("C相铁芯温度1"); + attributes.add(C_tem); + break; + } + return attributes; + } + + /** + * 检查站点是否存在设备信息 + * @param stationCode + * @return + */ + @Override + public Boolean check(String stationCode) { + // 查询站点 + StationVO station = stationService.getStationByCode(stationCode); + if(ObjectUtil.isEmpty(station)){ + throw new ServiceException("未查询到站点信息!"); + } + // 查询设备 + R> emInfos = deivceClient.getEmInfoByDept(Collections.singletonList(station.getRefDept())); + if(!emInfos.isSuccess() || CollectionUtil.isEmpty(emInfos.getData())){ + throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!"); + } + List devices = emInfos.getData().stream().filter(o->"2".equals(o.getEmType())).collect(Collectors.toList()); + if(CollectionUtil.isEmpty(devices)){ + throw new ServiceException("站点未配置机组设备信息、请先为站点添加设备,绑定设备实例,再进行月报查询!"); + } + return true; + } + + /** * 手绘运行数据表格 * @return */ @@ -280,16 +827,14 @@ public class RunMonthServiceImpl extends BaseServiceImpl curveToArray(List curves) { List attrValues = new ArrayList<>(); - curves.forEach(curve->{ - attrValues.addAll(curve.getValues().stream().map(value->{ - CurveAttrValueVo attrValue = new CurveAttrValueVo(); - attrValue.setAttribute(value.getAttribute()); - attrValue.setAttributeName(value.getAttributeName()); - attrValue.setTime(curve.getTime()); - attrValue.setValue(value.getValue()); - return attrValue; - }).collect(Collectors.toList())); - }); + curves.forEach(curve-> attrValues.addAll(curve.getValues().stream().map(value->{ + CurveAttrValueVo attrValue = new CurveAttrValueVo(); + attrValue.setAttribute(value.getAttribute()); + attrValue.setAttributeName(value.getAttributeName()); + attrValue.setTime(curve.getTime()); + attrValue.setValue(value.getValue()); + return attrValue; + }).collect(Collectors.toList()))); return attrValues.stream().collect(Collectors.groupingBy(CurveAttrValueVo::getAttribute)).entrySet().stream().map(entry->{ CurveYArrayVo yArray = new CurveYArrayVo(); yArray.setAttribute(entry.getKey()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java index c7a92e7..7e38882 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/RealMonitorServiceImpl.java @@ -252,8 +252,6 @@ public class RealMonitorServiceImpl implements IRealMonitorService { this.weather(nowWeather,weekWeather,item); // 前池水位 this.waterLevel(levelList,item); - // 总有功率 - this.activePower(item); }); log.info("步骤4站点数据处理 耗时 : {}",System.currentTimeMillis() - beginTime); return new TextMessage(JSONObject.toJSONString(validList.stream().peek(o->{ diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index fe2739c..8290da9 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; @@ -228,8 +227,7 @@ public class HygieneController extends BladeController { @ApiOperationSupport(order = 19) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) public R> hygieneTemplatePage(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( - param, HygieneTemplateEntity.class)); + IPage page = hygieneTemplateService.getHygieneTemplatePage(param, query); return R.data(page); } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java index 946d92b..8170e95 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java @@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper; import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; - /** * 卫生自查计划Mapper类 * diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java index 1a76e7c..d5bcf94 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java @@ -1,9 +1,12 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import org.apache.ibatis.annotations.Mapper; +import java.util.Map; + /** * 卫生自查模板Mapper类 * @@ -12,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface HygieneTemplateMapper extends BaseMapper { + /** + * 卫生自查页面 + * @param param 参数 + * @param page 分页类 + * @return 页面 + */ + IPage getHygieneTemplatePage(IPage page, Map param); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml index 28b08b9..cdb1378 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml @@ -1,4 +1,17 @@ + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java index 86d8637..7d050d0 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java @@ -10,6 +10,7 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; /** @@ -62,4 +63,11 @@ public interface IHygieneRecordService extends IService { * @param response 响应类 */ void exportHygieneRecordData(Long id, HttpServletResponse response); + + /** + * 查询关联卫生自查记录 + * @param planId 计划id + * @return 记录列表 + */ + List getReferenceRecord(Long planId); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java index 5f45e16..bd908d6 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java @@ -1,9 +1,13 @@ package com.hnac.hzims.safeproduct.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; +import org.springblade.core.mp.support.Query; + +import java.util.Map; /** * 卫生自查模板服务类 @@ -46,4 +50,12 @@ public interface IHygieneTemplateService extends IService * @return 模板实体类 */ HygieneTemplateEntity getHygieneTemplateByName(String name); + + /** + * 卫生自查页面 + * @param param 参数 + * @param query 分页类 + * @return 页面 + */ + IPage getHygieneTemplatePage(Map param, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index fb4a3d3..d0d3b88 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -7,11 +7,13 @@ import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; +import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; @@ -39,6 +41,7 @@ import java.net.URLEncoder; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Collectors; /** * 卫生自查计划服务实现类 @@ -63,15 +66,16 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); - // 若计划新增成功,新增关联责任区数据 - if (savePlan) { - hygienePlan = getPlanByName(hygienePlanDTO.getName()); - for (HygieneZoneEntity zone : zoneList) { - // 传计划id - if (hygienePlan != null) { - zone.setHygienePlanId(hygienePlan.getId()); - } - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); - } - // 校验通过则批量新增责任区数据 - return R.status(hygieneZoneService.saveBatch(zoneList)); + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + for (HygieneZoneEntity zone : zoneList) { + zone.setHygienePlanId(hygienePlan.getId()); + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); } - return R.status(Boolean.FALSE); + // 校验通过则批量新增责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); } /** @@ -141,9 +142,10 @@ public class HygienePlanServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().ne(HygienePlanEntity::getId, hygienePlanDTO.getId()); + queryWrapper.lambda().ne(HygienePlanEntity::getId, planId); queryWrapper.lambda().eq(HygienePlanEntity::getName, hygienePlanDTO.getName()); HygienePlanEntity hygienePlan = this.getOne(queryWrapper); if (hygienePlan != null) { @@ -153,28 +155,45 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); - // 若计划修改成功,修改关联责任区数据 - if (updatePlan) { - // 删除旧数据 - boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); - if (removeZone) { - hygienePlan = getPlanByName(hygienePlanDTO.getName()); - // 增加新数据 - for (HygieneZoneEntity zone : zoneList) { - // 传计划id - if (hygienePlan != null) { - zone.setHygienePlanId(hygienePlan.getId()); - } - String[] scores = zone.getCheckItemScore().split(",|,"); - // 校验检查项总成绩是否为标准总成绩 - BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); + // 删除旧的责任区数据 + boolean removeZone = hygieneZoneService.removeReferenceZone(planId); + if (!removeZone) { + throw new ServiceException("删除旧的责任区数据失败"); + } + // 新增新的责任区数据 + hygienePlan = getPlanByName(hygienePlanDTO.getName()); + for (HygieneZoneEntity zone : zoneList) { + zone.setHygienePlanId(hygienePlan.getId()); + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); + } + // 校验通过则批量修改责任区数据 + boolean saveZone = hygieneZoneService.saveBatch(zoneList); + if (!saveZone) { + throw new ServiceException("新增新的责任区数据失败"); + } + // 修改卫生自查记录的责任区id + List recordList = hygieneRecordService.getReferenceRecord(planId); + if (CollectionUtils.isNotEmpty(recordList)) { + List zones = hygieneZoneService.getReferenceZone(planId); + List ids = zones.stream().map(HygieneZoneEntity::getId).collect(Collectors.toList()); + StringBuilder zoneIds = new StringBuilder(); + for (int i = 0; i < ids.size(); i++) { + zoneIds.append(ids.get(i)); + if (i != ids.size() - 1) { + zoneIds.append(","); } - // 校验通过则批量修改责任区数据 - return R.status(hygieneZoneService.saveBatch(zoneList)); } + recordList.forEach(record -> record.setHygieneZoneIds(zoneIds.toString())); + return R.status(hygieneRecordService.updateBatchById(recordList)); } - return R.status(Boolean.FALSE); + return R.status(Boolean.TRUE); } /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 24d3a9f..5392c0a 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -84,9 +84,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl getReferenceRecord(Long planId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneRecordEntity::getHygienePlanId, planId); + return this.list(queryWrapper); + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java index 55f66bb..f2f99b5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java @@ -1,6 +1,8 @@ package com.hnac.hzims.safeproduct.service.impl; 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.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; @@ -11,13 +13,17 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateService; import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springblade.system.feign.ISysClient; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -31,6 +37,12 @@ public class HygieneTemplateServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { + // 重名校验 + HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName); + if (hygieneTemplate != null) { throw new ServiceException("模板名不可重复"); } - HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); - hygieneTemplate.setTemplateName(templateName); - boolean saveTemplate = this.save(hygieneTemplate); + // 新增模板 + HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity(); + hygieneTemplateEntity.setTemplateName(templateName); + boolean saveTemplate = this.save(hygieneTemplateEntity); if (!saveTemplate) { throw new ServiceException("卫生自查模板新增失败"); } - // 传模板id - HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName); + // 新增模板详情 + hygieneTemplate = getHygieneTemplateByName(templateName); List detailList = hygieneTemplateDTO.getTemplateDetailList(); - detailList.forEach(detail -> { - detail.setTemplateId(hygieneTemplateEntity.getId()); + for (HygieneTemplateDetailEntity detail : detailList) { + detail.setTemplateId(hygieneTemplate.getId()); String[] scores = detail.getCheckItemScore().split(",|,"); // 校验检查项总成绩是否为标准总成绩 BaseUtil.getSumScore(scores, 100); - }); - return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); + } + return hygieneTemplateDetailService.saveBatch(detailList); } /** @@ -70,26 +82,33 @@ public class HygieneTemplateServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { + HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper); + if (hygieneTemplate != null) { throw new ServiceException("模板名不可重复"); } - HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); - hygieneTemplate.setId(templateId); - hygieneTemplate.setTemplateName(templateName); - boolean updateTemplate = this.updateById(hygieneTemplate); + // 更新模板 + HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity(); + hygieneTemplateEntity.setId(templateId); + hygieneTemplateEntity.setTemplateName(templateName); + boolean updateTemplate = this.updateById(hygieneTemplateEntity); if (!updateTemplate) { throw new ServiceException("卫生自查模板更新失败"); } + // 更新模板详情 + // 删除旧的模板详情数据 boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId); if (!removeDetail) { throw new ServiceException("卫生自查模板详情数据删除失败"); } + // 新增新的模板详情数据 + hygieneTemplate = getHygieneTemplateByName(templateName); List detailList = hygieneTemplateDTO.getTemplateDetailList(); for (HygieneTemplateDetailEntity detail : detailList) { + detail.setTemplateId(hygieneTemplate.getId()); String[] scores = detail.getCheckItemScore().split(",|,"); BaseUtil.getSumScore(scores, 100); } @@ -133,4 +152,22 @@ public class HygieneTemplateServiceImpl extends ServiceImpl getHygieneTemplatePage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + IPage templatePage = hygieneTemplateMapper.getHygieneTemplatePage(page, param); + List templateList = templatePage.getRecords(); + templateList.forEach(template -> { + R deptName = sysClient.getDeptName(template.getCreateDept()); + if (deptName.isSuccess()) { + template.setCreateDeptName(deptName.getData()); + } + }); + templatePage.setRecords(templateList); + return templatePage; + } } 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 597e48e..ca24f67 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 @@ -138,7 +138,7 @@ public class TestScoreServiceImpl extends ServiceImpl s.getScore() != null).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)) { testScoreSumVO.setActualPeopleNum(list.size()); - List passCollect = list.stream().filter(s -> s.getScore() > testScoreSumVO.getPassingScore()).collect(Collectors.toList()); + List passCollect = list.stream().filter(s -> s.getScore() > testEntity.getPassingScore()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) { double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue(); testScoreSumVO.setPercentage(result); 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 9434144..516bede 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 @@ -31,9 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` ( `id` bigint(20) NOT NULL COMMENT '主键ID', `template_id` bigint(20) NOT NULL COMMENT '模板id', `zone` varchar(50) NOT NULL COMMENT '责任区', - `PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', - `CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', - `CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', + `principal` varchar(20) NOT NULL COMMENT '责任人', + `check_item` mediumtext NOT NULL COMMENT '检查项', + `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', diff --git a/pom.xml b/pom.xml index 09ee516..226f1e4 100644 --- a/pom.xml +++ b/pom.xml @@ -49,8 +49,7 @@ org.springblade blade-system-api - - 5.1.1.RELEASE.fix.4 + ${bladex.project.version} org.springblade @@ -77,7 +76,7 @@ com.hnac.hzinfo.data hzinfo-data-sdk - 5.1.1.RELEASE.fix.5 + 5.1.1.RELEASE.fix.4 com.xuxueli