Commit 57b06d39 authored by tank.li@mushiny.com's avatar tank.li@mushiny.com

wcs任务发送

parent 07915eeb
......@@ -6,6 +6,7 @@ import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.dto.MessageDTO;
import com.mushiny.heli.xnr.dto.StorageLocation;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
import com.mushiny.heli.xnr.wcs.WmsToWcsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,6 +27,8 @@ public class ICQAService {
private final static Logger logger = LoggerFactory.getLogger(ICQAService.class);
@Autowired
private SystemPropertiesManager systemPropertiesManager;
@Autowired
private WmsToWcsService wmsToWcsService;
/**
* 当前货架的盘点任务
......@@ -165,9 +168,9 @@ public class ICQAService {
String needFace = CommonUtils.parseString("POD_FACE",podOrder);
//int sameFaceIndex = index.get(needFace);
String tripPositionID;
List<Map> tripPositions = this.inboundService.existTripPosition(workStation, podId, needFace,"ICQAPod");
List<Map> tripPositions = this.existTripPosition(workStation, podId, needFace);
if (tripPositions.isEmpty()) {
BaseBpo baseBpo2 = new BaseBpo();
/*BaseBpo baseBpo2 = new BaseBpo();
baseBpo2.setTable("RCS_TRIPPOSITION");
tripPositionID = CommonUtils.genUUID();
baseBpo2.addKV("ID", tripPositionID);
......@@ -177,14 +180,21 @@ public class ICQAService {
baseBpo2.addKV("POSITION_NO", j + 1);
baseBpo2.addKV("WAREHOUSE_ID", CommonUtils.parseString("WAREHOUSE_ID", map));
baseBpo2.addKV("SECTION_ID", CommonUtils.parseString("SECTION_ID", map));
this.jdbcRepository.insertBusinessObject(baseBpo2);
this.jdbcRepository.insertBusinessObject(baseBpo2);*/
Integer podIndex = CommonUtils.parseInteger("POD_INDEX",podOrder);
Integer stopCellId = CommonUtils.parseInteger("STOPPOINT",podOrder);
Integer sectId = CommonUtils.parseInteger("RCS_SECTIONID",podOrder);
Integer face = CommonUtils.faceToInteger(needFace);
Integer wsDirect = CommonUtils.wsFace2Direct(
CommonUtils.parseInteger("WORKING_FACE_ORIENTATION",podOrder));
tripPositionID = this.wmsToWcsService.sendSingleTripToWcs(podIndex,sectId,stopCellId,wsDirect,face);
}else{
Map data = tripPositions.get(0);
tripPositionID = CommonUtils.parseString("ID",data);
}
Map newValue = new HashMap();
newValue.put("STATE", Sql_Table.AVAILABLE);//生成就结束了 是不是执行完看TRIPPOSITION_ID
newValue.put("STATE", Sql_Table.PROCESS);//生成就结束了 是不是执行完看TRIPPOSITION_ID
newValue.put("TRIPPOSITION_ID", tripPositionID);
CommonUtils.modifyUselessInfo(newValue);
......@@ -196,6 +206,12 @@ public class ICQAService {
}
}
public List<Map> existTripPosition(String workStation, String podId, String needFace) {
List<Map> datas = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_ICQA_PODORDER,
needFace,podId,workStation);
return datas;
}
public Map searchIcqa(Map data) {
String taskId = CommonUtils.parseString("taskId", data);
......@@ -329,7 +345,7 @@ public class ICQAService {
baseBpo.addKV("WORKSTATION_ID", stationName);
baseBpo.addKV("PODINDEX", storageLocation.getPodIndex());
baseBpo.addKV("AMOUNT", CommonUtils.parseString("AMOUNT", map));
baseBpo.addKV("STATE", Sql_Table.NEW);
baseBpo.addKV("STATE", Sql_Table.AVAILABLE);
baseBpo.addKV("WAREHOUSE_ID", CommonUtils.parseString("WAREHOUSE_ID", map));
baseBpo.addKV("SECTION_ID", CommonUtils.parseString("SECTION_ID", map));
//插入货架搬运任务 指令
......
......@@ -10,7 +10,6 @@ import com.mushiny.heli.xnr.wcs.WmsToWcsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
......@@ -113,11 +112,13 @@ public class InboundService {
Map data = invs.get(0);
String uid = CommonUtils.parseString("ID",data);
List<Map> lists = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_INV_SKU,uid,mID);
String id = null;
//是否存在记录
if(lists.isEmpty()){
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.TABLE_INV_STOCKUNIT);
baseBpo.addKV("ID",CommonUtils.genUUID());
id = CommonUtils.genUUID();
baseBpo.addKV("ID",id);
baseBpo.addKV("ITEMDATA_ID",mID);
baseBpo.addKV("STATE","Inventory");
baseBpo.addKV("AMOUNT",stored);//上架的数量
......@@ -134,10 +135,10 @@ public class InboundService {
Map newValue = new HashMap();
newValue.put("AMOUNT",amount+stored);//增加的库存数
CommonUtils.modifyUselessInfo(newValue);
id = CommonUtils.parseString("ID",inv);
Map con = new HashMap();
con.put("ITEMDATA_ID",mID);
con.put("UNITLOAD_ID",uid);
con.put("ID",id);
//con.put("UNITLOAD_ID",uid);
this.jdbcRepository.updateRecords(Sql_Table.TABLE_INV_STOCKUNIT,newValue,con);
}
......@@ -155,7 +156,7 @@ public class InboundService {
//结束货架任务信息 PodOrder
this.updateInboundPodOrder(Sql_Table.FINISH, podOrderId);
//增加入库流水记录
this.add2InboundHistory(entryId,pId,skuId,containerId);
this.add2InboundHistory(stored,entryId,pId,skuId,containerId,uid,id);
return messageDTO;
}
......@@ -169,10 +170,30 @@ public class InboundService {
con.put("ID",podOrderId);
//
int count = this.jdbcRepository.updateRecords(Sql_Table.WMS_INBOUND_PODORDER, newValue, con);
logger.debug("更新入库货架任务成功! count:"+count);
}
private void add2InboundHistory(String entryId, String pId, String skuId, String containerId) {
private void add2InboundHistory(Integer amount, String entryId, String pId,
String skuId, String containerId, String uid,String stockUnitId) {
//TODO
Map record = new HashMap();
record.put("ID",CommonUtils.genUUID());
CommonUtils.genUselessInfo(record);
record.put("RECORD_TOOL","Receive");
record.put("RECORD_TYPE","EACH_RECEIVE_TO_STOW");
record.put("AMOUNT",amount);
record.put("ITEMDATA_ITEMNO",skuId);
record.put("FROM_STATE","Inventory");
record.put("OPERATOR","Lisi");
record.put("FROM_STOCKUNIT",entryId);
record.put("TO_STOCKUNIT",stockUnitId);
record.put("TO_UNITLOAD",uid);
record.put("TO_STORAGELOCATION",containerId);
record.put("CLIENT_ID","Inventory");
record.put("WAREHOUSE_ID","Inventory");
this.jdbcRepository.insertRecord("INV_STOCKUNITRECORD",record);
logger.debug("增加库存历史记录成功:"+record);
}
private Map getIbOrderPosition(String entryId, String skuId) {
......@@ -303,7 +324,7 @@ public class InboundService {
baseBpo.addKV("WORKSTATION_ID",stationName);
baseBpo.addKV("PODINDEX",storageLocation.getPodIndex());
baseBpo.addKV("AMOUNT",CommonUtils.parseString("AMOUNT",map));
baseBpo.addKV("STATE", Sql_Table.NEW);
baseBpo.addKV("STATE", Sql_Table.AVAILABLE);
baseBpo.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
//插入货架搬运任务 指令
......@@ -365,9 +386,9 @@ public class InboundService {
String needFace = CommonUtils.parseString("POD_FACE",podOrder);
//int sameFaceIndex = index.get(needFace);
String tripPositionID;
List<Map> tripPositions = existTripPosition(workStation, podId, needFace,"StowPod");
List<Map> tripPositions = existTripPosition(workStation, podId, needFace);
if (tripPositions.isEmpty()) {
BaseBpo baseBpo2 = new BaseBpo();
/*BaseBpo baseBpo2 = new BaseBpo();
baseBpo2.setTable("RCS_TRIPPOSITION");
tripPositionID = CommonUtils.genUUID();
baseBpo2.addKV("ID", tripPositionID);
......@@ -380,16 +401,22 @@ public class InboundService {
//发送任务
//this.WcsAPI.sent
//发送任务结束
this.jdbcRepository.insertBusinessObject(baseBpo2);
this.jdbcRepository.insertBusinessObject(baseBpo2);*/
Integer podIndex = CommonUtils.parseInteger("POD_INDEX",podOrder);
Integer stopCellId = CommonUtils.parseInteger("STOPPOINT",podOrder);
Integer sectId = CommonUtils.parseInteger("RCS_SECTIONID",podOrder);
Integer face = CommonUtils.faceToInteger(needFace);
Integer wsDirect = CommonUtils.wsFace2Direct(
CommonUtils.parseInteger("WORKING_FACE_ORIENTATION",podOrder));
tripPositionID = this.wmsToWcsService.sendSingleTripToWcs(podIndex,sectId,stopCellId,wsDirect,face);
}else{
Map data = tripPositions.get(0);
tripPositionID = CommonUtils.parseString("ID",data);
tripPositionID = CommonUtils.parseString("TRIPPOSITION_ID",data);//实际是WCS返回的任务号
}
Map newValue = new HashMap();
newValue.put("STATE", Sql_Table.AVAILABLE);//生成就结束了 是不是执行完看TRIPPOSITION_ID
newValue.put("STATE", Sql_Table.PROCESS);//生成就结束了 是不是执行完看TRIPPOSITION_ID
newValue.put("TRIPPOSITION_ID", tripPositionID);
//newValue.put("TRIPPOSITION_ID", tripPositionID);
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
......@@ -403,84 +430,21 @@ public class InboundService {
private WmsToWcsService wmsToWcsService;
/**
* 发送任务到WCS 将状态变成Process 两种类型都处理
* 通过入库单号检查WCS任务信息
* @param entryId
* @return
*/
@Scheduled(fixedDelay = 10*1000L)
@Transactional
public void wcsTrip(){
//1、检查有没有执行完的
this.checkTasks();
//2、检查有没有未执行的
this.sendTasks();
}
private void checkTasks() {
List<Map> rcsTrips = this.jdbcRepository.queryBySql(Sql_Table.QUERY_RCSTRIP, //寻找RCSTRIP里新建的或执行中的任务,并且子表记录
Sql_Table.PROCESS, Sql_Table.PROCESS);
/*SELECT RCS_TRIPPOSITION.ID TRIPPOSITION_ID,RCS_TRIP.ID TRIP_ID,
WD_SECTION.RCS_SECTIONID,MD_POD.POD_INDEX,
MD_WORKSTATION.STOPPOINT,MD_WORKSTATION.WORKING_FACE_ORIENTATION,
RCS_TRIPPOSITION.POD_USING_FACE */
String tripId = "";
for (int i = 0; i < rcsTrips.size(); i++) {
Map row = rcsTrips.get(i);
String currentTripId = CommonUtils.parseString("TRIP_ID",row);
String tripPositionId = CommonUtils.parseString("TRIPPOSITION_ID",row);
String taskId = CommonUtils.parseString("TASKID",row);
public String checkInboundTasks(String entryId) {
List<Map> podOrders = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_INBOUND_PODORDER_BYENTRYID, entryId);
for (int i = 0; i < podOrders.size(); i++) {
Map row = podOrders.get(i);
String taskId = CommonUtils.parseString("TRIPPOSITION_ID",row);
String result = this.wmsToWcsService.agvTaskDetail(taskId);
Map data = JsonUtils.json2Map(result);
String state = CommonUtils.parseString("taskStatus",data);
if(Objects.equals("Finished",state)){
state = Sql_Table.FINISH;
this.updateTripPositionStatus(state, tripPositionId);
row.put("taskStatus",state);
}
}
//找所有子表标记为Finish但主表还存在Process的记录 更新调
//TODO
}
private void sendTasks() {
List<Map> rcsTrips = this.jdbcRepository.queryBySql(Sql_Table.QUERY_RCSTRIP, //寻找RCSTRIP里新建的或执行中的任务,并且子表记录
Sql_Table.NEW,Sql_Table.AVAILABLE);
/*SELECT RCS_TRIPPOSITION.ID TRIPPOSITION_ID,RCS_TRIP.ID TRIP_ID,
WD_SECTION.RCS_SECTIONID,MD_POD.POD_INDEX,
MD_WORKSTATION.STOPPOINT,MD_WORKSTATION.WORKING_FACE_ORIENTATION,
RCS_TRIPPOSITION.POD_USING_FACE */
String tripId = "";
for (int i = 0; i < rcsTrips.size(); i++) {
Map row = rcsTrips.get(i);
String currentTripId = CommonUtils.parseString("TRIP_ID",row);
String tripPositionId = CommonUtils.parseString("TRIPPOSITION_ID",row);
Integer face = CommonUtils.faceToInteger(CommonUtils.parseString("POD_USING_FACE",row));
if((i == rcsTrips.size()-1) || (!CommonUtils.isEmpty(tripId)
&& !Objects.equals(currentTripId,tripId))){
//原先的RCSTRIP状态更新
this.updateTripStatus(Sql_Table.PROCESS,tripId);
}
Integer podIndex = CommonUtils.parseInteger("POD_INDEX",row);
Integer stopCellId = CommonUtils.parseInteger("STOPPOINT",row);
Integer sectId = CommonUtils.parseInteger("RCS_SECTIONID",row);
Integer wsDirect = CommonUtils.wsFace2Direct(
CommonUtils.parseInteger("WORKING_FACE_ORIENTATION",row));
String taskId = this.wmsToWcsService.sendSingleTripToWcs(podIndex,sectId,stopCellId,wsDirect,face);
this.updateTripPositionStatus(Sql_Table.PROCESS, tripPositionId,taskId);
}
}
private void updateTripPositionStatus(String state, String tripPositionId, String taskId) {
Map newValue = new HashMap();
newValue.put("TRIPPOSITION_STATE",state);
newValue.put("TASKID",taskId);//增加一个字段
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put("ID",tripPositionId);
this.jdbcRepository.updateRecords("RCS_TRIPPOSITION",newValue,con);
return JsonUtils.list2Json(podOrders);
}
private void updateTripPositionStatus(String state, String tripPositionId) {
......@@ -494,16 +458,6 @@ public class InboundService {
}
private void updateTripStatus(String state, String tripId) {
Map newValue = new HashMap();
newValue.put("TRIP_STATE",state);
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put("ID",tripId);
this.jdbcRepository.updateRecords("RCS_TRIP",newValue,con);
}
/**
* 检查任务状态 如果完成将状态变成Finish 两种类型都处理
*/
......@@ -513,21 +467,14 @@ public class InboundService {
}
private Map<String, Integer> genIndexMap() {
Map<String, Integer> map = new HashMap<>();
map.put("A",1);
map.put("B",1);
map.put("C",1);
map.put("D",1);
return map;
}
public List<Map> existTripPosition(String workStation, String podId, String needFace,String type) {
List<Map> datas = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_TRIPPOSITION,
needFace,workStation,type,podId);
public List<Map> existTripPosition(String workStation, String podId, String needFace) {
List<Map> datas = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_INBOUND_PODORDER,
needFace,podId,workStation);
return datas;
}
private StorageLocation newStorageLocation() {
List<Map> list = this.jdbcRepository.queryBySql(Sql_Table.SQL_NEWSTORAGELOCATION);
if(list.isEmpty()){
......
......@@ -98,6 +98,7 @@ public interface Sql_Table {
String SQL_QUERY_CURRENTPOD = "SELECT WMS_POD_STATION.POD_ID, WMS_POD_STATION.POD_INDEX, WMS_POD_STATION.TOWARD, \n" +
" MD_WORKSTATION.WORKING_FACE_ORIENTATION, \n" +
" WMS_POD_STATION.TRIP_TASKID, \n" +
" WMS_POD_STATION.SECTION_ID, \n" +
" WMS_POD_STATION.PLACEMARK FROM WMS_POD_STATION, MD_WORKSTATION \n" +
" WHERE WMS_POD_STATION.PLACEMARK = MD_WORKSTATION.STOPPOINT \n" +
" AND MD_WORKSTATION.ID = ?";
......@@ -207,4 +208,11 @@ public interface Sql_Table {
"AND RCS_TRIP.TRIP_STATE= ?\n" +
"AND RCS_TRIPPOSITION.TRIPPOSITION_STATE=? \n" +
"ORDER BY POD_INDEX";
String SQL_QUERY_INBOUND_PODORDER = "SELECT * FROM WMS_INBOUND_PODORDER " +
"WHERE STATE='Available' AND POD_FACE=? " +
"AND POD_ID=? AND WORKSTATION_ID=? limit 1";
String SQL_QUERY_ICQA_PODORDER = "SELECT * FROM WMS_ICQA_PODORDER " +
"WHERE STATE='Available' AND POD_FACE=? " +
"AND POD_ID=? AND WORKSTATION_ID=? limit 1";
String SQL_QUERY_INBOUND_PODORDER_BYENTRYID = "SELECT * FROM WMS_INBOUND_PODORDER WHERE ENTRYID=?";
}
......@@ -331,8 +331,8 @@ public class WMSService {
public void podRelease(Map req) {
//货架号(数字)、工作站号(ID)/ SectionID
Integer podIndex = CommonUtils.parseInteger("podIndex", req);
String stationId = CommonUtils.parseString("stationId",req);
String sectionId = CommonUtils.parseString("sectionId",req);
this.wmsToWcsService.releasePod(stationId,sectionId,podIndex);
String stationId = CommonUtils.parseString("stationName",req);
//String sectionId = CommonUtils.parseString("sectionId",req);
this.wmsToWcsService.releasePod(stationId,podIndex);
}
}
......@@ -130,10 +130,10 @@ public class WmsToWcsService{
@Transactional
public void releasePod(String workStationId,String sectionId, Integer podIndex) {
logger.info("工作站 = {} 释放pod = {} ,sectionId = {} ",workStationId,podIndex,sectionId);
public void releasePod(String workStationId,Integer podIndex) {
logger.info("工作站 = {} 释放pod = {} ",workStationId,podIndex);
//先查询该停止点是否有任务
Map podStation = this.getByWorkStationIdAndPodIndex(workStationId,sectionId,podIndex);
Map podStation = this.getByWorkStationIdAndPodIndex(workStationId,podIndex);
if(podStation == null){
logger.info("工作站 :{} 没有pod : {} ,无法释放。。",workStationId, podIndex);
......@@ -152,6 +152,7 @@ public class WmsToWcsService{
logger.info("工作站 = {} 释放pod = {} ,wcs返回taskId:{}", workStationId, podIndex);
//更显pod状态
String sectionId = CommonUtils.parseString("SECTION_ID",podStation);
updatePodState(podIndex,sectionId, Sql_Table.AVAILABLE);
}
......@@ -159,9 +160,8 @@ public class WmsToWcsService{
return this.jdbcRepository.queryOneBySql(Sql_Table.SQL_QUERYPODBYINDEX, sectionId, podIndex);
}
private Map getByWorkStationIdAndPodIndex(String workStationId, String sectionId, Integer podIndex) {
logger.debug("条件 workStationId :"+workStationId+" sectionId:"
+sectionId+" pod: "+podIndex);
private Map getByWorkStationIdAndPodIndex(String workStationId, Integer podIndex) {
logger.debug("条件 workStationId :"+workStationId+" pod: "+podIndex);
Map data = this.jdbcRepository.queryOneBySql(Sql_Table.SQL_QUERY_CURRENTPOD, workStationId);
if(Objects.equals(podIndex, CommonUtils.parseInteger("POD_INDEX",data))){
return data;
......@@ -172,7 +172,15 @@ public class WmsToWcsService{
private void updatePodState(Integer podId, String sectionId,String status) {
Map newValue = new HashMap();
newValue.put("STATE",Sql_Table.AVAILABLE);
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put("SECTION_ID",sectionId);
con.put("POD_INDEX",podId);
this.jdbcRepository.updateRecords("MD_POD",newValue,con);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment