Commit 23db72e4 authored by tank.li@mushiny.com's avatar tank.li@mushiny.com

盘点任务回复

parent fd0d1b10
......@@ -88,4 +88,22 @@ public class WMSController {
return ResponseEntity.ok(dto);
}
@PostMapping(value = "/unlock", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> unlock(
@RequestBody String json) {
MessageDTO dto = MessageDTO.success();
try {
int count = this.wmsService.unlock();
if (count == 0) {
dto.setCODE(1);//失败
dto.setMESSAGE("解锁失败!");
}
} catch (Exception e) {
dto.setMESSAGE(e.getMessage());
dto.setCODE(1);
}
return ResponseEntity.ok(dto);
}
}
......@@ -38,7 +38,7 @@ public class ICQAService {
public Map currentPodTask(String stationName) {
Map dto = new HashMap();
//如果没有锁定 就没有任务
if(isLocked(stationName) ){
if(this.inboundService.isLockedByOthers(stationName, Sql_Table.STOWPOD) ){
dto.put("CODE",1);
dto.put("MSG","工作站"+stationName+"被占用,没有当前任务!");
return dto;
......@@ -127,29 +127,32 @@ public class ICQAService {
@Scheduled(fixedDelay = 10*1000L)
public void startICQATrip(){
//6db9c7c0-4f93-4fa1-82c0-fb6435af7aae
if(isLocked(WMSService.stationId)){
logger.error("工作站被锁定,无法启动盘点任务!");
if(this.inboundService.isLockedByOthers(WMSService.stationId,Sql_Table.ICQAPOD)){
logger.error("工作站被锁定,无法启动ICQA任务!");
return ;
}
//TODO 根据工作站查找
String pods = this.systemPropertiesManager.getProperty("EN_ROUTE_MAX_PODS_BINCHENK", Sql_Table.WAREHOUSE);
List<Map> runningPods = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_RUNNINGPODS,
"ICQAPod", Sql_Table.AVAILABLE,Sql_Table.PROCESS, Sql_Table.NEW);
if(pods == null){
pods = "5";
}
List<Map> runningPods = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_RUNNINGPODS_ICQA,
WMSService.stationId, Sql_Table.AVAILABLE,Sql_Table.PROCESS);
Integer limit = Integer.parseInt(pods) - runningPods.size(); //TODO 按工作站区分
//先找这么多货架 然后加载所有任务
List<Map> podIds = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_ICQAPODS, "ICQAPod", Sql_Table.AVAILABLE);
List<Map> podIds = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_ICQAPODS, Sql_Table.AVAILABLE, Sql_Table.PROCESS);
for (int i = 0; i < podIds.size() && i < limit; i++) {
Map map = podIds.get(i);
String podId = CommonUtils.parseString("POD_ID",map);
String workStation = CommonUtils.parseString("WORKSTATION_ID",map);
List<Map> orderPosition = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODORDERS
,podId, Sql_Table.NEW); //New Available Finish 没有Process
List<Map> orderPosition = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODORDERS_ICQA
,podId, Sql_Table.AVAILABLE); //New Available Finish 没有Process //TODO
if(orderPosition.isEmpty()){
logger.error("当前货架没有调度任务 podId:"+podId);
continue;
}
BaseBpo baseBpo = new BaseBpo();
/*BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable("RCS_TRIP");
String tripId = CommonUtils.genUUID();
baseBpo.addKV("ID",tripId);
......@@ -159,7 +162,7 @@ public class ICQAService {
baseBpo.addKV("TRIP_STATE",Sql_Table.NEW);
baseBpo.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
this.jdbcRepository.insertBusinessObject(baseBpo);
this.jdbcRepository.insertBusinessObject(baseBpo);*/
//序号生成 从1开始
//Map<String,Integer> index = this.genIndexMap();
for (int j = 0; j < orderPosition.size(); j++) {
......@@ -236,7 +239,15 @@ public class ICQAService {
//启动时 如果包含全库启动的 只能单起 不能混合
String type = CommonUtils.parseString("type", data);
String stationName = CommonUtils.parseString("stationName", data);
if (!this.inboundService.lockStowStation(stationName)) {
//查询是否为空
if(this.inboundService.isLockedByOthers(stationName, Sql_Table.STOWPOD)){
messageDTO.setCODE(1);
messageDTO.setMESSAGE("工作站被锁定或不存在,无法启动盘点任务!");
return messageDTO;
}
if (!this.inboundService.lockStowStation(stationName,Sql_Table.ICQAPOD)) {
messageDTO.setCODE(1);
messageDTO.setMESSAGE("工作站不存在 或 锁定工作站失败:" + stationName);
return messageDTO;
......
......@@ -272,12 +272,12 @@ public class InboundService {
//成功
MessageDTO dto = MessageDTO.success();
//查询是否为空
if(isLocked(stationName)){
if(isLockedByOthers(stationName, Sql_Table.STOWPOD)){
dto.setCODE(1);
dto.setMESSAGE("工作站被锁定或不存在,无法启动上架任务!");
return dto;
}
if(!this.lockStowStation(stationName)){
if(!this.lockStowStation(stationName,Sql_Table.STOWPOD)){
dto.setCODE(1);
dto.setMESSAGE("工作站锁定失败,无法启动上架任务!");
return dto;
......@@ -338,36 +338,42 @@ public class InboundService {
private String stationId = "6db9c7c0-4f93-4fa1-82c0-fb6435af7aae";*/
/**
* 定时启动任务 生成RCS_TRIP表数据
* 定时启动任务
*/
@Scheduled(fixedDelay = 10*1000L)
public void startInboundTrip(){
//6db9c7c0-4f93-4fa1-82c0-fb6435af7aae
if(isLocked(WMSService.stationId)){
if(this.isLockedByOthers(WMSService.stationId, Sql_Table.STOWPOD)){
logger.error("工作站被锁定,无法启动上架任务!");
return ;
}
//TODO
//TODO 根据工作站查找
String pods = this.systemPropertiesManager.getProperty("StowPodStationMaxPod", Sql_Table.WAREHOUSE);
List<Map> runningPods = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_RUNNINGPODS,
"StowPod", Sql_Table.AVAILABLE, Sql_Table.PROCESS, Sql_Table.NEW);
if(pods == null){
pods = "5";
}
List<Map> runningPods = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_RUNNINGPODS_INBOUND,
WMSService.stationId, Sql_Table.AVAILABLE,Sql_Table.PROCESS);
Integer limit = Integer.parseInt(pods) - runningPods.size(); //TODO 按工作站区分
//先找这么多货架 然后加载所有任务
List<Map> podIds = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODS, "StowPod", Sql_Table.AVAILABLE);
List<Map> podIds = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODS,
Sql_Table.AVAILABLE , Sql_Table.PROCESS);
for (int i = 0; i < podIds.size() && i < limit; i++) {
Map map = podIds.get(i);
String podId = CommonUtils.parseString("POD_ID",map);
String workStation = CommonUtils.parseString("WORKSTATION_ID",map);
List<Map> orderPosition = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODORDERS
,podId, Sql_Table.NEW); //New Available Finish 没有Process
List<Map> orderPosition = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_PODORDERS_INBOUND
,podId, Sql_Table.AVAILABLE); //Available Process Finish 没有Process
if(orderPosition.isEmpty()){
logger.error("当前货架没有调度任务 podId:"+podId);
continue;
}
//TODO 如有正在执行的POD任务 应该是添加到明细里
BaseBpo baseBpo = new BaseBpo();
/*BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable("RCS_TRIP");
String tripId = CommonUtils.genUUID();
baseBpo.addKV("ID",tripId);
......@@ -377,7 +383,7 @@ public class InboundService {
baseBpo.addKV("TRIP_STATE",Sql_Table.NEW);
baseBpo.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
this.jdbcRepository.insertBusinessObject(baseBpo);
this.jdbcRepository.insertBusinessObject(baseBpo);*/
//序号生成 从1开始
//Map<String,Integer> index = this.genIndexMap();
for (int j = 0; j < orderPosition.size(); j++) {
......@@ -512,7 +518,7 @@ public class InboundService {
storageLocation.setpName(pName);
}
public synchronized boolean lockStowStation(String stationId) {
public synchronized boolean lockStowStation(String stationId, String type) {
List<Map> stations = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_WORKSTATION,stationId);
if(stations.isEmpty()){
......@@ -524,7 +530,7 @@ public class InboundService {
newValue.put("VERSION",version+1);
newValue.put("ISCALLPOD",Boolean.TRUE);
newValue.put("OPERATOR_ID","LISI");
newValue.put("STATION_NAME","stowPod");
newValue.put("STATION_NAME",type);
Map con = new HashMap();
con.put("ID",stationId);
......@@ -534,17 +540,17 @@ public class InboundService {
return count != 0;
}
//用户名写死为 LISI
private boolean isLocked(String stationId) {
public boolean isLockedByOthers(String stationId, String type) {
List<Map> rows = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_WORKSTATION, stationId);
if(rows.isEmpty()){
return false;
return true;
}
Map data = rows.get(0);
String operator_id = CommonUtils.parseString("OPERATOR_ID",data);
String station_name = CommonUtils.parseString("STATION_NAME",data);
if(!CommonUtils.isEmpty(operator_id)
&& !Objects.equals(operator_id,"LISI")
&& !Objects.equals(station_name,"StowPod")){
&& !Objects.equals(station_name,type)){
return true;
}
return false;
......@@ -581,7 +587,7 @@ public class InboundService {
public Map currentPodTask(String stationName) {
Map dto = new HashMap();
//如果没有锁定 就没有任务
if(isLocked(stationName) ){
if(isLockedByOthers(stationName, Sql_Table.STOWPOD) ){
dto.put("CODE",1);
dto.put("MSG","工作站"+stationName+"被占用,没有当前任务!");
return dto;
......@@ -668,7 +674,7 @@ public class InboundService {
/*public Map prePodTask(String stationName) {
Map dto = new HashMap();
//如果没有锁定 就没有任务
if(isLocked(stationName) ){
if(isLockedByOthers(stationName) ){
dto.put("CODE",1);
dto.put("MSG","工作站"+stationName+"被占用,没有当前任务!");
return dto;
......
......@@ -32,7 +32,8 @@ public interface Sql_Table {
"AND INV_UNITLOAD.ID = INV_STOCKUNIT.UNITLOAD_ID\n" +
"AND INV_UNITLOAD.STORAGELOCATION_ID = MD_STORAGELOCATION.ID\n" +
"AND AMOUNT > 0 AND MD_STORAGELOCATION.`NAME` LIKE 'P00%'\n" +
"GROUP BY MD_ITEMDATA.ITEM_NO,MD_ITEMDATA.NAME LIMIT 200";
"GROUP BY MD_ITEMDATA.ITEM_NO,MD_ITEMDATA.NAME, " +
"MD_STORAGELOCATION.SECTION_ID,MD_ITEMDATA.CLIENT_ID LIMIT 200";
String SQL_FINDITEM_BYITENNO = "SELECT SUM(AMOUNT) AS SUMALL,MD_ITEMDATA.`ITEM_NO`,\n" +
"MD_ITEMDATA.`NAME` , \n" +
......@@ -73,19 +74,22 @@ public interface Sql_Table {
"AND MD_ITEMDATA.ITEM_NO=MD_ITEMDATA_SKUNO.ITEM_NO \n" +
"AND MD_ITEMDATA_SKUNO.SKU_NO=? AND POD_ID IS NOT NULL LIMIT 1";
String WMS_INBOUND_PODORDER = "WMS_INBOUND_PODORDER";
String SQL_QUERY_PODS = "SELECT DISTINCT POD_ID,WORKSTATION_ID,WAREHOUSE_ID,SECTION_ID " +
" FROM WMS_INBOUND_PODORDER" +
" WHERE POD_ID NOT IN (SELECT POD_ID FROM RCS_TRIP WHERE TRIP_TYPE=? AND TRIP_STATE=?) " +
" LIMIT 10";
" FROM WMS_INBOUND_PODORDER WHERE STATE=? AND POD_ID NOT IN " +
"(SELECT POD_ID FROM WMS_INBOUND_PODORDER WHERE STATE=?) LIMIT 10";
String SQL_QUERY_ICQAPODS = "SELECT DISTINCT POD_ID,WORKSTATION_ID,WAREHOUSE_ID,SECTION_ID " +
" FROM WMS_ICQA_PODORDER" +
" WHERE POD_ID NOT IN (SELECT POD_ID FROM RCS_TRIP WHERE TRIP_TYPE=? AND TRIP_STATE=?) " +
" LIMIT 10";
String SQL_QUERY_RUNNINGPODS = "SELECT DISTINCT POD_ID " +
"FROM RCS_TRIP WHERE TRIP_TYPE=? " +
"AND (TRIP_STATE=? OR TRIP_STATE=? OR TRIP_STATE=?)" +
" LIMIT 10";
String SQL_QUERY_PODORDERS = "SELECT * FROM WMS_INBOUND_PODORDER WHERE POD_ID=? AND STATE=? ";
" FROM WMS_ICQA_PODORDER WHERE STATE=? AND POD_ID NOT IN " +
"(SELECT POD_ID FROM WMS_ICQA_PODORDER WHERE STATE=?) LIMIT 10";
String SQL_QUERY_RUNNINGPODS_INBOUND = "SELECT * FROM WMS_INBOUND_PODORDER WHERE WORKSTATION_ID=? " +
"AND (STATE=? OR STATE=?) LIMIT 10";
String SQL_QUERY_RUNNINGPODS_ICQA = "SELECT * FROM WMS_ICQA_PODORDER WHERE WORKSTATION_ID=? " +
"AND (STATE=? OR STATE=?) LIMIT 10";
String SQL_QUERY_PODORDERS_INBOUND = "SELECT * FROM WMS_INBOUND_PODORDER WHERE POD_ID=? AND STATE=? ";
String SQL_QUERY_PODORDERS_ICQA = "SELECT * FROM WMS_INBOUND_PODORDER WHERE POD_ID=? AND STATE=? ";
String TABLE_MD_WORKSTATION = "MD_WORKSTATION";
String WMS_INBOUND_ORDER = "WMS_INBOUND_ORDER";
String WMS_INBOUND_ORDERPOSITION = "WMS_INBOUND_ORDERPOSITION";
......@@ -231,4 +235,6 @@ public interface Sql_Table {
"AND NOT EXISTS (SELECT 1 FROM WMS_INBOUND_ORDERPOSITION \n" +
"WHERE WMS_INBOUND_ORDERPOSITION.STATE<>'Finish' \n" +
"AND WMS_INBOUND_ORDERPOSITION.ENTRYID=WMS_INBOUND_ORDER.ENTRYID)";
String STOWPOD = "StowPod";
String ICQAPOD = "IcqaPod";
}
......@@ -310,7 +310,7 @@ public class WMSRespService {
return new ArrayList<>(temp.values());
}
@Scheduled(fixedDelay = 10*1000L)
@Scheduled(fixedDelay = 5000*1000L)
@Transactional
public void storageResp(){
List<Map> rows = this.jdbcRepository
......
......@@ -335,4 +335,21 @@ public class WMSService {
//String sectionId = CommonUtils.parseString("sectionId",req);
this.wmsToWcsService.releasePod(stationId,podIndex);
}
/**
*
*/
public int unlock() {
//货架号(数字)、工作站号(ID)/ SectionID
Map newValue = new HashMap();
newValue.put("ISCALLPOD",Boolean.FALSE);
newValue.put("OPERATOR_ID","");
newValue.put("STATION_NAME","");
Map con = new HashMap();
con.put("ID", this.stationId);
int count = this.jdbcRepository.updateRecords(Sql_Table.TABLE_MD_WORKSTATION, newValue ,con);
return count;
}
}
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