opt:手持功能优化
This commit is contained in:
@@ -21,7 +21,7 @@ public interface PdaMoveStorService {
|
|||||||
* 组盘确认
|
* 组盘确认
|
||||||
* @return PdaResponse
|
* @return PdaResponse
|
||||||
*/
|
*/
|
||||||
PdaResponse move(JSONObject whereJson);
|
JSONObject move(JSONObject whereJson);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,5 +29,5 @@ public interface PdaMoveStorService {
|
|||||||
*
|
*
|
||||||
* @return PdaResponse
|
* @return PdaResponse
|
||||||
*/
|
*/
|
||||||
List<JSONObject> querydtl(JSONObject whereJson);
|
JSONObject querydtl(JSONObject whereJson);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package org.nl.wms.pda_manage.ios_manage.service.impl;
|
package org.nl.wms.pda_manage.ios_manage.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.common.exception.BadRequestException;
|
||||||
import org.nl.wms.pda_manage.ios_manage.service.PdaMoveStorService;
|
import org.nl.wms.pda_manage.ios_manage.service.PdaMoveStorService;
|
||||||
import org.nl.wms.pda_manage.util.PdaResponse;
|
import org.nl.wms.pda_manage.util.PdaResponse;
|
||||||
import org.nl.wms.warehouse_manage.service.dao.mapper.MdPbGroupplateMapper;
|
import org.nl.wms.warehouse_manage.service.dao.mapper.MdPbGroupplateMapper;
|
||||||
@@ -20,19 +23,46 @@ public class PdaMoveStorServiceImpl implements PdaMoveStorService {
|
|||||||
private StIvtMoveinvdtlMapper stIvtMoveinvdtlMapper;
|
private StIvtMoveinvdtlMapper stIvtMoveinvdtlMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PdaResponse move(JSONObject whereJson) {
|
public JSONObject move(JSONObject whereJson) {
|
||||||
// 移出货位编码
|
// 移出货位编码
|
||||||
String struct_code = whereJson.getString("struct_code");
|
String struct_code = whereJson.getString("struct_code");
|
||||||
// 载具号
|
// 载具号
|
||||||
String vehicle_code = whereJson.getString("vehicle_code");
|
String vehicle_code = whereJson.getString("vehicle_code");
|
||||||
// 移入货位
|
// 移入货位
|
||||||
String move_struct_code = whereJson.getString("move_struct_code");
|
String move_struct_code = whereJson.getString("move_struct_code");
|
||||||
|
//数组
|
||||||
|
JSONArray rows = whereJson.getJSONArray("data");
|
||||||
|
if (ObjectUtil.isEmpty(move_struct_code)) {
|
||||||
|
throw new BadRequestException("移入货位不能为空!");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(rows)) {
|
||||||
|
throw new BadRequestException("物料明细不能为空!");
|
||||||
|
}
|
||||||
|
//todo 生成移库单、生成移库任务
|
||||||
|
|
||||||
return PdaResponse.requestOk();
|
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||||
|
ret.put("message","操作成功");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<JSONObject> querydtl(JSONObject whereJson) {
|
public JSONObject querydtl(JSONObject whereJson) {
|
||||||
return stIvtMoveinvdtlMapper.querydtl(whereJson);
|
// 移出货位编码
|
||||||
|
String struct_code = whereJson.getString("struct_code");
|
||||||
|
// 载具号
|
||||||
|
String vehicle_code = whereJson.getString("vehicle_code");
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(struct_code) && ObjectUtil.isEmpty(vehicle_code)) {
|
||||||
|
throw new BadRequestException("货位编码和载具编码不能同时为空!");
|
||||||
|
}
|
||||||
|
List<JSONObject> list = stIvtMoveinvdtlMapper.querydtl(whereJson);
|
||||||
|
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||||
|
ret.put("message","查询成功");
|
||||||
|
ret.put("data",list);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
|||||||
* @author Liuxy
|
* @author Liuxy
|
||||||
* @since 2025-06-06
|
* @since 2025-06-06
|
||||||
*/
|
*/
|
||||||
public interface PdaSchPointService extends IService<SchBasePoint> {
|
public interface PdaSchPointService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询点位信息
|
* 查询点位信息
|
||||||
@@ -22,7 +22,7 @@ public interface PdaSchPointService extends IService<SchBasePoint> {
|
|||||||
* }
|
* }
|
||||||
* @return PdaResponse
|
* @return PdaResponse
|
||||||
*/
|
*/
|
||||||
PdaResponse getPoint(JSONObject whereJson);
|
JSONObject getPoint(JSONObject whereJson);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解绑
|
* 解绑
|
||||||
@@ -33,7 +33,7 @@ public interface PdaSchPointService extends IService<SchBasePoint> {
|
|||||||
* }
|
* }
|
||||||
* @return PdaResponse
|
* @return PdaResponse
|
||||||
*/
|
*/
|
||||||
PdaResponse binding(JSONObject whereJson);
|
JSONObject binding(JSONObject whereJson);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 绑定
|
* 绑定
|
||||||
@@ -44,6 +44,6 @@ public interface PdaSchPointService extends IService<SchBasePoint> {
|
|||||||
* }
|
* }
|
||||||
* @return PdaResponse
|
* @return PdaResponse
|
||||||
*/
|
*/
|
||||||
PdaResponse dissect(JSONObject whereJson);
|
JSONObject dissect(JSONObject whereJson);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public interface PdaSchTaskService extends IService<SchBaseTask> {
|
|||||||
* }
|
* }
|
||||||
* @return PdaResponse
|
* @return PdaResponse
|
||||||
*/
|
*/
|
||||||
PdaResponse queryTask(JSONObject whereJson);
|
JSONObject queryTask(JSONObject whereJson);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重新下发
|
* 重新下发
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
package org.nl.wms.pda_manage.sch_manage.service.impl;
|
package org.nl.wms.pda_manage.sch_manage.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.http.HttpStatus;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import org.nl.common.exception.BadRequestException;
|
||||||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleinfoService;
|
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.mapper.StructattrMapper;
|
||||||
import org.nl.wms.pda_manage.sch_manage.service.PdaSchPointService;
|
import org.nl.wms.pda_manage.sch_manage.service.PdaSchPointService;
|
||||||
import org.nl.wms.pda_manage.util.PdaResponse;
|
import org.nl.wms.warehouse_manage.service.dao.mapper.StIvtMoveinvdtlMapper;
|
||||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
|
||||||
import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 手持点位操作 实现类
|
* 手持点位操作 实现类
|
||||||
@@ -21,43 +26,103 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
* @since 2025-06-06
|
* @since 2025-06-06
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class PdaSchPointServiceImpl extends ServiceImpl<SchBasePointMapper, SchBasePoint> implements PdaSchPointService {
|
public class PdaSchPointServiceImpl implements PdaSchPointService {
|
||||||
|
@Resource
|
||||||
/**
|
private StIvtMoveinvdtlMapper stIvtMoveinvdtlMapper;
|
||||||
* 载具信息服务
|
@Resource
|
||||||
*/
|
private IStructattrService iStructattrService;
|
||||||
@Autowired
|
@Resource
|
||||||
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService;
|
private StructattrMapper structattrMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PdaResponse getPoint(JSONObject whereJson) {
|
public JSONObject getPoint(JSONObject whereJson) {
|
||||||
SchBasePoint pointDao = this.getById(whereJson.getString("point_code"));
|
// 载具号
|
||||||
pointDao.setStoragevehicle_code(pointDao.getVehicle_code());
|
String vehicle_code = whereJson.getString("vehicle_code");
|
||||||
return PdaResponse.requestParamOk(pointDao);
|
|
||||||
|
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||||
|
throw new BadRequestException("载具编码不能为空!");
|
||||||
|
}
|
||||||
|
whereJson.remove("struct_code");
|
||||||
|
List<JSONObject> list = stIvtMoveinvdtlMapper.querydtl(whereJson);
|
||||||
|
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||||
|
ret.put("message","查询成功");
|
||||||
|
ret.put("data",list);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public JSONObject binding(JSONObject whereJson) {
|
||||||
|
// 载具号
|
||||||
|
String vehicle_code = whereJson.getString("vehicle_code");
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||||
|
throw new BadRequestException("载具编码不能为空!");
|
||||||
|
}
|
||||||
|
// 载具号
|
||||||
|
String struct_code = whereJson.getString("struct_code");
|
||||||
|
if (ObjectUtil.isEmpty(struct_code)) {
|
||||||
|
throw new BadRequestException("点位编码不能为空!");
|
||||||
|
}
|
||||||
|
Structattr struct = structattrMapper.selectOne(new LambdaQueryWrapper<Structattr>()
|
||||||
|
.eq(Structattr::getStruct_code, struct_code)
|
||||||
|
);
|
||||||
|
if(ObjectUtil.isEmpty(struct)){
|
||||||
|
throw new BadRequestException("找不到点位:"+struct_code);
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotEmpty(struct.getStoragevehicle_code())){
|
||||||
|
throw new BadRequestException("点位:"+struct_code+"上已有载具号:"+struct.getStoragevehicle_code()+",不允许再次绑定!");
|
||||||
|
}
|
||||||
|
List<Structattr> list = structattrMapper.selectList(new LambdaQueryWrapper<Structattr>()
|
||||||
|
.eq(Structattr::getStoragevehicle_code, vehicle_code)
|
||||||
|
);
|
||||||
|
if(list.size()>0){
|
||||||
|
throw new BadRequestException("载具:"+vehicle_code+"上已绑定在货位:"+list.get(0).getStruct_code()+",不允许再次绑定!");
|
||||||
|
}
|
||||||
|
iStructattrService.update(
|
||||||
|
new UpdateWrapper<Structattr>().lambda()
|
||||||
|
.eq(Structattr::getStruct_code, struct_code)
|
||||||
|
.set(Structattr::getStoragevehicle_code, vehicle_code)
|
||||||
|
);
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||||
|
ret.put("message","操作成功");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public PdaResponse binding(JSONObject whereJson) {
|
public JSONObject dissect(JSONObject whereJson) {
|
||||||
this.update(
|
// 载具号
|
||||||
new UpdateWrapper<SchBasePoint>().lambda()
|
String vehicle_code = whereJson.getString("vehicle_code");
|
||||||
.eq(SchBasePoint::getPoint_code, whereJson.getString("point_code"))
|
|
||||||
.set(SchBasePoint::getVehicle_code, null)
|
|
||||||
.set(SchBasePoint::getIos_id, null)
|
|
||||||
);
|
|
||||||
return PdaResponse.requestOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (ObjectUtil.isEmpty(vehicle_code)) {
|
||||||
@Transactional
|
throw new BadRequestException("载具编码不能为空!");
|
||||||
public PdaResponse dissect(JSONObject whereJson) {
|
}
|
||||||
// 判断载具是否存在
|
// 载具号
|
||||||
iMdPbStoragevehicleinfoService.getByCode(whereJson.getString("vehicle_code"));
|
String struct_code = whereJson.getString("struct_code");
|
||||||
this.update(
|
if (ObjectUtil.isEmpty(struct_code)) {
|
||||||
new UpdateWrapper<SchBasePoint>().lambda()
|
throw new BadRequestException("点位编码不能为空!");
|
||||||
.eq(SchBasePoint::getPoint_code, whereJson.getString("point_code"))
|
}
|
||||||
.set(SchBasePoint::getVehicle_code, whereJson.getString("vehicle_code"))
|
Structattr struct = structattrMapper.selectOne(new LambdaQueryWrapper<Structattr>()
|
||||||
|
.eq(Structattr::getStruct_code, struct_code)
|
||||||
);
|
);
|
||||||
return PdaResponse.requestOk();
|
if(ObjectUtil.isEmpty(struct)){
|
||||||
|
throw new BadRequestException("找不到点位:"+struct_code);
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isEmpty(struct.getStoragevehicle_code())){
|
||||||
|
throw new BadRequestException("点位:"+struct_code+"上无载具号:"+vehicle_code+",不需要解绑!");
|
||||||
|
}
|
||||||
|
|
||||||
|
iStructattrService.update(
|
||||||
|
new UpdateWrapper<Structattr>().lambda()
|
||||||
|
.eq(Structattr::getStruct_code, whereJson.getString("struct_code"))
|
||||||
|
.set(Structattr::getStoragevehicle_code, null)
|
||||||
|
);
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||||
|
ret.put("message","操作成功");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 手持任务操作 实现类
|
* 手持任务操作 实现类
|
||||||
@@ -84,8 +86,14 @@ public class PdaSchTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PdaResponse queryTask(JSONObject whereJson) {
|
public JSONObject queryTask(JSONObject whereJson) {
|
||||||
return PdaResponse.requestParamOk(this.baseMapper.queryPdaTask(whereJson));
|
List<JSONObject> list = this.baseMapper.queryPdaTask(whereJson);
|
||||||
|
|
||||||
|
JSONObject ret = new JSONObject();
|
||||||
|
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||||
|
ret.put("message","查询成功");
|
||||||
|
ret.put("data",list);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.wms.sch_manage.service.util;
|
package org.nl.wms.sch_manage.service.util;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -56,6 +57,7 @@ public class AutoTask {
|
|||||||
* 定时下发任务
|
* 定时下发任务
|
||||||
*/
|
*/
|
||||||
private void sendTask() {
|
private void sendTask() {
|
||||||
|
System.out.println("定时下发任务开始--------------------------"+ DateUtil.now());
|
||||||
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>()
|
||||||
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
.eq(SchBaseTask::getIs_delete, IOSConstant.IS_DELETE_NO)
|
||||||
.eq(SchBaseTask::getTask_status, TaskStatus.CREATE.getCode()));
|
.eq(SchBaseTask::getTask_status, TaskStatus.CREATE.getCode()));
|
||||||
@@ -67,5 +69,11 @@ public class AutoTask {
|
|||||||
AbstractTask task = taskFactory.getTask(taskDao.getConfig_code());
|
AbstractTask task = taskFactory.getTask(taskDao.getConfig_code());
|
||||||
task.sendTaskOne(taskDao.getTask_id());
|
task.sendTaskOne(taskDao.getTask_id());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(6000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("定时下发任务结束+++++++++++++++++++++++++++"+ DateUtil.now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package org.nl.wms.system_manage.service.quartz.config;
|
package org.nl.wms.system_manage.service.quartz.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.net.NetUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.nl.wms.system_manage.service.quartz.ISysQuartzJobService;
|
import org.nl.wms.system_manage.service.quartz.ISysQuartzJobService;
|
||||||
|
import org.nl.wms.system_manage.service.quartz.dao.SysQuartzJob;
|
||||||
import org.nl.wms.system_manage.service.quartz.utils.QuartzManage;
|
import org.nl.wms.system_manage.service.quartz.utils.QuartzManage;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -10,6 +12,8 @@ import org.springframework.boot.ApplicationRunner;
|
|||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.core.annotation.Order;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 项目启动时重新激活启用的定时任务
|
* 项目启动时重新激活启用的定时任务
|
||||||
@@ -33,5 +37,28 @@ public class JobRunner implements ApplicationRunner {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments applicationArguments) {
|
public void run(ApplicationArguments applicationArguments) {
|
||||||
|
//本机IP
|
||||||
|
String localIp = NetUtil.getLocalhostStr();
|
||||||
|
System.out.println("本机ip:"+localIp);
|
||||||
|
|
||||||
|
log.info("--------------------注入定时任务---------------------");
|
||||||
|
List<SysQuartzJob> quartzJobs = quartzJobService.findByIsPauseIsFalse();
|
||||||
|
quartzJobs.forEach(job -> {
|
||||||
|
if (judgmentIp(job.getJob_ip())) {
|
||||||
|
log.info("定时任务:{}, 执行ip: {}, 定时任务开启", job.getJob_name(), localIp);
|
||||||
|
System.out.println("定时任务: " + job.getJob_name() + ", 执行ip: " + localIp + ", 定时任务开启");
|
||||||
|
quartzManage.addJob(job);
|
||||||
|
} else {
|
||||||
|
log.info("定时任务 {} 未开启, 本机ip{} 与 调度ip{} 不同", job.getJob_name(), localIp, job.getJob_ip());
|
||||||
|
System.out.println("定时任务 " + job.getJob_name() + " 未开启, 本机ip: " + localIp + " 与 调度ip: " + job.getJob_ip() + " 不同");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
log.info("--------------------定时任务注入完成---------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Boolean judgmentIp(String ip) {
|
||||||
|
return NetUtil.localAddressList(null).stream()
|
||||||
|
.anyMatch(inet -> ip.equals(inet.getHostAddress()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ public class SysQuartzJob implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String sub_task;
|
private String sub_task;
|
||||||
|
|
||||||
|
private String job_ip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 失败状态
|
* 失败状态
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.nl.wms.system_manage.service.quartz.impl.SysQuartzJobServiceImpl;
|
|||||||
import org.quartz.DisallowConcurrentExecution;
|
import org.quartz.DisallowConcurrentExecution;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||||
@@ -35,8 +36,8 @@ public class ExecutionJob extends QuartzJobBean {
|
|||||||
/**
|
/**
|
||||||
* 该处仅供参考
|
* 该处仅供参考
|
||||||
*/
|
*/
|
||||||
@Resource
|
@Autowired
|
||||||
@Qualifier("meshandlerPool")
|
@Qualifier("threadPoolExecutor")
|
||||||
private ThreadPoolExecutor EXECUTOR;
|
private ThreadPoolExecutor EXECUTOR;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.wms.system_manage.service.quartz.utils;
|
package org.nl.wms.system_manage.service.quartz.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.net.NetUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.common.exception.BadRequestException;
|
import org.nl.common.exception.BadRequestException;
|
||||||
import org.nl.config.language.LangProcess;
|
import org.nl.config.language.LangProcess;
|
||||||
@@ -23,10 +24,16 @@ import static org.quartz.TriggerBuilder.newTrigger;
|
|||||||
public class QuartzManage {
|
public class QuartzManage {
|
||||||
private static final String JOB_NAME = "TASK_";
|
private static final String JOB_NAME = "TASK_";
|
||||||
|
|
||||||
@Resource(name = "quartzScheduler")
|
@Resource(name = "scheduler")
|
||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
|
|
||||||
public void addJob(SysQuartzJob quartzJob) {
|
public void addJob(SysQuartzJob quartzJob) {
|
||||||
|
//本机IP
|
||||||
|
String localIp = NetUtil.getLocalhostStr();
|
||||||
|
System.out.println("本机ip:"+localIp);
|
||||||
|
if (!judgmentIp(quartzJob.getJob_ip())) {
|
||||||
|
throw new BadRequestException("本机ip与"+localIp+"调度ip"+quartzJob.getJob_ip()+"不同");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// 构建job信息
|
// 构建job信息
|
||||||
JobDetail jobDetail = JobBuilder.newJob(ExecutionJob.class).
|
JobDetail jobDetail = JobBuilder.newJob(ExecutionJob.class).
|
||||||
@@ -42,18 +49,18 @@ public class QuartzManage {
|
|||||||
cronTrigger.getJobDataMap().put(SysQuartzJob.JOB_KEY, quartzJob);
|
cronTrigger.getJobDataMap().put(SysQuartzJob.JOB_KEY, quartzJob);
|
||||||
|
|
||||||
//重置启动时间
|
//重置启动时间
|
||||||
((CronTriggerImpl)cronTrigger).setStartTime(new Date());
|
((CronTriggerImpl) cronTrigger).setStartTime(new Date());
|
||||||
|
|
||||||
//执行定时任务
|
//执行定时任务
|
||||||
scheduler.scheduleJob(jobDetail,cronTrigger);
|
scheduler.scheduleJob(jobDetail, cronTrigger);
|
||||||
|
|
||||||
// 暂停任务
|
// 暂停任务
|
||||||
if (quartzJob.getIs_pause()) {
|
if (quartzJob.getIs_pause()) {
|
||||||
pauseJob(quartzJob);
|
pauseJob(quartzJob);
|
||||||
}
|
}
|
||||||
} catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("创建定时任务失败", e);
|
log.error("创建定时任务失败", e);
|
||||||
throw new BadRequestException(LangProcess.msg("error_Create"));
|
throw new BadRequestException("创建定时任务失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,4 +164,8 @@ public class QuartzManage {
|
|||||||
throw new BadRequestException(LangProcess.msg("error_Detele"));
|
throw new BadRequestException(LangProcess.msg("error_Detele"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static Boolean judgmentIp(String ip) {
|
||||||
|
return NetUtil.localAddressList(null).stream()
|
||||||
|
.anyMatch(inet -> ip.equals(inet.getHostAddress()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
<select id="querydtl" resultType="com.alibaba.fastjson.JSONObject">
|
<select id="querydtl" resultType="com.alibaba.fastjson.JSONObject">
|
||||||
SELECT
|
SELECT
|
||||||
plate.group_id,
|
plate.group_id,
|
||||||
|
plate.storagevehicle_code,
|
||||||
plate.qty_unit_name AS unit_code,
|
plate.qty_unit_name AS unit_code,
|
||||||
plate.qty,
|
plate.qty,
|
||||||
plate.frozen_qty,
|
plate.frozen_qty,
|
||||||
@@ -50,6 +51,8 @@
|
|||||||
LEFT JOIN st_ivt_structattr struct ON struct.storagevehicle_code = plate.storagevehicle_code
|
LEFT JOIN st_ivt_structattr struct ON struct.storagevehicle_code = plate.storagevehicle_code
|
||||||
WHERE
|
WHERE
|
||||||
1 =1
|
1 =1
|
||||||
|
and plate.status='02'
|
||||||
|
and plate.qty > 0
|
||||||
<if test="param.struct_code != null and param.struct_code != ''">
|
<if test="param.struct_code != null and param.struct_code != ''">
|
||||||
AND
|
AND
|
||||||
struct.struct_code = #{param.struct_code}
|
struct.struct_code = #{param.struct_code}
|
||||||
|
|||||||
Reference in New Issue
Block a user