Browse Source

fix: 设备助手功能开发

zhongwei
haungxing 2 months ago
parent
commit
d5b793b1bc
  1. 32
      hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateInsertDTO.java
  2. 32
      hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateQueryDTO.java
  3. 45
      hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IWeaviatesClient.java
  4. 6
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/ScheduledConstant.java
  5. 6
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java
  6. 13
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IOperAccessTaskClient.java
  7. 4
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java
  8. 5
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java
  9. 4
      hzims-service/equipment/pom.xml
  10. 85
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java
  11. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  12. 80
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  13. 40
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/DeviceLedgerVO.java
  14. 3
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java
  15. 37
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java
  16. 5
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java
  17. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java
  18. 61
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java
  19. 5
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java
  20. 17
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java
  21. 8
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java
  22. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  23. 1
      hzims-service/gglm-big-model/src/main/resources/template/template.yml
  24. 39
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java
  25. 10
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java
  26. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java
  27. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml
  28. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java
  29. 5
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java
  30. 17
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

32
hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateInsertDTO.java

@ -0,0 +1,32 @@
package com.hnac.gglm.bigmodel.api.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/09/18 19:50
* @Description: Weaviate新增数据对象
*/
@Data
public class WeaviateInsertDTO implements Serializable {
/**
* 实体列表
*/
private List entities;
/**
* 类名
*/
private String className;
/**
* 属性
*/
private Map<String,String> attrsMap;
}

32
hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateQueryDTO.java

@ -0,0 +1,32 @@
package com.hnac.gglm.bigmodel.api.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Map;
/**
* @Author: huangxing
* @Date: 2024/09/18 19:47
*/
@Data
@EqualsAndHashCode
public class WeaviateQueryDTO implements Serializable {
/**
* 返回结果字段
*/
private String resultFields;
/**
* 类名
*/
private String className;
/**
* 查询条件
*/
private Map<String,String> query;
}

45
hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IWeaviatesClient.java

@ -0,0 +1,45 @@
package com.hnac.gglm.bigmodel.api.feign;
import com.hnac.gglm.bigmodel.BigModelConstants;
import com.hnac.gglm.bigmodel.api.dto.WeaviateInsertDTO;
import com.hnac.gglm.bigmodel.api.dto.WeaviateQueryDTO;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
/**
* @Author: huangxing
* @Date: 2024/09/18 19:42
*/
@FeignClient(value = BigModelConstants.APP_NAME)
public interface IWeaviatesClient {
String PREFIX_API = "/feign/weaviate";
String SAVE_BATCH = PREFIX_API + "/saveBatch";
String DELETE_BY_IDS = PREFIX_API + "/deleteByIds";
String QUERY_LIST = PREFIX_API + "/queryList";
/**
* 删除
* @param ids ids,按逗号分隔
* @param className 类名
*/
@DeleteMapping(DELETE_BY_IDS)
void deleteByIds(@RequestParam("ids") String ids, @RequestParam("className") String className);
/**
* 查询
* @param query 查询参数
* @return 查询结果
*/
@PostMapping(QUERY_LIST)
R<Object> queryList(@RequestBody WeaviateQueryDTO query);
/**
* 批量保存
* @param insertDTO 插入数据
* @return 是否成功
*/
@PostMapping(SAVE_BATCH)
R saveBatch(@RequestBody WeaviateInsertDTO insertDTO);
}

6
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/ScheduledConstant.java

@ -28,4 +28,10 @@ public interface ScheduledConstant {
/**Fdp监测点与数据平台监测点绑定关系推送**/
String MONITOR_BANDING_PUSH = "monitorBandingPush";
/**设备台账数据生成**/
String DEVICE_LEDGER_DATA_GENERATE = "deviceLedgerDataGenerate";
/**设备台账数据存入向量数据库表名**/
String DEVICE_LEDGER_CLASS_NAME = "Hzn_lm_deviceLedger_data";
}

6
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java

@ -5,6 +5,7 @@ import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import org.springblade.core.tool.api.R;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
@ -26,4 +27,9 @@ public class AccessTaskClientFallback implements IOperAccessTaskClient {
public R finishAccessTask(OperAccessTaskDTO accessTaskDTO) {
return R.fail("修改失败!");
}
@Override
public R<List<String>> getAccessTaskOverview(String date, String emCode) {
return R.fail("获取检修任务概述失败!");
}
}

