Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 6 months ago
parent
commit
85c5c269c5
  1. 14
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java
  2. 0
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java
  3. 0
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java
  4. 0
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java
  5. 7
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java
  6. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java
  7. 26
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java
  8. 15
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java
  9. 130
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java
  10. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java
  11. 5
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java
  12. 44
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java
  13. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java
  14. 7
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java
  15. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java
  16. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml
  17. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  18. 1
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java
  19. 47
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  20. 5
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java
  21. 4
      hzims-service/hzims-big-model/pom.xml
  22. 1
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java
  23. 44
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java
  24. 28
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java
  25. 25
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java
  26. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java
  27. 46
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java
  28. 171
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java
  29. 24
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java
  30. 16
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java
  31. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java
  32. 14
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java
  33. 1
      hzims-service/message/pom.xml
  34. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java
  35. 44
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java
  36. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java
  37. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java
  38. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java
  39. 61
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java
  40. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java
  41. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java
  42. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  43. 134
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java
  44. 13
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java
  45. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java
  46. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml
  47. 19
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java
  48. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  49. 47
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java
  50. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  51. 19
      hzims-service/operational/src/main/resources/db/2.0.5.sql
  52. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  53. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java
  54. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java
  55. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java
  56. 63
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  57. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  58. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java
  59. 69
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java
  60. 18
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  61. 2
      hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

14
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AttrSelectionVO.java

@ -0,0 +1,14 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/24 15:55
*/
@Data
public class AttrSelectionVO extends SelectionVO implements Serializable {
private DataItemVO item;
}

0
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java → hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataItemVO.java

0
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java → hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/DataVO.java

0
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java → hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/RealDataVO.java

7
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClient.java

@ -19,6 +19,7 @@ package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.EquipmentConstants; import com.hnac.hzims.EquipmentConstants;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.CreateTableVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
@ -84,6 +85,9 @@ public interface IEmInfoClient {
String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath"; String DEVICE_BY_PATH = API_PREFIX + "/deviceByPath";
String EM_INFO_LIST = API_PREFIX + "/emInfoList"; String EM_INFO_LIST = API_PREFIX + "/emInfoList";
String RIDE_DEVICES = API_PREFIX + "/rideDevices";
@PostMapping(DETAIL) @PostMapping(DETAIL)
EmInfoEntity getByCode(@RequestParam("code") String id); EmInfoEntity getByCode(@RequestParam("code") String id);
@ -169,4 +173,7 @@ public interface IEmInfoClient {
@GetMapping(EM_INFO_LIST) @GetMapping(EM_INFO_LIST)
R<List<EmInfoEntity>> emInfoList(EmInfoEntity req); R<List<EmInfoEntity>> emInfoList(EmInfoEntity req);
@GetMapping(RIDE_DEVICES)
List<RideDeviceVo> rideDevices(@RequestParam("deptIds") List<Long> deptIds);
} }

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/feign/IEmInfoClientBack.java

@ -2,6 +2,7 @@ package com.hnac.hzims.equipment.feign;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.vo.CreateTableVO; import org.springblade.system.vo.CreateTableVO;
@ -114,4 +115,9 @@ public class IEmInfoClientBack implements IEmInfoClient {
public R<List<EmInfoEntity>> emInfoList(EmInfoEntity req) { public R<List<EmInfoEntity>> emInfoList(EmInfoEntity req) {
return R.fail("远程调用失败"); return R.fail("远程调用失败");
} }
@Override
public List<RideDeviceVo> rideDevices(List<Long> longs) {
return new ArrayList<>();
}
} }

26
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClient.java

@ -0,0 +1,26 @@
package com.hnac.hzims.operational.fill.feign;
import com.hnac.hzims.operational.OperationalConstants;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author ysj
*/
@FeignClient(
value = OperationalConstants.APP_NAME,
fallback = IGenerateClientFallback.class
)
public interface IGenerateClient {
String API_PREFIX = "/feign/generate/";
String STATION_GENERATE_BY_TIME = API_PREFIX + "/stationGenerateByTime";
@GetMapping(STATION_GENERATE_BY_TIME)
Double stationGenerateByTime(@RequestParam("stationId") String stationId,
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime);
}

15
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/fill/feign/IGenerateClientFallback.java

@ -0,0 +1,15 @@
package com.hnac.hzims.operational.fill.feign;
import org.springframework.stereotype.Component;
/**
* @author hx
*/
@Component
public class IGenerateClientFallback implements IGenerateClient {
@Override
public Double stationGenerateByTime(String stationId, String startTime, String endTime) {
return 0.0;
}
}

130
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/entity/StationRelation.java

@ -0,0 +1,130 @@
package com.hnac.hzims.operational.station.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import okhttp3.internal.annotations.EverythingIsNonNull;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 站点和霍山生态流量电站的关联关系表
* @author tanghaihao
* @date 2023年10月08日 13:58
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("station_relation")
public class StationRelation implements Serializable {
private static final long serialVersionUID=1L;
/**
* ID
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 站点编码
*/
@TableField("station_code")
private String stationCode;
/**
* 站点名称
*/
@TableField(exist = false)
private String stationName;
/**
* 设备编码
*/
@TableField("device_code")
private String deviceCode;
/**
* 设备名称
*/
@TableField(exist = false)
private String deviceName;
/**
* 核定流量
*/
@TableField("flow_value")
private String flowValue;
/**
* 低级告警负责人id
*/
@TableField("low_soe_user_id")
private String lowSoeUserId;
/**
* 低级告警电话号码
*/
@TableField("low_soe_phone")
private String lowSoePhone;
/**
* 中级告警负责人id
*/
@TableField("middle_soe_user_id")
private String middleSoeUserId;
/**
* 中级告警电话号码
*/
@TableField("middle_soe_phone")
private String middleSoePhone;
/**
* 高级告警负责人id
*/
@TableField("high_soe_user_id")
private String highSoeUserId;
/**
* 高级告警电话号码
*/
@TableField("high_soe_phone")
private String highSoePhone;
/**
* 当日是否发送预警
*/
@TableField("send_warning")
private Integer sendWarning;
/**
* 当日是否发送告警
*/
@TableField("send_soe")
private Integer sendSoe;
/**
* 创建时间
*/
@TableField("create_time")
private LocalDateTime createTime;
/**
* 更新时间
*/
@TableField("update_time")
private LocalDateTime updateTime;
/**
* 逻辑删除
*/
@TableField("is_deleted")
private Integer isDeleted;
}

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClient.java

@ -30,7 +30,7 @@ public interface IStationClient {
String LIST = API_PREFIX + "/list"; String LIST = API_PREFIX + "/list";
String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd"; String QUERY_EXIST_LGTD_LTTD = API_PREFIX + "/queryExistLgtdAndLttd";
String GET_ONE = API_PREFIX + "/getOne"; String GET_ONE = API_PREFIX + "/getOne";
String GET_STATIONS_BY_TYPE_AND_DURATION = API_PREFIX + "/getStationByTypeAndDuration";
String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes"; String QUERY_STATION_BY_CODES = API_PREFIX + "/querySatationByCodes";
@GetMapping(GET_LIST_ALL) @GetMapping(GET_LIST_ALL)
@ -81,4 +81,7 @@ public interface IStationClient {
*/ */
@PostMapping(QUERY_STATION_BY_CODES) @PostMapping(QUERY_STATION_BY_CODES)
R<List<StationEntity>> querySatationByCodes(@RequestParam("codes") List<String> codes); R<List<StationEntity>> querySatationByCodes(@RequestParam("codes") List<String> codes);
@GetMapping(GET_STATIONS_BY_TYPE_AND_DURATION)
R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime,@RequestParam(required = false) String type);
} }

5
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/feign/IStationClientFallBack.java

@ -76,4 +76,9 @@ public class IStationClientFallBack implements IStationClient {
public R<List<StationEntity>> querySatationByCodes(List<String> codes) { public R<List<StationEntity>> querySatationByCodes(List<String> codes) {
return R.data(new ArrayList<>()); return R.data(new ArrayList<>());
} }
@Override
public R<List<StationEntity>> getStationByTypeAndDuration(String startTime, String endTime, String type) {
return R.fail("远程调用失败!");
}
} }

44
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/station/vo/HomeMapStationVo.java

@ -0,0 +1,44 @@
package com.hnac.hzims.operational.station.vo;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.mp.support.QueryField;
/**
* @author ysj
*/
@Data
public class HomeMapStationVo {
@ApiModelProperty("行政区划")
private String areaCode;
@ApiModelProperty("编号")
private String code;
@ApiModelProperty("名称")
private String name;
@ApiModelProperty("经度(东经)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lgtd;
@ApiModelProperty("纬度(北纬)")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Float lttd;
@ApiModelProperty("所属机构")
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long refDept;
@ApiModelProperty("站点是否为国外 1:是;0:否")
private Boolean isAbroad;
@ApiModelProperty("所属国家")
private String refCountry;
}

8
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java

@ -25,6 +25,14 @@ public class HygieneTemplateDetailEntity extends BaseEntity {
@ApiModelProperty("责任区") @ApiModelProperty("责任区")
private String zone; private String zone;
@Size(max = 20, message = "责任人字段长度不能超过20")
@ApiModelProperty("责任人")
private String principal;
@ApiModelProperty("检查项") @ApiModelProperty("检查项")
private String checkItem; private String checkItem;
@Size(max = 255, message = "检查项分值字段长度不能超过255")
@ApiModelProperty("检查项分值")
private String checkItemScore;
} }

7
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/feign/EmInfoClient.java

@ -9,6 +9,7 @@ import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.DeviceVO; import com.hnac.hzims.equipment.vo.DeviceVO;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
@ -155,6 +156,12 @@ public class EmInfoClient implements IEmInfoClient {
return R.data(service.list(queryWrapper)); return R.data(service.list(queryWrapper));
} }
@Override
@GetMapping(RIDE_DEVICES)
public List<RideDeviceVo> rideDevices(@RequestParam("deptIds") List<Long> deptIds) {
return service.rideDevices(deptIds);
}
@PostMapping(GET_EM_CREATE_TABLE) @PostMapping(GET_EM_CREATE_TABLE)
@Override @Override
public List<CreateTableVO> getEmCreateTable(List<String> tableNames) { public List<CreateTableVO> getEmCreateTable(List<String> tableNames) {

1
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.java

@ -19,4 +19,5 @@ public interface EmParamMapper extends UserDataScopeBaseMapper<EmParamEntity> {
List<EmParamEntity> selectRideCountGroupEmIdByDepts(@Param("list") List<Long> list); List<EmParamEntity> selectRideCountGroupEmIdByDepts(@Param("list") List<Long> list);
List<EmParamEntity> rides(@Param("deviceIds") List<Long> deviceIds);
} }

9
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmParamMapper.xml

@ -53,4 +53,13 @@
'installedCapacity') 'installedCapacity')
</select> </select>
<select id="rides" resultType="com.hnac.hzims.equipment.entity.EmParamEntity">
SELECT * FROM HZIMS_EM_PARAM
WHERE `IS_DELETED` = 0
AND (PARAM_NAME = 'ct' OR PARAM_NAME = 'CT' OR PARAM_NAME = 'PR' OR PARAM_NAME = 'pt')
AND INFO_ID IN
<foreach collection="deviceIds" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
</mapper> </mapper>

2
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java

@ -98,4 +98,6 @@ public interface IEmInfoService extends BaseService<EmInfoEntity> {
List<EmInfoEntity> select(Long deptId); List<EmInfoEntity> select(Long deptId);
List<EmInfoTreeVO> getEmInfoTree(EmInfoEntity req); List<EmInfoTreeVO> getEmInfoTree(EmInfoEntity req);
List<RideDeviceVo> rideDevices(List<Long> deptIds);
} }

1
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmParamService.java

@ -19,4 +19,5 @@ public interface IEmParamService extends BaseService<EmParamEntity> {
Map<Long, Map<String,Double>> getRideCountGroupEmIdByDepts(List<Long> emIds); Map<Long, Map<String,Double>> getRideCountGroupEmIdByDepts(List<Long> emIds);
List<EmParamEntity> rides(List<Long> deviceIds);
} }

47
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -949,4 +949,51 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
return this.baseMapper.getEmInfoTree(queryWrapper); return this.baseMapper.getEmInfoTree(queryWrapper);
} }
@Override
public List<RideDeviceVo> rideDevices(List<Long> deptIds) {
// 查询设备
List<EmInfoEntity> devices = this.list(Wrappers.<EmInfoEntity>lambdaQuery()
.in(EmInfoEntity::getDepartment,deptIds)
.eq(EmInfoEntity::getHomePageDisplay,"1")
.eq(EmInfoEntity::getEmType,"2")
);
if(CollectionUtil.isEmpty(devices)){
return new ArrayList<>();
}
List<EmParamEntity> paramList = paramService.rides(devices.stream().map(EmInfoEntity::getId).collect(Collectors.toList()));
return devices.stream().map(device->{
RideDeviceVo rideDevice = new RideDeviceVo();
BeanUtil.copyProperties(device,rideDevice);
// 寻找设备配置参数
List<EmParamEntity> itemParamList = paramList.stream().filter(o->device.getId().equals(o.getInfoId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(itemParamList)) {
// 遍历设备配置参数
for (EmParamEntity paramEntity : itemParamList) {
String paramName = paramEntity.getParamName();
switch (paramName) {
case "ct":
case "CT":
rideDevice.setCt(Double.parseDouble(paramEntity.getParamValue()));
break;
case "pt":
case "PT":
rideDevice.setPt(Double.parseDouble(paramEntity.getParamValue()));
break;
default:
break;
}
}
// 设置ct * pt
if (null != rideDevice.getCt() && null != rideDevice.getPt()) {
rideDevice.setRide(rideDevice.getCt() * rideDevice.getPt());
}else{
rideDevice.setRide(1.0);
}
}else{
rideDevice.setRide(1.0);
}
return rideDevice;
}).collect(Collectors.toList());
}
} }

5
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmParamServiceImpl.java

@ -69,4 +69,9 @@ public class EmParamServiceImpl extends BaseServiceImpl<EmParamMapper, EmParamEn
return result; return result;
} }
@Override
public List<EmParamEntity> rides(List<Long> deviceIds) {
return this.baseMapper.rides(deviceIds);
}
} }

4
hzims-service/hzims-big-model/pom.xml

@ -75,6 +75,10 @@
<groupId>com.hnac.hzinfo.data</groupId> <groupId>com.hnac.hzinfo.data</groupId>
<artifactId>hzinfo-data-sdk</artifactId> <artifactId>hzinfo-data-sdk</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>equipment-api</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

1
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java

@ -21,6 +21,7 @@ public enum FuncRouteEnum {
CHOOSE_FAULT("choose_fault","选择故障",null), CHOOSE_FAULT("choose_fault","选择故障",null),
CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS), CONFIRM_YK("confirm_yk","遥控确认", FunctionConstants.TypeEnum.PARAMS),
SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS), SHOW_PARAM("show_param","设备参数查询", FunctionConstants.TypeEnum.PARAMS),
CHOOSE_YC("choose_yc","选择遥测数据",FunctionConstants.TypeEnum.CHOOSE)
; ;
@Getter @Getter
private String funcCode; private String funcCode;

44
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchStationTypeEnum.java

@ -0,0 +1,44 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/24 17:14
*/
@AllArgsConstructor
public enum SearchStationTypeEnum {
STATION_TOTAL("电站总数量",null,"智能运维平台接入电站总数为:%s"),
SET_TOTAL("站点总数量",null,"智能运维平台接入站点总数为:%s"),
HYDROPOWER_TOTAL("水电站总数量","0","智能运维平台接入水电站总数为:%s"),
WIND_POWER_TOTAL("风电场总数量","1","智能运维平台接入风电场总数为:%s"),
ENERGY_STORAGE_TOTAL("储能站总数量","3","智能运维平台接入储能站总数为:%s"),
PHOTOVOLTAIC_TOTAL("光伏站总数量","5","智能运维平台接入光伏站总数为:%s"),
CHARGE_TOTAL("充电站总数量","7","智能运维平台接入充电站总数为:%s"),
STATION_NUM("电站接入量",null,"智能运维平台接入电站总数为:%s"),
SET_NUM("站点接入量",null,"智能运维平台接入站点总数为:%s"),
HYDROPOWER_NUM("水电站接入量","0","智能运维平台接入水电站接入量为:%s"),
WIND_POWER_NUM("风电场接入量","1","智能运维平台接入风电场接入量为:%s"),
ENERGY_STORAGE_NUM("储能站接入量","3","智能运维平台接入储能站接入量为:%s"),
PHOTOVOLTAIC_NUM("光伏站接入量","5","智能运维平台接入光伏站接入量为:%s"),
CHARGE_NUM("充电站接入量","7","智能运维平台接入充电站接入量为:%s"),
;
@Getter
private String searchStationType;
@Getter
private String stationType;
@Getter
private String label;
public static SearchStationTypeEnum getTypeEnum(String searchStationType) {
return Arrays.stream(SearchStationTypeEnum.class.getEnumConstants())
.filter(e -> e.getSearchStationType().equals(searchStationType))
.findFirst()
.orElse(null);
}
}

28
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/SearchTypeEnum.java

