Commit 56a06cb1 authored by tank.li@mushiny.com's avatar tank.li@mushiny.com

调整任务发送之前

parent 7e639af0
......@@ -3,8 +3,10 @@ package com.mushiny.heli.xnr.controller;
import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.dto.ItemDTO;
import com.mushiny.heli.xnr.dto.MessageDTO;
import com.mushiny.heli.xnr.mq.MqSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -20,6 +22,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/heli")
public class HeliWMSController {
@Autowired
private MqSender mqSender;
private final static Logger logger = LoggerFactory.getLogger(HeliWMSController.class);
@PostMapping(value = "/icqaResp", produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -30,4 +35,13 @@ public class HeliWMSController {
return ResponseEntity.ok(dto);
}
@PostMapping(value = "/sendMsg", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> sendMsg(
@RequestBody String json){
logger.debug("json: " + json);
MessageDTO dto = MessageDTO.success();
mqSender.sendMsg(json, "amq.topic","monitor_pod_to_workstation.*");
return ResponseEntity.ok(dto);
}
}
......@@ -145,4 +145,18 @@ public class ICQAController {
return ResponseEntity.ok(dto);
}
/**
* @param json
* @return
*/
@PostMapping(value = "/skuNotFound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> skuNotFound(
@RequestBody String json){
Map reqData = JsonUtils.json2Map(json);
String taskId = CommonUtils.parseString("taskId",reqData);
String skuId = CommonUtils.parseString("skuId",reqData);
MessageDTO dto = this.icqaService.skuNotFound(taskId,skuId);
return ResponseEntity.ok(dto);
}
}
package com.mushiny.heli.xnr.controller;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.comm.JsonUtils;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* Created by Lisi on 2019-11-30.
*/
@RestController
@RequestMapping("/outbound")
public class OutboundController {
/**
* @param json
* @return
*/
@PostMapping(value = "/searchOutbound", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> searchInbound(
@RequestBody String json){
return ResponseEntity.ok(json);
}
}
package com.mushiny.heli.xnr.mq;
import com.mushiny.heli.xnr.beans.BaseBpo;
import com.mushiny.heli.xnr.comm.CommonUtils;
import com.mushiny.heli.xnr.comm.JsonUtils;
import com.mushiny.heli.xnr.controller.HeliWMSController;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
import com.mushiny.heli.xnr.service.Sql_Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.transaction.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class MqListener {
private final static Logger logger = LoggerFactory.getLogger(MqListener.class);
@Autowired
private JdbcRepository jdbcRepository;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "", durable = "true"),
exchange = @Exchange(value = "amq.topic" , ignoreDeclarationExceptions = "true"),
key = "monitor_pod_to_workstation.*"))
public void pod2Station(Message message){
byte[] body = message.getBody();
String jsonData = new String(body);
Map data = JsonUtils.json2Map(jsonData);
logger.info("monitor_pod_to_workstation:" + data);
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "", durable = "true"),
exchange = @Exchange(value = "amq.topic" , ignoreDeclarationExceptions = "true"),
key = "monitor_pod_to_workstation.*"))
public void pod2Station2(Message message){
byte[] body = message.getBody();
String jsonData = new String(body);
Map data = JsonUtils.json2Map(jsonData);
logger.info("monitor_pod_to_workstation2:" + data);
}
@RabbitListener(queues = "POD_STATION_HELI")
@Transactional
public void pod2Station3(Message message){
byte[] body = message.getBody();
String jsonData = new String(body);
Map data = JsonUtils.json2Map(jsonData);
logger.info("monitor_pod_to_workstation3:" + data);
int stopCellId = CommonUtils.parseInteger("stopCellId",data);
String sectionId = this.getSectionIdBySid(CommonUtils.parseInteger("sectionId",data));
String workstationId = this.getWorkstationIdByStopPoint(stopCellId,sectionId);
/*Integer sectionId;
Integer stopCellId; //停止点
Integer direction;//工作站相对停止点方向
String podId;
Integer podDirection;
String taskId;*/
List<Map> rows = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_POD_STATION,stopCellId,workstationId);
if(rows.isEmpty()){
Map record = new HashMap();
record.putAll(data);
//替换掉 便于查询
record.put("stopCellId",workstationId);
record.put("sectionId",sectionId);
CommonUtils.genUselessInfo(record);
this.jdbcRepository.insertRecord(Sql_Table.TABLE_WMS_POD_STATION,record);
logger.debug("新增记录成功");
}else{
Map newValue = new HashMap();
newValue.putAll(data);
newValue.put("stopCellId",workstationId);
newValue.put("sectionId",sectionId);
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put("stopCellId",workstationId);
con.put("sectionId",sectionId);
int ret = this.jdbcRepository.updateRecords(Sql_Table.TABLE_WMS_POD_STATION, newValue, con);
logger.debug("更新记录:"+data+" 结果为:"+ret);
}
}
private String getWorkstationIdByStopPoint(int stopCellId, String sectionId) {
Map row = this.jdbcRepository.queryOneBySql(Sql_Table.SQL_QUERYWDBYSTOP,stopCellId,sectionId);
return CommonUtils.parseString("ID",row);
}
private String getSectionIdBySid(Integer sid) {
Map row = this.jdbcRepository.queryOneBySql(Sql_Table.SQL_QUERYSECTIONBYSID,sid);
return CommonUtils.parseString("ID",row);
}
}
package com.mushiny.heli.xnr.mq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.UUID;
/**
* Created by Lisi on 2019-12-12.
*/
@Component
public class MqSender implements RabbitTemplate.ConfirmCallback {
private final static Logger logger = LoggerFactory.getLogger(MqSender.class);
private RabbitTemplate rabbitTemplate;
@Autowired
public MqSender(RabbitTemplate rabbitTemplate) {
this.rabbitTemplate = rabbitTemplate;
}
public void sendMsg(String message, String exchange, String route) {
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(exchange, route, message, correlationId);
logger.debug("成功往exchange:"+exchange+" route:"+route+" 发送消息:"+message);
}
@Override
public void confirm(CorrelationData correlationData, boolean b, String s) {
logger.debug("confirm String:" + s);
}
}
......@@ -452,4 +452,27 @@ public class ICQAService {
data.put("content",items);
return data;
}
public MessageDTO skuNotFound(String taskId, String skuId) {
MessageDTO messageDTO = MessageDTO.success();
Map newValue = new HashMap();
newValue.put("STATE",Sql_Table.FINISH);
newValue.put("MSG","没有物料");
newValue.put("COUNT","0");
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put("SKUID",skuId);
con.put("TASKID",taskId);
int count = this.jdbcRepository.updateRecords(Sql_Table.WMS_ICQA_ORDERPOSITION, newValue, con);
if(count == 0){
messageDTO.setMESSAGE("更新失败,entryId:"+taskId+" skuId:"+skuId);
messageDTO.setCODE(1);
return messageDTO;
}
return messageDTO;
}
}
......@@ -598,7 +598,7 @@ public class InboundService {
System.out.println(getFace(270,270));*/
}
public Map prePodTask(String stationName) {
/*public Map prePodTask(String stationName) {
Map dto = new HashMap();
//如果没有锁定 就没有任务
if(isLocked(stationName) ){
......@@ -617,7 +617,7 @@ public class InboundService {
}
Map data = datas.get(0);
/*`ID` varchar(255) NOT NULL,
*//*`ID` varchar(255) NOT NULL,
`ENTRYID` varchar(255) NOT NULL,
`ENTRYPOSITIONID` varchar(255) NOT NULL,
`SKUID` varchar(255) NOT NULL,
......@@ -625,7 +625,7 @@ public class InboundService {
`POD_FACE` varchar(255) NOT NULL,
`POD_LOCATE` varchar(255) NOT NULL,
`PODINDEX` int(11) DEFAULT NULL COMMENT '货架编号',
`STATE` varchar(255) COMMENT '状态',*/
`STATE` varchar(255) COMMENT '状态',*//*
String skuId = CommonUtils.parseString("SKUID",data);
List<Map> skus = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERYITEM_BYSKUNO, skuId);
if (skus.isEmpty()){
......@@ -637,5 +637,5 @@ public class InboundService {
data.put("SKUNAME",CommonUtils.parseString("NAME",sku));
return data;
}
}*/
}
......@@ -7,26 +7,6 @@ public interface Sql_Table {
String SQL_QUERY_INV_SKU = "SELECT * FROM INV_STOCKUNIT WHERE UNITLOAD_ID=? AND ITEMDATA_ID=?";
String SQL_QUERY_CURRENTPODTASK = "SELECT WMS_INBOUND_PODORDER.* \n" +
"FROM MD_POD,MD_WORKSTATION,RCS_TRIP, RCS_TRIPPOSITION, \n" +
"WMS_INBOUND_PODORDER, WMS_INBOUND_ORDERPOSITION \n" +
"WHERE MD_WORKSTATION.ID=RCS_TRIP.WORKSTATION_ID \n" +
"AND WMS_INBOUND_PODORDER.TRIPPOSITION_ID \n" +
"AND MD_POD.PLACEMARK=MD_WORKSTATION.STOPPOINT\n" +
"AND WMS_INBOUND_ORDERPOSITION.ID=WMS_INBOUND_PODORDER.ENTRYPOSITIONID \n" +
"AND WMS_INBOUND_ORDERPOSITION.STATE= ? \n" +
"AND RCS_TRIP.POD_ID=MD_POD.ID \n" +
"AND RCS_TRIPPOSITION.TRIPPOSITION_STATE = ? \n" +
"AND TRIP_STATE= ? \n" +
"AND RCS_TRIP.ID=RCS_TRIPPOSITION.TRIP_ID \n" +
"AND MD_WORKSTATION.ID = ? \n" +
"LIMIT 1";
String SQL_QUERY_INBOUNDORDER_BYPOSITIONSTATE = "SELECT WMS_INBOUND_ORDER.* " +
"FROM WMS_INBOUND_ORDER\n" +
"WHERE NOT EXISTS (SELECT * FROM WMS_INBOUND_ORDERPOSITION \n" +
"WHERE WMS_INBOUND_ORDERPOSITION.STATE<>? \n" +
"AND WMS_INBOUND_ORDERPOSITION.ENTRYID = WMS_INBOUND_ORDER.ENTRYID)";
String SQL_QUERYITEM_BYID = "SELECT * FROM MD_ITEMDATA WHERE ID=?";
String TABLE_MD_ITEMDATA = "MD_ITEMDATA";
......@@ -208,4 +188,8 @@ public interface Sql_Table {
" WHERE WMS_ICQA_ORDERPOSITION.TASKID=WMS_ICQA_ORDER.TASKID\n" +
" AND WMS_ICQA_ORDERPOSITION.STATE<>'Finish') \n" +
" AND WMS_ICQA_ORDER.STATE<>'Finish'";
String SQL_QUERY_POD_STATION = "SELECT * FROM WMS_POD_STATION WHERE STATION_ID=?";
String TABLE_WMS_POD_STATION = "WMS_POD_STATION";
String SQL_QUERYSECTIONBYSID = "SELECT * FROM WD_SECTION WHERE RCS_SECTIONID=?";
String SQL_QUERYWDBYSTOP = "SELECT * FROM MD_WORKSTATION WHERE STOPPOINT = ? AND SECTION_ID=?";
}
......@@ -120,7 +120,7 @@ public class WMSRespService {
}
private List<InboundOrderDTO> transfer2IcqaDTO(List<Map> data) {
return new ArrayList<>();
}
@Scheduled(fixedDelay = 50*1000L)
......
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