13
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IOperAccessTaskClient.java

@ -5,9 +5,12 @@ import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
/**
@ -22,6 +25,7 @@ public interface IOperAccessTaskClient {
String UPDATE_BY_ID = API_PREFIX + "/updateById";
String DO_UPDATE_BY_ID = API_PREFIX + "/doUpdateById";
String FINISH_ACCESS_TASK = API_PREFIX + "/finishAccessTask";
String GET_ACCESS_TASK_OVERVIEW = API_PREFIX + "/getAccessTaskOverview";
/**
* 更新检修任务状态接口
* @param entity
@ -46,4 +50,13 @@ public interface IOperAccessTaskClient {
@PostMapping(FINISH_ACCESS_TASK)
R finishAccessTask(@RequestBody OperAccessTaskDTO accessTaskDTO);
/**
* 获取检修任务概览列表
* @param date 日期
* @param emCode 设备编号
* @return 检修任务概览列表
*/
@GetMapping(GET_ACCESS_TASK_OVERVIEW)
R<List<String>> getAccessTaskOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode);
}

4
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java

@ -38,6 +38,7 @@ public interface ITicketInfoClient {
String GET_OPERATE_TICKET_STATISTIC = API_PREFIX + "/getOperateTicketStatistic";
String GET_OPERATE_WORK_STATISTIC = API_PREFIX + "/getOperateWorkStatistic";
String GET_WORK_TICKET_CHECK = API_PREFIX + "/getWorkTicketCheck";
String GET_WORK_TICKET_OVERVIEW = API_PREFIX + "/getWorkTicketOverview";
/**
* 根据ID更新票据状态为未完成
@ -136,4 +137,7 @@ public interface ITicketInfoClient {
R<SafeCheckStatisticVO> getWorkTicketCheck(@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate,
@RequestParam(value = "dept") Long dept);
@GetMapping(GET_WORK_TICKET_OVERVIEW)
R<List<String>> getWorkTicketOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode);
}

5
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java

@ -75,5 +75,10 @@ public class TicketInfoClientFallback implements ITicketInfoClient {
return R.data(new SafeCheckStatisticVO());
}
@Override
public R<List<String>> getWorkTicketOverview(String date, String emCode) {
return R.fail("查询失败!");
}
}

4
hzims-service/equipment/pom.xml

@ -77,6 +77,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>com.hnac.hzims</groupId>
<artifactId>big-model-api</artifactId>
</dependency>
</dependencies>
<build>

85
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java

@ -0,0 +1,85 @@
package com.hnac.hzims.equipment.scheduled;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hnac.gglm.bigmodel.api.dto.WeaviateInsertDTO;
import com.hnac.gglm.bigmodel.api.dto.WeaviateQueryDTO;
import com.hnac.gglm.bigmodel.api.feign.IWeaviatesClient;
import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.DeviceLedgerVO;
import com.hnac.hzims.fdp.constants.ScheduledConstant;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.stereotype.Component;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Author: huangxing
* @Date: 2024/09/18 18:33
* @Description: 设备台账定时任务
*/
@Component
@AllArgsConstructor
public class DeviceLedgerScheduledTask {
private final IEmInfoService emInfoService;
private final IWeaviatesClient weaviateClient;
@XxlJob(ScheduledConstant.DEVICE_LEDGER_DATA_GENERATE)
public ReturnT<String> execute(String param) throws Exception {
JSONObject paramJson = JSONObject.parseObject(param);
String emCode = Optional.ofNullable(paramJson).map(json -> json.getString("emCode")).orElse("");
String date = Optional.ofNullable(paramJson).map(json -> json.getString("date")).orElse(LocalDate.now().minusDays(1).format(DateUtil.DATE_FORMATTER));
List<DeviceLedgerVO> deviceLedgerList = emInfoService.getDeviceLedgerList(emCode, date);
// 向量库查询该设备的所有数据
WeaviateQueryDTO query = new WeaviateQueryDTO();
Map<String,String> queryMap = new HashMap<>();
if(Func.isNotEmpty(emCode)) {
queryMap.put("emCode",emCode);
}
queryMap.put("date",date);
query.setQuery(queryMap);
query.setClassName(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME);
R<Object> searchResult = weaviateClient.queryList(query);
if(searchResult.isSuccess() && Func.isNotEmpty(searchResult.getData())) {
// 取出数据ID 删除数据
JSONObject queryJson = JSONObject.parseObject(searchResult.getData().toString());
JSONArray data = Optional.ofNullable(queryJson).map(json -> json.getJSONObject("Get"))
.map(json -> json.getJSONArray(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME)).get();
List<String> ids = data.stream().map(item -> {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(item));
return Optional.ofNullable(jsonObject)
.map(json -> json.getJSONObject("_additional"))
.map(json -> json.getString("id"))
.orElse("");
}).filter(Func::isNotEmpty).collect(Collectors.toList());
if(Func.isNotEmpty(ids)) {
weaviateClient.deleteByIds(ids.toString(),ScheduledConstant.DEVICE_LEDGER_CLASS_NAME);
}
}
// 批量插入数据
WeaviateInsertDTO weaviateInsertDTO = new WeaviateInsertDTO();
weaviateInsertDTO.setEntities(deviceLedgerList);
weaviateInsertDTO.setClassName(ScheduledConstant.DEVICE_LEDGER_CLASS_NAME.replace("Hzn_lm_",""));
Map<String,String> attrMap = new HashMap<>();
attrMap.put("dataSummary","dataSummary");
weaviateInsertDTO.setAttrsMap(attrMap);
R saveResult = weaviateClient.saveBatch(weaviateInsertDTO);
if(!saveResult.isSuccess()) {
return new ReturnT<>("FAIL");
}
return new ReturnT<>("SUCCESS");
}
}

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