@ -0,0 +1,28 @@
package com.hnac.hzims.bigmodel.interactive.constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import java.util.Arrays;
/**
* @Author: huangxing
* @Date: 2024/05/24 17:13
*/
@AllArgsConstructor
public enum SearchTypeEnum {
REAL("实时"),
HISTORY("历史")
;
@Getter
private String searchType;
public static SearchTypeEnum getSearchType(String searchType) {
return Arrays.stream(SearchTypeEnum.class.getEnumConstants())
.filter(e -> e.getSearchType().equals(searchType))
.findFirst()
.orElse(null);
}
}

25
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java

@ -1,14 +1,13 @@
package com.hnac.hzims.bigmodel.interactive.controller; package com.hnac.hzims.bigmodel.interactive.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.BigModelConstants; import com.hnac.hzims.bigmodel.BigModelConstants;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.vo.StationSearchVO;
import com.hnac.hzinfo.log.annotation.Business; import com.hnac.hzinfo.log.annotation.Business;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -16,9 +15,7 @@ import org.springblade.core.tool.api.R;
import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.ControlDTO;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Author: huangxing * @Author: huangxing
@ -77,4 +74,22 @@ public class InteractiveController {
public R sendRemoteControl(@RequestBody ControlDTO operate) { public R sendRemoteControl(@RequestBody ControlDTO operate) {
return interactiveService.sendRemoteControl(operate); return interactiveService.sendRemoteControl(operate);
} }
@ApiOperation("解析接入站点数量")
@ApiOperationSupport(order = 7)
@PostMapping("/resolveStations")
public R resolveStations(@RequestBody StationSearchVO req) {
return R.data(interactiveService.resolveStations(req.getStartTime(),req.getEndTime(),req.getType(),req.getEnumType()));
}
@ApiOperation("站点发电量")
@ApiOperationSupport(order = 7)
@RequestMapping(value = "/generation",method = {RequestMethod.GET,RequestMethod.POST})
public R generation(@RequestParam @ApiParam("站点编号") String stationId,
@RequestParam @ApiParam("开始时间") String startTime,
@RequestParam @ApiParam("结束时间")String endTime) {
double generate = interactiveService.generation(stationId,startTime,endTime);
DecimalFormat format = new DecimalFormat("0.00");
return R.data(format.format(generate) + "kWh");
}
} }

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java

@ -2,6 +2,7 @@ package com.hnac.hzims.bigmodel.interactive.service;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.ControlDTO;
@ -14,6 +15,8 @@ import java.util.Map;
*/ */
public interface IInteractiveService { public interface IInteractiveService {
ExtraVO resolveStations(String startTime, String endTime, String type, String enumType);
R resolve(ModelFunctionReq req); R resolve(ModelFunctionReq req);
R ask(String question,String sessionId,String userId); R ask(String question,String sessionId,String userId);
@ -43,4 +46,6 @@ public interface IInteractiveService {
R knowledgeAsk(String question, String sessionId, String userId, String knowledge); R knowledgeAsk(String question, String sessionId, String userId, String knowledge);
R<Object> sendRemoteControl(ControlDTO operate); R<Object> sendRemoteControl(ControlDTO operate);
Double generation(String stationId, String startTime, String endTime);
} }

46
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ExtraResolveStrategyService.java

@ -12,15 +12,14 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.feign.IStationClient; import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient; import com.hnac.hzims.operational.station.feign.IStationVideoTypeClient;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO; import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceFuncVO;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.ControlDTO;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -45,6 +44,7 @@ public class ExtraResolveStrategyService {
private final IStationVideoTypeClient videoTypeClient; private final IStationVideoTypeClient videoTypeClient;
private final JumpRouteJoinStrategy jumpRouteJoinStrategy; private final JumpRouteJoinStrategy jumpRouteJoinStrategy;
private final DeviceClient deviceClient; private final DeviceClient deviceClient;
private final BladeLogger logger;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
/** /**
@ -74,25 +74,61 @@ public class ExtraResolveStrategyService {
return this.resolveConfirmRemote(extra); return this.resolveConfirmRemote(extra);
case SHOW_PARAM: case SHOW_PARAM:
return this.resolveShowParam(extra); return this.resolveShowParam(extra);
case CHOOSE_YC:
return this.resolveChooseYc(extra);
default: default:
break; break;
} }
} }
} }
else if(extra.containsKey("extra")){
return extra.getObject("extra",ExtraVO.class);
}
return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class); return JSONObject.parseObject(JSON.toJSONString(extra),ExtraVO.class);
} }
private ExtraVO resolveChooseYc(JSONObject extra) {
ExtraVO result = new ExtraVO();
JSONObject data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")));
if(data.containsKey("ycs")) {
List<AttrSelectionVO> attrs = JSONArray.parseArray(JSON.toJSONString(data.get("ycs")), AttrSelectionVO.class);
result.setSelection(attrs);
}
result.setFuncCode(FuncRouteEnum.CHOOSE_YC.getFuncCode());
result.setSpecial(true);
result.setType(FuncRouteEnum.CHOOSE_YC.getType().getType());
return result;
}
private ExtraVO resolveShowParam(Map<String,Object> extra) { private ExtraVO resolveShowParam(Map<String,Object> extra) {
ExtraVO result = new ExtraVO(); ExtraVO result = new ExtraVO();
result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode()); result.setFuncCode(FuncRouteEnum.SHOW_PARAM.getFuncCode());
result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType()); result.setType(FuncRouteEnum.SHOW_PARAM.getType().getType());
Map<String,Object> param = new HashMap(1); Map<String,Object> param = new HashMap(1);
DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class); DataVO data = JSONObject.parseObject(JSON.toJSONString(extra.get("data")),DataVO.class);
if(Func.isNotEmpty(data) && Func.isNotEmpty(data.getReal()) && Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) { if(Func.isNotEmpty(data)) {
if(Func.isNotEmpty(data.getReal())) {
if(Func.isNotEmpty(data.getReal().getTime()) && StringUtil.isNotBlank(data.getReal().getTime())) {
RealDataVO real = data.getReal(); RealDataVO real = data.getReal();
Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME); Date date = DateUtil.parse(real.getTime(), PATTERN_DATETIME);
real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME)); real.setTime(DateUtil.format(date,DateUtil.PATTERN_DATETIME));
} }
}
// if(Func.isNotEmpty(data.getItem())) {
// if("历史".equals(data.getType())) {
// // 历史数据需要手动查询功能ID供前端使用
// DataItemVO item = data.getItem();
// R<List<DeviceInstanceAttrVO>> attrR = deviceClient.getOnlineAttr(item.getDeviceId());
// if(attrR.isSuccess() && CollectionUtil.isNotEmpty(attrR.getData())) {
// List<DeviceInstanceAttrVO> attrList = attrR.getData();
// Optional<String> facDeviceIdOptional = attrList.stream().parallel().filter(f -> item.getSignage().equals(f.getSignage()))
// .map(DeviceInstanceAttrVO::getFacDeviceAttrId).findFirst();
// logger.info("hzims-big-model:resolveShowParam:facDeviceId",facDeviceIdOptional.orElse(""));
// item.setAttrId(facDeviceIdOptional.orElse(null));
// }
// }
// }
}
param.put("data", data); param.put("data", data);
result.setParams(param); result.setParams(param);
return result; return result;

171
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java

@ -5,25 +5,42 @@ import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl; import com.hnac.hzims.bigmodel.configuration.BigModelInvokeUrl;
import com.hnac.hzims.bigmodel.entity.FunctionEntity; import com.hnac.hzims.bigmodel.entity.FunctionEntity;
import com.hnac.hzims.bigmodel.function.service.IFunctionService; import com.hnac.hzims.bigmodel.function.service.IFunctionService;
import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum; import com.hnac.hzims.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants;
import com.hnac.hzims.bigmodel.interactive.constants.SearchStationTypeEnum;
import com.hnac.hzims.bigmodel.interactive.constants.SearchTypeEnum;
import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq; import com.hnac.hzims.bigmodel.interactive.req.ModelFunctionReq;
import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService;
import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService; import com.hnac.hzims.bigmodel.interactive.service.IJumpPageService;
import com.hnac.hzims.bigmodel.interactive.service.IParamsService; import com.hnac.hzims.bigmodel.interactive.service.IParamsService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzims.equipment.feign.IEmInfoClient;
import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo;
import com.hnac.hzims.equipment.vo.RideDeviceVo;
import com.hnac.hzims.operational.fill.feign.IGenerateClient;
import com.hnac.hzims.operational.main.constant.HomePageConstant;
import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.feign.IStationClient;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyseCodeByAnalyseDataPO;
import com.hnac.hzinfo.datasearch.analyse.po.AnalyzeDataConditionPO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeDataConditionVO;
import com.xxl.job.core.log.XxlJobLogger; import com.xxl.job.core.log.XxlJobLogger;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.dto.ControlDTO; import org.springblade.system.dto.ControlDTO;
import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.dto.DeptStationDTO;
import org.springblade.system.feign.IDeptClient; import org.springblade.system.feign.IDeptClient;
@ -35,7 +52,10 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum; import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.TypeEnum;
@ -52,8 +72,14 @@ public class InteractiveServiceImpl implements IInteractiveService {
private final BladeLogger logger; private final BladeLogger logger;
private final IEmInfoClient deviceClient;
private final IRemoteClient remoteClient; private final IRemoteClient remoteClient;
private final IStationClient stationClient;
private final IGenerateClient generateClient;
private final IJumpPageService jumpPageService; private final IJumpPageService jumpPageService;
private final IParamsService paramsService; private final IParamsService paramsService;
@ -66,12 +92,44 @@ public class InteractiveServiceImpl implements IInteractiveService {
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IAnalyseDataSearchClient analyseDataSearchClient;
private final ExtraResolveStrategyService extraResolveStrategyService; private final ExtraResolveStrategyService extraResolveStrategyService;
private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("station-device-generate-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
@Value("${fdp.host}") @Value("${fdp.host}")
private String fdpHost; private String fdpHost;
@Override @Override
public ExtraVO resolveStations(String startTime, String endTime, String type, String enumType) {
ExtraVO extraVO = new ExtraVO();
extraVO.setType(TypeEnum.PARAMS.getType());
extraVO.setFuncCode("stations_num");
String label;
SearchStationTypeEnum stationTypeEnum = SearchStationTypeEnum.getTypeEnum(enumType);
if(!startTime.equals(endTime)) {
label = String.format("自%s到%s时间为止,",startTime,endTime);
}
else {
startTime = null;
endTime = null;
label = "目前";
}
R<List<StationEntity>> stationListR = stationClient.getStationByTypeAndDuration(startTime, endTime, stationTypeEnum.getStationType());
Assert.isTrue(stationListR.isSuccess(),() -> {
throw new ServiceException("获取接入站点数量失败!");
});
Map<String, Object> params = new HashMap<>();
params.put("searchStationType",stationTypeEnum.getSearchStationType());
params.put("label",label + String.format(stationTypeEnum.getLabel(),stationListR.getData().size()));
params.put("startTime",startTime);
params.put("endTime",endTime);
extraVO.setParams(params);
return extraVO;
}
@Override
public R resolve(ModelFunctionReq req) { public R resolve(ModelFunctionReq req) {
logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req));
FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName());
@ -115,18 +173,7 @@ public class InteractiveServiceImpl implements IInteractiveService {
} }
private void addQuestionSessionId(String sessionId) { private void addQuestionSessionId(String sessionId) {
// 添加redis问题会话 redisTemplate.opsForList().leftPush(HZIMS_BIGMODEL_ASK_KEY,sessionId);
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY);
if(ObjectUtil.isEmpty(json)){
List<String> asks = Collections.singletonList(sessionId);
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks));
}else{
List<String> asks = JSONObject.parseArray(json.toString(),String.class);
if(!asks.contains(sessionId)){
asks.add(sessionId);
}
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY,JSONObject.toJSONString(asks));
}
} }
@Override @Override
@ -277,4 +324,96 @@ public class InteractiveServiceImpl implements IInteractiveService {
public R<Object> sendRemoteControl(ControlDTO operate) { public R<Object> sendRemoteControl(ControlDTO operate) {
return remoteClient.sendCtrl(operate); return remoteClient.sendCtrl(operate);
} }
/**
* 站点发电量
* @param stationId
* @param startTime
* @param endTime
* @return
*/
@Override
public Double generation(String stationId, String startTime, String endTime) {
// 步骤1.查询站点
R<StationEntity> station = stationClient.getStationByCode(stationId);
if(!station.isSuccess() || ObjectUtil.isEmpty(station.getData())){
return 0.0;
}
// 步骤2.查询填报发电量
double fill = generateClient.stationGenerateByTime(stationId,startTime,endTime);
// 步骤3.查询设备
List<RideDeviceVo> devices = deviceClient.rideDevices(Collections.singletonList(station.getData().getRefDept()));
if(CollectionUtil.isEmpty(devices)){
return fill;
}
// 步骤4.遍历设备查询发电量
// 监控线程执行完后返回结果
CountDownLatch countDownLatch = new CountDownLatch(devices.size());
List<Double> deviceGenerate = new CopyOnWriteArrayList();
for(RideDeviceVo device : devices){
pool.submit(()->{
deviceGenerate.add(this.periodTargetFloat(startTime,endTime,5,6,device.getNumber(),device.getRide(), HomePageConstant.HYDROPOWER_GENERATE_POWER));
});
countDownLatch.countDown();
}
//所有模板数据获取完成后释放锁
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
return fill + deviceGenerate.stream().mapToDouble(Double::doubleValue).sum();
}
/***
* 指标数据列表查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号
* @param ride 配电比
* @param signages 指标
* @return
*/
private Double periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setSignages(signages);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
po.setSignboardConditions(signboardConditions);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return 0.0;
}
List<AnalyzeDataConditionVO> records = result.getData();
if(CollectionUtil.isEmpty(records)){
return 0.0;
}
AnalyzeDataConditionVO analyzeDataConditionVO = records.get(0);
if (ObjectUtil.isEmpty(analyzeDataConditionVO)) {
return 0.0;
}
List<AnalyseDataTaosVO> analyseDataTaosVOList = analyzeDataConditionVO.getList();
if (CollectionUtil.isEmpty(analyseDataTaosVOList)) {
return 0.0;
}
AnalyseDataTaosVO analyseDataTaosVO = analyzeDataConditionVO.getList().get(0);
if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) {
return 0.0;
}
return Double.parseDouble(analyseDataTaosVO.getVal()) * ride;
}
} }

24
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/StationSearchVO.java

@ -0,0 +1,24 @@
package com.hnac.hzims.bigmodel.interactive.vo;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/05/25 14:03
*/
@Data
public class StationSearchVO implements Serializable {
private String startTime;
private String endTime;
@NotBlank(message = "查询类型不能为空")
private String type;
private String enumType;
}

16
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java

@ -23,6 +23,7 @@ import com.xxl.job.core.log.XxlJobLogger;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil; import org.springblade.core.tool.utils.StringUtil;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -90,12 +91,7 @@ public class InteractiveSchedule {
@XxlJob(GET_INTERACTIVE_RESULT) @XxlJob(GET_INTERACTIVE_RESULT)
public ReturnT getInteractiveResult(String params) { public ReturnT getInteractiveResult(String params) {
Object json = redisTemplate.opsForValue().get(HZIMS_BIGMODEL_ASK_KEY); List<String> sessionIds = redisTemplate.opsForList().range(HZIMS_BIGMODEL_ASK_KEY, 0, -1);
if(ObjectUtil.isEmpty(json)){
XxlJobLogger.log("未获取到问题标识,或者用户未进行提问!");
return ReturnT.SUCCESS;
}
List<String> sessionIds = JSONObject.parseArray(json.toString(),String.class);
if(CollectionUtil.isEmpty(sessionIds)){ if(CollectionUtil.isEmpty(sessionIds)){
XxlJobLogger.log("问题都已经回答完毕!"); XxlJobLogger.log("问题都已经回答完毕!");
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
@ -106,13 +102,13 @@ public class InteractiveSchedule {
if(sessionIds.contains(answerVO.getSessionId())){ if(sessionIds.contains(answerVO.getSessionId())){
WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId());
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
if(Func.isNotEmpty(session)) {
wsService.sendMessage(session,message); wsService.sendMessage(session,message);
} }
// 问题回答完成,去除redis问题标记
if(answerVO.getRunning() == 0){
sessionIds.remove(answerVO.getSessionId());
} }
redisTemplate.opsForValue().set(HZIMS_BIGMODEL_ASK_KEY, JSONObject.toJSONString(sessionIds)); if(answerVO.getRunning() == 0) {
redisTemplate.opsForList().remove(HZIMS_BIGMODEL_ASK_KEY,1,answerVO.getSessionId());
}
}, getAnswerPoolExecutor)); }, getAnswerPoolExecutor));
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/XxlJobHandlerConstant.java

