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

init

parent 628d6f6e
......@@ -4,11 +4,15 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.util.TimeZone;
@SpringBootApplication
@EnableScheduling
public class XnrInterfaceApplication {
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
SpringApplication.run(XnrInterfaceApplication.class, args);
}
......
......@@ -228,7 +228,8 @@ public class CommonUtils {
public static void genUselessInfo(Map record) {
//record.put("ID",genUUID());
record.putIfAbsent("CREATED_DATE",new Timestamp(System.currentTimeMillis()));
Date date = DateUtils.asDate(LocalDateTime.now());
record.putIfAbsent("CREATED_DATE",new Timestamp(date.getTime()));
record.putIfAbsent("CREATED_BY","SYSTEM");
/*record.put("CLIENT_ID","SYSTEM");*/
//record.putIfAbsent("WAREHOUSE_ID", "DEFAULT");
......@@ -238,7 +239,8 @@ public class CommonUtils {
public static void modifyUselessInfo(Map record) {
record.put("MODIFIED_BY","SYSTEM");
record.put("MODIFIED_DATE",new Timestamp(System.currentTimeMillis()));
Date date = DateUtils.asDate(LocalDateTime.now());
record.put("MODIFIED_DATE",new Timestamp(date.getTime()));
}
public static Long parseLong(String key, Map data) {
......
package com.mushiny.heli.xnr.comm;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
/**
* Created by Lisi on 2019-11-28.
*/
public class DateUtils {
public static Date asDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
public static Date asDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
public static LocalDate asLocalDate(Date date) {
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
}
public static LocalDateTime asLocalDateTime(Date date) {
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
}
}
......@@ -99,7 +99,7 @@ public class InboundController {
@RequestBody String json){
Map reqData = JsonUtils.json2Map(json);
String entryId = CommonUtils.parseString("entryId",reqData);
String skuId = CommonUtils.parseString("entryId",reqData);
String skuId = CommonUtils.parseString("skuId",reqData);
MessageDTO dto = this.inboundService.skuNotFound(entryId,skuId);
return ResponseEntity.ok(dto);
}
......@@ -146,7 +146,15 @@ public class InboundController {
return ResponseEntity.ok(JsonUtils.map2Json(dto));
}
//前次操作
//前次操作 暂时实现不了 可以再次生成上架任务
@PostMapping(value = "/prePodTask", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> prePodTask(
@RequestBody String json){
/*Map station = JsonUtils.json2Map(json);
//工作站号码
Map dto = this.inboundService.prePodTask(CommonUtils.parseString("stationName",station));
return ResponseEntity.ok(JsonUtils.map2Json(dto));*/
return null;
}
}
......@@ -151,14 +151,36 @@ public class InboundService {
this.jdbcRepository.updateRecords(Sql_Table.TABLE_INV_STOCKUNIT,newValue,con);
}
String msg = "OK";
//查询入库单的入库数量
Map ibOrderPosition = this.getIbOrderPosition(entryId,skuId);
if(stored > CommonUtils.parseInteger("AMOUNT",ibOrderPosition)){
msg = "物料多货";
}else if(stored < CommonUtils.parseInteger("AMOUNT",ibOrderPosition)){
msg = "物料少货";
}
String pId = CommonUtils.parseString("ID", ibOrderPosition);
//更新入库单状态
this.updateInboundOrderStatus(entryId,skuId, Sql_Table.FINISH,stored,"OK");
this.updateInboundOrderStatus(entryId,skuId, Sql_Table.FINISH,stored,msg);
//增加入库流水记录
this.add2InboundHistory(entryId,pId,skuId,containerId);
return messageDTO;
}
private void add2InboundHistory(String entryId, String pId, String skuId, String containerId) {
//TODO
}
private Map getIbOrderPosition(String entryId, String skuId) {
List<Map> data = this.jdbcRepository
.queryBySql(Sql_Table.SQL_QUERY_INBOUNDORDERPOSITION,entryId,skuId);
if(data.isEmpty()){
return null;
}
return data.get(0);
}
/**
* 更新入库单状态
* @param entryId
......@@ -176,6 +198,7 @@ public class InboundService {
newValue.put("STATE",state);
newValue.put("MSG",msg);
newValue.put("STORED",stored);
CommonUtils.modifyUselessInfo(newValue);
Map con = new HashMap();
con.put("SKUID",skuId);
......@@ -198,7 +221,7 @@ public class InboundService {
*/
public MessageDTO skuNotFound(String entryId, String skuId) {
return this.updateInboundOrderStatus(entryId, skuId, Sql_Table.ERROR,0, "SKU NOT FOUND");
return this.updateInboundOrderStatus(entryId, skuId, Sql_Table.ERROR,0, "物料丢失");
}
......@@ -315,32 +338,59 @@ public class InboundService {
baseBpo.addKV("WAREHOUSE_ID",CommonUtils.parseString("WAREHOUSE_ID",map));
baseBpo.addKV("SECTION_ID",CommonUtils.parseString("SECTION_ID",map));
this.jdbcRepository.insertBusinessObject(baseBpo);
//序号生成 从1开始
Map<String,Integer> index = this.genIndexMap();
for (int j = 0; j < orderPosition.size(); j++) {
//如果存在就不要再创建
Map podOrders = orderPosition.get(j);
BaseBpo baseBpo2 = new BaseBpo();
baseBpo2.setTable("RCS_TRIPPOSITION");
String tripPositionID = CommonUtils.genUUID();
baseBpo2.addKV("ID",tripPositionID);
baseBpo2.addKV("TRIP_ID",tripId);
baseBpo2.addKV("POD_USING_FACE",CommonUtils.parseString("POD_FACE",map));
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);
//如果存在RCS_TRIPPOSITION就不要再创建
Map podOrder = orderPosition.get(j);
String needFace = CommonUtils.parseString("POD_FACE",map);
int sameFaceIndex = index.get(needFace);
String tripPositionID;
List<Map> tripPositions = existTripPosition(workStation, podId, needFace);
if (tripPositions.isEmpty()) {
BaseBpo baseBpo2 = new BaseBpo();
baseBpo2.setTable("RCS_TRIPPOSITION");
tripPositionID = CommonUtils.genUUID();
baseBpo2.addKV("ID", tripPositionID);
baseBpo2.addKV("TRIP_ID", tripId);
baseBpo2.addKV("POD_USING_FACE", needFace);
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);
}else{
Map data = tripPositions.get(0);
tripPositionID = CommonUtils.parseString("ID",data);
}
Map newValue = new HashMap();
newValue.put("STATE", Sql_Table.FINISH);//生成就结束了 是不是执行完看TRIPPOSITION_ID
newValue.put("TRIPPOSITION_ID", tripPositionID);
newValue.put("TRIPPOSITION_ID", tripPositionID);
Map con = new HashMap();
con.put("ID",CommonUtils.parseString("ID",podOrders));
con.put("ID",CommonUtils.parseString("ID",podOrder));
this.jdbcRepository.updateRecords(Sql_Table.WMS_INBOUND_PODORDER, newValue,con);
}
}
}
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;
}
private List<Map> existTripPosition(String workStation, String podId, String needFace) {
List<Map> datas = this.jdbcRepository.queryByKey(Sql_Table.SQL_QUERY_TRIPPOSITION,
needFace,workStation,podId);
return datas;
}
public static final String SQL_NEWSTORAGELOCATION = "SELECT MD_STORAGELOCATION.* FROM MD_STORAGELOCATION,INV_UNITLOAD \n" +
"WHERE MD_STORAGELOCATION.ID=INV_UNITLOAD.STORAGELOCATION_ID \n" +
"AND MD_STORAGELOCATION.POD_ID IS NOT NULL AND INV_UNITLOAD.ID NOT IN \n" +
......@@ -467,4 +517,45 @@ public class InboundService {
return data;
}
public Map prePodTask(String stationName) {
Map dto = new HashMap();
//如果没有锁定 就没有任务
if(isLocked(stationName) ){
dto.put("CODE",1);
dto.put("MSG","工作站"+stationName+"被占用,没有当前任务!");
return dto;
}
List<Map> datas = this.jdbcRepository.queryBySql(Sql_Table.SQL_QUERY_CURRENTPODTASK,
Sql_Table.AVAILABLE, Sql_Table.PROCESS, Sql_Table.PROCESS,stationName);
if(datas.isEmpty()){
dto.put("CODE",1);
dto.put("MSG","没有找到当前在工作站的货架");
return dto;
}
Map data = datas.get(0);
/*`ID` varchar(255) NOT NULL,
`ENTRYID` varchar(255) NOT NULL,
`ENTRYPOSITIONID` varchar(255) NOT NULL,
`SKUID` varchar(255) NOT NULL,
`POD_ID` varchar(255) NOT NULL,
`POD_FACE` varchar(255) NOT NULL,
`POD_LOCATE` varchar(255) NOT NULL,
`PODINDEX` int(11) DEFAULT NULL 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()){
dto.put("CODE",1);
dto.put("MSG","没有找到当前上架商品信息, SKU:"+skuId);
return dto;
}
Map sku = skus.get(0);
data.put("SKUNAME",CommonUtils.parseString("NAME",sku));
return data;
}
}
package com.mushiny.heli.xnr.service;
/**
* Created by Lisi on 2019-11-27.
* Created by Lisi on 2019-11-27
*/
public interface Sql_Table {
......@@ -65,4 +65,12 @@ public interface Sql_Table {
String WMS_INBOUND_ORDERPOSITION = "WMS_INBOUND_ORDERPOSITION";
String WMS_OUTBOUND_ORDER = "WMS_OUTBOUND_ORDER";
String WMS_OUTBOUND_ORDERPOSITION = "WMS_OUTBOUND_ORDERPOSITION";
String SQL_QUERY_INBOUNDORDERPOSITION = "SELECT * FROM WMS_INBOUND_ORDERPOSITION " +
"WHERE ENTRYID=? AND SKUID=?";
String SQL_QUERY_TRIPPOSITION = "SELECT RCS_TRIPPOSITION.ID FROM RCS_TRIP,RCS_TRIPPOSITION \n" +
"WHERE RCS_TRIP.ID=RCS_TRIPPOSITION.TRIP_ID \n" +
"AND RCS_TRIPPOSITION.TRIPPOSITION_STATE='Available'\n" +
"AND RCS_TRIPPOSITION.POD_USING_FACE=?\n" +
"AND RCS_TRIP.WORKSTATION_ID=? " +
"AND RCS_TRIP.POD_ID=? limit 1";
}
......@@ -42,6 +42,8 @@ public class WMSService {
baseBpo.addKV("WAREHOUSE_ID",inboundOrderDTO.getFACTORY());
baseBpo.addKV("SECTION_ID",inboundOrderDTO.getSECTION());
baseBpo.addKV("STATE", Sql_Table.AVAILABLE);
baseBpo.addKV("STATE", Sql_Table.AVAILABLE);
//增加了订单上架的序号 按入库单序号来
this.jdbcRepository.insertBusinessObject(baseBpo);
}
......
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