@ -103,4 +103,6 @@ public interface IEmInfoService extends IService<EmInfoEntity> {
List<RideDeviceVo> rideDevices(List<Long> deptIds);
List<StationEmInfoVO> getStationEmList();
List<DeviceLedgerVO> getDeviceLedgerList(String emCode,String date);
}

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

@ -19,12 +19,14 @@ import com.hnac.hzims.equipment.service.*;
import com.hnac.hzims.equipment.vo.*;
import com.hnac.hzims.fdp.service.IFdpQuestionService;
import com.hnac.hzims.operational.access.feign.IAccessMaterialClient;
import com.hnac.hzims.operational.access.feign.IOperAccessTaskClient;
import com.hnac.hzims.operational.access.vo.MaterialConsumeVO;
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.hzims.spare.feign.ISpareClient;
import com.hnac.hzims.spare.vo.SparePartVO;
import com.hnac.hzims.ticket.workTicket.feign.ITicketInfoClient;
import com.hnac.hzims.util.TableJsonUtils;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
@ -125,6 +127,12 @@ public class EmInfoServiceImpl extends ServiceImpl<EmInfoMapper, EmInfoEntity> i
@Autowired
private IFdpQuestionService questionService;
@Autowired
private IOperAccessTaskClient accessTaskClient;
@Autowired
private ITicketInfoClient ticketInfoClient;
@Value("${hzims.equipment.emInfo.code}")
public String deviceCodePath;
@ -1010,6 +1018,7 @@ public class EmInfoServiceImpl extends ServiceImpl<EmInfoMapper, EmInfoEntity> i
if (stationOptional.isPresent()) {
StationEntity stationEntity = stationOptional.get();
StationEmInfoVO stationEmInfoVO = new StationEmInfoVO();
stationEmInfoVO.setEmId(emInfo.getId().toString());
stationEmInfoVO.setEmName(emInfo.getName());
stationEmInfoVO.setEmCode(emInfo.getNumber());
stationEmInfoVO.setStationCode(stationEntity.getCode());
@ -1021,4 +1030,75 @@ public class EmInfoServiceImpl extends ServiceImpl<EmInfoMapper, EmInfoEntity> i
return result;
}
@Override
public List<DeviceLedgerVO> getDeviceLedgerList(String emCode, String date) {
// 若emCode为空,则查询出所有设备形成一个list
List<EmInfoEntity> emInfoList = new ArrayList<>();
if(Func.isNotEmpty(emCode)){
LambdaQueryWrapper<EmInfoEntity> queryWrapper = Wrappers.<EmInfoEntity>lambdaQuery().eq(EmInfoEntity::getNumber, emCode);
EmInfoEntity emInfoEntity = this.getOne(queryWrapper);
if(Func.isEmpty(emInfoEntity)) {
throw new HzServiceException("查询设备失败!");
}
emInfoList.add(emInfoEntity);
}else{
List<EmInfoEntity> emInfos = this.list();
if(Func.isEmpty(emInfos)) {
throw new HzServiceException("暂无设备数据");
}
emInfoList.addAll(emInfos);
}
// 获取站点列表
R<List<StationEntity>> stationsResult = stationClient.getListAll();
if(!stationsResult.isSuccess()) {
throw new HzServiceException("获取站点列表失败!");
}
return emInfoList.stream().flatMap(emInfo -> this.getDeviceLedgerListByEmCode(emInfo,date,stationsResult.getData()).stream().filter(Func::isNotEmpty)).collect(Collectors.toList());
}
/**
* 根据设备编号获取设备台账列表
* @param emInfo 设备实体类
* @param date 查询日期
* @return 台账列表
*/
private List<DeviceLedgerVO> getDeviceLedgerListByEmCode(EmInfoEntity emInfo, String date, List<StationEntity> stationList) {
List<DeviceLedgerVO> result = new ArrayList<>();
Optional<StationEntity> stationOptional = stationList.stream().filter(station -> emInfo.getDepartment().equals(station.getRefDept())).findFirst();
if(!stationOptional.isPresent()) {
return result;
}
DeviceLedgerVO deviceLedgerVO = new DeviceLedgerVO();
deviceLedgerVO.setDeviceCode(emInfo.getNumber());
deviceLedgerVO.setDeviceName(emInfo.getName());
deviceLedgerVO.setStationCode(stationOptional.get().getCode());
deviceLedgerVO.setStationName(stationOptional.get().getName());
deviceLedgerVO.setDate(date);
// TODO 获取设备两票、检修、缺陷等数据填入 dataSummary
R<List<String>> accessTaskOverview = accessTaskClient.getAccessTaskOverview(date, emInfo.getNumber());
if(!accessTaskOverview.isSuccess()) {
throw new HzServiceException("获取设备台账失败!");
}
if(Func.isNotEmpty(accessTaskOverview.getData())) {
List<DeviceLedgerVO> deviceLedgerVOList = accessTaskOverview.getData().stream().map(overview -> {
DeviceLedgerVO deviceLedger = BeanUtil.copy(deviceLedgerVO, DeviceLedgerVO.class);
deviceLedger.setDataSummary(overview);
deviceLedger.setType("检修");
return deviceLedger;
}).collect(Collectors.toList());
result.addAll(deviceLedgerVOList);
}
R<List<String>> workTicketOverview = ticketInfoClient.getWorkTicketOverview(date, emInfo.getNumber());
if(Func.isNotEmpty(workTicketOverview.getData())) {
List<DeviceLedgerVO> deviceLedgerVOList = workTicketOverview.getData().stream().map(overview -> {
DeviceLedgerVO deviceLedger = BeanUtil.copy(deviceLedgerVO, DeviceLedgerVO.class);
deviceLedger.setDataSummary(overview);
deviceLedger.setType("工作票");
return deviceLedger;
}).collect(Collectors.toList());
result.addAll(deviceLedgerVOList);
}
return result;
}
}

40
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/DeviceLedgerVO.java

@ -0,0 +1,40 @@
package com.hnac.hzims.equipment.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/09/18 18:45
*/
@Data
@ApiModel(value = "设备台账VO对象",description = "大模型使用")
@EqualsAndHashCode
public class DeviceLedgerVO implements Serializable {
@ApiModelProperty("站点编号")
private String stationCode;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("设备编号")
private String deviceCode;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("日期")
private String date;
@ApiModelProperty("数据类型")
private String type;
@ApiModelProperty("数据概括")
private String dataSummary;
}

3
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java

@ -22,6 +22,9 @@ public class StationEmInfoVO implements Serializable {
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("设备ID")
private String emId;
@ApiModelProperty("设备编号")
private String emCode;

37
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java

@ -0,0 +1,37 @@
package com.hnac.gglm.bigmodel.api.feign;
import com.hnac.gglm.bigmodel.api.dto.WeaviateInsertDTO;
import com.hnac.gglm.bigmodel.api.dto.WeaviateQueryDTO;
import com.hnac.gglm.bigmodel.database.service.WeaviateService;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;
/**
* @Author: huangxing
* @Date: 2024/09/19 19:06
*/
@RestController
@AllArgsConstructor
public class WeaviatesClient implements IWeaviatesClient {
private final WeaviateService weaviateService;
@Override
@DeleteMapping(DELETE_BY_IDS)
public void deleteByIds(@RequestParam("ids") String ids, @RequestParam("className") String className) {
weaviateService.delete(ids,className);
}
@Override
@PostMapping(QUERY_LIST)
public R<Object> queryList(@RequestBody WeaviateQueryDTO query) {
return R.data(weaviateService.query(query.getResultFields(), query.getClassName(), query.getQuery()));
}
@Override
@PostMapping(SAVE_BATCH)
public R saveBatch(@RequestBody WeaviateInsertDTO insertDTO) {
return R.status(weaviateService.saveBatch(insertDTO.getEntities(), insertDTO.getClassName(), insertDTO.getAttrsMap()));
}
}

5
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java

@ -82,4 +82,9 @@ public class BigModelInvokeApi {
*/
private String createTable;
/**
*
*/
private String deleteTable;
}

6
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java

@ -1,5 +1,6 @@
package com.hnac.gglm.bigmodel.database.controller;
import com.hnac.gglm.bigmodel.api.dto.WeaviateQueryDTO;
import com.hnac.gglm.bigmodel.database.dto.WeaviateSaveDTO;
import com.hnac.gglm.bigmodel.database.service.WeaviateService;
import io.weaviate.client.v1.data.model.WeaviateObject;
@ -38,4 +39,9 @@ public class WeaviateController {
public R<Boolean> removeById(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) {
return R.status(weaviateService.delete(id,className));
}
@GetMapping("/query")
public R<Object> query(@RequestBody WeaviateQueryDTO query) {
return R.data(weaviateService.query(query.getResultFields(),query.getClassName(),query.getQuery()));
}
}

61
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java

@ -9,13 +9,22 @@ import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.configuration.BigModelInvokeApi;
import com.hnac.gglm.bigmodel.utils.RequestClientUtil;
import com.hnac.hzinfo.exception.HzServiceException;
import io.weaviate.client.Config;
import io.weaviate.client.WeaviateAuthClient;
import io.weaviate.client.WeaviateClient;
import io.weaviate.client.base.Result;
import io.weaviate.client.v1.auth.exception.AuthException;
import io.weaviate.client.v1.data.api.ObjectCreator;
import io.weaviate.client.v1.data.api.ObjectDeleter;
import io.weaviate.client.v1.data.api.ObjectUpdater;
import io.weaviate.client.v1.data.api.ObjectsGetter;
import io.weaviate.client.v1.data.model.WeaviateObject;
import io.weaviate.client.v1.filters.Operator;
import io.weaviate.client.v1.filters.WhereFilter;
import io.weaviate.client.v1.graphql.GraphQL;
import io.weaviate.client.v1.graphql.model.GraphQLResponse;
import io.weaviate.client.v1.graphql.query.Get;
import io.weaviate.client.v1.graphql.query.fields.Field;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.api.ResultCode;
@ -109,8 +118,14 @@ public class WeaviateService {
// }
public Boolean saveBatch(List entities,String className, Map<String,String> attrsMap) {
Map<String,String> createTableParams = new HashMap<>(1);
Map<java.lang.String,Object> createTableParams = new HashMap<>(2);
Map<String,String> deleteTableParams = new HashMap<>(1);
deleteTableParams.put("table_name",className);
createTableParams.put("table_name",className);
List<String> vectorStr = Lists.newArrayList();
attrsMap.keySet().forEach(key -> vectorStr.add(key));
createTableParams.put("vector_names",vectorStr.toArray(new String[vectorStr.size()]));
RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams);
RequestClientUtil.postCall(gglmUrl + invokeApi.getCreateTable(),createTableParams);
Map<String,Object> params = new HashMap<>(2);
params.put("table_name", className);
@ -296,4 +311,48 @@ public class WeaviateService {
}).collect(Collectors.toList());
return floats.toArray(new Float[floats.size()]);
}
/**
* 查询weaviate数据property数据
* @param resultFields 返回字段
* @param query 筛选条件 k-查询字段 v-查询值 目前仅支持String类型查询
* @return 查询结果
*/
public Object query(String resultFields,String className,Map<String,String> query) {
List<String> fieldList = Func.toStrList(",", resultFields);
Get get = weaviateClient.graphQL().get();
get.withClassName(className);
List<Field> fields = fieldList.stream().map(fieldStr -> Field.builder().name(fieldStr).build()).collect(Collectors.toList());
Field additionalId = Field.builder().name("_additional { id }").build();
fields.add(additionalId);
get.withFields(fields.toArray(new Field[fields.size()]));
if(Func.isNotEmpty(query)) {
List<WhereFilter> whereFilters = query.entrySet().stream().map(e -> WhereFilter.builder()
.path(e.getKey())
.operator(Operator.Equal)
.valueString(e.getValue())
.build()).collect(Collectors.toList());
whereFilters.forEach(where -> get.withWhere(where));
}
return get.run().getResult().getData();
}
// public static void main(String[] args) throws AuthException {
// Config config = new Config("http", "192.168.60.16:9992");
// WeaviateClient client = WeaviateAuthClient.apiKey(config, "123");
// Field itemName = Field.builder().name("item_name").build();
// Field itemId = Field.builder().name("item_id").build();
// Field additionalId = Field.builder().name("_additional { id }").build();
// WhereFilter where = WhereFilter.builder()
// .path(new String[]{ "item_name" })
// .operator(Operator.Equal)
// .valueString("湖北宜昌泵站")
// .build();
// Result<GraphQLResponse> result = client.graphQL().get()
// .withClassName("Hzn_lm_form_station")
// .withFields(itemName,itemId,additionalId)
// .withWhere(where)
// .run();
// System.out.println(JSON.toJSONString(result.getResult().getData()));
// }
}