@ -1,5 +1,7 @@
package com.hnac.hzims.bigmodel.schedule; package com.hnac.hzims.bigmodel.schedule;
import com.hnac.hzims.common.constant.CommonConstant;
/** /**
* @Author: huangxing * @Author: huangxing
* @Date: 2024/04/28 16:19 * @Date: 2024/04/28 16:19
@ -18,6 +20,6 @@ public interface XxlJobHandlerConstant {
String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result"; String INTERACTIVE_RESULT_KEY = "hzllm:interactive:result";
String HZIMS_BIGMODEL_ASK_KEY = "hzims:bigmodel:ask:key"; String HZIMS_BIGMODEL_ASK_KEY = CommonConstant.TENANT_ID + ":hzims:bigmodel:ask:key";
} }

14
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java

@ -117,6 +117,8 @@ public class InteractiveHandler extends TextWebSocketHandler {
case CHOOSE_FAULT: case CHOOSE_FAULT:
this.handleFaultChoose(messageContext,sessionId); this.handleFaultChoose(messageContext,sessionId);
break; break;
case CHOOSE_YC:
this.handleDataChoose(messageContext,sessionId);
default: default:
break; break;
} }
@ -209,4 +211,16 @@ public class InteractiveHandler extends TextWebSocketHandler {
extra.put("data",data); extra.put("data",data);
interactiveService.specialAsk(sessionId,userId,extra); interactiveService.specialAsk(sessionId,userId,extra);
} }
private void handleDataChoose(JSONObject messageContext,String sessionId) {
IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class);
String userId = messageContext.getString("userId");
String funcCode = messageContext.getString("funcCode");
FaultSelectionVO selectionVO = messageContext.getObject("selection",FaultSelectionVO.class);
Map<String, Object> extra = new HashMap<>(2);
extra.put("func",funcCode);
extra.put("data",selectionVO);
interactiveService.specialAsk(sessionId,userId,extra);
}
} }

1
hzims-service/message/pom.xml

@ -88,7 +88,6 @@
<dependency> <dependency>
<groupId>org.springblade</groupId> <groupId>org.springblade</groupId>
<artifactId>blade-system-api</artifactId> <artifactId>blade-system-api</artifactId>
<version>5.0.2-SNAPSHOT</version>
</dependency> </dependency>
<!-- blade-api end --> <!-- blade-api end -->

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/controller/GenerateController.java

@ -80,4 +80,13 @@ public class GenerateController extends BladeController {
return service.pageCondition(filter, query); return service.pageCondition(filter, query);
} }
/**
* 新增
*/
@PostMapping("/test")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "测试发电量保存", notes = "传入InsertPowerEntity对象")
public R test(@RequestBody GenerateEntity entity) {
return R.status(service.test(entity));
}
} }

44
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/feign/GenerateClient.java

@ -0,0 +1,44 @@
package com.hnac.hzims.operational.fill.feign;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.operational.fill.entity.GenerateEntity;
import com.hnac.hzims.operational.fill.service.GenerateService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
/**
* @author ysj
*/
@RestController
@Slf4j
@AllArgsConstructor
public class GenerateClient implements IGenerateClient {
private final GenerateService generateService;
@Override
@GetMapping(STATION_GENERATE_BY_TIME)
public Double stationGenerateByTime(@RequestParam("stationId") String stationId,
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime) {
Date start = DateUtil.parse(startTime,DateUtil.PATTERN_DATETIME);
List<GenerateEntity> generates = generateService.list(Wrappers.<GenerateEntity>lambdaQuery()
.eq(GenerateEntity::getStationCode,stationId)
.ge(GenerateEntity::getFillDate,DateUtil.format(start,DateUtil.PATTERN_DATE))
.le(GenerateEntity::getFillDate,endTime)
);
if(CollectionUtil.isEmpty(generates)){
return 0.0;
}
return generates.stream().mapToDouble(GenerateEntity::getGenerate).sum();
}
}

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/GenerateService.java

@ -37,4 +37,6 @@ public interface GenerateService extends BaseService<GenerateEntity> {
List<PowerMonthVo> generateThreeYear(String start, String end, String station); List<PowerMonthVo> generateThreeYear(String start, String end, String station);
List<PowerMonthVo> fillPowerMon(String code); List<PowerMonthVo> fillPowerMon(String code);
boolean test(GenerateEntity entity);
} }

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java

@ -26,10 +26,7 @@ import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -246,6 +243,29 @@ public class GenerateServiceImpl extends BaseServiceImpl<GenerateMapper, Generat
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public boolean test(GenerateEntity entity) {
Calendar calendar = Calendar.getInstance();
Date end = calendar.getTime();
calendar.add(Calendar.MONTH,-calendar.get(Calendar.MONTH));
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));
Random random = new Random();
Date start = calendar.getTime();
while (end.compareTo(start) > 0){
entity.setId(null);
entity.setFillDate(DateUtil.format(start,DateUtil.PATTERN_DATE));
entity.setGenerate((random.nextDouble() * 1360) + 19000);
this.save(entity);
calendar.add(Calendar.DAY_OF_MONTH,1);
start = calendar.getTime();
}
return true;
}
/** /**
* 获取近年月份集合 * 获取近年月份集合

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/IAnalyseDataService.java

@ -15,10 +15,13 @@ public interface IAnalyseDataService {
<T> List<AnalyzeCodeBySignagesVO> getAnalyzeCodeBySignages(Function<T, MultiAnalyzeCodePO> convert, T resource); <T> List<AnalyzeCodeBySignagesVO> getAnalyzeCodeBySignages(Function<T, MultiAnalyzeCodePO> convert, T resource);
List<AnalyzeCodeBySignagesVO> analyzeCodeBySignages(List<MultiAnalyzeCodePO> list);
List<AnalyzeDataConditionVO> periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List<String> signages);
List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages); List<AnalyseDataTaosVO> periodTargetData(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, String signages);
List<AnalyseDataTaosVO> periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List<String> deviceCodes, String signages); List<AnalyseDataTaosVO> periodTargetDatas(String startTime, String endTime, Integer accessRules, Integer cycleType, List<String> deviceCodes, String signages);
Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Integer ride ,String signages); Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, Double ride ,String signages);
} }

61
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/AnalyseDataServiceImpl.java

@ -22,7 +22,10 @@ import org.springframework.stereotype.Service;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -47,6 +50,58 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
return result; return result;
} }
/**
* 查询设备实例属性标识
* @param list
* @return
*/
@Override
public List<AnalyzeCodeBySignagesVO> analyzeCodeBySignages(List<MultiAnalyzeCodePO> list) {
R<List<AnalyzeCodeBySignagesVO>> result = analyseDataSearchClient.getAnalyzeCodeBySignages(list);
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){
return new ArrayList<>();
}
return result.getData();
}
/***
* 指标数据列表查询
* @param startTime 开始时间
* @param endTime 结束时间
* @param accessRules 取数规则 : 0=最早值 1=最大值 2=最小值 3=平均值 4=和值 5=差值 6=最新值
* @param cycleType 间隔周期 : 0-> 1-> 2-> 小时 3-> 4-> 5-> 6->
* @param deviceCode 设备编号
* @param signages 指标集合
* @return
*/
@Override
public List<AnalyzeDataConditionVO> periodTargetSignages(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode, List<String> signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
signages.forEach(signage->{
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
analyzeDataConditionPO.setFull(1);
po.setDeviceCode(deviceCode);
analyzeDataConditionPO.setKeepFigures(2);
analyzeDataConditionPO.setAccessRules(accessRules);
analyzeDataConditionPO.setSaveTimeType(cycleType);
analyzeDataConditionPO.setSignages(signage);
// 间隔
analyzeDataConditionPO.setTimeInterval(1);
analyzeDataConditionPO.setBeginTime(LocalDateTime.parse(DateUtil.format(new Date(), startTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
analyzeDataConditionPO.setEndTime(LocalDateTime.parse(DateUtil.format(new Date(), endTime), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME)));
signboardConditions.add(analyzeDataConditionPO);
});
po.setSignboardConditions(signboardConditions);
log.error("period_targets_data_request {}",po);
R<List<AnalyzeDataConditionVO>> result = analyseDataSearchClient.getAnalyzeDataByAnalyzeCodeAndSignages(po);
if (!result.isSuccess() || CollectionUtil.isEmpty(result.getData())) {
return new ArrayList<>();
}
log.error("period_targets_data_resp {}",result);
return result.getData();
}
/*** /***
* 指标数据列表查询 * 指标数据列表查询
* @param startTime 开始时间 * @param startTime 开始时间
@ -134,7 +189,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
* @return * @return
*/ */
@Override @Override
public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Integer ride,String signages) { public Float periodTargetFloat(String startTime, String endTime, Integer accessRules, Integer cycleType, String deviceCode,Double ride,String signages) {
AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO(); AnalyseCodeByAnalyseDataPO po = new AnalyseCodeByAnalyseDataPO();
List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>(); List<AnalyzeDataConditionPO> signboardConditions = new ArrayList<>();
AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO(); AnalyzeDataConditionPO analyzeDataConditionPO = new AnalyzeDataConditionPO();
@ -170,7 +225,7 @@ public class AnalyseDataServiceImpl implements IAnalyseDataService {
if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) { if (ObjectUtil.isEmpty(analyseDataTaosVO) || StringUtil.isBlank(analyseDataTaosVO.getVal())) {
return 0f; return 0f;
} }
return Float.parseFloat(Optional.ofNullable(analyseDataTaosVO.getVal()).orElse("0")) * ride; return Float.parseFloat(String.valueOf(Double.parseDouble(analyseDataTaosVO.getVal()) * ride)) ;
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java

@ -631,6 +631,8 @@ public class HydropowerServiceImpl implements HydropowerService {
// 年发电量 // 年发电量
kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum()); kpi.setGenerateYear(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerYear).sum());
// 月发电量 // 月发电量
kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum()); kpi.setGenerateMon(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerMon).sum());
// 日发电量 // 日发电量
kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum()); kpi.setGenerateDay(targets.stream().mapToDouble(HydropowerUnitTargetVo::getPowerDay).sum());

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/RunReportConstant.java

@ -5,4 +5,9 @@ public interface RunReportConstant {
* 运行月报定时任务 * 运行月报定时任务
*/ */
String TASK_VALUE_RUN_REPORT_CREATE = "runReportCreateHandler"; String TASK_VALUE_RUN_REPORT_CREATE = "runReportCreateHandler";
/**
* 数据平台霍山生态流量监测模型标识
*/
String HS_MODEL_SIGNAGE = "hs_ecological_flow_model";
} }

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java

@ -10,6 +10,7 @@ import com.hnac.hzims.operational.data.service.HzimsDataService;
import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService; import com.hnac.hzims.operational.main.service.IMainSystemMonitoringService;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HomeMapStationVo;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -177,9 +178,9 @@ public class StationController extends BladeController {
@ApiLog @ApiLog
@GetMapping("/getHomeStationList") @GetMapping("/getHomeStationList")
@ApiOperationSupport(order = 91) @ApiOperationSupport(order = 91)
@ApiOperation(value = "获取首页站点列表", notes = "") @ApiOperation(value = "获取首页地图站点列表", notes = "")
public R<List<StationEntity>> getHomeStationList(@RequestParam(value = "deptId", required = false) Long deptId, @RequestParam(value = "types", required = false) List<Integer> types, @RequestParam(value = "serveType", required = false) Integer serveType) { public R<List<HomeMapStationVo>> getHomeStationList() {
return R.data(stationService.getHomeStationList(deptId, types, serveType,true)); return R.data(stationService.homeMapStationVo());
} }
@ApiLog @ApiLog

134
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationRelationController.java

@ -0,0 +1,134 @@
package com.hnac.hzims.operational.station.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.station.RunReportConstant;
import com.hnac.hzims.operational.station.entity.StationRelation;
import com.hnac.hzims.operational.station.service.IStationRelationService;
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient;
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @author tanghaihao
* @date 2023年10月08日 15:04
*/
@RestController
@RequestMapping("/station/station-relation")
@AllArgsConstructor
@Api(value = "站点和霍山生态流量电站的关联关系管理",tags = "站点和霍山生态流量电站的关联关系管理")
public class StationRelationController {
private final IStationRelationService stationRelationService;
private final DeviceClient deviceClient;
@GetMapping("/list")
@ApiOperation("查询列表")
@ApiOperationSupport(order = 1)
public R<List<StationRelation>> list(StationRelation stationRelation) {
return R.data(stationRelationService.getStationRelationList(stationRelation));
}
@GetMapping("/page")
@ApiOperation("分页查询列表")
@ApiOperationSupport(order = 2)
public R<IPage<StationRelation>> page(StationRelation stationRelation, Query query) {
return R.data(stationRelationService.getStationRelationPageList(stationRelation, query));
}
@PostMapping("/save")
@ApiOperation("保存")
@ApiOperationSupport(order = 3)
public R save(@RequestBody @Valid StationRelation stationRelation) {
if (Func.isEmpty(stationRelation.getStationCode())) {
return R.fail("站点编码不能为空");
}
if (Func.isEmpty(stationRelation.getDeviceCode())) {
return R.fail("设备编码不能为空");
}
if (Func.isEmpty(stationRelation.getLowSoeUserId())) {
return R.fail("低级告警负责人不能为空");
}
if (Func.isEmpty(stationRelation.getLowSoePhone())) {
return R.fail("低级告警电话号码不能为空");
}
if (Func.isEmpty(stationRelation.getMiddleSoeUserId())) {
return R.fail("中级告警负责人不能为空");
}
if (Func.isEmpty(stationRelation.getMiddleSoePhone())) {
return R.fail("中级告警电话号码不能为空");
}
if (Func.isEmpty(stationRelation.getHighSoeUserId())) {
return R.fail("高级告警负责人不能为空");
}
if (Func.isEmpty(stationRelation.getHighSoePhone())) {
return R.fail("高级告警电话号码不能为空");
}
if (Func.isEmpty(stationRelation.getFlowValue())) {
return R.fail("核定流量不能为空");
}
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode())
.or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()));
wrapper.eq(StationRelation::getIsDeleted, 0);
int count = stationRelationService.count(wrapper);
if (count > 0) {
return R.fail("站点关联关系已存在");
}
return R.status(stationRelationService.save(stationRelation));
}
@PostMapping("/update")
@ApiOperation("编辑")
@ApiOperationSupport(order = 4)
public R update(@RequestBody @Valid StationRelation stationRelation) {
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
wrapper.and(item -> item.eq(StationRelation::getStationCode, stationRelation.getStationCode())
.or().eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode()));
wrapper.eq(StationRelation::getIsDeleted, 0);
wrapper.ne(StationRelation::getId, stationRelation.getId());
int count = stationRelationService.count(wrapper);
if (count > 0) {
return R.fail("站点关联关系已存在");
}
return R.status(stationRelationService.updateById(stationRelation));
}
@GetMapping("/remove")
@ApiOperation("删除")
@ApiOperationSupport(order = 5)
public R remove(Long id) {
LambdaUpdateWrapper<StationRelation> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(StationRelation::getIsDeleted, 1);
wrapper.eq(StationRelation::getId, id);
stationRelationService.update(wrapper);
return R.success("操作成功");
}
@GetMapping("/getDevice")
@ApiOperation("获取生态流量模型的设备信息")
@ApiOperationSupport(order = 6)
public R<List<DeviceInstanceVO>> getDevice() {
R<List<DeviceInstanceVO>> rData = deviceClient.getDeviceByModelSignage(RunReportConstant.HS_MODEL_SIGNAGE);
if (rData.getCode() == 200) {
List<DeviceInstanceVO> data = rData.getData();
return R.data(data);
} else {
return R.fail("获取设备信息失败");
}
}
}

13
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/feign/StationClient.java

@ -14,6 +14,7 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -137,6 +138,18 @@ public class StationClient implements IStationClient {
.in(StationEntity::getCode,codes))); .in(StationEntity::getCode,codes)));
} }
@Override
@GetMapping("/getStationByTypeAndDuration")
public R<List<StationEntity>> getStationByTypeAndDuration(@RequestParam(required = false) String startTime,
@RequestParam(required = false) String endTime,
@RequestParam(required = false) String type) {
LambdaQueryWrapper<StationEntity> wrapper = Wrappers.<StationEntity>lambdaQuery()
.eq(StringUtil.isNotBlank(type) && Func.isNotEmpty(type),StationEntity::getType, type)
.le(StringUtil.isNotBlank(endTime) && Func.isNotEmpty(endTime),StationEntity::getCreateTime, endTime)
.ge(StringUtil.isNotBlank(startTime) && Func.isNotEmpty(startTime),StationEntity::getCreateTime, startTime);
return R.data(stationService.list(wrapper));
}
@Override @Override
@PostMapping("/getStationByCodeOrRedDept") @PostMapping("/getStationByCodeOrRedDept")

8
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.java

@ -0,0 +1,8 @@
package com.hnac.hzims.operational.station.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.operational.station.entity.StationRelation;
public interface StationRelationMapper extends BaseMapper<StationRelation> {
}

5
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationRelationMapper.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.operational.station.mapper.StationRelationMapper">
</mapper>

19
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationRelationService.java

@ -0,0 +1,19 @@
package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.operational.station.entity.StationRelation;
import org.springblade.core.mp.support.Query;
import java.util.List;
/**
* @author tanghaihao
* @date 2023年10月08日 15:04
*/
public interface IStationRelationService extends IService<StationRelation> {
List<StationRelation> getStationRelationList(StationRelation stationRelation);
IPage<StationRelation> getStationRelationPageList(StationRelation stationRelation, Query query);
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.station.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.operational.main.vo.StationCountVo; import com.hnac.hzims.operational.main.vo.StationCountVo;
import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.entity.StationEntity;
import com.hnac.hzims.operational.station.vo.HomeMapStationVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.base.BaseService;
@ -136,4 +137,6 @@ public interface IStationService extends BaseService<StationEntity> {
* @return 更新是否成功 * @return 更新是否成功
*/ */
boolean updateBatchSort(List<StationEntity> req); boolean updateBatchSort(List<StationEntity> req);
List<HomeMapStationVo> homeMapStationVo();
} }

