Commit 5abf2c44 authored by DESKTOP-VKRD9QF\Administration's avatar DESKTOP-VKRD9QF\Administration

Merge remote-tracking branch 'origin/jdt'

parents 89da235d 246b9472
package com.aps.controller;
import com.aps.common.util.ParamValidator;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -8,6 +9,9 @@ import com.aps.common.util.R;
import com.aps.entity.ApsTimeConfig;
import com.aps.service.ApsTimeConfigService;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
......@@ -35,26 +39,38 @@ public class ApsTimeConfigController {
@Operation(summary = "获取APS时间配置", description = "获取APS时间配置信息")
public R<ApsTimeConfig> getConfig() {
ApsTimeConfig config = apsTimeConfigService.getConfig();
if (config != null) {
return R.ok(config);
} else {
// 如果没有配置,返回默认配置
config = new ApsTimeConfig();
return R.ok(config);
}
}
/**
* 更新APS时间配置
*/
@PutMapping("/updateConfig")
@Operation(summary = "更新APS时间配置", description = "通过Map参数更新APS时间配置")
@PostMapping("/updateConfig")
@Operation(summary = "更新APS时间配置", description = "更新APS时间配置")
public R<String> updateConfig(@RequestBody Map<String, Object> configMap) {
boolean result = apsTimeConfigService.updateConfigFromMap(configMap);
if (result) {
// 使用ParamValidator处理和验证数据
Map<String, Object> processedConfigMap = new HashMap<>();
LocalDateTime baseTime = ParamValidator.parseDateTime(configMap.get("baseTime").toString(), "基准时间");
processedConfigMap.put("baseTime", baseTime);
Double freezeDate = ParamValidator.getDouble(configMap, "freezeDate", "冻结日期");
processedConfigMap.put("freezeDate", BigDecimal.valueOf(freezeDate));
Double startCount = ParamValidator.getDouble(configMap, "startCount", "前置时间");
processedConfigMap.put("startCount", BigDecimal.valueOf(startCount));
Double endCount = ParamValidator.getDouble(configMap, "endCount", "后置时间");
processedConfigMap.put("endCount", BigDecimal.valueOf(endCount));
boolean result = apsTimeConfigService.updateConfigFromMap(processedConfigMap);
return R.ok("配置更新成功");
} else {
return R.failed("配置更新失败");
}
}
}
......@@ -33,7 +33,7 @@ public class LanuchController {
*/
@PostMapping("/execute")
@Operation(summary = "启动工单")
public R<String> lanuch(@RequestBody Map<String, String> params) {
public R<ProdSceneConfig> lanuch(@RequestBody Map<String, String> params) {
String sceneName = params.get("sceneName");
String userId = params.get("userId");
......@@ -47,7 +47,15 @@ public class LanuchController {
@Operation(summary = "运算")
public R<Chromosome> schedule(@RequestBody Map<String, String> params) {
String sceneId = params.get("sceneId");
// 如果需要处理时间字段,可以从params中获取并转换
// 例如:开始时间、结束时间等
String startTimeStr = params.get("startTime");
String endTimeStr = params.get("endTime");
// 在这里可以添加时间格式转换逻辑
// 根据不同格式解析时间字符串
Chromosome scheduleChromosomes = planResultService.schedule(sceneId);
return R.ok(scheduleChromosomes);
}
......@@ -57,7 +65,7 @@ public class LanuchController {
*/
@PostMapping("/copyScene")
@Operation(summary = "复制场景")
public R<String> copyScene(@RequestBody Map<String, String> params) {
public R<ProdSceneConfig> copyScene(@RequestBody Map<String, String> params) {
String oldSceneId = params.get("oldSceneId");
String newSceneName = params.get("newSceneName");
String userId = params.get("userId");
......
......@@ -17,7 +17,7 @@ public interface LanuchService {
* @author: jdt
* @return 结果
*/
R<String> lanuch( String sceneId, String username);
R<ProdSceneConfig> lanuch( String sceneId, String username);
/**
* 生成设备日历数据
......@@ -25,7 +25,7 @@ public interface LanuchService {
* @author: jdt
* @return 结果
*/
R<String> copyScene( String oldSceneId, String username,String newSceneId);
R<ProdSceneConfig> copyScene( String oldSceneId, String username,String newSceneId);
/**
......
......@@ -86,7 +86,7 @@ public class LanuchServiceImpl implements LanuchService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<String> lanuch(String sceneName, String username) {
public R<ProdSceneConfig> lanuch(String sceneName, String username) {
// 参数校验
if (sceneName == null || sceneName.trim().isEmpty()) {
throw new IllegalArgumentException("场景名称不能为空");
......@@ -97,12 +97,13 @@ public class LanuchServiceImpl implements LanuchService {
}
String sceneId = null;
try {
// 1. 创建场景
sceneId = createScene(sceneName, username);
if (sceneId == null) {
ProdSceneConfig sceneConfig = createScene(sceneName, username);
if (sceneConfig == null) {
throw new RuntimeException("场景名称已存在");
}
sceneId = sceneConfig.getSceneId();
prodEquipSpecialCalService.copyFromEquipCapacityDef(sceneId);
......@@ -125,13 +126,8 @@ public class LanuchServiceImpl implements LanuchService {
generateProcessRelationsBatch(prodLaunchOrders, sceneId);
log.info("场景数据生成完成,场景ID:{}", sceneId);
return R.ok("场景数据生成成功");
} catch (Exception e) {
// 发生任何异常都应回滚事务
// 如果sceneId已经创建但在事务完成前发生异常,则事务回滚会自动清理数据
log.error("场景生成过程中发生异常,事务将回滚", e);
throw new RuntimeException("场景生成失败"); // 重新抛出异常以触发事务回滚
}
return R.ok(sceneConfig);
}
......@@ -143,7 +139,7 @@ public class LanuchServiceImpl implements LanuchService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public R<String> copyScene(String oldSceneId,String username, String newSceneName) {
public R<ProdSceneConfig> copyScene(String oldSceneId,String username, String newSceneName) {
// Validate input parameters
if (oldSceneId == null || oldSceneId.trim().isEmpty()) {
throw new IllegalArgumentException("原场景ID不能为空");
......@@ -166,10 +162,11 @@ public class LanuchServiceImpl implements LanuchService {
throw new RuntimeException("源场景不存在");
}
// 创建场景
String newSceneId = createScene(newSceneName, username);
if (newSceneId == null) {
ProdSceneConfig newSceneConfig = createScene(newSceneName, username);
if (newSceneConfig == null) {
throw new RuntimeException("场景名称已存在");
}
String newSceneId = newSceneConfig.getSceneId();
// 复制数据
copyProdLaunchOrders(oldScene.getSceneId(), newSceneId);
......@@ -181,7 +178,7 @@ public class LanuchServiceImpl implements LanuchService {
// 复制染色体文件(排产结果)
copyChromosomeFile(oldScene.getSceneId(), newSceneId);
return R.ok("场景数据复制成功");
return R.ok(newSceneConfig);
}
/**
......@@ -321,10 +318,10 @@ public class LanuchServiceImpl implements LanuchService {
*
◦ @param sceneName 场景名称
◦ @return 场景ID,如果场景已存在则返回null
◦ @return 场景配置对象,如果场景已存在则返回null
*/
private String createScene(String sceneName,String userId) {
private ProdSceneConfig createScene(String sceneName,String userId) {
// 检查场景名称是否已存在
boolean exists = prodSceneConfigService.lambdaQuery()
.eq(ProdSceneConfig::getSceneName, sceneName)
......@@ -346,7 +343,7 @@ public class LanuchServiceImpl implements LanuchService {
prodSceneConfigService.save(sceneConfig);
log.info("创建新场景成功,场景ID:{},名称:{}", sceneId, sceneName);
return sceneId;
return sceneConfig;
}
/**
......
......@@ -1139,7 +1139,7 @@ private GlobalParam InitGlobalParam()
machine.setMaintenanceWindows(new ArrayList<>());
}
List<ProdEquipSpecialCal> machineProdEquipSpecialCals = ProdEquipSpecialCals.stream()
.filter(t -> t.getEquipId() == machine.getId()&&t.getReferenceType()==1)
.filter(t -> t.getPlanResourceId()== machine.getId()&&t.getReferenceType()==1)
.collect(Collectors.toList());
List<Shift> shifts1=new ArrayList<>();
for (ProdEquipSpecialCal machineProdEquipSpecialCal : machineProdEquipSpecialCals) {
......@@ -1340,7 +1340,7 @@ private GlobalParam InitGlobalParam()
com.aps.entity.Gantt.ResourceGanttVO resourceGanttVO = new com.aps.entity.Gantt.ResourceGanttVO();
resourceGanttVO.setId(machine.getId());
resourceGanttVO.setName(machine.getId()+"号设备");
resourceGanttVO.setName(machine.getName());
resourceGanttVO.setShift(convertToShiftVO(machine));
resourceGanttVO.setCode(machine.getCode());
// 转换任务列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment