|
@@ -1,15 +1,25 @@
|
|
|
package com.tld.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.mysql.cj.xdevapi.JsonString;
|
|
|
import com.tld.excel.ExcelUtils;
|
|
|
+import com.tld.mapper.ErrorMapper;
|
|
|
import com.tld.mapper.UserMapper;
|
|
|
import com.tld.mapper.WarehousingMapper;
|
|
|
import com.tld.model.*;
|
|
|
+import com.tld.model.Error;
|
|
|
import com.tld.service.WarehousingService;
|
|
|
+import com.tld.util.DateUtil;
|
|
|
+import com.tld.util.HttpClientUtil;
|
|
|
+import org.apache.http.ParseException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -23,6 +33,12 @@ public class WarehousingServiceImpl implements WarehousingService {
|
|
|
@Autowired
|
|
|
private UserMapper userMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ErrorMapper errorMapper;
|
|
|
+
|
|
|
+// @Resource
|
|
|
+// private HttpClientUtil httpClientUtil;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -53,22 +69,28 @@ public class WarehousingServiceImpl implements WarehousingService {
|
|
|
listMaterialClass = warehousingMapper.getMaterialClassType(wllbCode);
|
|
|
}
|
|
|
StringBuffer stringBuffer = new StringBuffer();
|
|
|
- List<Integer> listString = new LinkedList<>();//库存剩余数量
|
|
|
+ Map<String, Object> listMap = new HashMap<>();
|
|
|
for(int i = 0; i < listMaterialClass.size(); i++) {
|
|
|
Map<String, Object> map1 = warehousingMapper.getScanNum(listMaterialClass.get(i).getStorageLocationCode(), num);
|
|
|
if(Double.parseDouble(String.valueOf(map1.get("scanNum"))) < Double.parseDouble(String.valueOf(map1.get("storageLocationCapacity")))){
|
|
|
//查询库存是否同物料同批次存在
|
|
|
- int countProduc = warehousingMapper.getInventoryProduc(listMaterialClass.get(i).getWllbCode(), producDate, listMaterialClass.get(i).getStorageLocationCode());
|
|
|
- if(countProduc == 0){
|
|
|
+ List<String> countProduc = warehousingMapper.getInventoryProduc(listMaterialClass.get(i).getWllbCode(), producDate, listMaterialClass.get(i).getStorageLocationCode());
|
|
|
+ if(countProduc.size() == 0){
|
|
|
stringBuffer.append(listMaterialClass.get(i).getStorageLocationCode() + ",");
|
|
|
int surplusNum = (int) (Double.parseDouble(String.valueOf(map1.get("storageLocationCapacity"))) - Double.parseDouble(String.valueOf(map1.get("scanNum"))) + Double.parseDouble(num));
|
|
|
- listString.add(surplusNum);
|
|
|
+ listMap.put(listMaterialClass.get(i).getStorageLocationCode(), surplusNum);
|
|
|
+ } else {
|
|
|
+ if(String.valueOf(countProduc.get(0)).equals(producDate)){
|
|
|
+ stringBuffer.append(listMaterialClass.get(i).getStorageLocationCode() + ",");
|
|
|
+ int surplusNum = (int) (Double.parseDouble(String.valueOf(map1.get("storageLocationCapacity"))) - Double.parseDouble(String.valueOf(map1.get("scanNum"))) + Double.parseDouble(num));
|
|
|
+ listMap.put(listMaterialClass.get(i).getStorageLocationCode(), surplusNum);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
List<StorageLocation> list = warehousingMapper.recommend(stringBuffer.toString());
|
|
|
map.put("data", list);
|
|
|
- map.put("listString", listString);//返回库位剩余数量
|
|
|
+ map.put("listString", listMap);//返回库位剩余数量
|
|
|
map.put("msg", "200");
|
|
|
} catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@@ -159,9 +181,7 @@ public class WarehousingServiceImpl implements WarehousingService {
|
|
|
//存入给gs的返回数据
|
|
|
ReturnWarehousing returnWarehousing = new ReturnWarehousing()
|
|
|
.setWarehousingNum(receiveGoods1.getWarehousingNum())
|
|
|
-
|
|
|
.setGsCk(warehousingVirtual1.getGsCk())
|
|
|
-
|
|
|
.setSourceType(receiveGoods1.getSourceType())
|
|
|
.setMoveType(receiveGoods1.getMoveType())
|
|
|
.setEntryNumber(receiveGoods1.getEntryNumber())
|
|
@@ -169,7 +189,9 @@ public class WarehousingServiceImpl implements WarehousingService {
|
|
|
.setReceiveGoodsId(receiveGoods1.getId())
|
|
|
.setMaterialId(receiveGoods1.getMaterialId())
|
|
|
.setStorageCode(codeGenerateRk())
|
|
|
- .setOrderNumber(receiveGoods1.getOrderNumber());
|
|
|
+ .setOrderNumber(receiveGoods1.getOrderNumber())
|
|
|
+ .setUserName(warehousingVirtual1.getUserName())
|
|
|
+ .setStorageLocationCode(warehousingVirtual1.getStorageLocationCode());
|
|
|
warehousingMapper.addReturnWarehousing(returnWarehousing);
|
|
|
//判断是否有已存在的采购单号
|
|
|
if(!stringBuilder.toString().contains(receiveGoods1.getOrderNumber() + ",")){
|
|
@@ -193,17 +215,41 @@ public class WarehousingServiceImpl implements WarehousingService {
|
|
|
@Override
|
|
|
public void plugOutWarehousing(String orderNumber) {
|
|
|
try{
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- int year = cal.get(Calendar.YEAR);
|
|
|
- int month = cal.get(Calendar.MONTH) + 1;
|
|
|
- int day = cal.get(Calendar.DATE) ;
|
|
|
- List<ReturnWarehousing> list = new ArrayList<>();
|
|
|
for(ReturnWarehousing returnWarehousing : warehousingMapper.getPlugOutWarehousing(orderNumber)){
|
|
|
- returnWarehousing.setYear(String.valueOf(year));
|
|
|
- returnWarehousing.setMonth(String.valueOf(month));
|
|
|
- returnWarehousing.setTime(year + "-" + month + "-" + day);
|
|
|
- returnWarehousing.setIsNotRed("0");
|
|
|
- list.add(returnWarehousing);
|
|
|
+ JSONObject returnData = new JSONObject();
|
|
|
+ JSONObject BillItems = new JSONObject();
|
|
|
+ JSONObject strJson = new JSONObject();
|
|
|
+ strJson.put("PurOrderID", returnWarehousing.getOrderNumber());//采购单id
|
|
|
+ strJson.put("WMSID", returnWarehousing.getId());//入库单id
|
|
|
+ strJson.put("WMSCode", returnWarehousing.getStorageCode());//入库单编号
|
|
|
+ strJson.put("WareHouse", "e7f6bff1-e6ab-49e7-9");//仓库id
|
|
|
+ strJson.put("SourceBillDate", DateUtil.dateConversion(returnWarehousing.getScrq()));//业务日期
|
|
|
+ strJson.put("SourceType", returnWarehousing.getSourceType());//来源类型
|
|
|
+ strJson.put("MoveType", returnWarehousing.getMoveType());//移动类型
|
|
|
+ strJson.put("Creator", "测试");//制单人姓名
|
|
|
+ BillItems.put("WMSItemID", returnWarehousing.getReceiveGoodsId());//利道WMS入库单分录ID
|
|
|
+ BillItems.put("PurOrderID", returnWarehousing.getOrderNumber());//采购单id
|
|
|
+ BillItems.put("PurOrderItemID", returnWarehousing.getEntryNumber());//采购订单明细ID
|
|
|
+ BillItems.put("Material", returnWarehousing.getMaterialId());//物料id
|
|
|
+ BillItems.put("Quantity", returnWarehousing.getWarehousingNum());//入库数量
|
|
|
+ BillItems.put("FlexField1", returnWarehousing.getWbs());//wbs
|
|
|
+ BillItems.put("FlexField1Code", " ");//WBS编号
|
|
|
+ BillItems.put("FlexField1Name", " ");//WBS名称
|
|
|
+ List<JSONObject> list = new LinkedList<>();
|
|
|
+ list.add(BillItems);
|
|
|
+ strJson.put("BillItems", list);
|
|
|
+ returnData.put("strJson", JSON.toJSONString(strJson));
|
|
|
+ System.out.println(returnData);
|
|
|
+ HttpClientUtil httpClientUtil1 = new HttpClientUtil();
|
|
|
+ Map<String, Object> result = httpClientUtil1.doPost("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreatePurInStock", returnData);
|
|
|
+ if(Integer.parseInt(result.get("msg").toString()) != 200){
|
|
|
+ //如果失败存入报错信息跟数据
|
|
|
+ Error error = new Error()
|
|
|
+ .setErrorInfo(result.get("data").toString())
|
|
|
+ .setUrl("http://42.159.85.29:52480/cwbase/sg/V1/ERP/TELD/DEVTEST/API_WMS_PurInStock/CreatePurInStock")
|
|
|
+ .setDataVal(strJson.toJSONString());
|
|
|
+ errorMapper.addError(error);
|
|
|
+ }
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
@@ -283,4 +329,8 @@ public class WarehousingServiceImpl implements WarehousingService {
|
|
|
}
|
|
|
return (stringBuilder.append(count + 1)).toString();
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|