下发修改

parent c5ab1f7a
......@@ -23,6 +23,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.aps.common.util.R.ok;
@RestController
@RequestMapping("/queryChromosome")
@Tag(name = "甘特图数据查询", description = "甘特图数据查询")
......@@ -52,19 +54,18 @@ public class ChromosomeDataController {
@PathVariable String entityName,
@RequestBody Paged paged) {
// 获取sceneId(文件实体需要,数据库实体可选)
String sceneId = paged.getCondition("sceneId") != null ?
paged.getCondition("sceneId").getFieldValue() : null;
// 文件实体必须要有sceneId
if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) {
return R.ok(null);
return R.ok(null);
}
Map<String, Object> result = chromosomeDataService.queryChromosomeDataWithConditions(
sceneId, entityName, paged);
return R.ok(result);
return ok(result);
}
......@@ -85,7 +86,6 @@ public class ChromosomeDataController {
@PathVariable String entityName,
@RequestBody Paged paged) {
// 获取sceneId(文件实体需要,数据库实体可选)
String sceneId = paged.getCondition("sceneId") != null ?
paged.getCondition("sceneId").getFieldValue() : null;
......@@ -98,12 +98,11 @@ public class ChromosomeDataController {
// 直接调用服务层的list查询方法
List<Object> result = chromosomeDataService.queryChromosomeDataList(sceneId, entityName, paged);
if (result == null) {
return R.ok(Collections.emptyList(), "查询成功,但未找到匹配的数据");
return ok(Collections.emptyList(), "查询成功,但未找到匹配的数据");
}
return R.ok(result);
return ok(result);
}
......@@ -124,17 +123,18 @@ public class ChromosomeDataController {
@PathVariable String entityName,
@RequestParam String id) {
// 参数校验
if (id == null || id.isEmpty()) {
return R.ok(null);
}
// 文件实体必须要有sceneId
if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) {
return R.failed("文件实体查询时sceneId不能为空");
return R.ok(null);
}
Object result = chromosomeDataService.queryChromosomeDataById(sceneId, entityName, id);
return R.ok(result);
return ok(result);
}
......@@ -164,20 +164,25 @@ public class ChromosomeDataController {
@Parameter(description = "要更新的数据 (必须包含id字段)", required = true)
@RequestBody Map<String, Object> data) {
// 参数校验
if (data == null || data.isEmpty()) {
throw new RuntimeException("更新数据不能为空");
}
if (data.get("id") == null) {
throw new RuntimeException("更新数据必须包含id字段");
}
// 文件实体必须要有sceneId
if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) {
throw new RuntimeException("文件实体更新时sceneId不能为空");
throw new RuntimeException("文件实体更新时sceneId不能为空");
}
if (entityName.equalsIgnoreCase("machine")){
if (entityName.equalsIgnoreCase("machine")) {
return chromosomeDataService.updateMachineOption(sceneId, taskId, data);
}
boolean success = chromosomeDataService.updateChromosomeData(sceneId, entityName, data);
return R.ok("更新成功");
boolean success = chromosomeDataService.updateChromosomeData(sceneId, entityName, data);
return ok("更新成功");
}
......@@ -196,112 +201,10 @@ public class ChromosomeDataController {
public R<List<FieldInfo>> getEntityInfo(
@Parameter(description = "实体名称", required = true)
@PathVariable String entityName) {
System.out.println("getEntityInfo");
List<FieldInfo> fieldInfos = chromosomeDataService.getEntityInfo(entityName);
return R.ok(fieldInfos);
return ok(fieldInfos);
}
//
// // 处理setupTime字段
// if (data.containsKey("setupTime")) {
// Object setupTimeObj = data.get("setupTime");
// if (setupTimeObj instanceof Integer) {
// machineOption.setSetupTime((Integer) setupTimeObj);
// } else if (setupTimeObj instanceof Long) {
// machineOption.setSetupTime(((Long) setupTimeObj).intValue());
// } else if (setupTimeObj instanceof String) {
// machineOption.setSetupTime(Integer.parseInt((String) setupTimeObj));
// }
// }
//
// // 处理teardownTime字段
// if (data.containsKey("teardownTime")) {
// Object teardownTimeObj = data.get("teardownTime");
// if (teardownTimeObj instanceof Integer) {
// machineOption.setTeardownTime((Integer) teardownTimeObj);
// } else if (teardownTimeObj instanceof Long) {
// machineOption.setTeardownTime(((Long) teardownTimeObj).intValue());
// } else if (teardownTimeObj instanceof String) {
// machineOption.setTeardownTime(Integer.parseInt((String) teardownTimeObj));
// }
// }
//
// // 处理contantTime字段
// if (data.containsKey("contantTime")) {
// Object contantTimeObj = data.get("contantTime");
// if (contantTimeObj instanceof Integer) {
// machineOption.setContantTime((Integer) contantTimeObj);
// } else if (contantTimeObj instanceof Long) {
// machineOption.setContantTime(((Long) contantTimeObj).intValue());
// } else if (contantTimeObj instanceof String) {
// machineOption.setContantTime(Integer.parseInt((String) contantTimeObj));
// }
// }
// // 处理equipCode字段
// if (data.containsKey("equipCode")) {
// machineOption.setEquipCode(String.valueOf(data.get("equipCode")));
// }
//
// // 处理resourceCode字段
// if (data.containsKey("resourceCode")) {
// machineOption.setResourceCode(String.valueOf(data.get("resourceCode")));
// }
// 忽略id等未知字段
private boolean updateMachineOptionsForEntry(Entry targetEntry, List<?> machineOptions, ObjectMapper objectMapper) {
boolean allSuccess = true;
for (Object optionObj : machineOptions) {
if (!(optionObj instanceof Map)) {
allSuccess = false;
continue;
}
Map<?, ?> optionMap = (Map<?, ?>) optionObj;
// 获取machineId
Object machineIdObj = optionMap.get("machineId");
if (machineIdObj == null) {
allSuccess = false;
continue;
}
String machineOptionId = String.valueOf(machineIdObj);
// 在entry的machineOptions列表中找到对应的machineOption
MachineOption targetMachineOption = null;
for (MachineOption machineOption : targetEntry.getMachineOptions()) {
if (String.valueOf(machineOption.getMachineId()).equals(machineOptionId)) {
targetMachineOption = machineOption;
break;
}
}
if (targetMachineOption == null) {
allSuccess = false;
continue;
}
// 更新machineOption的字段
MachineOption updatedMachineOption = objectMapper.convertValue(optionMap, MachineOption.class);
// 替换原来的machineOption
int index = targetEntry.getMachineOptions().indexOf(targetMachineOption);
targetEntry.getMachineOptions().set(index, updatedMachineOption);
}
return allSuccess;
}
/**
* 判断是否为文件实体
*/
......
......@@ -280,7 +280,7 @@ if(finishedOrder==null||finishedOrder.size()==0)
public void decode(Chromosome chromosome) {
List<OrderMaterialRequirement> orderMaterials = materialRequirementService.buildMultiLevelRequirementNetwork(chromosome, sceneId, baseTime,_globalParam);
// List<OrderMaterialRequirement> orderMaterials = materialRequirementService.buildMultiLevelRequirementNetwork(chromosome, sceneId, baseTime,_globalParam);
if(_globalParam.isIsCheckSf()) {
int isnew= generateGlobalOpList(chromosome);
......
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