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

盘点任务回复

parent 6b966008
......@@ -26,9 +26,18 @@ public class HeliWMSController {
private MqSender mqSender;
private final static Logger logger = LoggerFactory.getLogger(HeliWMSController.class);
//inboundResp
@PostMapping(value = "/inboundResp", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> inboundResp(
@RequestBody String json){
logger.debug("inboundResp: " + json);
MessageDTO dto = MessageDTO.success();
return ResponseEntity.ok(dto);
}
@PostMapping(value = "/icqaResp", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MessageDTO> syncItem(
public ResponseEntity<MessageDTO> icqaResp(
@RequestBody String json){
logger.debug("icqaResp: " + json);
MessageDTO dto = MessageDTO.success();
......
package com.mushiny.heli.xnr.dto;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.util.List;
/**
* Created by Lisi on 2019-12-17.
*/
public class IcqaOrderDTO implements java.io.Serializable {
@JsonProperty("ICQAID")
private String TASKID;
@JsonProperty("TIMES")
private Integer TIMES;
@JsonProperty("FACTORY")
private String FACTORY;
@JsonProperty("SECTION")
private String SECTION;
@JsonProperty("DATA")
List<IcqaOrderPosition> DATA;
@JsonIgnore
public String getTASKID() {
return TASKID;
}
@JsonIgnore
public void setTASKID(String TASKID) {
this.TASKID = TASKID;
}
@JsonIgnore
public Integer getTIMES() {
return TIMES;
}
@JsonIgnore
public void setTIMES(Integer TIMES) {
this.TIMES = TIMES;
}
@JsonIgnore
public String getFACTORY() {
return FACTORY;
}
@JsonIgnore
public void setFACTORY(String FACTORY) {
this.FACTORY = FACTORY;
}
@JsonIgnore
public String getSECTION() {
return SECTION;
}
@JsonIgnore
public void setSECTION(String SECTION) {
this.SECTION = SECTION;
}
@JsonIgnore
public List<IcqaOrderPosition> getDATA() {
return DATA;
}
public void setDATA(List<IcqaOrderPosition> DATA) {
this.DATA = DATA;
}
}
package com.mushiny.heli.xnr.dto;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import java.io.Serializable;
/**
* 电梯配置
*/
public class IcqaOrderPosition implements Serializable {
@JsonProperty("SKUID")
private String SKUID;
@JsonProperty("AMOUNT")
private Integer AMOUNT;
@JsonProperty("COUNT")
private Integer COUNT;
@JsonProperty("STATE")
private String STATE;
@JsonProperty("MSG")
private String MSG;
@JsonIgnore
public Integer getCOUNT() {
return COUNT;
}
@JsonIgnore
public void setCOUNT(Integer COUNT) {
this.COUNT = COUNT;
}
@JsonIgnore
public String getSTATE() {
return STATE;
}
@JsonIgnore
public void setSTATE(String STATE) {
this.STATE = STATE;
}
@JsonIgnore
public String getMSG() {
return MSG;
}
@JsonIgnore
public void setMSG(String MSG) {
this.MSG = MSG;
}
@JsonIgnore
public String getSKUID() {
return SKUID;
}
@JsonIgnore
public void setSKUID(String SKUID) {
this.SKUID = SKUID;
}
@JsonIgnore
public Integer getAMOUNT() {
return AMOUNT;
}
@JsonIgnore
public void setAMOUNT(Integer AMOUNT) {
this.AMOUNT = AMOUNT;
}
}
......@@ -215,4 +215,10 @@ public interface Sql_Table {
"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=?";
String SQL_QUERY_INBOUND_POSFINISH = "SELECT * FROM WMS_INBOUND_ORDER \n" +
"WHERE WMS_INBOUND_ORDER.NEED_RESP=0 \n" +
"AND WMS_INBOUND_ORDER.STATE<>'Finish'\n" +
"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)";
}
......@@ -3,10 +3,7 @@ package com.mushiny.heli.xnr.service;
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.dto.InboundOrderDTO;
import com.mushiny.heli.xnr.dto.InboundOrderPosition;
import com.mushiny.heli.xnr.dto.OutboundOrderDTO;
import com.mushiny.heli.xnr.dto.OutboundOrderPosition;
import com.mushiny.heli.xnr.dto.*;
import com.mushiny.heli.xnr.jdbc.repositories.JdbcRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -45,6 +42,7 @@ public class WMSRespService {
public static final String TABLE_OBORDER = "WMS_OUTBOUND_ORDER";
public static final String TABLE_IBORDER = "WMS_INBOUND_ORDER";
public static final String TABLE_ICQAORDER = "WMS_INBOUND_ORDER";
public static final String SQL_QUERYALL_ICQAORDER =
"SELECT * FROM WMS_ICQA_ORDER,WMS_ICQA_ORDERPOSITION " +
"WHERE WMS_ICQA_ORDER.TASKID = WMS_ICQA_ORDERPOSITION.TASKID " +
......@@ -85,22 +83,22 @@ public class WMSRespService {
HttpHeaders headers = this.getHttpHeaders();
List<Map> data = this.jdbcRepository.queryBySql(SQL_QUERYALL_ICQAORDER,FINISH);
List<InboundOrderDTO> data2 = this.transfer2IcqaDTO(data);//合并主表记录
List<IcqaOrderDTO> data2 = this.transfer2IcqaDTO(data);//合并主表记录
for (int i = 0; i < data2.size(); i++) {
InboundOrderDTO inboundOrderDTO = data2.get(i);
String json = JsonUtils.bean2Json(inboundOrderDTO);
IcqaOrderDTO icqaOrderDTO = data2.get(i);
String json = JsonUtils.bean2Json(icqaOrderDTO);
logger.debug("post data: " + json);
HttpEntity<String> httpEntity = new HttpEntity<String>(json, headers);
ResponseEntity<String> res = restTemplate.postForEntity(this.icqaResp_url, httpEntity, String.class);
Map result = JsonUtils.json2Map(res.getBody());
logger.debug("result: " + result);
if(CommonUtils.parseInteger("CODE",result) == 0){
logger.debug("成功回调"+inboundOrderDTO.getENTRYID());
logger.debug("成功回调"+icqaOrderDTO.getTASKID());
Map newValue = new HashMap();
newValue.put("NEED_RESP",2);
Map con = new HashMap();
con.put("TASKID",inboundOrderDTO.getENTRYID());
this.jdbcRepository.updateRecords(TABLE_IBORDER,newValue,con);
con.put("TASKID",icqaOrderDTO.getTASKID());
this.jdbcRepository.updateRecords(TABLE_ICQAORDER,newValue,con);
}
}
//检查是否有明细已完成 需要将主表记录更新为完成Finish 本来是一条语句完成的
......@@ -119,8 +117,35 @@ public class WMSRespService {
}
}
private List<InboundOrderDTO> transfer2IcqaDTO(List<Map> data) {
return new ArrayList<>();
private List<IcqaOrderDTO> transfer2IcqaDTO(List<Map> data) {
//return new ArrayList<>();
Map<String,IcqaOrderDTO> temp = new HashMap();
for (int i = 0; i < data.size(); i++) {
Map map = data.get(i);
String taskid = (String) map.get("TASKID");
if(temp.get(taskid) == null){
IcqaOrderDTO inboundOrderDTO = new IcqaOrderDTO();
inboundOrderDTO.setTASKID(taskid);
inboundOrderDTO.setSECTION((String) map.get("SECTION_ID"));
inboundOrderDTO.setFACTORY((String) map.get("WAREHOUSE_ID"));
inboundOrderDTO.setTIMES(CommonUtils.parseInteger("TIMES",map));
inboundOrderDTO.setDATA(new ArrayList<>());
temp.put(taskid,inboundOrderDTO);
}
IcqaOrderDTO icqaOrderDTO = temp.get(taskid);
//每行一条明细记录
IcqaOrderPosition icqaOrderPosition = new IcqaOrderPosition();
icqaOrderPosition.setSKUID((String) map.get("SKUID"));
icqaOrderPosition.setAMOUNT(CommonUtils.parseInteger("AMOUNT",map));
icqaOrderPosition.setMSG(CommonUtils.parseString("MSG",map));
icqaOrderPosition.setSTATE(CommonUtils.parseString("STATE",map));
icqaOrderPosition.setCOUNT(CommonUtils.parseInteger("COUNT",map));
icqaOrderDTO.getDATA().add(icqaOrderPosition);
}
//返回所有
return new ArrayList<>(temp.values());
}
@Scheduled(fixedDelay = 50*1000L)
......@@ -150,6 +175,23 @@ public class WMSRespService {
this.jdbcRepository.updateRecords(TABLE_IBORDER,newValue,con);
}
}
//检查是否有任务完成的 将 NEED_RESP 修改成1
//检查是否有明细已完成 需要将主表记录更新为完成Finish 本来是一条语句完成的
List<Map> allFinishedInbound = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_INBOUND_POSFINISH);
for (int i = 0; i < allFinishedInbound.size(); i++) {
Map icqaOrder = allFinishedInbound.get(i);
BaseBpo baseBpo = new BaseBpo();
baseBpo.setTable(Sql_Table.WMS_INBOUND_ORDER);
baseBpo.setId(CommonUtils.parseString("ENTRYID",icqaOrder));
baseBpo.setIdName("ENTRYID");
baseBpo.addKV("STATE",Sql_Table.FINISH);
baseBpo.addKV("NEED_RESP", 1);
CommonUtils.modifyUselessInfo(baseBpo.getKv());
this.jdbcRepository.updateBusinessObject(baseBpo);
}
}
private HttpHeaders getHttpHeaders() {
......@@ -244,8 +286,8 @@ public class WMSRespService {
if(temp.get(entryId) == null){
InboundOrderDTO inboundOrderDTO = new InboundOrderDTO();
inboundOrderDTO.setENTRYID(entryId);
inboundOrderDTO.setSECTION((String) map.get("SECTION"));
inboundOrderDTO.setFACTORY((String) map.get("FACTORY"));
inboundOrderDTO.setSECTION((String) map.get("SECTION_ID"));
inboundOrderDTO.setFACTORY((String) map.get("WAREHOUSE_ID"));
inboundOrderDTO.setTIMES(CommonUtils.parseInteger("TIMES",map));
inboundOrderDTO.setDATA(new ArrayList<>());
temp.put(entryId,inboundOrderDTO);
......
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