363 lines
12 KiB
Java
363 lines
12 KiB
Java
|
|
package hhwms;
|
|||
|
|
|
|||
|
|
import java.math.BigDecimal;
|
|||
|
|
import java.math.BigInteger;
|
|||
|
|
import java.text.ParseException;
|
|||
|
|
import java.text.SimpleDateFormat;
|
|||
|
|
import java.util.ArrayList;
|
|||
|
|
import java.util.Collections;
|
|||
|
|
import java.util.Date;
|
|||
|
|
import java.util.LinkedList;
|
|||
|
|
import java.util.List;
|
|||
|
|
import java.util.Random;
|
|||
|
|
|
|||
|
|
import org.apache.commons.lang.StringUtils;
|
|||
|
|
import org.hibernate.Query;
|
|||
|
|
import org.hibernate.Session;
|
|||
|
|
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
|||
|
|
|
|||
|
|
import com.dev.energy.server.model.EntityFactory;
|
|||
|
|
import com.dev.energy.server.model.security.User;
|
|||
|
|
import com.dev.swms.server.model.base.LocationStorage;
|
|||
|
|
import com.dev.swms.server.model.base.Warehouse;
|
|||
|
|
import com.dev.swms.server.model.base.WarehouseAreaStatus;
|
|||
|
|
import com.dev.swms.server.model.shipping.PickTicket;
|
|||
|
|
import com.dev.swms.server.model.shipping.SeedWall;
|
|||
|
|
import com.dev.swms.server.model.shipping.WaveDoc;
|
|||
|
|
import com.dev.swms.server.model.shipping.WaveDocStatus;
|
|||
|
|
|
|||
|
|
import net.sf.json.JSONArray;
|
|||
|
|
import net.sf.json.JSONObject;
|
|||
|
|
|
|||
|
|
public class test {
|
|||
|
|
|
|||
|
|
public static void main(String[] args) {
|
|||
|
|
/* String json="["
|
|||
|
|
+ "{'entryId':'entry-board-201912300001','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'},"
|
|||
|
|
+ "{'entryId':'entry-board-201912300002','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'}"
|
|||
|
|
+ "]";
|
|||
|
|
String json1="["
|
|||
|
|
+ "{'orderId':'entry-board-201912300001','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'},"
|
|||
|
|
+ "{'orderId':'entry-board-201912300003','workOrder':'workOrder-board-201912300001','skuType':'board','skuId':'sku-board-0001','amount':'100','unit':'件','lineName':'line0001','sendTime':'2019-12-30 15:15:14'}"
|
|||
|
|
+ "]";
|
|||
|
|
//storeInbardown(json);
|
|||
|
|
storeInbardown(json1);
|
|||
|
|
returnInbardown();*/
|
|||
|
|
/*String s = new SimpleDateFormat("yyMMdd").format(new Date());
|
|||
|
|
System.out.println(s);
|
|||
|
|
StringBuilder str=new StringBuilder();
|
|||
|
|
str.append(s);
|
|||
|
|
Random random=new Random();
|
|||
|
|
//随机生du成数字,并添加zhi到字符串
|
|||
|
|
// for(int i=0;i<8;i++){
|
|||
|
|
// str.append(random.nextInt(10));
|
|||
|
|
// }
|
|||
|
|
int min=10000000;
|
|||
|
|
int max=99999999;
|
|||
|
|
int sum = random.nextInt(max)%(max-min+1) + min;
|
|||
|
|
str.append(sum);
|
|||
|
|
System.out.println(str);*/
|
|||
|
|
/*List<Integer> list = new ArrayList<>();
|
|||
|
|
list.add(1);
|
|||
|
|
list.add(2);
|
|||
|
|
list.add(3);
|
|||
|
|
list.add(4);
|
|||
|
|
list.add(5);
|
|||
|
|
list.add(32);
|
|||
|
|
list.add(100);
|
|||
|
|
list.add(500);
|
|||
|
|
System.out.println(list.subList(0,6));*/
|
|||
|
|
/*SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
String date1="2022-06-24 22:05:10";
|
|||
|
|
String date2="2022-06-24 22:05:15";
|
|||
|
|
Date d1=null;
|
|||
|
|
Date d2=null;
|
|||
|
|
try {
|
|||
|
|
d1 = sdf.parse(date1);
|
|||
|
|
d2 = sdf.parse(date2);
|
|||
|
|
long t1=d1.getTime();
|
|||
|
|
long t2=d2.getTime();
|
|||
|
|
long mill=t2-t1;
|
|||
|
|
int total=(int)(mill/1000);
|
|||
|
|
System.out.println(total);
|
|||
|
|
} catch (ParseException e) {
|
|||
|
|
// TODO Auto-generated catch block
|
|||
|
|
e.printStackTrace();
|
|||
|
|
}*/
|
|||
|
|
/* List<String> gzz=new ArrayList<String>();
|
|||
|
|
gzz.add("001");
|
|||
|
|
gzz.add("002");
|
|||
|
|
gzz.add("003");
|
|||
|
|
gzz.add("004");
|
|||
|
|
gzz.add("005");
|
|||
|
|
gzz.add("006");
|
|||
|
|
gzz.add("007");
|
|||
|
|
gzz.add("008");
|
|||
|
|
int k=0;
|
|||
|
|
int j=0;
|
|||
|
|
for(int i=0;i<138;i++){
|
|||
|
|
k++;
|
|||
|
|
if(k==11){
|
|||
|
|
k=1;
|
|||
|
|
j++;
|
|||
|
|
if(j==gzz.size()){
|
|||
|
|
j=0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
System.out.println((i+1)+"任务"+gzz.get(j)+"工作站");
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
/*returnMove();*/
|
|||
|
|
/*List<String> list = new ArrayList<>();
|
|||
|
|
LinkedList<String> list2 = new LinkedList<>();
|
|||
|
|
list.add("李四");
|
|||
|
|
list.add("王五");
|
|||
|
|
list.add("王");
|
|||
|
|
list.add("张三");
|
|||
|
|
for(String id:list){
|
|||
|
|
if(id.equals("李四")){
|
|||
|
|
list2.addLast(id);
|
|||
|
|
}else if(id.equals("王五")){
|
|||
|
|
list2.addLast(id);
|
|||
|
|
}else{
|
|||
|
|
list2.addFirst(id);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
for(String id:list2){
|
|||
|
|
System.out.println(id);
|
|||
|
|
}*/
|
|||
|
|
zz();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void zz(){
|
|||
|
|
String a="123";
|
|||
|
|
String b=a+1;
|
|||
|
|
System.out.println(b);
|
|||
|
|
}
|
|||
|
|
public String spilt(String str) {
|
|||
|
|
StringBuffer sb = new StringBuffer();
|
|||
|
|
String[] temp = str.split(",");
|
|||
|
|
for (int i = 0; i < temp.length; i++) {
|
|||
|
|
if (!"".equals(temp[i]) && temp[i] != null)
|
|||
|
|
sb.append("'" + temp[i] + "',");
|
|||
|
|
}
|
|||
|
|
String result = sb.toString();
|
|||
|
|
String tp = result.substring(result.length() - 1, result.length());
|
|||
|
|
if (",".equals(tp))
|
|||
|
|
return result.substring(0, result.length() - 1);
|
|||
|
|
else
|
|||
|
|
return result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static int sequence = 0;
|
|||
|
|
private static int length = 6;
|
|||
|
|
|
|||
|
|
public static synchronized String getLocalTrmSeqNum() {
|
|||
|
|
sequence = sequence >= 999999 ? 1 : sequence + 1;
|
|||
|
|
String datetime = new SimpleDateFormat("yyMMddHHmmss")
|
|||
|
|
.format(new Date());
|
|||
|
|
String s = Integer.toString(sequence);
|
|||
|
|
return "Task"+datetime +addLeftZero(s, length);
|
|||
|
|
}
|
|||
|
|
public static String addLeftZero(String s, int length) {
|
|||
|
|
// StringBuilder sb=new StringBuilder();
|
|||
|
|
int old = s.length();
|
|||
|
|
if (length > old) {
|
|||
|
|
char[] c = new char[length];
|
|||
|
|
char[] x = s.toCharArray();
|
|||
|
|
if (x.length > length) {
|
|||
|
|
throw new IllegalArgumentException(
|
|||
|
|
"Numeric value is larger than intended length: " + s
|
|||
|
|
+ " LEN " + length);
|
|||
|
|
}
|
|||
|
|
int lim = c.length - x.length;
|
|||
|
|
for (int i = 0; i < lim; i++) {
|
|||
|
|
c[i] = '0';
|
|||
|
|
}
|
|||
|
|
System.arraycopy(x, 0, c, lim, x.length);
|
|||
|
|
return new String(c);
|
|||
|
|
}
|
|||
|
|
return s.substring(0, length);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public static void storeInbardown(String json) {
|
|||
|
|
|
|||
|
|
JSONArray jsonArray = JSONArray.fromObject(json);
|
|||
|
|
for(int i = 0;i<jsonArray.size();i++) {
|
|||
|
|
JSONObject jsonObject = JSONObject.fromObject(jsonArray.get(i).toString());
|
|||
|
|
String entryId=(String) jsonObject.get("entryId");
|
|||
|
|
String workOrder=(String) jsonObject.get("workOrder");
|
|||
|
|
String skuType=(String) jsonObject.get("skuType");
|
|||
|
|
String skuId=(String) jsonObject.get("skuId");
|
|||
|
|
String amount=(String) jsonObject.get("amount");
|
|||
|
|
String unit=(String) jsonObject.get("unit");
|
|||
|
|
String sendTime=(String) jsonObject.get("sendTime");
|
|||
|
|
String lineName=(String) jsonObject.get("lineName");
|
|||
|
|
System.out.println(entryId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void returnInbardown() {
|
|||
|
|
|
|||
|
|
JSONObject jsonObject = new JSONObject();
|
|||
|
|
jsonObject.put("entryId", "entry-board-201912300001");
|
|||
|
|
jsonObject.put("workOrder", "workOrder-board-201912300001");
|
|||
|
|
jsonObject.put("skuType", "board");
|
|||
|
|
jsonObject.put("skuId", "sku-board-0001");
|
|||
|
|
jsonObject.put("amount", "100");
|
|||
|
|
jsonObject.put("unit", "件");
|
|||
|
|
jsonObject.put("lineName", "line0001");
|
|||
|
|
jsonObject.put("stored", "100");
|
|||
|
|
jsonObject.put("rejection", "0");
|
|||
|
|
jsonObject.put("scrap", "0");
|
|||
|
|
jsonObject.put("unqualified", "0");
|
|||
|
|
jsonObject.put("sendTime", "2019-12-30 15:15:14");
|
|||
|
|
jsonObject.put("finishTime", "2019-12-30 17:15:15");
|
|||
|
|
System.out.println(jsonObject.toString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void returnMove() {
|
|||
|
|
|
|||
|
|
JSONObject JSONObject=new JSONObject();
|
|||
|
|
JSONArray containerJSONArray=new JSONArray();
|
|||
|
|
|
|||
|
|
JSONObject containerObject=new JSONObject();
|
|||
|
|
containerObject.put("containerCode", "9001006593");//容器编码
|
|||
|
|
containerObject.put("containerHotType", "C");//热度类型
|
|||
|
|
containerObject.put("containerHotValue", "");//热度数值
|
|||
|
|
containerJSONArray.add(containerObject);
|
|||
|
|
|
|||
|
|
JSONObject.put("containers", containerJSONArray);
|
|||
|
|
JSONObject.put("warehouseId", 1);
|
|||
|
|
System.out.println(JSONObject.toString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*public void addCreatewaveDoc(Integer count){
|
|||
|
|
Session session = ((HibernateDaoSupport)this.commonDao).getSessionFactory().openSession();
|
|||
|
|
try {
|
|||
|
|
boolean bool=true;
|
|||
|
|
String sql2="";
|
|||
|
|
if(count==0){
|
|||
|
|
sql2=" select "
|
|||
|
|
+ " pick.ptIds "
|
|||
|
|
+ " from( "
|
|||
|
|
+ " select pt.id as ptIds,GROUP_CONCAT(CONCAT('',item.id)) as mx,count(*) as counts from pick_ticket_detail ptd "
|
|||
|
|
+ " left join item item on item.id=ptd.ITEM_ID "
|
|||
|
|
+ " left join pick_ticket pt on pt.id=ptd.PICK_TICKET_ID"
|
|||
|
|
+ " left join wave_doc wd on wd.id=pt.wave_Doc_ID "
|
|||
|
|
+ " where wd.id is null "
|
|||
|
|
+ " group by pt.id "
|
|||
|
|
+ " order by mx )pick "
|
|||
|
|
+ " where pick.counts=1 ";
|
|||
|
|
}else{
|
|||
|
|
sql2=" select "
|
|||
|
|
+ " pick.ptIds "
|
|||
|
|
+ " from "
|
|||
|
|
+ " (select pt.id as ptIds, item.code as wl,count(item.code) as number from pick_ticket_detail ptd "
|
|||
|
|
+ " left join item item on item.id=ptd.ITEM_ID "
|
|||
|
|
+ " left join pick_ticket pt on pt.id=ptd.PICK_TICKET_ID "
|
|||
|
|
+ " left join wave_doc wd on wd.id=pt.wave_Doc_ID "
|
|||
|
|
+ " where 1=1 "
|
|||
|
|
+ " and wd.id is null "
|
|||
|
|
+ " group by pt.id,item.code) pick "
|
|||
|
|
+ " order by pick.number desc ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Query query = session.createSQLQuery(sql2);
|
|||
|
|
List<BigInteger> picks=query.list();
|
|||
|
|
List<BigInteger> pickIds=removeDuplicate(picks);
|
|||
|
|
|
|||
|
|
List<Object[]> objs = commonDao.findByQuery("select count(sw.id),sw.locationStorage.description from SeedWall sw "
|
|||
|
|
+ " where 1=1 "
|
|||
|
|
+ " and sw.locationStorage.status='OCCUPY' "
|
|||
|
|
+ " and sw.locationStorage.zone.name='工作站' "
|
|||
|
|
+ " and sw.locationStorage.type='拣货' "
|
|||
|
|
+ " and sw.locationStorage.disabled=0 "
|
|||
|
|
+ " and sw.status='FREE'"
|
|||
|
|
+ " group by sw.locationStorage.description");
|
|||
|
|
|
|||
|
|
if(pickIds.size()>0){
|
|||
|
|
String pid=StringUtils.strip(pickIds.toString(),"[]");
|
|||
|
|
int amount=pickIds.size();
|
|||
|
|
List<PickTicket> ptds=commonDao.findByQuery(" from PickTicket pt where pt.id in ("+pid+") ");
|
|||
|
|
for (int i = 0; i <objs.size(); i++) {
|
|||
|
|
Object[] obj=objs.get(i);
|
|||
|
|
Long sum=(Long)obj[0];
|
|||
|
|
String name=(String)obj[1];
|
|||
|
|
int number=0;
|
|||
|
|
if(sum>pickIds.size()){
|
|||
|
|
number=pickIds.size();
|
|||
|
|
}else{
|
|||
|
|
number=sum.intValue();
|
|||
|
|
}
|
|||
|
|
if (amount==0) {
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WaveDoc waveDoc=null;
|
|||
|
|
if (bool) {
|
|||
|
|
String sql=" from SeedWall s "
|
|||
|
|
+ " where 1=1 "
|
|||
|
|
+ " and s.locationStorage.status='OCCUPY' "
|
|||
|
|
+ " and s.locationStorage.disabled='false'"
|
|||
|
|
+ " and s.locationStorage.description='"
|
|||
|
|
+ name
|
|||
|
|
+ "' "
|
|||
|
|
+ " and s.locationStorage.type='拣货'"
|
|||
|
|
+ " and s.status='FREE' "
|
|||
|
|
+ " order by s.locationStorage.id, s.code";
|
|||
|
|
List<SeedWall> sws=commonDao.findByQuery(sql);
|
|||
|
|
waveDoc = EntityFactory.getEntity(WaveDoc.class);
|
|||
|
|
String code =bussinessCodeManager.generateDayCode("BC", 3);
|
|||
|
|
waveDoc.setCode(code);
|
|||
|
|
Warehouse warehouse=this.load(Warehouse.class,1L);
|
|||
|
|
User u=this.load(User.class,1L);
|
|||
|
|
waveDoc.setWarehouse(warehouse);
|
|||
|
|
waveDoc.setUserID(u.getId());
|
|||
|
|
waveDoc.setUserName(u.getLoginName());
|
|||
|
|
waveDoc.setCreateDate(new Date());
|
|||
|
|
waveDoc.setStatus(WaveDocStatus.OPEN);
|
|||
|
|
waveDoc.setQuantity(waveDoc.getOrderQuantity());
|
|||
|
|
commonDao.store(waveDoc);
|
|||
|
|
WaveDoc waveDocs=(WaveDoc) commonDao.findByQuery(" from WaveDoc where code='"+code+"' ").get(0);
|
|||
|
|
for (int j = 0; j < number; j++) {
|
|||
|
|
SeedWall s=sws.get(j);
|
|||
|
|
LocationStorage ls=s.getLocationStorage();
|
|||
|
|
String bzq=s.getCode();
|
|||
|
|
PickTicket pt=ptds.get(j);
|
|||
|
|
String newbzq=bzq.replace("-", "");
|
|||
|
|
pt.setExecutePlanNo(newbzq);
|
|||
|
|
pt.setWorker3(ls.getWorker3());
|
|||
|
|
pt.setWaveDoc(waveDocs);
|
|||
|
|
pt.setSeedWall(s);
|
|||
|
|
pt.setShipToName(ls.getDescription());
|
|||
|
|
s.setStatus(WarehouseAreaStatus.OCCUPY);
|
|||
|
|
commonDao.store(s);
|
|||
|
|
commonDao.store(pt);
|
|||
|
|
amount=amount-1;
|
|||
|
|
if (amount==0) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
RefreshWaveDoc(waveDoc.getId());
|
|||
|
|
refreshWaveDoc(waveDoc.getId());//对应的订单数量需要更新
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} catch (Exception e) {
|
|||
|
|
e.printStackTrace();
|
|||
|
|
System.out.print("连接失败");
|
|||
|
|
}finally{
|
|||
|
|
session.close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
}
|