47
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationRelationServiceImpl.java

@ -0,0 +1,47 @@
package com.hnac.hzims.operational.station.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.operational.station.entity.StationRelation;
import com.hnac.hzims.operational.station.mapper.StationRelationMapper;
import com.hnac.hzims.operational.station.service.IStationRelationService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author tanghaihao
* @date 2023年10月08日 14:37
*/
@Service
public class StationRelationServiceImpl extends ServiceImpl<StationRelationMapper, StationRelation> implements IStationRelationService {
@Override
public List<StationRelation> getStationRelationList(StationRelation stationRelation) {
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
if (Func.isNotEmpty(stationRelation.getStationCode())) {
wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode());
}
if (Func.isNotEmpty(stationRelation.getDeviceCode())) {
wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode());
}
wrapper.eq(StationRelation::getIsDeleted, 0);
return this.list(wrapper);
}
@Override
public IPage<StationRelation> getStationRelationPageList(StationRelation stationRelation, Query query) {
LambdaQueryWrapper<StationRelation> wrapper = new LambdaQueryWrapper();
if (Func.isNotEmpty(stationRelation.getStationCode())) {
wrapper.eq(StationRelation::getStationCode, stationRelation.getStationCode());
}
if (Func.isNotEmpty(stationRelation.getDeviceCode())) {
wrapper.eq(StationRelation::getDeviceCode, stationRelation.getDeviceCode());
}
wrapper.eq(StationRelation::getIsDeleted, 0);
return this.page(Condition.getPage(query), wrapper);
}
}

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java

@ -25,6 +25,7 @@ import com.hnac.hzims.operational.station.mapper.StationMapper;
import com.hnac.hzims.operational.station.service.IStationAttributeService; import com.hnac.hzims.operational.station.service.IStationAttributeService;
import com.hnac.hzims.operational.station.service.IStationPushConfigService; import com.hnac.hzims.operational.station.service.IStationPushConfigService;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.vo.HomeMapStationVo;
import com.hnac.hzims.operational.station.vo.StationAndDeptVo; import com.hnac.hzims.operational.station.vo.StationAndDeptVo;
import com.hnac.hzims.operational.station.vo.StationPushConfigVO; import com.hnac.hzims.operational.station.vo.StationPushConfigVO;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
@ -776,4 +777,31 @@ public class StationServiceImpl extends BaseServiceImpl<StationMapper, StationEn
} }
return this.updateBatchById(stations); return this.updateBatchById(stations);
} }
/**
* 获取首页地图站点列表
* @return
*/
@Override
public List<HomeMapStationVo> homeMapStationVo() {
List<StationEntity> stations = this.list(Wrappers.<StationEntity>lambdaQuery()
.isNotNull(StationEntity::getRefDept)
.isNotNull(StationEntity::getAreaCode)
);
if(CollectionUtil.isEmpty(stations)){
return new ArrayList<>();
}
return stations.stream().map(o->{
HomeMapStationVo mapStation = new HomeMapStationVo();
mapStation.setAreaCode(o.getAreaCode());
mapStation.setName(o.getName());
mapStation.setCode(o.getCode());
mapStation.setLttd(o.getLttd());
mapStation.setLgtd(o.getLgtd());
mapStation.setRefDept(o.getRefDept());
mapStation.setIsAbroad(o.getIsAbroad());
mapStation.setRefCountry(o.getRefCountry());
return mapStation;
}).collect(Collectors.toList());
}
} }

19
hzims-service/operational/src/main/resources/db/2.0.5.sql

@ -0,0 +1,19 @@
DROP TABLE IF EXISTS `station_relation`;
CREATE TABLE `station_relation` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`station_code` varchar(200) DEFAULT NULL COMMENT '站点编码',
`device_code` varchar(128) DEFAULT NULL COMMENT '设备编码',
`send_warning` int(11) DEFAULT '0' COMMENT '当日是否发送预警',
`send_soe` int(11) DEFAULT '0' COMMENT '当日是否发送告警',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
`is_deleted` tinyint(1) DEFAULT '0' COMMENT '逻辑删除',
`low_soe_user_id` varchar(20) DEFAULT NULL COMMENT '低级告警负责人id',
`low_soe_phone` varchar(20) DEFAULT NULL COMMENT '低级告警电话号码',
`middle_soe_user_id` varchar(20) DEFAULT NULL COMMENT '中级告警负责人id',
`middle_soe_phone` varchar(20) DEFAULT NULL COMMENT '中级告警电话号码',
`high_soe_user_id` varchar(20) DEFAULT NULL COMMENT '高级告警负责人id',
`high_soe_phone` varchar(20) DEFAULT NULL COMMENT '高级告警电话号码',
`flow_value` double(12,3) DEFAULT NULL COMMENT '核定流量',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=51 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='站点和霍山生态流量电站的关联关系表';

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java

@ -218,7 +218,7 @@ public class HygieneController extends BladeController {
@ApiOperation(value = "卫生自查模板详情") @ApiOperation(value = "卫生自查模板详情")
@ApiOperationSupport(order = 18) @ApiOperationSupport(order = 18)
@Operate(label = "卫生自查模板详情", type = BusinessType.QUERY, ignore = false) @Operate(label = "卫生自查模板详情", type = BusinessType.QUERY, ignore = false)
public R hygieneTemplateDetail(@RequestParam Long id) { public R<HygieneTemplateDetailVO> hygieneTemplateDetail(@RequestParam Long id) {
HygieneTemplateDetailVO detail = hygieneTemplateService.getHygieneTemplateDetail(id); HygieneTemplateDetailVO detail = hygieneTemplateService.getHygieneTemplateDetail(id);
return R.data(detail); return R.data(detail);
} }
@ -227,7 +227,7 @@ public class HygieneController extends BladeController {
@ApiOperation(value = "卫生自查模板分页") @ApiOperation(value = "卫生自查模板分页")
@ApiOperationSupport(order = 19) @ApiOperationSupport(order = 19)
@Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false)
public R hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { public R<IPage<HygieneTemplateEntity>> hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( IPage<HygieneTemplateEntity> page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper(
param, HygieneTemplateEntity.class)); param, HygieneTemplateEntity.class));
return R.data(page); return R.data(page);

1
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.annotation.UserDataAuth;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/** /**
* 卫生自查计划Mapper类 * 卫生自查计划Mapper类
* *

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java

@ -18,4 +18,11 @@ public interface IHygieneTemplateDetailService extends IService<HygieneTemplateD
* @return 模板详情列表 * @return 模板详情列表
*/ */
List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId); List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId);
/**
* 删除关联模板详情数据
* @param templateId 模板id
* @return true-成功false-失败
*/
boolean removeReferenceDetail(Long templateId);
} }

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java

@ -39,4 +39,11 @@ public interface IHygieneTemplateService extends IService<HygieneTemplateEntity>
* @return 详情 * @return 详情
*/ */
HygieneTemplateDetailVO getHygieneTemplateDetail(Long id); HygieneTemplateDetailVO getHygieneTemplateDetail(Long id);
/**
* 根据模板名获取模板
* @param name 模板名
* @return 模板实体类
*/
HygieneTemplateEntity getHygieneTemplateByName(String name);
} }

63
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java

