工器具台账

This commit is contained in:
hayu 2025-06-06 14:19:37 +08:00
parent f36d85dc1e
commit cac137011a
6 changed files with 121 additions and 1 deletions

View File

@ -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

View File

@ -160,6 +160,21 @@ public class RetainedEquipmentInfo {
private List<RetainedEquipmentInfo> modelList;
/**
* 是否伸展APP
*/
private boolean expanded = false;
/**
* 编码
*/
private String maCode;
/**
* 下次检验时间
*/
private String nextCheckTime;
/**
* 检验状态
*/
private String checkStatus;
}

View File

@ -152,4 +152,11 @@ public interface ComplexQueryMapper {
* @return
*/
List<RetainedEquipmentInfo> getToolsLedgerList(RetainedEquipmentInfo bean);
/**
* 工器具台账详情查询
* @param bean
* @return
*/
List<RetainedEquipmentInfo> getToolsLedgerDetailsList(RetainedEquipmentInfo bean);
}

View File

@ -116,4 +116,11 @@ public interface ComplexQueryService {
* @return
*/
List<RetainedEquipmentInfo> getToolsLedgerList(RetainedEquipmentInfo bean);
/**
* 工器具台账详情查询
* @param bean
* @return
*/
List<RetainedEquipmentInfo> getToolsLedgerDetailsList(RetainedEquipmentInfo bean);
}

View File

@ -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<RetainedEquipmentInfo> getToolsLedgerDetailsList(RetainedEquipmentInfo bean) {
List<RetainedEquipmentInfo> 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<RetainedEquipmentInfo> groupByThirdTypeId(List<RetainedEquipmentInfo> dbList) {
// 按thirdTypeId分组同时保留typeName
Map<Integer, List<RetainedEquipmentInfo>> 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<RetainedEquipmentInfo> 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 "";
}
}
}

View File

@ -1182,4 +1182,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and mt2.type_id is not null
</select>
<select id="getToolsLedgerDetailsList" resultType="com.bonus.material.basic.domain.RetainedEquipmentInfo">
SELECT
mt1.type_id as typeId,
mt2.type_name as typeName,
mt1.type_name as typeModelName,
mm.ma_code as maCode,
mm.next_check_time as nextCheckTime
FROM
ma_machine mm
LEFT JOIN ma_type mt1 on mt1.type_id=mm.type_id and mt1.del_flag=0
LEFT JOIN ma_type mt2 on mt2.type_id=mt1.parent_id and mt2.del_flag=0
WHERE
mm.type_id=#{typeId}
and mm.ma_status='1'
</select>
</mapper>