天眼同步提交及浙大调度优化
This commit is contained in:
@@ -76,6 +76,22 @@ public class QueryZDAgvTaskStatus {
|
||||
}
|
||||
} else if ("FINISHED".equals(status)) {
|
||||
if (inst != null){
|
||||
String startPoint=inst.getStart_point_code();
|
||||
Device start_device = deviceAppService.findDeviceByCode(startPoint);
|
||||
if (start_device.getDeviceDriver() instanceof SiteDeviceDriver) {
|
||||
SiteDeviceDriver siteDeviceDriver=(SiteDeviceDriver)start_device.getDeviceDriver();
|
||||
if(siteDeviceDriver.getMode()!=10) {
|
||||
try {
|
||||
siteDeviceDriver.writing(10);
|
||||
siteDeviceDriver.writing(10);
|
||||
siteDeviceDriver.writing(10);
|
||||
siteDeviceDriver.writing(10);
|
||||
siteDeviceDriver.writing(10);
|
||||
}catch(Exception e){
|
||||
log.error("写入信号失败:{}{}",e,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
}
|
||||
|
||||
@@ -182,8 +182,7 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
public List<SchBasePoint> getPointList(SchBasePoint region) {
|
||||
if (ObjectUtil.isEmpty(region)) return this.list();
|
||||
return pointMapper.selectList(new LambdaQueryWrapper<SchBasePoint>()
|
||||
.eq(SchBasePoint::getRegion_code, region.getRegion_code())
|
||||
.eq(SchBasePoint::getIs_has_workder, true));
|
||||
.eq(SchBasePoint::getRegion_code, region.getRegion_code()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.wms.sch.point.service.task;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.RedisUtils;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自动同步点位状态
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SyncPoint {
|
||||
|
||||
@Autowired
|
||||
private ISchBasePointService schBasePointService;
|
||||
|
||||
|
||||
public void run() throws Exception {
|
||||
try {
|
||||
log.info("自动线程开始查询天眼点位状态");
|
||||
String url = "http://10.44.101.61:12346/api/getStatus?binNo=ALL";
|
||||
log.info("下发天眼查询点位状态请求:{}", url);
|
||||
HttpResponse result = HttpRequest.post(url)
|
||||
.body(String.valueOf(new JSONObject()))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
log.info("查询天眼点位数据:" + result.body());
|
||||
SchBasePoint schBasePoint = new SchBasePoint();
|
||||
schBasePoint.setRegion_code("ZC");
|
||||
List<SchBasePoint> schBasePointList = schBasePointService.getPointList(schBasePoint);
|
||||
JSONArray jsonArray = JSONArray.parseArray(result.body());
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject=jsonArray.getJSONObject(i);
|
||||
for(SchBasePoint temp:schBasePointList){
|
||||
if (temp.getPoint_code().equals(jsonObject.getString("binNo"))){
|
||||
if(jsonObject.getInteger("pred")==0&&"2".equals(temp.getPoint_status())
|
||||
||jsonObject.getInteger("pred")==1&&"1".equals(temp.getPoint_status())){
|
||||
log.info("检测到点位{}当前库存有变动pred={},更新lms库存",jsonObject.getString("binNo"),jsonObject.getInteger("pred"));
|
||||
temp.setPoint_status(String.valueOf(jsonObject.getInteger("pred")+1));
|
||||
schBasePointService.update(temp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("自动线程查询天眼点位失败{}{}", e, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user