|
|
@ -7,7 +7,9 @@ import com.iflytop.gd.app.common.enums.CraftStates; |
|
|
|
import com.iflytop.gd.app.core.CraftsContext; |
|
|
|
import com.iflytop.gd.app.mapper.CraftsMapper; |
|
|
|
import com.iflytop.gd.app.model.entity.Crafts; |
|
|
|
import com.iflytop.gd.app.model.entity.Ores; |
|
|
|
import com.iflytop.gd.app.model.vo.CraftStatusVO; |
|
|
|
import com.iflytop.gd.app.model.vo.SetCraftsVO; |
|
|
|
import com.iflytop.gd.common.exception.AppException; |
|
|
|
import com.iflytop.gd.common.result.ResultCode; |
|
|
|
import jakarta.annotation.PostConstruct; |
|
|
@ -32,6 +34,7 @@ public class CraftsService extends ServiceImpl<CraftsMapper, Crafts> { |
|
|
|
private final StateMachineFactory<CraftStates, CraftEvents> stateMachineFactory; |
|
|
|
private final WebSocketService webSocketService; |
|
|
|
private final CraftsStepService craftsStepService; |
|
|
|
private final OresService oresService; |
|
|
|
|
|
|
|
private ExecutorService executor; |
|
|
|
private final ConcurrentHashMap<String, CraftsContext> contextMap = new ConcurrentHashMap<>(); |
|
|
@ -45,7 +48,7 @@ public class CraftsService extends ServiceImpl<CraftsMapper, Crafts> { |
|
|
|
/** |
|
|
|
* 配置工艺 |
|
|
|
*/ |
|
|
|
public synchronized void setCraft(Long craftId, String heatId) { |
|
|
|
public synchronized SetCraftsVO setCraft(Long craftId, String heatId) { |
|
|
|
// 校验已有上下文状态,仅允许在 READY、STOPPED 或 FINISHED 状态下重置 |
|
|
|
CraftsContext existing = contextMap.get(heatId); |
|
|
|
if (existing != null) { |
|
|
@ -56,6 +59,7 @@ public class CraftsService extends ServiceImpl<CraftsMapper, Crafts> { |
|
|
|
clearCraftContext(heatId); |
|
|
|
} |
|
|
|
Crafts craft = this.getById(craftId); |
|
|
|
Ores ores = oresService.getById(craft.getOresId()); |
|
|
|
CraftsContext ctx = new CraftsContext( |
|
|
|
heatId, |
|
|
|
craft, |
|
|
@ -64,6 +68,13 @@ public class CraftsService extends ServiceImpl<CraftsMapper, Crafts> { |
|
|
|
craftsStepService |
|
|
|
); |
|
|
|
contextMap.put(heatId, ctx); |
|
|
|
SetCraftsVO setCraftsVO = new SetCraftsVO(); |
|
|
|
setCraftsVO.setHeatId(heatId); |
|
|
|
setCraftsVO.setCraftsName(craft.getName()); |
|
|
|
setCraftsVO.setCraftsId(craft.getId()); |
|
|
|
setCraftsVO.setOresName(ores.getName()); |
|
|
|
setCraftsVO.setOresId(ores.getId()); |
|
|
|
return setCraftsVO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|