5
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java

@ -20,4 +20,9 @@ public interface ParamKeyConstants {
/**视频巡检识别url**/
String VIDEO_INSPECTION_URL = "gglm:bigModel:video:inspection:url";
/**业务平台应用领域**/
String LIBRARY_AREA = "gglm:bigModel:library:area";
/**应用平台知识库权限等级**/
String LIBRARY_AUTH_LEVEL = "gglm:bigModel:library:authLevel";
}

17
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java

@ -1,9 +1,11 @@
package com.hnac.gglm.bigmodel.interactive.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.BigModelConstants;
import com.hnac.gglm.bigmodel.business.service.DataSourceService;
import com.hnac.gglm.bigmodel.business.vo.SqlVO;
import com.hnac.gglm.bigmodel.interactive.constants.ParamKeyConstants;
import com.hnac.gglm.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.gglm.bigmodel.interactive.dto.ControlDTO;
import com.hnac.gglm.bigmodel.interactive.req.ModelFunctionReq;
@ -14,11 +16,16 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.ParamCache;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* @Author: huangxing
@ -32,6 +39,7 @@ public class HznlmInteractiveController {
private final IHznlmInteractiveService interactiveService;
private final DataSourceService dataSourceService;
private final RedisTemplate redisTemplate;
@PostMapping(value = "/get_auth_data")
@ApiOperation("获取鉴权数据")
@ -60,4 +68,13 @@ public class HznlmInteractiveController {
public R<ExtraVO> controlDevice(@RequestBody @Valid ControlDTO req) {
return R.data(interactiveService.controlDevice(req));
}
@PostMapping("/knowledge_auth")
@ApiOperation("知识库鉴权")
@ApiOperationSupport(order = 5)
public R knowledgeAuth(@RequestBody AuthDataDTO req) {
return R.data(interactiveService.knowledgeAuth(req));
}
}

8
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
/**
* @Author: huangxing
@ -23,4 +24,11 @@ public interface IHznlmInteractiveService {
ExtraVO controlDevice(ControlDTO req);
/**
* 获取知识库鉴权
* @param req 请求参数
* @return 鉴权数据
*/
Map<String,Object> knowledgeAuth(AuthDataDTO req);
}

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java

@ -1,10 +1,12 @@
package com.hnac.gglm.bigmodel.interactive.service.impl;
import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.business.dto.ControlDeviceAuthDTO;
import com.hnac.gglm.bigmodel.business.feign.IAuthClient;
import com.hnac.gglm.bigmodel.business.service.AuthenticationService;
import com.hnac.gglm.bigmodel.interactive.constants.DataAuthTypeEnum;
import com.hnac.gglm.bigmodel.interactive.constants.FuncRouteEnum;
import com.hnac.gglm.bigmodel.interactive.constants.ParamKeyConstants;
import com.hnac.gglm.bigmodel.interactive.dto.AuthDataDTO;
import com.hnac.gglm.bigmodel.interactive.dto.ControlDTO;
import com.hnac.gglm.bigmodel.interactive.factory.ResolveFactory;
@ -19,6 +21,7 @@ import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.ParamCache;
import org.springblade.system.dto.DeptStationDTO;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
@ -80,6 +83,16 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
return result;
}
@Override
public Map<String, Object> knowledgeAuth(AuthDataDTO req) {
String areaAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AREA);
String levelAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AUTH_LEVEL);
Map<String,Object> result = new HashMap<>();
result.put("areaAuth", Optional.ofNullable(areaAuth).map(auth -> Func.toStrList(",",auth)).orElse(Lists.newArrayList()));
result.put("levelAuth",Optional.ofNullable(levelAuth).map(Integer::valueOf).orElse(0));
return result;
}
public List<AuthDataVO> getDeptAuthData(String userId) {
List<DeptStationDTO> deptStationDTOs = authenticationService.getStationPermissionsById(userId);
return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList());

1
hzims-service/gglm-big-model/src/main/resources/template/template.yml

@ -67,6 +67,7 @@ gglm:
identifyForm: "/custom/auto_form"
insertVectors: "/vector/insert_vectors"
createTable: "/vector/create_table"
deleteTable: "/vector/delete_table"
swagger:
base-packages: com.hnac.hzims.bigmodel

39
hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java

@ -2,11 +2,15 @@ package com.hnac.hzims.operational.access.feign;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.operational.access.constants.AccessConstants;
import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO;
import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity;
import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.operational.access.service.IOperAccessTaskDetailService;
import com.hnac.hzims.operational.access.service.IOperAccessTaskService;
import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity;
import com.hnac.hzims.operational.defect.service.IOperPhenomenonService;
@ -32,14 +36,13 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -52,6 +55,7 @@ import java.util.stream.Collectors;
public class OperAccessTaskClient implements IOperAccessTaskClient, IAccessTaskClient {
private final IOperAccessTaskService taskService;
private final IOperAccessTaskDetailService taskDetailService;
private final IOperPhenomenonService phenomenonService;
private final IFlowClient flowClient;
private final RedisTemplate redisTemplate;
@ -108,6 +112,33 @@ public class OperAccessTaskClient implements IOperAccessTaskClient, IAccessTaskC
return taskService.finishAccessTask(accessTaskDTO);
}
@Override
@GetMapping("/getAccessTaskOverview")
public R<List<String>> getAccessTaskOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode) {
LambdaQueryWrapper<OperAccessTaskEntity> queryWrapper = Wrappers.<OperAccessTaskEntity>lambdaQuery()
.eq(OperAccessTaskEntity::getEmCode, emCode)
.like(OperAccessTaskEntity::getPlanStartTime, date);
List<OperAccessTaskEntity> accessTaskList = taskService.list(queryWrapper);
String overviewTemplate = "%s于%s对%s执行了检修任务,耗时%02d小时,检修内容为%s";
// 形成概述列表
if(CollectionUtil.isNotEmpty(accessTaskList)) {
List<String> overviewList = accessTaskList.stream().map(task -> {
List<OperAccessTaskDetailEntity> detailEntityList = taskDetailService.list(Wrappers.<OperAccessTaskDetailEntity>lambdaQuery().eq(OperAccessTaskDetailEntity::getTaskId, task.getId()));
if (Func.isEmpty(detailEntityList)) {
return null;
}
String details = detailEntityList.stream().map(OperAccessTaskDetailEntity::getContent).collect(Collectors.joining(","));
// 确保日期格式一致
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String formattedDate = sdf.format(task.getPlanStartTime());
String overview = String.format(overviewTemplate, task.getCreateUserName(), formattedDate, task.getEmName(), task.getActHours(), details);
return overview;
}).filter(Func::isNotEmpty).collect(Collectors.toList());
return R.data(overviewList);
}
return R.data(null);
}
@Override
@GetMapping("/billing")

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