@ -18,6 +18,7 @@ import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper;
import com.hnac.hzims.safeproduct.service.IHygienePlanService; import com.hnac.hzims.safeproduct.service.IHygienePlanService;
import com.hnac.hzims.safeproduct.service.IHygieneRecordService; import com.hnac.hzims.safeproduct.service.IHygieneRecordService;
import com.hnac.hzims.safeproduct.service.IHygieneZoneService; import com.hnac.hzims.safeproduct.service.IHygieneZoneService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO;
import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
@ -62,16 +63,17 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
public boolean removePlan(Long id) { public boolean removePlan(Long id) {
// 删除计划数据 // 删除计划数据
boolean remove = this.removeById(id); boolean remove = this.removeById(id);
if (remove) { if (!remove) {
throw new ServiceException("删除卫生自查计划失败");
}
// 删除记录数据 // 删除记录数据
boolean removeRecord = hygieneRecordService.removeReferenceRecord(id); boolean removeRecord = hygieneRecordService.removeReferenceRecord(id);
if (removeRecord) { if (!removeRecord) {
throw new ServiceException("删除卫生自查记录失败");
}
// 删除责任区数据 // 删除责任区数据
return hygieneZoneService.removeReferenceZone(id); return hygieneZoneService.removeReferenceZone(id);
} }
}
return false;
}
/** /**
* 卫生自查计划分页 * 卫生自查计划分页
@ -115,24 +117,21 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity);
hygienePlanDTO.setStandardScore(100); hygienePlanDTO.setStandardScore(100);
boolean savePlan = this.save(hygienePlanEntity); boolean savePlan = this.save(hygienePlanEntity);
if (!savePlan) {
throw new ServiceException("卫生自查计划新增失败");
}
// 新增关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划新增成功,新增关联责任区数据
if (savePlan) {
hygienePlan = getPlanByName(hygienePlanDTO.getName()); hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) { for (HygieneZoneEntity zone : zoneList) {
// 传计划id
if (hygienePlan != null) {
zone.setHygienePlanId(hygienePlan.getId()); zone.setHygienePlanId(hygienePlan.getId());
}
String[] scores = zone.getCheckItemScore().split(",|,"); String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩 // 校验检查项总成绩是否为标准总成绩
getSumScore(scores, hygienePlanDTO.getStandardScore()); BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
} }
// 校验通过则批量新增责任区数据 // 校验通过则批量新增责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList)); return R.status(hygieneZoneService.saveBatch(zoneList));
} }
return R.status(Boolean.FALSE);
}
/** /**
* 修改卫生自查计划 * 修改卫生自查计划
@ -152,18 +151,26 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
HygienePlanEntity hygienePlanEntity = new HygienePlanEntity(); HygienePlanEntity hygienePlanEntity = new HygienePlanEntity();
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity);
boolean updatePlan = this.updateById(hygienePlanEntity); boolean updatePlan = this.updateById(hygienePlanEntity);
if (!updatePlan) {
throw new ServiceException("卫生自查计划修改失败");
}
// 修改关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划修改成功,修改关联责任区数据 // 删除旧的责任区数据
if (updatePlan) { boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId());
if (!removeZone) {
throw new ServiceException("删除旧的责任区数据失败");
}
// 新增新的责任区数据
hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) { for (HygieneZoneEntity zone : zoneList) {
zone.setHygienePlanId(hygienePlan.getId());
String[] scores = zone.getCheckItemScore().split(",|,"); String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩 // 校验检查项总成绩是否为标准总成绩
getSumScore(scores, hygienePlanDTO.getStandardScore()); BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
} }
// 校验通过则批量修改责任区数据 // 校验通过则批量修改责任区数据
return R.status(hygieneZoneService.updateBatchById(zoneList)); return R.status(hygieneZoneService.saveBatch(zoneList));
}
return R.status(Boolean.FALSE);
} }
/** /**
@ -210,24 +217,6 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
} }
/** /**
* 计算累计分值
* @param scores 各项分值
* @param standardScore 标准总分值
*/
private void getSumScore(String[] scores, Integer standardScore) {
int sum = 0;
for (String score : scores) {
sum += Integer.parseInt(score);
if (sum > standardScore) {
throw new ServiceException("累计分值超过标准总分值");
}
}
if (sum < standardScore) {
throw new ServiceException("标准总分值未全部分配");
}
}
/**
* 根据编码查询卫生自查计划 * 根据编码查询卫生自查计划
*/ */
@Override @Override

12
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

@ -84,9 +84,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
// 获取当月时间 // 获取当月时间
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date()); String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date());
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号 // 查询同月的最新编号
String lastCode = getLastCode(currentNormMonth); String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号 // 生成编号
String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth); String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth);
hygieneRecordEntity.setCode(code); hygieneRecordEntity.setCode(code);
// 周数计算 // 周数计算
@ -102,13 +102,13 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
} }
} }
boolean save = this.save(hygieneRecordEntity); boolean save = this.save(hygieneRecordEntity);
// 若自查记录新增成功,修改自查计划状态为已完成 if (!save) {
if (save) { throw new ServiceException("卫生自查记录新增失败");
}
// 修改自查计划状态为已完成
hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue()); hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue());
return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS); return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS);
} }
return R.fail("新增失败");
}
/** /**
* 修改卫生自查记录 * 修改卫生自查记录

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java

@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 卫生自查模板详情服务实现类 * 卫生自查模板详情服务实现类
@ -27,4 +28,16 @@ public class HygieneTemplateDetailServiceImpl extends ServiceImpl<HygieneTemplat
queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId); queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId);
return this.list(queryWrapper); return this.list(queryWrapper);
} }
/**
* 删除关联模板详情数据
*/
@Override
public boolean removeReferenceDetail(Long templateId) {
QueryWrapper<HygieneTemplateDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId);
List<HygieneTemplateDetailEntity> list = this.list(queryWrapper);
List<Long> ids = list.stream().map(HygieneTemplateDetailEntity::getId).collect(Collectors.toList());
return this.removeByIds(ids);
}
} }

69
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java

@ -8,9 +8,9 @@ import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper; import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper;
import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService;
import com.hnac.hzims.safeproduct.service.IHygieneTemplateService; import com.hnac.hzims.safeproduct.service.IHygieneTemplateService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,19 +37,28 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Override @Override
public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) { public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName(); String templateName = hygieneTemplateDTO.getTemplateName();
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); // 重名校验
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateEntity> list = this.list(queryWrapper); if (hygieneTemplate != null) {
if (CollectionUtil.isNotEmpty(list)) {
throw new ServiceException("模板名不可重复"); throw new ServiceException("模板名不可重复");
} }
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); // 新增模板
hygieneTemplate.setTemplateName(templateName); HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
boolean saveTemplate = this.save(hygieneTemplate); hygieneTemplateEntity.setTemplateName(templateName);
boolean saveTemplate = this.save(hygieneTemplateEntity);
if (!saveTemplate) { if (!saveTemplate) {
throw new ServiceException("卫生自查模板新增失败"); throw new ServiceException("卫生自查模板新增失败");
} }
return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); // 新增模板详情
hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, 100);
}
return hygieneTemplateDetailService.saveBatch(detailList);
} }
/** /**
@ -60,21 +69,37 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
public boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) { public boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName(); String templateName = hygieneTemplateDTO.getTemplateName();
Long templateId = hygieneTemplateDTO.getTemplateId(); Long templateId = hygieneTemplateDTO.getTemplateId();
// 重名校验
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName);
queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId); queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId);
List<HygieneTemplateEntity> list = this.list(queryWrapper); HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) { if (hygieneTemplate != null) {
throw new ServiceException("模板名不可重复"); throw new ServiceException("模板名不可重复");
} }
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); // 更新模板
hygieneTemplate.setId(templateId); HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
hygieneTemplate.setTemplateName(templateName); hygieneTemplateEntity.setId(templateId);
boolean updateTemplate = this.updateById(hygieneTemplate); hygieneTemplateEntity.setTemplateName(templateName);
boolean updateTemplate = this.updateById(hygieneTemplateEntity);
if (!updateTemplate) { if (!updateTemplate) {
throw new ServiceException("卫生自查模板修改失败"); throw new ServiceException("卫生自查模板更新失败");
} }
return hygieneTemplateDetailService.updateBatchById(hygieneTemplateDTO.getTemplateDetailList()); // 更新模板详情
// 删除旧的模板详情数据
boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId);
if (!removeDetail) {
throw new ServiceException("卫生自查模板详情数据删除失败");
}
// 新增新的模板详情数据
hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,");
BaseUtil.getSumScore(scores, 100);
}
return hygieneTemplateDetailService.saveBatch(detailList);
} }
/** /**
@ -104,4 +129,14 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
hygieneTemplateDetailVO.setTemplateDetailList(details); hygieneTemplateDetailVO.setTemplateDetailList(details);
return hygieneTemplateDetailVO; return hygieneTemplateDetailVO;
} }
/**
* 根据模板名获取模板
*/
@Override
public HygieneTemplateEntity getHygieneTemplateByName(String name) {
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name);
return this.getOne(queryWrapper);
}
} }

18
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -395,4 +395,22 @@ public class BaseUtil {
} }
return fileName; return fileName;
} }
/**
* 计算累计分值
* @param scores 各项分值
* @param standardScore 标准总分值
*/
public static void getSumScore(String[] scores, Integer standardScore) {
int sum = 0;
for (String score : scores) {
sum += Integer.parseInt(score);
if (sum > standardScore) {
throw new ServiceException("累计分值超过标准总分值");
}
}
if (sum < standardScore) {
throw new ServiceException("标准总分值未全部分配");
}
}
} }

2
hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

@ -31,7 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
`id` bigint(20) NOT NULL COMMENT '主键ID', `id` bigint(20) NOT NULL COMMENT '主键ID',
`template_id` bigint(20) NOT NULL COMMENT '模板id', `template_id` bigint(20) NOT NULL COMMENT '模板id',
`zone` varchar(50) NOT NULL COMMENT '责任区', `zone` varchar(50) NOT NULL COMMENT '责任区',
`prinicipal` varchar(20) NOT NULL COMMENT '责任人',
`check_item` mediumtext 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_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` 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 '创建时间', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

Loading…
Cancel
Save