diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateInsertDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateInsertDTO.java new file mode 100644 index 0000000..c260115 --- /dev/null +++ b/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 attrsMap; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateQueryDTO.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/dto/WeaviateQueryDTO.java new file mode 100644 index 0000000..e1b84fd --- /dev/null +++ b/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 query; + +} diff --git a/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IWeaviatesClient.java b/hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/api/feign/IWeaviatesClient.java new file mode 100644 index 0000000..1afb7d2 --- /dev/null +++ b/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 queryList(@RequestBody WeaviateQueryDTO query); + + /** + * 批量保存 + * @param insertDTO 插入数据 + * @return 是否成功 + */ + @PostMapping(SAVE_BATCH) + R saveBatch(@RequestBody WeaviateInsertDTO insertDTO); + +} diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/ScheduledConstant.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/ScheduledConstant.java index 158ff26..c42035c 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/fdp/constants/ScheduledConstant.java +++ b/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"; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java index c404380..f898855 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/AccessTaskClientFallback.java +++ b/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> getAccessTaskOverview(String date, String emCode) { + return R.fail("获取检修任务概述失败!"); + } } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IOperAccessTaskClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IOperAccessTaskClient.java index b762a37..b8d954f 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/feign/IOperAccessTaskClient.java +++ b/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> getAccessTaskOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode); + } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java index 725db6c..06b7384 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/ITicketInfoClient.java +++ b/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 getWorkTicketCheck(@RequestParam(value = "startDate") String startDate, @RequestParam(value = "endDate") String endDate, @RequestParam(value = "dept") Long dept); + + @GetMapping(GET_WORK_TICKET_OVERVIEW) + R> getWorkTicketOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode); } diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java index bc833cf..95ea66e 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClientFallback.java +++ b/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> getWorkTicketOverview(String date, String emCode) { + return R.fail("查询失败!"); + } + } diff --git a/hzims-service/equipment/pom.xml b/hzims-service/equipment/pom.xml index b198c7b..639b25b 100644 --- a/hzims-service/equipment/pom.xml +++ b/hzims-service/equipment/pom.xml @@ -77,6 +77,10 @@ org.apache.commons commons-collections4 + + com.hnac.hzims + big-model-api + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java new file mode 100644 index 0000000..6ed8ea2 --- /dev/null +++ b/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 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 deviceLedgerList = emInfoService.getDeviceLedgerList(emCode, date); + // 向量库查询该设备的所有数据 + WeaviateQueryDTO query = new WeaviateQueryDTO(); + Map 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 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 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 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"); + } + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index cc2d5f4..c9b2978 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -103,4 +103,6 @@ public interface IEmInfoService extends IService { List rideDevices(List deptIds); List getStationEmList(); + + List getDeviceLedgerList(String emCode,String date); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index 1982eef..5403dfb 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/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 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 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 i return result; } + @Override + public List getDeviceLedgerList(String emCode, String date) { + // 若emCode为空,则查询出所有设备形成一个list + List emInfoList = new ArrayList<>(); + if(Func.isNotEmpty(emCode)){ + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery().eq(EmInfoEntity::getNumber, emCode); + EmInfoEntity emInfoEntity = this.getOne(queryWrapper); + if(Func.isEmpty(emInfoEntity)) { + throw new HzServiceException("查询设备失败!"); + } + emInfoList.add(emInfoEntity); + }else{ + List emInfos = this.list(); + if(Func.isEmpty(emInfos)) { + throw new HzServiceException("暂无设备数据"); + } + emInfoList.addAll(emInfos); + } + // 获取站点列表 + R> 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 getDeviceLedgerListByEmCode(EmInfoEntity emInfo, String date, List stationList) { + List result = new ArrayList<>(); + Optional 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> accessTaskOverview = accessTaskClient.getAccessTaskOverview(date, emInfo.getNumber()); + if(!accessTaskOverview.isSuccess()) { + throw new HzServiceException("获取设备台账失败!"); + } + if(Func.isNotEmpty(accessTaskOverview.getData())) { + List 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> workTicketOverview = ticketInfoClient.getWorkTicketOverview(date, emInfo.getNumber()); + if(Func.isNotEmpty(workTicketOverview.getData())) { + List 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; + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/DeviceLedgerVO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/DeviceLedgerVO.java new file mode 100644 index 0000000..fc7cb57 --- /dev/null +++ b/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; + +} diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java index 9ec4688..5824e4a 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java +++ b/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; diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/api/feign/WeaviatesClient.java new file mode 100644 index 0000000..bacaf79 --- /dev/null +++ b/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 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())); + } +} diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java index 2695c5c..dbeed23 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java +++ b/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; + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java index 2b1a90d..108a655 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/controller/WeaviateController.java +++ b/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 removeById(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { return R.status(weaviateService.delete(id,className)); } + + @GetMapping("/query") + public R query(@RequestBody WeaviateQueryDTO query) { + return R.data(weaviateService.query(query.getResultFields(),query.getClassName(),query.getQuery())); + } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java index ae56587..4a8afcf 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java +++ b/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 attrsMap) { - Map createTableParams = new HashMap<>(1); + Map createTableParams = new HashMap<>(2); + Map deleteTableParams = new HashMap<>(1); + deleteTableParams.put("table_name",className); createTableParams.put("table_name",className); + List 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 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 query) { + List fieldList = Func.toStrList(",", resultFields); + Get get = weaviateClient.graphQL().get(); + get.withClassName(className); + List 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 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 result = client.graphQL().get() +// .withClassName("Hzn_lm_form_station") +// .withFields(itemName,itemId,additionalId) +// .withWhere(where) +// .run(); +// System.out.println(JSON.toJSONString(result.getResult().getData())); +// } } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java index ac6d666..c1d960c 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/constants/ParamKeyConstants.java +++ b/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"; + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java index 78649ee..6201655 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/HznlmInteractiveController.java +++ b/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 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)); + } + + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java index 0392499..f87eea0 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInteractiveService.java +++ b/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 knowledgeAuth(AuthDataDTO req); + } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java index f78f897..9712d09 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java +++ b/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 knowledgeAuth(AuthDataDTO req) { + String areaAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AREA); + String levelAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AUTH_LEVEL); + Map 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 getDeptAuthData(String userId) { List deptStationDTOs = authenticationService.getStationPermissionsById(userId); return deptStationDTOs.stream().map(this::convertDeptAuthData).collect(Collectors.toList()); diff --git a/hzims-service/gglm-big-model/src/main/resources/template/template.yml b/hzims-service/gglm-big-model/src/main/resources/template/template.yml index e56ec85..745470a 100644 --- a/hzims-service/gglm-big-model/src/main/resources/template/template.yml +++ b/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 diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java index 35066e4..a526cd8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/feign/OperAccessTaskClient.java +++ b/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> getAccessTaskOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(OperAccessTaskEntity::getEmCode, emCode) + .like(OperAccessTaskEntity::getPlanStartTime, date); + List accessTaskList = taskService.list(queryWrapper); + String overviewTemplate = "%s于%s对%s执行了检修任务,耗时%02d小时,检修内容为%s"; + // 形成概述列表 + if(CollectionUtil.isNotEmpty(accessTaskList)) { + List overviewList = accessTaskList.stream().map(task -> { + List detailEntityList = taskDetailService.list(Wrappers.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") diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java index e4b98b2..a69faeb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationController.java +++ b/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> getAllList() { + return R.data(stationService.getAllList()); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java index a21772e..95e025e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.java +++ b/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 { /** @@ -291,4 +292,10 @@ public interface StationMapper extends UserDataScopeBaseMapper { * @return 排序最大值 */ Integer getMaxSort(); + + /** + * 获取所有站点列表 + * @return 站点列表 + */ + List getAllList(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml index a2089a1..a9f030d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/mapper/StationMapper.xml @@ -467,4 +467,7 @@ + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java index 25cf102..a928802 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationService.java @@ -142,4 +142,6 @@ public interface IStationService extends IService { List homeMapStationVo(); List stations(StationEntity entity); + + List getAllList(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 332e01e..f2492f2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -861,4 +861,9 @@ public class StationServiceImpl extends ServiceImpl getAllList() { + return this.baseMapper.getAllList(); + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java index b1efde8..977fe88 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/feign/TicketInfoClient.java +++ b/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> getWorkTicketOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(WorkTicketInfoEntity::getEmCode, emCode).like(WorkTicketInfoEntity::getPlanStartTime, date); + List workTicketList = infoService.list(queryWrapper); + String overviewTemplate = "%s在%s为%s设备开具了一张工作票,工作内容为%s。"; + if(Func.isNotEmpty(workTicketList)) { + List 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; + } + }