@ -12,6 +12,7 @@ import com.hnac.hzims.operational.station.entity.StationEntity;
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.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/station")
@ -206,4 +208,12 @@ public class StationController extends BladeController {
public R instanceFdpStation(@RequestBody StationEntity req) {
return R.status(stationService.instanceFdpStation(req));
}
@GetMapping("/getAllList")
@ApiOperationSupport(order = 13)
@ApiOperation(value = "获取所有站点", notes = "获取所有站点")
@ApiInterface
public R<List<Map>> getAllList() {
return R.data(stationService.getAllList());
}
}

7
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java

@ -13,6 +13,7 @@ import org.apache.ibatis.annotations.Param;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
import java.util.List;
import java.util.Map;
public interface StationMapper extends UserDataScopeBaseMapper<StationEntity> {
/**
@ -291,4 +292,10 @@ public interface StationMapper extends UserDataScopeBaseMapper<StationEntity> {
* @return 排序最大值
*/
Integer getMaxSort();
/**
* 获取所有站点列表
* @return 站点列表
*/
List<Map> getAllList();
}

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml

@ -467,4 +467,7 @@
<select id="getMaxSort" resultType="java.lang.Integer">
select max(`sort`) from `hzims_station` where `is_deleted` = 0
</select>
<select id="getAllList" resultType="java.util.Map">
select `id` station_id,`ref_dept`,`code` item_id,`name` item_name from `hzims_station` where `is_deleted` = 0
</select>
</mapper>

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

@ -142,4 +142,6 @@ public interface IStationService extends IService<StationEntity> {
List<HomeMapStationVo> homeMapStationVo();
List<StationVO> stations(StationEntity entity);
List<Map> getAllList();
}

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

@ -861,4 +861,9 @@ public class StationServiceImpl extends ServiceImpl<StationMapper, StationEntity
}
return StationWrapper.builder().listVO(stations);
}
@Override
public List<Map> getAllList() {
return this.baseMapper.getAllList();
}
}

17
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java

@ -293,4 +293,21 @@ public class TicketInfoClient implements ITicketInfoClient {
return R.data(vo);
}
@Override
@GetMapping(GET_WORK_TICKET_OVERVIEW)
public R<List<String>> getWorkTicketOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode) {
LambdaQueryWrapper<WorkTicketInfoEntity> queryWrapper = Wrappers.<WorkTicketInfoEntity>lambdaQuery()
.eq(WorkTicketInfoEntity::getEmCode, emCode).like(WorkTicketInfoEntity::getPlanStartTime, date);
List<WorkTicketInfoEntity> workTicketList = infoService.list(queryWrapper);
String overviewTemplate = "%s在%s为%s设备开具了一张工作票,工作内容为%s。";
if(Func.isNotEmpty(workTicketList)) {
List<String> overviewList = workTicketList.stream().map(workTicketInfo -> {
String startTime = workTicketInfo.getPlanStartTime().format(DateUtil.DATETIME_FORMATTER);
return String.format(overviewTemplate, workTicketInfo.getCreateUserName(), startTime, workTicketInfo.getEmName(), workTicketInfo.getWorkContent());
}).collect(Collectors.toList());
return R.data(overviewList);
}
return null;
}
}

Loading…
Cancel
Save