parent
b6585973ca
commit
c816bb40db
@ -0,0 +1,31 @@
|
||||
package com.zhehekeji.web.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zhehekeji.core.pojo.Result;
|
||||
import com.zhehekeji.web.entity.SteeringEngine;
|
||||
import com.zhehekeji.web.mapper.SteeringEngineMapper;
|
||||
import com.zhehekeji.web.service.sick.SickConnMap;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api( tags = "堆垛机")
|
||||
@RequestMapping(value = "/SteeringEngineController")
|
||||
@RestController()
|
||||
@Slf4j
|
||||
public class SteeringEngineController {
|
||||
@Resource
|
||||
SteeringEngineMapper steeringEngineMapper;
|
||||
@GetMapping("/start")
|
||||
@ApiOperation(value = "sick扫码枪开始扫")
|
||||
public Result userCenter() {
|
||||
List<SteeringEngine> list =steeringEngineMapper.selectList(new QueryWrapper<>());
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package com.zhehekeji.web.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhehekeji.web.service.PlcCmdInfo;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("\"steeringEngine\"")
|
||||
public class SteeringEngine {
|
||||
private String workunitid;
|
||||
private String dloc;
|
||||
private String jobnum;
|
||||
private String loggnum;
|
||||
private String pltnum;
|
||||
|
||||
|
||||
private String plttype;
|
||||
private String sloc;
|
||||
private String workunitdesc;
|
||||
private String workunitstatus;
|
||||
|
||||
public static PlcCmdInfo getPlcCmdInfo(SteeringEngine steeringEngine) {
|
||||
PlcCmdInfo plcCmdInfo = new PlcCmdInfo();
|
||||
plcCmdInfo.setTaskId(String.valueOf(steeringEngine.getJobnum()));
|
||||
plcCmdInfo.setOrderNum(String.valueOf(steeringEngine.getPltnum()));
|
||||
plcCmdInfo.setPlcId(String.valueOf(steeringEngine.getWorkunitid()));
|
||||
if(steeringEngine.getSloc()!=null && steeringEngine.getSloc().endsWith("000")){
|
||||
plcCmdInfo.setLeftRight1(Integer.valueOf(steeringEngine.getSloc().substring(3,4)));
|
||||
plcCmdInfo.setColumn1(Integer.valueOf(steeringEngine.getSloc().substring(4,6)));
|
||||
plcCmdInfo.setRow1(Integer.valueOf(steeringEngine.getSloc().substring(6,8)));
|
||||
plcCmdInfo.setSeparation1(1);
|
||||
}else {
|
||||
plcCmdInfo.setLeftRight1(0);
|
||||
plcCmdInfo.setColumn1(0);
|
||||
plcCmdInfo.setRow1(0);
|
||||
plcCmdInfo.setSeparation1(1);
|
||||
}
|
||||
if(steeringEngine.getDloc()!=null && steeringEngine.getDloc().endsWith("000")){
|
||||
plcCmdInfo.setLeftRight2(Integer.valueOf(steeringEngine.getSloc().substring(3,4)));
|
||||
plcCmdInfo.setColumn2(Integer.valueOf(steeringEngine.getSloc().substring(4,6)));
|
||||
plcCmdInfo.setRow2(Integer.valueOf(steeringEngine.getSloc().substring(6,8)));
|
||||
plcCmdInfo.setSeparation2(1);
|
||||
}else {
|
||||
plcCmdInfo.setLeftRight2(0);
|
||||
plcCmdInfo.setColumn2(0);
|
||||
plcCmdInfo.setRow2(0);
|
||||
plcCmdInfo.setSeparation2(1);
|
||||
}
|
||||
return plcCmdInfo;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
package com.zhehekeji.web.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhehekeji.web.entity.SteeringEngine;
|
||||
|
||||
@DS("slave")
|
||||
public interface SteeringEngineMapper extends BaseMapper<SteeringEngine> {
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.zhehekeji.web.service;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhehekeji.web.entity.SteeringEngine;
|
||||
import com.zhehekeji.web.mapper.SteeringEngineMapper;
|
||||
import com.zhehekeji.web.mapper.StockLogMapper;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@DS("slave")
|
||||
public class SteeringEngineService extends ServiceImpl<SteeringEngineMapper,SteeringEngine> implements IService<SteeringEngine>{
|
||||
@Resource
|
||||
private PlcService plcService;
|
||||
private Map<String,SteeringEngine> steeringEngineMap = new ConcurrentHashMap<>();
|
||||
|
||||
void check(){
|
||||
List<SteeringEngine> list = list();
|
||||
Map<String,SteeringEngine> newMap = list.stream().collect(Collectors.toMap(SteeringEngine::getWorkunitdesc, v->v));
|
||||
for (String streetId : newMap.keySet()){
|
||||
//如果为空或状态不同,则进入随行记录
|
||||
if(steeringEngineMap.get(streetId) ==null){
|
||||
//记录
|
||||
steeringEngineMap.put(streetId,newMap.get(streetId));
|
||||
}else if(!steeringEngineMap.get(streetId).getWorkunitstatus().equals("0") && !steeringEngineMap.get(streetId).getWorkunitstatus().equals(newMap.get(streetId).getWorkunitstatus())){
|
||||
|
||||
//在跑随行
|
||||
if(!newMap.get(streetId).getJobnum().equals("0")){
|
||||
plcService.orderStart(SteeringEngine.getPlcCmdInfo(newMap.get(streetId)));
|
||||
}
|
||||
|
||||
//随行结束
|
||||
else {
|
||||
plcService.orderStop(SteeringEngine.getPlcCmdInfo(newMap.get(streetId)));
|
||||
}
|
||||
|
||||
//记录
|
||||
steeringEngineMap.put(streetId,newMap.get(streetId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue