From 14b05bae7ed8f20e80695a8defdfca12447e7de3 Mon Sep 17 00:00:00 2001
From: LGH <1746689524@qq.com>
Date: Wed, 6 Jul 2022 10:12:25 +0800
Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=9C=8B=E6=9D=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
6.program/pom.xml | 24 ++++--
.../service/impl/CraftInfoServiceImpl.java | 2 +-
.../service/impl/CurrTaskServiceImpl.java | 14 +++-
.../service/impl/OrderInfoServiceImpl.java | 2 +-
.../mt/wms/empty/task/AsynRunTaskService.java | 5 ++
.../com/mt/wms/empty/task/RunTaskUtils.java | 2 +-
.../com/mt/wms/empty/task/ScheduledTask.java | 74 ++++++++++++++++---
.../com/mt/wms/empty/vo/NowCurrTaskDetVo.java | 5 ++
.../wms/empty/websocket/WebSocketServer.java | 17 +++--
9 files changed, 114 insertions(+), 31 deletions(-)
diff --git a/6.program/pom.xml b/6.program/pom.xml
index 712e735..ef5d67e 100644
--- a/6.program/pom.xml
+++ b/6.program/pom.xml
@@ -24,7 +24,7 @@
pom
1.0
- wms
+ wms-qj
wms
https://wms.picaiba.com
@@ -51,10 +51,12 @@
5-->
- jdbc:p6spy:mysql://192.168.6.51:30306/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
+
+ jdbc:p6spy:mysql://mysql.picaiba.com:30307/mt_wms_qj?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
root
- ABC.10086
+
+ 1qaz@WSX3edc$RFV
smtp.mxhichina.com
@@ -98,11 +100,11 @@
wms
wms
-
+ 10
jdbc:p6spy:mysql://mysql.picaiba.com:30306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
@@ -149,11 +151,11 @@
wms
wms
-
+ 10
jdbc:p6spy:mysql://localhost:3306/wms?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
@@ -422,6 +424,14 @@
true
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+ @
+ false
+
+
diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java
index 34fb50b..048c210 100644
--- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java
+++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/service/impl/CraftInfoServiceImpl.java
@@ -63,7 +63,7 @@ public class CraftInfoServiceImpl extends BaseService implements CraftInfoServic
public R> page(CraftInfoQueryParam craftInfoQueryParam) {
QueryWrapper wrapper=new QueryWrapper<>();
wrapper.like(StringUtils.isNotBlank(craftInfoQueryParam.getCraftCode()),CraftInfo.CRAFT_CODE,craftInfoQueryParam.getCraftCode())
- .orderByDesc(CraftInfo.CREATE_TIME);
+ .orderByAsc(CraftInfo.CREATE_TIME);
Page page = craftInfoServiceBiz.page(new Page<>(craftInfoQueryParam.getCurrent(), craftInfoQueryParam.getSize()), wrapper);
return successful(new PageVo<>(page,CraftInfoVo.class));
}
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java
index 360cae0..5170b4a 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java
@@ -20,10 +20,7 @@ import com.mt.wms.empty.enums.TaskTypeEnum;
import com.mt.wms.empty.params.AutoCurrTaskParam;
import com.mt.wms.empty.params.CurrTaskQueryParam;
import com.mt.wms.empty.params.TaskCreateParam;
-import com.mt.wms.empty.service.CurrTaskDetService;
-import com.mt.wms.empty.service.CurrTaskService;
-import com.mt.wms.empty.service.TaskDetHisService;
-import com.mt.wms.empty.service.TaskHisService;
+import com.mt.wms.empty.service.*;
import com.mt.wms.empty.task.RunTaskUtils;
import com.mt.wms.empty.task.TaskDistanceUtils;
import com.mt.wms.empty.vo.ApmsEndProcessVo;
@@ -77,6 +74,8 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
TaskDistanceUtils taskDistanceUtils;
@Autowired
RunTaskUtils runTaskUtils;
+ @Autowired
+ AutoExeTaskServiceBiz autoExeTaskServiceBiz;
@Override
public CurrTaskVo getCurrTask(IdParam idParam) {
@@ -202,6 +201,13 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService
@Override
public R runTask(Long taskId) throws InterruptedException, IOException {
CurrTask currTask = currTaskServiceBiz.getById(taskId);
+ //是否为自动任务
+ if (currTask.getIsAuto()==1){
+ List exeTaskList = autoExeTaskServiceBiz.list(new QueryWrapper().eq(AutoExeTask.F_TASK_ID, taskId));
+ if (exeTaskList.size()==0){
+ return R.failed("该任务为多步骤加工任务且该步骤不是第一步,请选择第一步骤任务执行!");
+ }
+ }
return runTaskUtils.runTaskForInKiln(taskId);
}
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java
index 823c40e..e11109b 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java
@@ -176,7 +176,7 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic
CurrTaskVo currTask = currTaskService.getCurrTask(IdParam.builder().id(orderInfo.getCurrTaskId()).build());
orderInfo.setABeginTime(currTask.getABeginTime());
orderInfo.setAEndTime(currTask.getAEndTime());
- orderInfo.setTaskType(currTask.getTaskType());
+ orderInfo.setTaskType(currTask.getProcessType());
orderInfo.setStatus(currTask.getStatus());
orderInfo.setKilnId(currTask.getKilnId());
orderInfo.setStartPosition(currTask.getStartPosition());
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java
index 99ea8b8..dccbecb 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java
@@ -117,6 +117,8 @@ public class AsynRunTaskService extends BaseService {
Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue());
//执行成功,托盘进炉
if (status==1){
+ //开始记录能源消耗
+ asynStartRecordConsume(currTaskId,currTask.getKilnId());
logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功===");
//更新调度表状态为完成
runTask.setUpdateTime(LocalDateTime.now());
@@ -197,6 +199,7 @@ public class AsynRunTaskService extends BaseService {
Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue());
//执行成功,托盘进炉
if (status==1){
+ asynStartRecordConsume(currTaskId,currTask.getKilnId());
logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功===");
//更新调度表状态为完成
runTask.setUpdateTime(LocalDateTime.now());
@@ -392,6 +395,8 @@ public class AsynRunTaskService extends BaseService {
Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode();
Integer status = sendTaskToRgv(vehicleId, currTaskId, startPoint, endPoint, currTask.getPlcValue());
if (status==1){
+ //加工完成,记录结束时能源消耗
+ asynEndRecordConsume(currTaskId,currTask.getKilnId());
logger.info("===执行任务:"+currTaskId+" ,车辆搬运任务,车辆:"+vehicleId+" ,起点:"+startPoint+" ,终点:"+endPoint+"任务执行成功===");
//更新关系表状态为完成
runTask.setUpdateTime(LocalDateTime.now());
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java
index fc5cd7b..d60dec5 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/RunTaskUtils.java
@@ -260,7 +260,7 @@ public class RunTaskUtils {
currTask.setOutTargetPosition(location.getCode());
currTaskServiceBiz.updateById(currTask);
// 2022/2/16 异步调用车辆
- asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleInfoList.get(0).getId());
+ asynRunTaskService.asynRunTaskForKilnToWarehouse(currTask.getId(),vehicleId);
return R.ok("操作成功!当前目标窑炉已满,托盘加入缓存区待加工队列。");
}else {
return R.ok("当前缓存区已满,无法从加工炉出炉到缓存区。");
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java
index 2ace784..73b4357 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java
@@ -35,7 +35,7 @@ import java.util.Map;
@Component
public class ScheduledTask extends BaseService {
- private final static Logger logger = LoggerFactory.getLogger(AsynRunTaskService.class);
+ private final static Logger logger = LoggerFactory.getLogger(ScheduledTask.class);
@Resource
private KilnInfoServiceBiz kilnInfoServiceBiz;
@@ -74,13 +74,52 @@ public class ScheduledTask extends BaseService {
@Resource
private OrderInfoServiceBiz orderInfoServiceBiz;
+ @Test
+ public void test() throws IOException {
+ }
+ @Scheduled(fixedDelay = 1000*60)
public void testWebsocket() throws IOException {
- webSocketServer.sendtoAll(LocalDateTime.now()+"测试");
+ //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情
+ List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1));
+ List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class);
+ for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList
+ ) {
+ Long kilnId = nowCurrTask.getKilnId();
+ Boolean kilnWorking = true;
+ //查询对应炉号是否Working
+ if (kilnWorking){
+ String nameSpace = plcNameSpaceServiceBiz.getOne(new QueryWrapper()
+ .eq(PlcNameSpace.EQ_TYPE, 0)
+ .eq(PlcNameSpace.TYPE, 0)
+ .eq(PlcNameSpace.EQ_ID, kilnId)).getName();
+ //设定时间
+ // TODO: 2022/4/11 PLC变量名称设定时间和剩余时间统一命名
+ Integer setupTime = 300;
+ //剩余时间
+ Integer remainingTime = 122;
+ nowCurrTask.setSetupTime(setupTime);
+ nowCurrTask.setRemainingTime(remainingTime);
+ int completeness =(int) (((float)remainingTime/(float)setupTime )*100);
+ nowCurrTask.setCompleteness(completeness);
+ //标识卡详情
+ List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId()));
+ List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
+ for (CurrTaskDetVo currTaskDetVo:currTaskDetVoList
+ ) {
+ String customerName = orderInfoServiceBiz.getOne(new QueryWrapper().eq(OrderInfo.ORDER_NO, currTaskDetVo.getOrderNo())).getCustomerName();
+ currTaskDetVo.setCustomer(customerName);
+ }
+ nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList);
+ }
+ }
+ System.out.println(JSON.toJSONString(nowCurrTaskDetVoList));
+ webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList),"2");
}
/**
* 正在加工的加工任务详情
*/
+ //@Scheduled(fixedDelay = 1000*60)
public void screen() throws IOException {
//查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情
List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1));
@@ -95,13 +134,27 @@ public class ScheduledTask extends BaseService {
.eq(PlcNameSpace.EQ_TYPE, 0)
.eq(PlcNameSpace.TYPE, 0)
.eq(PlcNameSpace.EQ_ID, kilnId)).getName();
+ KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId);
+ nowCurrTask.setKilnCode(kilnInfo.getCode());
//设定时间
- // TODO: 2022/4/11 PLC变量名称设定时间和剩余时间统一命名
- Integer setupTime = Integer.parseInt(readPlcToString(nameSpace, "SetupTime"));
+ Integer setupTime =1;
//剩余时间
- Integer remainingTime = Integer.parseInt(readPlcToString(nameSpace, "RemainingTime"));
+ Integer remainingTime=0;
+ if (kilnInfo.getType()!=4){
+ remainingTime = Integer.parseInt(readPlcToString(nameSpace, "ProgramTimeRemain"));
+ }
+ if(kilnInfo.getType()==1||kilnInfo.getType()==3){
+ //运行时间
+ Integer runTime = Integer.parseInt(readPlcToString(nameSpace, "ProgramRunTime"));
+ setupTime=runTime+remainingTime;
+ }
+ if (kilnInfo.getType()==2){
+ setupTime=Integer.parseInt(readPlcToString(nameSpace, "SetTime"));
+ }
nowCurrTask.setSetupTime(setupTime);
nowCurrTask.setRemainingTime(remainingTime);
+ int completeness =(int) (((float)remainingTime/(float)setupTime )*100);
+ nowCurrTask.setCompleteness(completeness);
//标识卡详情
List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, nowCurrTask.getId()));
List currTaskDetVoList = BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class);
@@ -118,6 +171,7 @@ public class ScheduledTask extends BaseService {
/**
* 查询加工完成的窑炉
*/
+ //@Scheduled(fixedDelay = 1000*60*3)
public void taskForStockToKiln() throws IOException {
//两辆车是否都空闲,只有两辆车都空闲才被允许做任务
List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0));
@@ -141,6 +195,7 @@ public class ScheduledTask extends BaseService {
Boolean resultBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
if (resultBoolean){
//调用RunTaskUtils.runTaskForOutKiln
+ logger.info(kilnInfo.getCode()+kilnInfo.getKilnAlias()+"识别到允许出炉信号,进入出库程序!");
runTaskUtils.runTaskForOutKiln(kilnId);
break;
}
@@ -381,7 +436,7 @@ public class ScheduledTask extends BaseService {
//遍历窑炉,空窑炉查询缓存区是否有等待加工的任务,
//待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉
- //@Scheduled(fixedDelay = 1000*30)
+ //@Scheduled(fixedDelay = 1000*60)
public void runTaskForEmptyKiln() throws IOException {
List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper()
.eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0));
@@ -398,7 +453,7 @@ public class ScheduledTask extends BaseService {
//查询炉子是否allowIn
Boolean kilnAllowIn = kilnAllowIn(kilnInfo.getId());
if (kilnAllowIn){
- //缓存去是否有目标位置为窑炉的待加工任务
+ //缓存区是否有目标位置为窑炉的待加工任务
List inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper()
.eq(InStockInfo.TYPE, 1)
.eq(InStockInfo.KILN_ID, kilnInfo.getId())
@@ -428,6 +483,7 @@ public class ScheduledTask extends BaseService {
}
//遍历正在工作炉子的报警变量,记录报警
+ //@Scheduled(fixedDelay = 1000*30)
public void listenKilnAlarm(){
List kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo:kilnInfoList
@@ -484,10 +540,10 @@ public class ScheduledTask extends BaseService {
}
- //监听车辆是否在线
+ //监听车辆是否在线(暂时不用)
public void listenVehicleOnline() throws IOException {
List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper()
- .eq(VehicleInfo.STATUS, 2));
+ .eq(VehicleInfo.STATUS, 0));
for (VehicleInfo vehicleInfo:vehicleInfoList
) {
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java
index ffcdba0..b0538bf 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/vo/NowCurrTaskDetVo.java
@@ -59,6 +59,11 @@ public class NowCurrTaskDetVo extends BaseVo implements PageVo.ConvertVo{
*/
@ApiModelProperty(value = "工艺剩余时间",example = "0")
private Integer remainingTime;
+ /**
+ * 工艺进度
+ */
+ @ApiModelProperty(value = "工艺进度",example = "0")
+ private Integer completeness;
/**
* 标识卡list
diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java
index 4d43ee4..8a60bdd 100644
--- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java
+++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/websocket/WebSocketServer.java
@@ -26,13 +26,14 @@ public class WebSocketServer {
//前端的id 右后端给他
public synchronized String getUniqeId(){
- return UUID.randomUUID().toString()+System.currentTimeMillis();
+ //return UUID.randomUUID().toString()+System.currentTimeMillis();
+ return id;
}
//与某个客户端的连接会话,需要通过它来给客户端发送数据
private Session session;
private static Logger log = LogManager.getLogger(WebSocketServer.class);
- private String id = "";
+ private String id = getUniqeId();
public Integer getCurrentNum(){
return webSocketSet.size();
@@ -135,15 +136,15 @@ public class WebSocketServer {
*/
public void sendtoUser(String message,String sendUserId) throws IOException {
if (webSocketSet.get(sendUserId) != null) {
- if(!id.equals(sendUserId)){
- webSocketSet.get(sendUserId).sendMessage( "用户" + id + "发来消息:" + "
" + message);
- }
- else{
+ //if(!id.equals(sendUserId)){
+ //webSocketSet.get(sendUserId).sendMessage( "用户" + id + "发来消息:" + "
" + message);
+ // }
+ //else{
webSocketSet.get(sendUserId).sendMessage(message);
- }
+ //}
} else {
//如果用户不在线则返回不在线信息给自己
- sendtoUser("当前用户不在线",id);
+ //sendtoUser("当前用户不在线",id);
}
}