Commit dcf3cafd authored by DESKTOP-VKRD9QF\Administration's avatar DESKTOP-VKRD9QF\Administration

Merge remote-tracking branch 'origin/jdt'

parents c11b1563 243d5000
...@@ -68,9 +68,11 @@ public class ParamValidator { ...@@ -68,9 +68,11 @@ public class ParamValidator {
throw new IllegalArgumentException(fieldName + "不能为空字符串"); throw new IllegalArgumentException(fieldName + "不能为空字符串");
} }
return strValue; return strValue;
} else if (value instanceof Integer || value instanceof Long) {
return String.valueOf(value);
} }
throw new IllegalArgumentException(fieldName + "必须是字符串类型"); throw new IllegalArgumentException(fieldName + "必须是字符串、整数或长整数类型");
} }
public static Integer getInteger(Map<String, Object> params, String key, String fieldName) { public static Integer getInteger(Map<String, Object> params, String key, String fieldName) {
......
...@@ -419,6 +419,45 @@ public class SwaggerMapParamConfig { ...@@ -419,6 +419,45 @@ public class SwaggerMapParamConfig {
"}" "}"
)); ));
break; break;
case "changeTimeConfig":
properties.put("configDate", new StringSchema().description("配置日期").example("2025-12-22T10:00:00"));
properties.put("freezeHours", new StringSchema().description("冻结小时数").example("2.5"));
properties.put("preUnitValue", new StringSchema().description("前置单位值").example("1.0"));
properties.put("postUnitValue", new StringSchema().description("后置单位值").example("1.5"));
examples.put("完整配置示例", createExample(
"完整更新时间配置",
"{\n" +
" \"configDate\": \"2025-12-22T10:00:00\",\n" +
" \"freezeHours\": \"2.5\",\n" +
" \"preUnitValue\": \"1.0\",\n" +
" \"postUnitValue\": \"1.5\"\n" +
"}"
));
examples.put("部分配置更新示例", createExample(
"仅更新部分配置项",
"{\n" +
" \"freezeHours\": \"3.0\",\n" +
" \"preUnitValue\": \"2.0\"\n" +
"}"
));
break;
case "updateConfig":
properties.put("baseTime", new StringSchema().description("基准时间").example("2025-12-23T10:00:00"));
properties.put("freezeDate", new StringSchema().description("冻结日期").example("30"));
properties.put("startCount", new StringSchema().description("开始计数").example("1"));
properties.put("endCount", new StringSchema().description("结束计数").example("100"));
examples.put("APS时间配置更新示例", createExample(
"更新APS时间配置",
"{\n" +
" \"baseTime\": \"2025-12-23T10:00:00\",\n" +
" \"freezeDate\": 30,\n" +
" \"startCount\": 1,\n" +
" \"endCount\": 100\n" +
"}"
));
break;
} }
if (!properties.isEmpty()) { if (!properties.isEmpty()) {
...@@ -499,6 +538,10 @@ public class SwaggerMapParamConfig { ...@@ -499,6 +538,10 @@ public class SwaggerMapParamConfig {
return "批量操作染色体数据请求参数"; return "批量操作染色体数据请求参数";
case "deleteChromosomeData": case "deleteChromosomeData":
return "删除染色体数据请求参数"; return "删除染色体数据请求参数";
case "changeTimeConfig":
return "修改时间配置请求参数";
case "updateConfig":
return "更新APS时间配置请求参数";
default: default:
return "请求参数"; return "请求参数";
} }
......
package com.aps.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.aps.common.util.R;
import com.aps.entity.ApsTimeConfig;
import com.aps.service.ApsTimeConfigService;
import java.util.Map;
/**
* <p>
* APS时间配置表 前端控制器
* </p>
*
* @author MyBatis-Plus
* @since 2025-12-23
*/
@RestController
@RequestMapping("/apsTimeConfig")
@Tag(name = "APS时间配置管理", description = "APS时间配置管理")
public class ApsTimeConfigController {
@Autowired
private ApsTimeConfigService apsTimeConfigService;
/**
* 获取APS时间配置
*/
@GetMapping("/getConfig")
@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时间配置")
public R<String> updateConfig(@RequestBody Map<String, Object> configMap) {
boolean result = apsTimeConfigService.updateConfigFromMap(configMap);
if (result) {
return R.ok("配置更新成功");
} else {
return R.failed("配置更新失败");
}
}
}
...@@ -54,17 +54,17 @@ public class CodeGeneratorController { ...@@ -54,17 +54,17 @@ public class CodeGeneratorController {
return codeGeneratorService.getTableList(config); return codeGeneratorService.getTableList(config);
} }
@GetMapping("/test-connection/{dataSourceName}") // @GetMapping("/test-connection/{dataSourceName}")
@Operation(summary = "测试指定数据源连接", description = "测试指定数据源连接") // @Operation(summary = "测试指定数据源连接", description = "测试指定数据源连接")
public String testConnection(@PathVariable String dataSourceName) { // public String testConnection(@PathVariable String dataSourceName) {
DatabaseConfig config = databaseConfigService.getDatabaseConfig(dataSourceName); // DatabaseConfig config = databaseConfigService.getDatabaseConfig(dataSourceName);
if (config == null) { // if (config == null) {
return dataSourceName + " 数据源配置不存在"; // return dataSourceName + " 数据源配置不存在";
} // }
//
boolean isConnected = databaseConfigService.testConnection(config); // boolean isConnected = databaseConfigService.testConnection(config);
return isConnected ? dataSourceName + " 数据库连接成功!" : dataSourceName + " 数据库连接失败!"; // return isConnected ? dataSourceName + " 数据库连接成功!" : dataSourceName + " 数据库连接失败!";
} // }
@PostMapping("/generate/{dataSourceName}") @PostMapping("/generate/{dataSourceName}")
@Operation(summary = "使用指定数据源生成代码", description = "使用指定数据源生成代码") @Operation(summary = "使用指定数据源生成代码", description = "使用指定数据源生成代码")
......
package com.aps.entity;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@TableName("aps_time_config")
public class ApsTimeConfig {
@TableField(exist = false)
private Long id; // 配置表无ID字段,使用exist=false标记
private LocalDateTime baseTime;
private BigDecimal freezeDate;
private BigDecimal startCount;
private BigDecimal endCount;
}
\ No newline at end of file
...@@ -27,4 +27,5 @@ private BigDecimal efficiencyCoeff; ...@@ -27,4 +27,5 @@ private BigDecimal efficiencyCoeff;
private Integer minUtilization; private Integer minUtilization;
private Integer maxUtilization; private Integer maxUtilization;
private String referenceName; private String referenceName;
private Long planResourceId;
} }
\ No newline at end of file
...@@ -22,4 +22,5 @@ private Long creatorUserId; ...@@ -22,4 +22,5 @@ private Long creatorUserId;
private LocalDateTime creationTime; private LocalDateTime creationTime;
private Integer referenceType;//2 是节假日 1 是产能 private Integer referenceType;//2 是节假日 1 是产能
private String id; private String id;
private Long planResourceId;
} }
\ No newline at end of file
package com.aps.mapper;
import com.aps.entity.ApsTimeConfig;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* APS时间配置表 Mapper 接口
* </p>
*
* @author MyBatis-Plus
* @since 2025-12-23
*/
public interface ApsTimeConfigMapper extends BaseMapper<ApsTimeConfig> {
}
package com.aps.service;
import com.aps.entity.ApsTimeConfig;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Map;
/**
* <p>
* APS时间配置表 服务类
* </p>
*
* @author MyBatis-Plus
* @since 2025-12-23
*/
public interface ApsTimeConfigService extends IService<ApsTimeConfig> {
/**
* 获取配置信息(只有一条记录)
*/
ApsTimeConfig getConfig();
/**
* 更新配置信息(先删除后插入)
*/
boolean updateConfig(ApsTimeConfig config);
/**
* 从Map更新配置信息
*/
boolean updateConfigFromMap(Map<String, Object> configMap);
}
package com.aps.service.impl;
import com.aps.entity.ApsTimeConfig;
import com.aps.mapper.ApsTimeConfigMapper;
import com.aps.service.ApsTimeConfigService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
/**
* <p>
* APS时间配置表 服务实现类
* </p>
*
* @author MyBatis-Plus
* @since 2025-12-23
*/
@Service
public class ApsTimeConfigServiceImpl extends ServiceImpl<ApsTimeConfigMapper, ApsTimeConfig> implements ApsTimeConfigService {
@Override
public ApsTimeConfig getConfig() {
// 查询表中的唯一配置记录
QueryWrapper<ApsTimeConfig> queryWrapper = new QueryWrapper<>();
return this.getOne(queryWrapper);
}
@Override
public boolean updateConfig(ApsTimeConfig config) {
// 先删除所有配置记录(由于表只存一条数据)
QueryWrapper<ApsTimeConfig> deleteWrapper = new QueryWrapper<>();
this.remove(deleteWrapper);
// 然后插入新配置
return this.save(config);
}
@Override
public boolean updateConfigFromMap(Map<String, Object> configMap) {
ApsTimeConfig config = new ApsTimeConfig();
// 从Map中提取并设置各个字段
if (configMap.containsKey("baseTime") && configMap.get("baseTime") != null) {
Object baseTimeObj = configMap.get("baseTime");
if (baseTimeObj instanceof String) {
// 如果是字符串格式,尝试解析为LocalDateTime
try {
config.setBaseTime(LocalDateTime.parse((String) baseTimeObj, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
} catch (Exception e) {
// 如果格式不对,尝试其他格式
config.setBaseTime(LocalDateTime.parse((String) baseTimeObj));
}
} else if (baseTimeObj instanceof LocalDateTime) {
config.setBaseTime((LocalDateTime) baseTimeObj);
}
}
if (configMap.containsKey("freezeDate") && configMap.get("freezeDate") != null) {
Object freezeDateObj = configMap.get("freezeDate");
if (freezeDateObj instanceof BigDecimal) {
config.setFreezeDate((BigDecimal) freezeDateObj);
} else if (freezeDateObj instanceof Number) {
config.setFreezeDate(new BigDecimal(freezeDateObj.toString()));
} else if (freezeDateObj instanceof String) {
config.setFreezeDate(new BigDecimal((String) freezeDateObj));
}
}
if (configMap.containsKey("startCount") && configMap.get("startCount") != null) {
Object startCountObj = configMap.get("startCount");
if (startCountObj instanceof BigDecimal) {
config.setStartCount((BigDecimal) startCountObj);
} else if (startCountObj instanceof Number) {
config.setStartCount(new BigDecimal(startCountObj.toString()));
} else if (startCountObj instanceof String) {
config.setStartCount(new BigDecimal((String) startCountObj));
}
}
if (configMap.containsKey("endCount") && configMap.get("endCount") != null) {
Object endCountObj = configMap.get("endCount");
if (endCountObj instanceof BigDecimal) {
config.setEndCount((BigDecimal) endCountObj);
} else if (endCountObj instanceof Number) {
config.setEndCount(new BigDecimal(endCountObj.toString()));
} else if (endCountObj instanceof String) {
config.setEndCount(new BigDecimal((String) endCountObj));
}
}
// 使用先删除后插入的策略更新配置
QueryWrapper<ApsTimeConfig> deleteWrapper = new QueryWrapper<>();
this.remove(deleteWrapper);
return this.save(config);
}
}
...@@ -790,10 +790,10 @@ public class LanuchServiceImpl implements LanuchService { ...@@ -790,10 +790,10 @@ public class LanuchServiceImpl implements LanuchService {
ProdOrderProcess prodOrderProcess = new ProdOrderProcess(); ProdOrderProcess prodOrderProcess = new ProdOrderProcess();
// 根据connection.getSourceoperationid()去routing_detail表查taskSeq
prodOrderProcess.setTaskSeq(getTaskSeqFromRoutingDetail(connection.getSourceoperationid(), connection.getSourceoperation())); prodOrderProcess.setTaskSeq(getTaskSeqFromRoutingDetail(connection.getSourceoperationid(), connection.getSourceoperation()));
// 根据connection.getDestoperationid()去routing_detail表查targetTaskSeq
prodOrderProcess.setTargetTaskSeq(getTaskSeqFromRoutingDetail(connection.getDestoperationid(), connection.getDestoperation())); prodOrderProcess.setTargetTaskSeq(getTaskSeqFromRoutingDetail(connection.getDestoperationid(), connection.getDestoperation()));
......
...@@ -75,7 +75,8 @@ public class ProdEquipSpecialCalServiceImpl extends ServiceImpl<ProdEquipSpecial ...@@ -75,7 +75,8 @@ public class ProdEquipSpecialCalServiceImpl extends ServiceImpl<ProdEquipSpecial
specialCal.setEquipCode(capacityDef.getEquipCode()); specialCal.setEquipCode(capacityDef.getEquipCode());
specialCal.setStartDate(capacityDef.getEffectiveStartTime()); specialCal.setStartDate(capacityDef.getEffectiveStartTime());
specialCal.setEndDate(capacityDef.getEffectiveEndTime()); specialCal.setEndDate(capacityDef.getEffectiveEndTime());
specialCal.setPlanResourceId(capacityDef.getPlanResourceId());
specialCal.setPlanResourceId(capacityDef.getPlanResourceId());
// 处理数值类型转换的空值 // 处理数值类型转换的空值
if (capacityDef.getEfficiencyCoeff() != null) { if (capacityDef.getEfficiencyCoeff() != null) {
specialCal.setEfficiencyCoeff(capacityDef.getEfficiencyCoeff().longValue()); specialCal.setEfficiencyCoeff(capacityDef.getEfficiencyCoeff().longValue());
......
...@@ -1142,7 +1142,7 @@ private GlobalParam InitGlobalParam() ...@@ -1142,7 +1142,7 @@ private GlobalParam InitGlobalParam()
List<MesShiftWorkSched> ShiftWorkScheds = MesShiftWorkScheds.stream() List<MesShiftWorkSched> ShiftWorkScheds = MesShiftWorkScheds.stream()
.filter(t -> (long) t.getWeekWorkSchedId() == machineProdEquipSpecialCal.getReferenceId()) .filter(t -> (long) t.getWeekWorkSchedId() == machineProdEquipSpecialCal.getReferenceId())
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Shift> Shifts = mergeShiftData(ShiftWorkScheds); List<Shift> Shifts = mergeShiftDataToEng(ShiftWorkScheds);
for (Shift shift : Shifts) { for (Shift shift : Shifts) {
shift.setMachineId(machine.getId()); shift.setMachineId(machine.getId());
...@@ -1164,7 +1164,7 @@ private GlobalParam InitGlobalParam() ...@@ -1164,7 +1164,7 @@ private GlobalParam InitGlobalParam()
List<MesShiftWorkSched> ShiftWorkScheds = MesShiftWorkScheds.stream() List<MesShiftWorkSched> ShiftWorkScheds = MesShiftWorkScheds.stream()
.filter(t -> (long) t.getWeekWorkSchedId() == PlanResource.getWorkSchedId()) .filter(t -> (long) t.getWeekWorkSchedId() == PlanResource.getWorkSchedId())
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Shift> Shifts = mergeShiftData(ShiftWorkScheds); List<Shift> Shifts = mergeShiftDataToEng(ShiftWorkScheds);
for (Shift shift : Shifts) { for (Shift shift : Shifts) {
shift.setSpecial(false); shift.setSpecial(false);
shift.setMachineId(machine.getId()); shift.setMachineId(machine.getId());
...@@ -1272,6 +1272,51 @@ private GlobalParam InitGlobalParam() ...@@ -1272,6 +1272,51 @@ private GlobalParam InitGlobalParam()
/**
* 合并重复的ShiftData,将serialNumber收集为列表英文格式0,1,2,3,4,5,6
* @param originalList 原始数据列表
* @return 合并后的MergedShiftData列表
*/
public static List<Shift> mergeShiftDataToEng(List<MesShiftWorkSched> originalList) {
// 按shiftStart和shiftEnd分组
Map<String, Shift> groupMap = new HashMap<>();
for (MesShiftWorkSched data : originalList) {
// 用shiftStart+shiftEnd作为分组key
String groupKey = data.getShiftStart().toString() + "_" + data.getShiftEnd().toString();
// 将中文的星期几转换为英文格式(周日是0,周一到周日依次为0-6)
// 假设数据库中startWeekDay是1-7(周一到周日),需要转换为0-6(周日到周六)
int engDay = (data.getStartWeekDay() % 7); // 将1-7转换为0-6,其中周日为0
if (groupMap.containsKey(groupKey)) {
// 已存在分组:添加serialNumber到列表
Shift merged = groupMap.get(groupKey);
merged.getDays().add(engDay);
} else {
// 新分组:创建MergedShiftData并初始化
Shift merged = new Shift();
merged.setStartTime(data.getShiftStart().toLocalTime());
merged.setEndTime(data.getShiftEnd().toLocalTime());
merged.setStatus(0);
// 初始化序号列表
Set<Integer> serials =new HashSet<>();
serials.add(engDay);
merged.setDays(serials);
groupMap.put(groupKey, merged);
}
}
// 转换为列表返回
return new ArrayList<>(groupMap.values());
}
/** /**
* 将 ScheduleChromosome 转换为 ResourceGanttVO 列表 * 将 ScheduleChromosome 转换为 ResourceGanttVO 列表
* @param scheduleChromosome 调度结果 * @param scheduleChromosome 调度结果
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aps.mapper.ApsTimeConfigMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.aps.entity.ApsTimeConfig">
<id column="BASE_TIME" property="baseTime" />
<result column="FREEZE_DATE" property="freezeDate" />
<result column="START_COUNT" property="startCount" />
<result column="END_COUNT" property="endCount" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
BASE_TIME, FREEZE_DATE, START_COUNT, END_COUNT
</sql>
</mapper>
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