定时任务分开处理

main
judy 1 year ago
parent 933ca08db5
commit 0a1e126159
  1. 4
      shkj-admin/src/main/resources/application-test.yml
  2. 72
      shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTask.java
  3. 2
      shkj-wms/src/main/java/com/shkj/wms/plc/PlcEventTmpTask.java
  4. 15
      shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java
  5. 2
      shkj-wms/src/main/resources/mapper/wms/BusinDataTaskMapper.xml

@ -15,7 +15,7 @@ spring:
url: jdbc:mysql://127.0.0.1:3306/po1_wms_wcs?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://127.0.0.1:3306/po1testsh?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: root
password: 123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
@ -69,7 +69,7 @@ spring:
# 端口,默认为6379
port: 6379
# 数据库索引
database: 1
database: 0
# 密码
password:
# password: 123456

@ -143,24 +143,8 @@ public class PlcEventTask {
if (plcList.size() == 0) {
return;
}
for (WcsPlcConnectVo conn : plcList) {
if(conn.getPlcIp().contains(".41")){
PlcOperate plcOperate_41 = plcInit.getPlcOperate_41();
if (plcOperate_41 ==null){
plcInit.connect(conn.getPlcIp());
}
plcTask(plcInit.getPlcOperate_41(), conn, conn.getPointTables());
}
if(conn.getPlcIp().contains(".50")){
PlcOperate plcOperate_50 = plcInit.getPlcOperate_50();
if (plcOperate_50 ==null){
plcInit.connect(conn.getPlcIp());
}
plcTask(plcOperate_50, conn, conn.getPointTables());
}
if ("1".equals(conn.getDevType())){
if(conn.getPlcIp().contains(".60")){
PlcOperate plcOperate_60 = plcInit.getPlcOperate_60();
if (plcOperate_60 ==null){
@ -215,6 +199,60 @@ public class PlcEventTask {
doDevStatus(plcOperate_110,"6");
}
}
// if(conn.getPlcIp().contains(".41")){
// PlcOperate plcOperate_41 = plcInit.getPlcOperate_41();
// if (plcOperate_41 ==null){
// plcInit.connect(conn.getPlcIp());
// }
// plcTask(plcInit.getPlcOperate_41(), conn, conn.getPointTables());
// }
//
// if(conn.getPlcIp().contains(".50")){
// PlcOperate plcOperate_50 = plcInit.getPlcOperate_50();
// if (plcOperate_50 ==null){
// plcInit.connect(conn.getPlcIp());
// }
// plcTask(plcOperate_50, conn, conn.getPointTables());
// }
}
}
// @Scheduled(fixedRate = 200)
public void init1() {
//查询需要连接的PLC,初始化连接对象
List<WcsPlcConnectVo> plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1"));
if (plcList.size() == 0) {
return;
}
for (WcsPlcConnectVo conn : plcList) {
if ("2".equals(conn.getDevType()) && conn.getPlcIp().contains(".41")){
PlcOperate plcOperate_41 = plcInit.getPlcOperate_41();
if (plcOperate_41 ==null){
plcInit.connect(conn.getPlcIp());
}
plcTask(plcInit.getPlcOperate_41(), conn, conn.getPointTables());
}
}
}
// @Scheduled(fixedRate = 200)
public void init2() {
//查询需要连接的PLC,初始化连接对象
List<WcsPlcConnectVo> plcList = iWcsPlcConnectService.selectWcsPlcConnectList(new WcsPlcConnect().setIsActive("1"));
if (plcList.size() == 0) {
return;
}
for (WcsPlcConnectVo conn : plcList) {
if ("3".equals(conn.getDevType()) && conn.getPlcIp().contains(".50")){
PlcOperate plcOperate_50 = plcInit.getPlcOperate_50();
if (plcOperate_50 ==null){
plcInit.connect(conn.getPlcIp());
}
plcTask(plcOperate_50, conn, conn.getPointTables());
}
}
}
@Scheduled(fixedDelay = 6000)

@ -427,7 +427,7 @@ class WeightRandomStrategy<k, V extends Number> {
}
}
public java.lang.String randome(){
public String randome(){
Map.putAll(weightMap);
String k = random();
return k;

@ -228,8 +228,14 @@ public class ScheduledTasks {
taskQueryBo.setTaskType("21");
List<BusinDataTaskVo> businDataTaskVo21 = iBusinDataTaskService.selectBusinDataTask1(taskQueryBo);
businDataTaskVos.addAll(businDataTaskVo21);
for (BusinDataTaskVo businDataTaskVo : businDataTaskVos){
doTask(businDataTaskVo);
}
}
@Transactional(rollbackFor = Exception.class)
public void doTask(BusinDataTaskVo businDataTaskVo) {
String taskType = businDataTaskVo.getTaskType();
Long taskId = businDataTaskVo.getId();
Long containerId = businDataTaskVo.getContainerId();
@ -240,9 +246,9 @@ public class ScheduledTasks {
if (taskType.equals("0") || taskType.equals("7")) {
//获取要出入库的条码信息
List<BusinDataTaskGoodsVo> businDataTaskGoodsVos = iBusinDataTaskGoodsService.selectBusinTaskGoodsByTaskCode(businDataTaskVo.getId());
if(ObjectUtils.isEmpty(businDataTaskGoodsVos)){
/* if(ObjectUtils.isEmpty(businDataTaskGoodsVos)){
continue;
}
}*/
BusinDataTaskGoodsVo goodsVo = businDataTaskGoodsVos.get(0);
String vehicheModel = goodsVo.getVehicheModel();
String color = goodsVo.getColor();
@ -1550,7 +1556,8 @@ public class ScheduledTasks {
//统一提交任务数据
iBusinDataTaskService.saveOrUpdate(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class));
}
}
//查看堆垛机是否拥堵
public Result<Boolean> PLCout(BusinDataTask businDataTask){

@ -231,7 +231,7 @@
</select>
<select id="selectTaskManagement" resultType="com.shkj.wms.vo.BusinDataTaskManageVo" parameterType="com.shkj.wms.bo.BusinTaskManageQueryBo">
select task.id as taskId
select task.id as taskCode
,task.create_time,goodsData.vehiche_model,goodsData.color,task.task_status,task_type from busin_data_task
task
left join (select task_code,min(goods_no) goods_no from busin_data_task_goods where 1=1

Loading…
Cancel
Save