diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/feign/IDefectStatisticClient.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/feign/IDefectStatisticClient.java new file mode 100644 index 0000000..6c6aeb2 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/feign/IDefectStatisticClient.java @@ -0,0 +1,30 @@ +package com.hnac.hzims.operational.defect.feign; + +import com.hnac.hzims.operational.OperationalConstants; +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.RequestParam; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/09/21 16:32 + */ +@FeignClient(OperationalConstants.APP_NAME) +public interface IDefectStatisticClient { + + String PREFIX_API = "/feign/defect_statistic"; + String GET_DEFECT_OVERVIEW = PREFIX_API + "/getDefectOverview"; + + /** + * 获取缺陷概览 + * @param date 日期 + * @param emCode 设备编码 + * @return 缺陷概览 + */ + @GetMapping(GET_DEFECT_OVERVIEW) + R> getDefectOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode); + +} 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 5403dfb..31d2369 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 @@ -21,6 +21,7 @@ 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.defect.feign.IDefectStatisticClient; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -133,6 +134,9 @@ public class EmInfoServiceImpl extends ServiceImpl i @Autowired private ITicketInfoClient ticketInfoClient; + @Autowired + private IDefectStatisticClient defectStatisticClient; + @Value("${hzims.equipment.emInfo.code}") public String deviceCodePath; @@ -1074,7 +1078,6 @@ public class EmInfoServiceImpl extends ServiceImpl i 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("获取设备台账失败!"); @@ -1098,6 +1101,16 @@ public class EmInfoServiceImpl extends ServiceImpl i }).collect(Collectors.toList()); result.addAll(deviceLedgerVOList); } + R> defectOverview = defectStatisticClient.getDefectOverview(date, emInfo.getNumber()); + if(Func.isNotEmpty(defectOverview.getData())) { + List deviceLedgerVOList = defectOverview.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/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 745a53d..2ba6d18 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 @@ -118,15 +118,19 @@ public class WeaviateService { // } public Boolean saveBatch(List entities,String className, Map attrsMap) { - 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); + // 查询Weaviate 4.7.0表是否存在 若不存则新建表 + Result existResult = weaviateClient.schema().exists().withClassName("Hzn_lm_" + className).run(); + if(existResult.hasErrors() || !existResult.getResult()) { + 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); List> data = new ArrayList<>(); @@ -171,20 +175,22 @@ public class WeaviateService { * @return 删除结果 */ public Boolean delete(String ids,String className) { - ObjectDeleter deleter = weaviateClient.data().deleter(); - deleter.withClassName(className); - if(Func.isEmpty(ids)) { - Result> allObject = weaviateClient.data().objectsGetter().withClassName(className).withLimit(10000).run(); - if(!allObject.hasErrors()) { - ids = allObject.getResult().stream().map(WeaviateObject::getId).collect(Collectors.joining(",")); - } + if(Func.isEmpty(ids) && Func.isNotEmpty(className)) { + // 删除className + Map deleteTableParams = new HashMap<>(1); + deleteTableParams.put("table_name",className); + RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams); + } else { + // 删除记录 + ObjectDeleter deleter = weaviateClient.data().deleter(); + deleter.withClassName(className); + Func.toStrList(",",ids).forEach(id -> { + Result result = deleter.withID(id).run(); + if(result.hasErrors()) { + throw new HzServiceException(ResultCode.FAILURE,id + "记录删除失败!"); + } + }); } - Func.toStrList(",",ids).forEach(id -> { - Result result = deleter.withID(id).run(); - if(result.hasErrors()) { - throw new HzServiceException(ResultCode.FAILURE,id + "记录删除失败!"); - } - }); return true; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java index fb33e07..9ab80ef 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java +++ b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; import com.hnac.gglm.bigmodel.interactive.constants.ParamKeyConstants; import java.util.HashMap; +import java.util.Map; /** * @Author: huangxing @@ -56,6 +57,11 @@ public class ControlAnswerResolveServiceImpl implements IAnswerResolveService { log.info("机器人巡检传参为:{}", JSON.toJSONString(param)); String body = HttpRequest.post("http://192.168.60.29:8080/api/hzinfo-inspect/plan/initiateRobotPlan").body(JSON.toJSONString(param)).execute().body(); log.info("结果为:{}",body); + ExtraVO result = originExtra.toJavaObject(ExtraVO.class); + result.setType(FunctionConstants.TypeEnum.PARAMS.getType()); + Map extraParams = new HashMap<>(); + extraParams.put("name","查看巡检任务"); + result.setParams(extraParams); } } ExtraVO result = originExtra.toJavaObject(ExtraVO.class); diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/CreateTaskController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/CreateTaskController.java index f6c8258..b26a923 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/CreateTaskController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/CreateTaskController.java @@ -3,15 +3,13 @@ package com.hnac.hzinfo.inspect.task.controller; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzinfo.inspect.request.GenerateTaskVO; import com.hnac.hzinfo.inspect.task.service.ICreateTaskService; +import com.hnac.hzinfo.inspect.task.service.impl.FileUploaderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @ClassName CreateTaskController @@ -27,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController; public class CreateTaskController extends BladeController { private final ICreateTaskService createTaskService; + private final FileUploaderService uploaderService; @PostMapping("/createShowTask") @ApiOperation("生成演示数据") @@ -36,4 +35,9 @@ public class CreateTaskController extends BladeController { return R.success("成功!"); } + @GetMapping("/test") + public R test(@RequestParam String url, @RequestParam String fileName) { + return R.data(uploaderService.upload(url,fileName)); + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/DefectStatisticClient.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/DefectStatisticClient.java new file mode 100644 index 0000000..6e958d1 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/feign/DefectStatisticClient.java @@ -0,0 +1,54 @@ +package com.hnac.hzims.operational.defect.feign; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; +import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService; +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.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: huangxing + * @Date: 2024/09/21 16:38 + */ +@RestController +@AllArgsConstructor +public class DefectStatisticClient implements IDefectStatisticClient { + + private final IOperDefectStatisticsService defectStatisticsService; + + @Override + @GetMapping(GET_DEFECT_OVERVIEW) + public R> getDefectOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode) { + // 查询缺陷列表 + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery() + .eq(OperDefectStatisticsEntity::getEmCode, emCode) + .like(OperDefectStatisticsEntity::getFindTime, date) + .eq(OperDefectStatisticsEntity::getIsDefect, 1) + .isNotNull(OperDefectStatisticsEntity::getConclusion); + List defectStatisticsEntities = defectStatisticsService.list(queryWrapper); + String overviewTemplate = "%s于%s在%s设备上发现一例%s缺陷,经过详细的分析与测试,最终定论结果为%s"; + if(Func.isNotEmpty(defectStatisticsEntities)) { + List overviewList = defectStatisticsEntities.stream().map(defect -> { + String finderName = defect.getFinderName(); + String findTime = DateUtil.formatDateTime(defect.getFindTime()); + String emName = defect.getName(); + String defectName = defect.getFaultName(); + String conclusion = defect.getConclusion(); + return String.format(overviewTemplate, finderName, findTime, emName, defectName, conclusion); + }).collect(Collectors.toList()); + return R.data(overviewList); + } + return R.data(Lists.newArrayList()); + } + +}