Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -128,13 +128,12 @@ public class SimulationDemandController {
|
||||
|
||||
/**
|
||||
* 给 MES系统使用 查询是否开模件的待办列表
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryTodoList")
|
||||
@Operation(summary = "条件查询待办(需求)列表", description = "条件查询待办(需求)列表")
|
||||
public SdmResponse queryTodoList(@RequestBody DemandQryReq req) {
|
||||
return demandService.queryTodoList(req);
|
||||
public SdmResponse queryTodoList(@RequestParam String isMoldMaking) {
|
||||
return demandService.queryTodoList(isMoldMaking);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface SimulationDemandMapper extends BaseMapper<SimulationDemand> {
|
||||
|
||||
Set<String> getAllCodeList();
|
||||
|
||||
List<SpdmDemandVo> getDemandListWithCondition(@Param("req") DemandQryReq req);
|
||||
List<SpdmDemandVo> getDemandListWithCondition(@Param("isMoldMaking") String isMoldMaking);
|
||||
|
||||
List<SpdmDemandVo> getDemandListByProjectId(@Param("nodeId") String nodeId);
|
||||
|
||||
|
||||
@@ -8,8 +8,5 @@ public class DemandQryReq {
|
||||
* 是否开模件 Y/N
|
||||
*/
|
||||
private String isMoldMaking;
|
||||
/**
|
||||
* 物料号
|
||||
*/
|
||||
private String materialNo;
|
||||
|
||||
}
|
||||
|
||||
@@ -178,6 +178,10 @@ public class SpdmDemandVo extends BaseEntity {
|
||||
* 物料号
|
||||
*/
|
||||
private String materialNo;
|
||||
/**
|
||||
* 是否开模件
|
||||
*/
|
||||
private String isMoldMaking;
|
||||
/**
|
||||
* 需求附件id列表
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface IDemandService {
|
||||
|
||||
SdmResponse<PageDataResp<List<FileMetadataInfoResp>>> queryDemandFiles(QueryDirReq req);
|
||||
|
||||
SdmResponse queryTodoList(DemandQryReq req);
|
||||
SdmResponse queryTodoList(String isMoldMaking);
|
||||
|
||||
SdmResponse addDemandNoPermission(SpdmAddDemandReq req);
|
||||
|
||||
|
||||
@@ -1250,8 +1250,8 @@ public class DemandServiceImpl extends BaseService implements IDemandService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SdmResponse queryTodoList(DemandQryReq req) {
|
||||
List<SpdmDemandVo> demandVoList = mapper.getDemandListWithCondition(req);
|
||||
public SdmResponse queryTodoList(String isMoldMaking) {
|
||||
List<SpdmDemandVo> demandVoList = mapper.getDemandListWithCondition(isMoldMaking);
|
||||
if (CollectionUtils.isNotEmpty(demandVoList)) {
|
||||
for (SpdmDemandVo demandVo : demandVoList) {
|
||||
QueryDirReq dirReq = new QueryDirReq();
|
||||
|
||||
@@ -70,6 +70,7 @@ import java.lang.reflect.Field;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -208,6 +209,10 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
2017166413785972755L, 2017166413785972758L, 2017166413785972774L, 2017166413785972780L, 2017166417586012738L,
|
||||
2017166417586012737L);
|
||||
|
||||
// 通过标识判断是否走查询现场视图逻辑(0不查询,1查询)
|
||||
@Value("${lyricFlag:1}")
|
||||
private int lyricFlag;
|
||||
|
||||
/**
|
||||
* 判断字符串是否可以安全转换为Long类型
|
||||
*
|
||||
@@ -2161,12 +2166,161 @@ public class LyricInternalServiceImpl implements ILyricInternalService {
|
||||
spdmNodeVo.setCreatorObj(userMap.get(creator));
|
||||
}
|
||||
}
|
||||
// 将当前阶段放到项目对象中返回
|
||||
setCurrentPhase(nodeList);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("data", nodeList);
|
||||
jsonObject.put("total", total);
|
||||
return SdmResponse.success(jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置项目当前阶段信息
|
||||
* @param nodeList
|
||||
*/
|
||||
public void setCurrentPhase(List<SpdmNodeVo> nodeList) {
|
||||
// 过滤出自建和EP的项目
|
||||
// EP类型项目
|
||||
List<SpdmNodeVo> epProjectNodeList = nodeList.stream().filter(node -> SYNC_PROJECT_SOURCE.equals(node.getProjectSource())).toList();
|
||||
// 自建类型项目
|
||||
List<SpdmNodeVo> dmProjectNodeList = nodeList.stream().filter(node -> !SYNC_PROJECT_SOURCE.equals(node.getProjectSource())).toList();
|
||||
if (CollectionUtils.isNotEmpty(epProjectNodeList)) {
|
||||
// 设置EP类型项目
|
||||
setEpCurrentPhase(epProjectNodeList);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(dmProjectNodeList)) {
|
||||
// 设置自建类型项目
|
||||
setDmCurrentPhase(dmProjectNodeList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置EP类型项目当前阶段信息
|
||||
* @param dmProjectNodeList
|
||||
*/
|
||||
private void setEpCurrentPhase(List<SpdmNodeVo> dmProjectNodeList) {
|
||||
// 1. 提取节点编码
|
||||
List<String> nodeCodeList = dmProjectNodeList.stream()
|
||||
.map(SpdmNodeVo::getNodeCode)
|
||||
// 过滤空的nodeCode,避免无效查询和后续匹配问题
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(nodeCodeList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 查询视图数据
|
||||
if (lyricFlag == 1) {
|
||||
Map<String, String> projectStageMap;
|
||||
try {
|
||||
List<LyricVProjectToDM> lyricVProjectList = lyricVProjectToDmService.lambdaQuery()
|
||||
.in(LyricVProjectToDM::getProjectNum, nodeCodeList)
|
||||
.list();
|
||||
// 3. 转换为Map
|
||||
projectStageMap = lyricVProjectList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
LyricVProjectToDM::getProjectNum, // key:项目编号(nodeCode)
|
||||
LyricVProjectToDM::getStage, // value:当前阶段
|
||||
// 解决重复key问题:保留第一个值
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
} catch (MyBatisSystemException ex) {
|
||||
log.warn("查询EP项目信息并设置当前阶段发生异常,项目编号:{}", nodeCodeList, ex);
|
||||
return;
|
||||
}
|
||||
// 4. 设置当前阶段
|
||||
dmProjectNodeList.forEach(spdmNodeVo -> {
|
||||
String nodeCode = spdmNodeVo.getNodeCode();
|
||||
if (StringUtils.isNotBlank(nodeCode)) {
|
||||
spdmNodeVo.setCurrentPhase(projectStageMap.get(nodeCode));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自建项目当前阶段信息
|
||||
* @param nodeList
|
||||
*/
|
||||
private void setDmCurrentPhase(List<SpdmNodeVo> nodeList) {
|
||||
List<String> nodeUuidList = nodeList.stream()
|
||||
.map(SpdmNodeVo::getUuid)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 1. 初始化时间格式化器
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// 2. 查询所有父节点为目标节点的阶段类型节点
|
||||
List<SimulationNode> allPhaseNodeList = nodeService.lambdaQuery()
|
||||
.in(SimulationNode::getParentId, nodeUuidList)
|
||||
.eq(SimulationNode::getNodeType, NodeTypeEnum.PHASE.getValue())
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(allPhaseNodeList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 按项目节点ID(tag1)分组,预处理:过滤时间为空的节点
|
||||
Map<String, List<SimulationNode>> phaseNodeByProjectIdMap = allPhaseNodeList.stream()
|
||||
.filter(phaseNode -> StringUtils.isNotBlank(phaseNode.getBeginTime())
|
||||
&& StringUtils.isNotBlank(phaseNode.getEndTime()))
|
||||
.collect(Collectors.groupingBy(SimulationNode::getTag1));
|
||||
|
||||
// 4. 获取当前时间戳
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
// 5. 遍历每个项目节点的阶段列表,判断当前生效阶段
|
||||
phaseNodeByProjectIdMap.forEach((projectNodeId, phaseNodeList) -> {
|
||||
// 按开始时间升序排序
|
||||
List<SimulationNode> sortedPhaseNodeList = phaseNodeList.stream()
|
||||
.sorted(Comparator.comparingLong(phaseNode -> parseTimeToMillis(phaseNode.getBeginTime(), sdf)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 查找当前时间落在【开始时间, 结束时间】内的阶段节点
|
||||
SimulationNode currentPhaseNode = sortedPhaseNodeList.stream()
|
||||
.filter(phaseNode -> isCurrentTimeInRange(phaseNode, currentTime, sdf))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
// 找到当前阶段,回写至对应的SpdmNodeVo
|
||||
if (Objects.nonNull(currentPhaseNode)) {
|
||||
nodeList.stream()
|
||||
.filter(node -> projectNodeId.equals(node.getUuid()))
|
||||
.findFirst()
|
||||
.ifPresent(node -> node.setCurrentPhase(currentPhaseNode.getNodeName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具方法:将时间字符串解析为时间戳,解析失败抛运行时异常
|
||||
* @param timeStr 时间字符串(yyyy-MM-dd HH:mm:ss)
|
||||
* @param sdf 时间格式化器
|
||||
* @return 时间戳
|
||||
*/
|
||||
private long parseTimeToMillis(String timeStr, SimpleDateFormat sdf) {
|
||||
try {
|
||||
return sdf.parse(timeStr).getTime();
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException("时间解析失败,时间字符串:" + timeStr, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具方法:判断当前时间是否落在阶段节点的[开始时间, 结束时间]范围内
|
||||
* @param phaseNode 阶段节点
|
||||
* @param currentTime 当前时间戳
|
||||
* @param sdf 时间格式化器
|
||||
* @return true-在范围内,false-不在/解析失败
|
||||
*/
|
||||
private boolean isCurrentTimeInRange(SimulationNode phaseNode, long currentTime, SimpleDateFormat sdf) {
|
||||
try {
|
||||
long beginTime = sdf.parse(phaseNode.getBeginTime()).getTime();
|
||||
long endTime = sdf.parse(phaseNode.getEndTime()).getTime();
|
||||
return currentTime >= beginTime && currentTime <= endTime;
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException("阶段节点时间解析失败,节点ID:" + phaseNode.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询固定时间内的待办数据
|
||||
*/
|
||||
|
||||
@@ -187,13 +187,14 @@
|
||||
<select id="getDemandListWithCondition" resultType="com.sdm.project.model.vo.SpdmDemandVo">
|
||||
SELECT
|
||||
sd.*,
|
||||
mold_material.property_value AS materialNo
|
||||
mold_material.property_value AS materialNo,
|
||||
is_mold.property_value AS isMoldMaking
|
||||
FROM simulation_demand sd
|
||||
INNER JOIN simulation_demand_extra is_mold
|
||||
ON sd.uuid = is_mold.demand_id
|
||||
AND is_mold.property_name = 'isMoldMaking'
|
||||
<if test="req.isMoldMaking != null">
|
||||
AND is_mold.property_value = #{req.isMoldMaking}
|
||||
<if test="isMoldMaking != null">
|
||||
AND is_mold.property_value = #{isMoldMaking}
|
||||
</if>
|
||||
LEFT JOIN simulation_demand_extra mold_material
|
||||
ON sd.uuid = mold_material.demand_id
|
||||
|
||||
Reference in New Issue
Block a user