设备修改

parent 86789f0a
...@@ -566,6 +566,8 @@ public class SwaggerMapParamConfig { ...@@ -566,6 +566,8 @@ public class SwaggerMapParamConfig {
return "回退版本请求参数"; return "回退版本请求参数";
case "getSceneVersion": case "getSceneVersion":
return "获取场景文件数字请求参数"; return "获取场景文件数字请求参数";
case "deleteAllScenesByUser":
return "删除用户所有场景请求参数";
default: default:
return "请求参数"; return "请求参数";
} }
......
...@@ -121,6 +121,47 @@ public class LanuchController { ...@@ -121,6 +121,47 @@ public class LanuchController {
return result ? R.ok(true) : R.ok(false, "删除场景失败"); return result ? R.ok(true) : R.ok(false, "删除场景失败");
} }
/**
* 删除用户下所有场景
*/
@PostMapping("/deleteAllScenesByUser")
@Operation(summary = "删除用户下所有场景")
public R<Boolean> deleteAllScenesByUser(@RequestBody Map<String, String> params) {
String userId = params.get("userId");
if (userId == null || userId.isEmpty()) {
return R.failed("用户ID不能为空");
}
// 查询该用户的所有场景
List<ProdSceneConfig> scenes = prodSceneConfigService.lambdaQuery()
.eq(ProdSceneConfig::getCreateUser, userId)
.list();
boolean hasDeletionFailure = false;
String failureMessage = "";
// 逐个删除场景
for (ProdSceneConfig scene : scenes) {
try {
boolean result = prodSceneConfigService.deleteSceneById(scene.getSceneId());
if (!result) {
hasDeletionFailure = true;
failureMessage += "场景ID " + scene.getSceneId() + " 删除失败; ";
}
} catch (Exception e) {
hasDeletionFailure = true;
failureMessage += "场景ID " + scene.getSceneId() + " 删除异常: " + e.getMessage() + "; ";
}
}
if (hasDeletionFailure) {
return R.ok(false, failureMessage);
}
return R.ok(true, "成功删除用户 " + userId + " 下的 " + scenes.size() + " 个场景");
}
/** /**
* 获取用户所有场景 * 获取用户所有场景
*/ */
......
...@@ -36,26 +36,20 @@ public class ChromosomeDataController { ...@@ -36,26 +36,20 @@ public class ChromosomeDataController {
@PathVariable String entityName, @PathVariable String entityName,
@RequestBody Paged paged) { @RequestBody Paged paged) {
try {
// 获取sceneId(文件实体需要,数据库实体可选) // 获取sceneId(文件实体需要,数据库实体可选)
String sceneId = paged.getCondition("sceneId") != null ? String sceneId = paged.getCondition("sceneId") != null ?
paged.getCondition("sceneId").getFieldValue() : null; paged.getCondition("sceneId").getFieldValue() : null;
// 文件实体必须要有sceneId // 文件实体必须要有sceneId
if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) { if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) {
return R.failed("文件实体查询时sceneId不能为空"); return R.ok(null);
} }
Map<String, Object> result = chromosomeDataService.queryChromosomeDataWithConditions( Map<String, Object> result = chromosomeDataService.queryChromosomeDataWithConditions(
sceneId, entityName, paged); sceneId, entityName, paged);
return R.ok(result); return R.ok(result);
} catch (Exception e) {
// 检查是否是场景文件不存在的异常
if (e.getMessage() != null && e.getMessage().contains("未找到场景ID为") && e.getMessage().contains("的Chromosome数据")) {
return R.ok(null);
}
return R.failed("查询失败: " + e.getMessage());
}
} }
/** /**
...@@ -114,25 +108,18 @@ public class ChromosomeDataController { ...@@ -114,25 +108,18 @@ public class ChromosomeDataController {
@PathVariable String entityName, @PathVariable String entityName,
@RequestParam String id) { @RequestParam String id) {
try {
// 文件实体必须要有sceneId // 文件实体必须要有sceneId
if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) { if (isFileEntity(entityName) && (sceneId == null || sceneId.isEmpty())) {
return R.failed("文件实体查询时sceneId不能为空"); return R.failed("文件实体查询时sceneId不能为空");
} }
Object result = chromosomeDataService.queryChromosomeDataById(sceneId, entityName, id); Object result = chromosomeDataService.queryChromosomeDataById(sceneId, entityName, id);
if (result != null) {
return R.ok(result); return R.ok(result);
} else {
return R.failed("未找到ID为 " + id + " 的数据");
}
} catch (Exception e) {
// 检查是否是场景文件不存在的异常
if (e.getMessage() != null && e.getMessage().contains("未找到场景ID为") && e.getMessage().contains("的Chromosome数据")) {
return R.ok(null);
}
return R.failed("查询失败: " + e.getMessage());
}
} }
......
...@@ -638,6 +638,7 @@ public class ResourceGanttController { ...@@ -638,6 +638,7 @@ public class ResourceGanttController {
taskVO.setDuration(0); // taskVO.setDuration(0); //
taskVO.setEquipId(machine.getId()); taskVO.setEquipId(machine.getId());
taskVO.setEquipCode(machine.getCode());
taskVO.setShopId(machine.getId()); taskVO.setShopId(machine.getId());
taskVO.setShopName(resourceGanttVO.getShopName()); taskVO.setShopName(resourceGanttVO.getShopName());
taskVO.setStatus(0); // 默认值 taskVO.setStatus(0); // 默认值
......
...@@ -76,7 +76,8 @@ public class TaskVO { ...@@ -76,7 +76,8 @@ public class TaskVO {
@Schema(description = "设备ID") @Schema(description = "设备ID")
private long equipId; private long equipId;
@Schema(description = "设备编码")
private String equipCode;
@Schema(description = "车间ID") @Schema(description = "车间ID")
private long shopId; private long shopId;
......
...@@ -19,6 +19,7 @@ public class Order { ...@@ -19,6 +19,7 @@ public class Order {
private String materialCode; private String materialCode;
private String serie; private String serie;
private Integer routingId; private Integer routingId;
private String routingCode;
private double quantity = 100; // 100个 private double quantity = 100; // 100个
private double sYQuantity; private double sYQuantity;
private LocalDateTime startDate; private LocalDateTime startDate;
......
...@@ -34,7 +34,8 @@ public class KpiCalculator { ...@@ -34,7 +34,8 @@ public class KpiCalculator {
.mapToDouble(Machine::getRate) .mapToDouble(Machine::getRate)
.max() .max()
.orElse(0); .orElse(0);
addKpi(kpiMetrics,"最大设备利用率", machineMaxRate, "实际工作时间/计划工作时间 最大", 0, 1);
addKpi(kpiMetrics,"最大设备利用率", Math.round(machineMaxRate * 100.0) / 100.0, "实际工作时间/计划工作时间 最大", 0, 1);
//最小设备利用率 //最小设备利用率
double machineMinRate = chromosome.getMachines().stream() double machineMinRate = chromosome.getMachines().stream()
.mapToDouble(Machine::getRate) .mapToDouble(Machine::getRate)
......
...@@ -321,6 +321,7 @@ if(routingIds.size()==0) ...@@ -321,6 +321,7 @@ if(routingIds.size()==0)
order.setRoutingId(headers1.getId()); order.setRoutingId(headers1.getId());
order.setRoutingCode(headers1.getCode());
ProdLaunchOrder prodOrderMain= convertToLaunchOrder(order,""); ProdLaunchOrder prodOrderMain= convertToLaunchOrder(order,"");
List<RoutingDetailEquip> finalRoutingDetailEquips = routingDetailEquips; List<RoutingDetailEquip> finalRoutingDetailEquips = routingDetailEquips;
......
...@@ -4,6 +4,7 @@ import com.aps.entity.Algorithm.Chromosome; ...@@ -4,6 +4,7 @@ import com.aps.entity.Algorithm.Chromosome;
import com.aps.entity.ProdProcessExec; import com.aps.entity.ProdProcessExec;
import com.aps.entity.basic.Entry; import com.aps.entity.basic.Entry;
import com.aps.entity.basic.MachineOption; import com.aps.entity.basic.MachineOption;
import com.aps.entity.basic.Order;
import com.aps.entity.common.*; import com.aps.entity.common.*;
import com.aps.service.plan.SceneService; import com.aps.service.plan.SceneService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -88,8 +89,94 @@ public class ChromosomeDataService { ...@@ -88,8 +89,94 @@ public class ChromosomeDataService {
EntityConfig config = getEntityConfig(entityName); EntityConfig config = getEntityConfig(entityName);
if (config.getDataSource() == DataSourceType.FILE) { if (config.getDataSource() == DataSourceType.FILE) {
Object data = queryFileData(sceneId, config); // 特殊处理:当实体是MachineOption时,需要先获取Entry列表,再提取符合条件的Entry的MachineOption
return applyConditionsToList(data, paged); if ("machineoption".equalsIgnoreCase(config.getEntityName())) {
// 先获取Entry列表(而不是MachineOption列表)
EntityConfig entryConfig = new EntityConfig();
entryConfig.setEntityName("entry");
entryConfig.setDataSource(DataSourceType.FILE);
entryConfig.setFieldName("allOperations");
Object entryData = queryFileData(sceneId, entryConfig);
if (entryData instanceof List) {
List<?> entryList = (List<?>) entryData;
List<MachineOption> resultMachineOptions = new ArrayList<>();
// 过滤Entry列表,只保留与场景ID匹配的Entry
for (Object obj : entryList) {
if (obj instanceof Entry) {
Entry entry = (Entry) obj;
// 检查Entry的SceneId是否匹配
if (entry.getSceneId() != null && !entry.getSceneId().equals(sceneId)) {
continue; // 跳过不属于当前场景的Entry
}
// 检查Entry是否满足其他条件
boolean matchesOtherConditions = true;
if (!CollectionUtils.isEmpty(paged.getConditions())) {
for (ConditionEntity condition : paged.getConditions()) {
if (condition != null && !"sceneId".equalsIgnoreCase(condition.getFieldName())) {
if (!matchesCondition(entry, condition.getFieldName(), condition.getFieldValue(),
ConditionEnum.getByName(condition.getConditionalType()))) {
matchesOtherConditions = false;
break;
}
}
}
}
if (matchesOtherConditions && entry.getMachineOptions() != null) {
// 如果Entry满足所有条件,添加其MachineOptions
resultMachineOptions.addAll(entry.getMachineOptions());
}
}
}
return (List<Object>) (List<?>) resultMachineOptions;
} else {
return new ArrayList<>();
}
} else if ("order".equalsIgnoreCase(config.getEntityName())) {
// 特殊处理:当实体是Order时,使用orderId字段进行查询
Object data = queryFileData(sceneId, config);
if (data instanceof List) {
List<?> orderList = (List<?>) data;
List<Order> resultOrders = new ArrayList<>();
// 过滤Order列表,只保留与场景ID匹配的Order(如果Order中有SceneId的话)
for (Object obj : orderList) {
if (obj instanceof Order) {
Order order = (Order) obj;
// 检查Order是否满足条件
boolean matchesOtherConditions = true;
if (!CollectionUtils.isEmpty(paged.getConditions())) {
for (ConditionEntity condition : paged.getConditions()) {
if (condition != null && !"sceneId".equalsIgnoreCase(condition.getFieldName())) {
if (!matchesCondition(order, condition.getFieldName(), condition.getFieldValue(),
ConditionEnum.getByName(condition.getConditionalType()))) {
matchesOtherConditions = false;
break;
}
}
}
}
if (matchesOtherConditions) {
resultOrders.add(order);
}
}
}
return (List<Object>) (List<?>) resultOrders;
} else {
return new ArrayList<>();
}
} else {
Object data = queryFileData(sceneId, config);
return applyConditionsToList(data, paged);
}
} else { } else {
// 数据库查询 // 数据库查询
return databaseQueryService.queryDatabaseDataList(config, paged); return databaseQueryService.queryDatabaseDataList(config, paged);
...@@ -287,7 +374,107 @@ public class ChromosomeDataService { ...@@ -287,7 +374,107 @@ public class ChromosomeDataService {
* 查询文件数据(分页+条件) * 查询文件数据(分页+条件)
*/ */
private Map<String, Object> queryFileDataWithConditions(String sceneId, EntityConfig config, Paged paged) { private Map<String, Object> queryFileDataWithConditions(String sceneId, EntityConfig config, Paged paged) {
Object data = queryFileData(sceneId, config); Object data;
// 特殊处理:当实体是MachineOption时,需要先获取Entry列表,再提取符合条件的Entry的MachineOption
if ("machineoption".equalsIgnoreCase(config.getEntityName())) {
// 先获取Entry列表(而不是MachineOption列表)
EntityConfig entryConfig = new EntityConfig();
entryConfig.setEntityName("entry");
entryConfig.setDataSource(DataSourceType.FILE);
entryConfig.setFieldName("allOperations");
Object entryData = queryFileData(sceneId, entryConfig);
if (entryData instanceof List) {
List<?> entryList = (List<?>) entryData;
List<MachineOption> resultMachineOptions = new ArrayList<>();
// 过滤Entry列表,只保留与场景ID匹配的Entry
for (Object obj : entryList) {
if (obj instanceof Entry) {
Entry entry = (Entry) obj;
// 检查Entry的SceneId是否匹配
if (entry.getSceneId() != null && !entry.getSceneId().equals(sceneId)) {
continue; // 跳过不属于当前场景的Entry
}
// 检查Entry是否满足其他条件
boolean matchesOtherConditions = true;
if (!CollectionUtils.isEmpty(paged.getConditions())) {
for (ConditionEntity condition : paged.getConditions()) {
if (condition != null && !"sceneId".equalsIgnoreCase(condition.getFieldName())) {
if (!matchesCondition(entry, condition.getFieldName(), condition.getFieldValue(),
ConditionEnum.getByName(condition.getConditionalType()))) {
matchesOtherConditions = false;
break;
}
}
}
}
if (matchesOtherConditions && entry.getMachineOptions() != null) {
// 如果Entry满足所有条件,添加其MachineOptions
resultMachineOptions.addAll(entry.getMachineOptions());
}
}
}
data = resultMachineOptions;
} else {
data = new ArrayList<MachineOption>();
}
} else if ("order".equalsIgnoreCase(config.getEntityName())) {
// 特殊处理:当实体是Order时,使用orderId字段进行查询
Object orderData = queryFileData(sceneId, config);
if (orderData instanceof List) {
List<?> orderList = (List<?>) orderData;
List<Order> resultOrders = new ArrayList<>();
// 过滤Order列表,只保留满足条件的Order
for (Object obj : orderList) {
if (obj instanceof Order) {
Order order = (Order) obj;
// 检查Order是否满足条件
boolean matchesOtherConditions = true;
if (!CollectionUtils.isEmpty(paged.getConditions())) {
for (ConditionEntity condition : paged.getConditions()) {
if (condition != null && !"sceneId".equalsIgnoreCase(condition.getFieldName())) {
if (!matchesCondition(order, condition.getFieldName(), condition.getFieldValue(),
ConditionEnum.getByName(condition.getConditionalType()))) {
matchesOtherConditions = false;
break;
}
}
}
}
if (matchesOtherConditions) {
resultOrders.add(order);
}
}
}
data = resultOrders;
} else {
data = new ArrayList<Order>();
}
} else {
data = queryFileData(sceneId, config);
if (data instanceof List) {
List<?> dataList = (List<?>) data;
// 应用条件过滤
if (!CollectionUtils.isEmpty(paged.getConditions())) {
dataList = filterDataByConditions(dataList, paged.getConditions());
}
data = dataList;
}
}
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
int page = paged.getPageIndex() != null ? paged.getPageIndex() : 1; int page = paged.getPageIndex() != null ? paged.getPageIndex() : 1;
...@@ -296,11 +483,6 @@ public class ChromosomeDataService { ...@@ -296,11 +483,6 @@ public class ChromosomeDataService {
if (data instanceof List) { if (data instanceof List) {
List<?> dataList = (List<?>) data; List<?> dataList = (List<?>) data;
// 应用条件过滤
if (!CollectionUtils.isEmpty(paged.getConditions())) {
dataList = filterDataByConditions(dataList, paged.getConditions());
}
int total = dataList.size(); int total = dataList.size();
int fromIndex = (page - 1) * size; int fromIndex = (page - 1) * size;
fromIndex = Math.min(fromIndex, total); fromIndex = Math.min(fromIndex, total);
...@@ -342,6 +524,10 @@ public class ChromosomeDataService { ...@@ -342,6 +524,10 @@ public class ChromosomeDataService {
for (Object obj : entryList) { for (Object obj : entryList) {
if (obj instanceof Entry) { if (obj instanceof Entry) {
Entry entry = (Entry) obj; Entry entry = (Entry) obj;
// 检查Entry的SceneId是否匹配(如果Entry中有SceneId的话)
if (entry.getSceneId() != null && !entry.getSceneId().equals(sceneId)) {
continue; // 跳过不属于当前场景的Entry
}
// 检查Entry的ID是否匹配 // 检查Entry的ID是否匹配
if (String.valueOf(entry.getId()).equals(id)) { if (String.valueOf(entry.getId()).equals(id)) {
// 如果ID匹配,返回该Entry的MachineOptions // 如果ID匹配,返回该Entry的MachineOptions
...@@ -350,8 +536,29 @@ public class ChromosomeDataService { ...@@ -350,8 +536,29 @@ public class ChromosomeDataService {
} }
} }
} }
throw new RuntimeException("未找到ID为 " + id + " 的数据"); return null; // 找不到数据时返回null而不是抛出异常
} }
// // 特殊处理:当实体是Order时,使用orderId字段进行查询
// if ("order".equalsIgnoreCase(config.getEntityName())) {
// Object result = queryFileData(sceneId, config);
//
// if (result instanceof List) {
// List<?> orderList = (List<?>) result;
// // 查找orderId匹配的Order
// for (Object obj : orderList) {
// if (obj instanceof Order) {
// Order order = (Order) obj;
// // 检查Order的orderId是否匹配
// if (order.getOrderId() != null && order.getOrderId().equals(id)) {
// // 如果orderId匹配,返回该Order
// return order;
// }
// }
// }
// }
// return null; // 找不到数据时返回null而不是抛出异常
// }
Object result = queryFileData(sceneId, config); Object result = queryFileData(sceneId, config);
...@@ -379,7 +586,7 @@ public class ChromosomeDataService { ...@@ -379,7 +586,7 @@ public class ChromosomeDataService {
if (item != null) { if (item != null) {
return item; return item;
} else { } else {
throw new RuntimeException("未找到ID为 " + id + " 的数据"); return null; // 找不到数据时返回null而不是抛出异常
} }
} else { } else {
// 如果不是列表,直接返回结果 // 如果不是列表,直接返回结果
...@@ -412,6 +619,9 @@ public class ChromosomeDataService { ...@@ -412,6 +619,9 @@ public class ChromosomeDataService {
* 将数据应用条件过滤并返回列表 * 将数据应用条件过滤并返回列表
*/ */
private List<Object> applyConditionsToList(Object data, Paged paged) { private List<Object> applyConditionsToList(Object data, Paged paged) {
// 检查是否是直接传入的EntityConfig(这种情况可能需要获取场景ID和实体类型)
// 实际上这个方法是在queryChromosomeDataList中调用的,此时数据已经从文件中获取
if (data instanceof List) { if (data instanceof List) {
List<Object> dataList = (List<Object>) data; List<Object> dataList = (List<Object>) data;
......
...@@ -165,7 +165,7 @@ public class DatabaseQueryService { ...@@ -165,7 +165,7 @@ public class DatabaseQueryService {
} }
} }
throw new RuntimeException("未找到ID为 " + id + " 的数据"); return null; // 找不到数据时返回null而不是抛出异常
} }
/** /**
......
...@@ -288,6 +288,7 @@ public class LanuchServiceImpl implements LanuchService { ...@@ -288,6 +288,7 @@ public class LanuchServiceImpl implements LanuchService {
dispatch.setOpe(entry1.getRoutingDetailName()); dispatch.setOpe(entry1.getRoutingDetailName());
dispatch.setRoutingDetailId(entry1.getRoutingDetailId()); dispatch.setRoutingDetailId(entry1.getRoutingDetailId());
dispatch.setStatus(12L); dispatch.setStatus(12L);
// 添加到列表中 // 添加到列表中
dispatches.add(dispatch); dispatches.add(dispatch);
} }
...@@ -360,6 +361,7 @@ public class LanuchServiceImpl implements LanuchService { ...@@ -360,6 +361,7 @@ public class LanuchServiceImpl implements LanuchService {
launchOrder.setCreateUser(String.valueOf(order.getCreatoruserid())); launchOrder.setCreateUser(String.valueOf(order.getCreatoruserid()));
launchOrder.setMaterialCode(order.getMmcode()); launchOrder.setMaterialCode(order.getMmcode());
launchOrder.setEndDate(order.getDeliverytime()); launchOrder.setEndDate(order.getDeliverytime());
launchOrder.setStartDate(order.getBegintime());
try { try {
launchOrder.setOrderPriority(Integer.valueOf(order.getPrioritry())); launchOrder.setOrderPriority(Integer.valueOf(order.getPrioritry()));
......
...@@ -940,6 +940,7 @@ private GlobalParam InitGlobalParam() ...@@ -940,6 +940,7 @@ private GlobalParam InitGlobalParam()
order.setOrderCode(lo.getOrderCode()); order.setOrderCode(lo.getOrderCode());
order.setOrderId(lo.getOrderId()); order.setOrderId(lo.getOrderId());
order.setRoutingId(lo.getRoutingId()); order.setRoutingId(lo.getRoutingId());
order.setRoutingCode(lo.getRoutingCode());
order.setMaterialId(lo.getMaterialId()); order.setMaterialId(lo.getMaterialId());
order.setStartDate(lo.getStartDate()); order.setStartDate(lo.getStartDate());
order.setDueDate(lo.getEndDate()); order.setDueDate(lo.getEndDate());
......
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