haungxing
2 months ago
6 changed files with 140 additions and 27 deletions
@ -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<List<String>> getDefectOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode); |
||||||
|
|
||||||
|
} |
@ -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<List<String>> getDefectOverview(@RequestParam("date") String date, @RequestParam("emCode") String emCode) { |
||||||
|
// 查询缺陷列表
|
||||||
|
LambdaQueryWrapper<OperDefectStatisticsEntity> queryWrapper = Wrappers.<OperDefectStatisticsEntity>lambdaQuery() |
||||||
|
.eq(OperDefectStatisticsEntity::getEmCode, emCode) |
||||||
|
.like(OperDefectStatisticsEntity::getFindTime, date) |
||||||
|
.eq(OperDefectStatisticsEntity::getIsDefect, 1) |
||||||
|
.isNotNull(OperDefectStatisticsEntity::getConclusion); |
||||||
|
List<OperDefectStatisticsEntity> defectStatisticsEntities = defectStatisticsService.list(queryWrapper); |
||||||
|
String overviewTemplate = "%s于%s在%s设备上发现一例%s缺陷,经过详细的分析与测试,最终定论结果为%s"; |
||||||
|
if(Func.isNotEmpty(defectStatisticsEntities)) { |
||||||
|
List<String> 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()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue