diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java index 9781542a..53de4ff3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/controller/ComplexQueryController.java @@ -59,6 +59,17 @@ public class ComplexQueryController extends BaseController { return AjaxResult.success(complexQueryService.getToolsLedgerList(bean)); } + /** + * 工器具台账详情--APP + * @param bean + * @return + */ + @ApiOperation(value = "工器具台账详情查询") + @GetMapping("/getToolsLedgerDetailsList") + public AjaxResult getToolsLedgerDetailsList(RetainedEquipmentInfo bean) { + return AjaxResult.success(complexQueryService.getToolsLedgerDetailsList(bean)); + } + /** * 保有设备总量查询不带分页 * @param bean diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/RetainedEquipmentInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/RetainedEquipmentInfo.java index caf1766b..eeb830f9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/RetainedEquipmentInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/domain/RetainedEquipmentInfo.java @@ -160,6 +160,21 @@ public class RetainedEquipmentInfo { private List modelList; + /** + * 是否伸展(APP) + */ private boolean expanded = false; + /** + * 编码 + */ + private String maCode; + /** + * 下次检验时间 + */ + private String nextCheckTime; + /** + * 检验状态 + */ + private String checkStatus; } \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java index f667d6b0..0c698797 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/mapper/ComplexQueryMapper.java @@ -152,4 +152,11 @@ public interface ComplexQueryMapper { * @return */ List getToolsLedgerList(RetainedEquipmentInfo bean); + + /** + * 工器具台账详情查询 + * @param bean + * @return + */ + List getToolsLedgerDetailsList(RetainedEquipmentInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java index 39184872..514b311d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/ComplexQueryService.java @@ -116,4 +116,11 @@ public interface ComplexQueryService { * @return */ List getToolsLedgerList(RetainedEquipmentInfo bean); + + /** + * 工器具台账详情查询 + * @param bean + * @return + */ + List getToolsLedgerDetailsList(RetainedEquipmentInfo bean); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java index dde40803..6dda1b3e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/basic/service/impl/ComplexQueryServiceImpl.java @@ -9,12 +9,18 @@ import com.bonus.material.basic.domain.vo.MaTypeSelectInfo; import com.bonus.material.basic.mapper.ComplexQueryMapper; import com.bonus.material.basic.service.ComplexQueryService; import lombok.extern.slf4j.Slf4j; +import org.hibernate.validator.internal.util.StringHelper; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -527,6 +533,31 @@ public class ComplexQueryServiceImpl implements ComplexQueryService { } } + @Override + public List getToolsLedgerDetailsList(RetainedEquipmentInfo bean) { + List list =new ArrayList<>(); + try { + list = complexQueryMapper.getToolsLedgerDetailsList(bean); + if (list.size() > 0) { + for (RetainedEquipmentInfo bean1 : list) { + if (!StringHelper.isNullOrEmptyString(bean1.getNextCheckTime())){ + //时间数据处理 + bean1.setCheckStatus(determineCheckStatus(bean1.getNextCheckTime()));; + } else { + bean1.setCheckStatus(""); + } + } + } + return list; + } catch (Exception e){ + log.error("获取设备详情列表失败,参数:{}", bean, e); + return new ArrayList<>(); + } + } + + /** + * 数据格式处理 + */ public List groupByThirdTypeId(List dbList) { // 按thirdTypeId分组,同时保留typeName Map> groupedMap = dbList.stream() @@ -542,7 +573,8 @@ public class ComplexQueryServiceImpl implements ComplexQueryService { if (!items.isEmpty()) { RetainedEquipmentInfo category = new RetainedEquipmentInfo(); category.setThirdTypeId(thirdTypeId); - category.setTypeName(items.get(0).getTypeName()); // 取第一个元素的typeName + // 取第一个元素的typeName + category.setTypeName(items.get(0).getTypeName()); List specs = items.stream() .map(item -> { @@ -552,6 +584,7 @@ public class ComplexQueryServiceImpl implements ComplexQueryService { spec.setBuyPrice(item.getBuyPrice()); spec.setStoreNum(item.getStoreNum()); spec.setManageType(item.getManageType()); + spec.setTypeId(item.getTypeId()); return spec; }) .collect(Collectors.toList()); @@ -563,4 +596,35 @@ public class ComplexQueryServiceImpl implements ComplexQueryService { return result; } + + /** + * 根据 nextCheckTime 判断检测状态 + */ + private String determineCheckStatus(String nextCheckTimeStr) { + try { + // 当前日期 + LocalDate now = LocalDate.now(); + // 解析 yyyy-MM-dd HH:mm:ss 格式的字符串,并提取日期部分(yyyy-MM-dd) + LocalDateTime nextCheckDateTime = LocalDateTime.parse(nextCheckTimeStr, + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + LocalDate nextCheckDate = nextCheckDateTime.toLocalDate(); + // 计算日期差(now -> nextCheckDate) + long daysBetween = ChronoUnit.DAYS.between(now, nextCheckDate); + if (daysBetween > 90) { + return "正常"; + } else if (daysBetween > 30) { + return "三月内检测到期"; + } else if (daysBetween > 0) { + return "一月内检测到期"; + } else { + return "已过期"; + } + } catch (DateTimeParseException e) { + log.warn("日期格式错误:{}", nextCheckTimeStr, e); + return ""; + } catch (Exception e) { + log.warn("未知错误解析日期:{}", nextCheckTimeStr, e); + return ""; + } + } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml index 008300f3..13a4f304 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml @@ -1182,4 +1182,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mt2.type_id is not null + +