This commit is contained in:
郭飞 2025-05-28 14:13:45 +08:00
commit a8f558b65a
13 changed files with 447 additions and 95 deletions

View File

@ -5425,6 +5425,116 @@ public class ToSAPServiceImpl {
return undoId;
}
//盘盈出库--pc
public String MaterialScrapStockOutPc(List<Map<String, Object>> queryForList, String siteName, String user,String commitDate,
String opCode,String qtc,String costName) throws Exception {
String rcode;
String undoId = "";
String rmsg = null;
if (queryForList == null || queryForList.size() < 1) {
return "";
}
try {
JSONObject sendData = new JSONObject(true);
JSONObject header = new JSONObject(true);
sendData.put("HEAD", header);
JSONObject body = new JSONObject(true);
sendData.put("BODY", body);
JSONArray itemArray = new JSONArray();
/*
HEAD
*/
header.put("INTF_ID", "MM067");
String uniqueID = UUID.randomUUID().toString();
header.put("REQ_KEYID", uniqueID);
header.put("SRC_MSGID", uniqueID);
header.put("SRC_SYSTEM", "WMS");
header.put("DEST_SYSTEM", "SAP");
header.put("REQUSER", user);
/*
BODY
*/
body.put("ITEM", itemArray);
body.put("ITEMID", uniqueID);
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyyMMdd");
Date date = inputFormat.parse(commitDate);
String outputDate = outputFormat.format(date);
//过账日期
body.put("BUDAT", outputDate);
//凭证日期
body.put("BLDAT", outputDate);
//凭证抬头文本
body.put("BKTXT", uniqueID);
//用户名
body.put("USNAM", user);
for (Map<String, Object> mm : queryForList) {
JSONObject item = new JSONObject(true);
// MATNR 发货物料号
item.put("MATNR", mm.get("MATERIALSPECNAME"));
// WERKS 发货工厂
item.put("WERKS", mm.get("ERPFACTORY"));
// LGORT 发货库存地点
item.put("LGORT", mm.get("ERPLOCATION"));
//BWART 移动类型
item.put("BWART", qtc);
item.put("KOSTL", costName);
//MENGE 数量
item.put("MENGE", mm.get("MATERIALQUANTITY"));
//MENGE 单位
item.put("MEINS", mm.get("UNIT"));
//需要SAP改动Z07,Z08目前都需要返单号
//ZLLORDER 自定义领料单号
// item.put("ZLLORDER", mm.get("SHIPREQUESTNAME"));
// //ZLLITEM 自定义领料单行号
// item.put("ZLLITEM", mm.get("SHIPREQUESTDETAILNAME"));
itemArray.add(item);
}
log.info("SendTOSAP >>>>" + sendData);
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendData.toJSONString());
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN");
rcode = returnJsonObject.get("STATUS").toString();
rmsg = returnJsonObject.get("MSGTXT").toString();
if ("S".equals(rcode)) {
undoId = returnJsonObject.get("MBLNR").toString()+"_"+returnJsonObject.get("MJAHR").toString();//将物料凭证号与凭证年度拼在一起
}
//将log写到表里
UUID uuid = UUID.randomUUID();
ErpMessageLog erplog = new ErpMessageLog();
erplog.setEventUser("");
erplog.setServerName("WmsToErp");
if ("Z05".equals(qtc)) {
erplog.setEventName("盘亏出库");
} else {
erplog.setEventName("报废出库");
}
erplog.setId(uuid.toString());
erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
erplog.setMessageId(UUID.randomUUID().toString());
erplog.setSendMsg(sendData.toJSONString());
erplog.setSendMsg2(sendData.toJSONString());
erplog.setReturnMsg2(sapreturn);
erplog.setResultCode(rcode);
MessageLogUtil.writeMessageLog(erplog);
} catch (Exception e) {
log.info(e.getMessage(), e);
throw new RuntimeException("SAP返回" + rmsg);
}
if (!"S".equals(rcode)) {
throw new RuntimeException("SAP返回" + rmsg);
}
return undoId;
}
/**
* 退料入库
*
@ -5527,6 +5637,7 @@ public class ToSAPServiceImpl {
}
public String makeReturnStockIn(List<Map<String, Object>> list, String eventUser, String commitDate) throws JsonMappingException, JsonProcessingException {
if (list == null || list.size() < 1) {
return "";
@ -5980,10 +6091,8 @@ public class ToSAPServiceImpl {
item.put("BWART",moveType);
item.put("MENGE", mm.get("MATERIALQUANTITY"));
item.put("MEINS", mm.get("UNIT"));
if ("413E".equals(moveType)) {
item.put("UMMAT_KDAUF", mm.get("OLDSALESHIPREQUESTNAME"));
item.put("UMMAT_KDPOS", mm.get("OLDSALESHIPREQUESTDETAILNAME"));
}
item.put("UMMAT_KDAUF", mm.get("OLDSALESHIPREQUESTNAME"));
item.put("UMMAT_KDPOS", mm.get("OLDSALESHIPREQUESTDETAILNAME"));
String insmk = "";
// if("NG".equals(pqcResult) ){
// insmk = "3";
@ -5991,21 +6100,12 @@ public class ToSAPServiceImpl {
// String insmk = StringUtils.equals(mm.get("OQARESULTSTATE").toString(),"END")?"":"X";
item.put("INSMK", insmk);
/*if("411E".equals(moveType) || "413E".equals(moveType)) {
if("411E".equals(moveType) || "413E".equals(moveType)) {
item.put("MAT_KDAUF", mm.get("SALESHIPREQUESTNAME")); // 发货销售订单编码
item.put("MAT_KDPOS", mm.get("SALESHIPREQUESTDETAILNAME")); // 发货销售订单项目编码
} else if("413".equals(moveType) || "413E".equals(moveType)) {
item.put("UMMAT_KDAUF", SALESHIPREQUESTNAME); // 发货销售订单编码
item.put("UMMAT_KDPOS", SALESHIPREQUESTDETAILNAME); // 发货销售订单项目编码
}*/
if ("411E".equals(moveType)) {
item.put("MAT_KDAUF", mm.get("OLDSALESHIPREQUESTNAME")); // 发货销售订单编码
item.put("MAT_KDPOS", mm.get("OLDSALESHIPREQUESTDETAILNAME")); // 发货销售订单项目编码
}
if ("413".equals(moveType) || "413E".equals(moveType)) {
item.put("MAT_KDAUF", mm.get("SALESHIPREQUESTNAME")); // 发货销售订单编码
item.put("MAT_KDPOS", mm.get("SALESHIPREQUESTDETAILNAME")); // 发货销售订单项目编码
}
itemData.add(item);
@ -6587,7 +6687,7 @@ public class ToSAPServiceImpl {
/**
* 转工单-
* @param materialPackingList
* @param mapList
* @param mes
* @param bwart
* @return
@ -6606,7 +6706,6 @@ public class ToSAPServiceImpl {
sendData.put("HEAD", header);
JSONObject body = new JSONObject(true);
sendData.put("BODY", body);
JSONArray itemArray = new JSONArray();
/*
HEAD
@ -6639,36 +6738,9 @@ public class ToSAPServiceImpl {
}
for (Map<String, Object> mm : mapList) {
mm.put("BWART", bwart);
JSONObject item = new JSONObject(true);
/*if(materialPackingList.size()>0) {
// MATNR 发货物料号
item.put("MATNR", mm.getMATNR());
// WERKS 发货工厂
item.put("WERKS", mm.getWERKS());
// LGORT 发货库存地点
item.put("LGORT", mm.getLGORT());
//MENGE 数量
item.put("MENGE",mm.getMENGE());
//MENGE 单位
item.put("MEINS",mm.getMEINS());
item.put("BWART", bwart);
//ZLLORDER 自定义领料单号
// item.put("ZLLORDER", "LL1010250408001");
item.put("ZLLORDER", mm.getZLLORDER());
//ZLLITEM 自定义领料单行号
// item.put("ZLLITEM", "0001");
item.put("ZLLITEM", mm.getZLLITEM());
//AUFNR 订单号
item.put("AUFNR", mm.getAUFNR());
}
itemArray.add(item);*/
}
System.out.println(mapList);
/*log.info("SendTOSAP >>>>" + sendData);
log.info("SendTOSAP >>>>" + sendData);
String sendDatas = sendData.toJSONString();
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendDatas);
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
@ -6681,24 +6753,28 @@ public class ToSAPServiceImpl {
}
//将log写到表里
ErpMessageLog erplog = new ErpMessageLog();
erplog.setEventUser("");
erplog.setEventUser(mes);
erplog.setServerName("WmsToErp");
erplog.setEventName("MES物料消耗261和转工单");
if ("261".equals(bwart)) {
erplog.setEventName("转工单-入库");
} else {
erplog.setEventName("转工单-出库");
}
erplog.setInterfaceTime(TimeStampUtil.getCurrentTime(TimeStampUtil.FORMAT_DEFAULT));
erplog.setMessageId(UUID.randomUUID().toString());
erplog.setSendMsg(sendData.toJSONString());
erplog.setSendMsg2(sendData.toJSONString());
erplog.setReturnMsg2(sapreturn);
erplog.setResultCode(rcode);
MessageLogUtil.writeMessageLog(erplog);*/
MessageLogUtil.writeMessageLog(erplog);
} catch (Exception e) {
log.info(e.getMessage(), e);
// throw new RuntimeException("SAP返回" + e.toString());
throw new RuntimeException("SAP返回" + e.toString());
}
/* if (!"S".equals(rcode)) {
if (!"S".equals(rcode)) {
throw new RuntimeException("SAP返回" + rmsg);
}*/
return null;
}
return undoId;
}
/**

View File

@ -29,8 +29,8 @@ public class CostCenterController {
* @return
*/
@RequestMapping(value = "/getCostCenter", method = RequestMethod.GET)
public BaseResponse<Object> getCostCenter() {
List<CostCenter> costCenters = costCenterService.getCostCenter();
public BaseResponse<Object> getCostCenter(String erpFactory) {
List<CostCenter> costCenters = costCenterService.getCostCenter(erpFactory);
return RespGenerator.returnOK(costCenters);
}

View File

@ -7,6 +7,7 @@ import com.cim.idm.constants.delivery.DeliveryStateEnums;
import com.cim.idm.constants.receive.ReceiveTypeEnums;
import com.cim.idm.framework.IDMFrameServiceProxy;
import com.cim.idm.framework.data.EventInfo;
import com.cim.idm.model.MaterialReceiveParam;
import com.cim.idm.model.dto.AuxiliaryOutIn;
import com.cim.idm.model.dto.delivery.DeliveryEditDto;
import com.cim.idm.model.dto.delivery.StoreDetailDto;
@ -21,6 +22,7 @@ import com.cim.idm.service.CostCenterService;
import com.cim.idm.service.IDeliveryService;
import com.cim.idm.service.IMaterialPackingService;
import com.cim.idm.service.IMaterialShipService;
import com.cim.idm.service.Impl.NoInvoiceManagerServiceImpl;
import com.cim.idm.service.impl.QMSServiceImpl;
import com.cim.idm.service.impl.ToSAPServiceImpl;
import com.cim.idm.utils.AjaxResult;
@ -32,6 +34,7 @@ import com.cim.idm.wmspackage.materialpacking.management.data.MaterialPackingKey
import com.cim.idm.wmspackage.materialpacking.management.info.CreateInfo;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.transaction.annotation.Transactional;
@ -43,6 +46,7 @@ import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.ParseException;
import java.util.*;
import com.cim.idm.service.Impl.SDKMaterialPackingServiceImpl;
@ -59,6 +63,10 @@ public class MaterialReceiveActController {
@Resource
private IMaterialPackingService mpService;
@Autowired
NoInvoiceManagerServiceImpl NoInvoiceManagerServiceImpl;
@Autowired
private ToSAPServiceImpl toSAPService;
private static Log log = LogFactory.getLog(MaterialReceiveActController.class);
private EventInfo makeEventInfo;
@ -327,6 +335,7 @@ public class MaterialReceiveActController {
String checkType = auxiliaryOutIn.getCheckType();
String user = auxiliaryOutIn.getUser();
String nums = auxiliaryOutIn.getNums();
BigDecimal numsBigDecimal = new BigDecimal(nums);
String siteName = auxiliaryOutIn.getSiteName();
String erpFactory = auxiliaryOutIn.getErpFactory();
String erpLocation = auxiliaryOutIn.getErpLocation();
@ -338,14 +347,14 @@ public class MaterialReceiveActController {
return AjaxResult.me().setSuccess(false).setMessage("物料编号" + materialSpecName + "不存在");
}
if ("盘盈".equals(checkType)) {
String phase = materialInfo.getPhase() != null ? materialInfo.getPhase() : "C";
String width = materialInfo.getWidth();
String materialUnit = materialInfo.getMaterialUnit();
String materialType = materialInfo.getMaterialType();
String descCn = materialInfo.getDescCn();
List<String> boxIds = MaterialPackingServiceImpl.generateBoxID("LabelId", siteName,
"1", DateUtil.now(), "WL", erpFactory);
//470110856|1|C|75mm*1000m|SHBP01JT1202305240009|20230524|11|75
String newBoxId = materialSpecName + "|1|" + phase + "|" + width + "|" + boxIds.get(0) + "|"
//470110856|1||75mm*1000m|SHBP01JT1202305240009|20230524|11|75
String newBoxId = materialSpecName + "|1|" + "|" + width + "|" + boxIds.get(0) + "|"
+ makeDate.replace("-", "").substring(0, 8) + "|" + materialUnit + "|" + nums;
EventInfo makeEventInfo = new EventInfoUtil().makeEventInfo("TrackOutBox", user, "TrackOutBox");
Map<String, Object> bindMap = new HashMap<String, Object>();
@ -360,12 +369,14 @@ public class MaterialReceiveActController {
bindMap.put("stockState", "Created");
bindMap.put("materialPackingName", newBoxId);
bindMap.put("charge", boxIds.get(0));
bindMap.put("materialPackingType", "Box");
bindMap.put("truegg", width);
bindMap.put("unit", materialUnit);
bindMap.put("materialType", materialType);
bindMap.put("createUser", user);
bindMap.put("createTime", DateUtil.now());
CreateInfo createInfo = new CreateInfo();
createInfo.setMaterialPackingName(newBoxId);
createInfo.setMaterialPackingType("Box");
createInfo.setSiteName(auxiliaryOutIn.getSiteName());
createInfo.setUserColumns(bindMap);
MaterialPacking materialPacking = MaterialPackingServiceProxy.getMaterialPackingService().create(
@ -373,12 +384,146 @@ public class MaterialReceiveActController {
List<HashMap<String, Object>> maps = costCenterService.getByMaterialPackingName(newBoxId);
return AjaxResult.me().setResultObj(maps);
} else {
// todo
List<HashMap<String, Object>> maps = costCenterService.getMaterialPacking(materialSpecName,siteName,erpFactory,
List<LinkedHashMap<String, Object>> maps = costCenterService.getMaterialPacking(materialSpecName,siteName,erpFactory,
erpLocation, location, nums);
return AjaxResult.me().setResultObj(maps);
if (maps == null || maps.size() <= 0) {
return AjaxResult.me().setSuccess(false).setMessage("没有符合条件的数据");
}
BigDecimal materialquantity = maps.stream()
.map(map -> (BigDecimal) map.get("MATERIALQUANTITY"))
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (materialquantity.compareTo(numsBigDecimal) < 0) {
return AjaxResult.me().setSuccess(false).setMessage("数量不足");
}
List<LinkedHashMap<String, Object>> linkedHashMaps = pickMaterialQuantities(maps, numsBigDecimal);
return AjaxResult.me().setResultObj(linkedHashMaps);
}
}
public List<LinkedHashMap<String, Object>> pickMaterialQuantities(List<LinkedHashMap<String, Object>> maps, BigDecimal requiredQuantity) {
List<LinkedHashMap <String, Object>> resultList = new ArrayList<>();
BigDecimal remaining = requiredQuantity;
for (LinkedHashMap<String, Object> item : maps) {
// 获取当前记录的数量
BigDecimal materialQuantity = (BigDecimal) item.get("MATERIALQUANTITY");
if (materialQuantity == null || materialQuantity.compareTo(BigDecimal.ZERO) <= 0
|| remaining.compareTo(BigDecimal.ZERO) <= 0) {
continue; // 数量无效
}
// 计算可以取多少
BigDecimal take = materialQuantity.min(remaining);
// 创建新的记录并设置数量
LinkedHashMap<String, Object> newItem = new LinkedHashMap<>(item); // 复制原有字段
newItem.put("MATERIALQUANTITY", take); // 替换数量
// 添加到结果集
resultList.add(newItem);
// 更新剩余数量
remaining = remaining.subtract(take);
// 如果已经满足需求退出循环
if (remaining.compareTo(BigDecimal.ZERO) == 0) {
break;
}
}
return resultList;
}
/**
* 盘盈入库---pc
* @param in
* @return
* @throws ParseException
*/
@RequestMapping(value = "/QTRCommit", method = RequestMethod.POST)
public AjaxResult QTRCommit(@RequestBody JSONObject in ) throws ParseException {
MaterialReceiveRequest sl = JSON.toJavaObject(in, MaterialReceiveRequest.class);
String commitDateString = sl.getCommitDate();
List<MaterialPacking> boxList = sl.getBoxList();
String user2 = sl.getUser();
String opCode = sl.getOpCode();
String commitDate = commitDateString + " 00:00:00";
String costName = sl.getCostName();
String lifnr = sl.getLifnr();
String qtc = sl.getQtc();
NoInvoiceManagerServiceImpl.QTR(boxList,user2,commitDate,opCode,costName,lifnr,qtc);
return AjaxResult.me().setResultObj(null);
}
/**
* 盘亏出库---pc
* @param in
* @return
*/
@RequestMapping(value = "/QTCCommit", method = RequestMethod.POST)
@Transactional
public AjaxResult QTCCommit(@RequestBody JSONObject in ){
MaterialReceiveRequest sl = JSON.toJavaObject(in, MaterialReceiveRequest.class);
MaterialReceiveParam slParam = JSON.toJavaObject(in, MaterialReceiveParam.class);
List<MaterialPacking> boxList = sl.getBoxList();
List<Map<String, Object>> boxListParam = slParam.getBoxList();
String siteName = sl.getSiteName();
String user = in.get("user").toString();
String commitDatesString = sl.getCommitDate();
String commitDate = commitDatesString + " 00:00:00";
String opCode = sl.getOpCode();
// 移动类型
String qtc = sl.getQtc();
// 成本中心
String costName = sl.getCostName();
String undoId = "";
try {
undoId = toSAPService.MaterialScrapStockOutPc(boxListParam,siteName,user,commitDate,opCode,qtc,costName);
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.me().setSuccess(false).setMessage(e.toString());
}
if (StringUtils.isEmpty(undoId)) {
return AjaxResult.me().setSuccess(false).setMessage("undoId为空");
}
// 发送过账
EventInfoUtil util = new EventInfoUtil();
String enentName = "报废出库";
if ("Z05".equals(qtc)) {
enentName = "盘亏出库";
}
makeEventInfo = util.makeEventInfo(enentName, user, enentName);
// 更新库存状态
SDKMaterialPackingServiceImpl.SaveUnDoInfo(undoId,commitDate);
List<MaterialPacking> updateList = new ArrayList<>();
for(MaterialPacking materialPacking : boxList) {
List<HashMap<String, Object>> maps = costCenterService.getByMaterialPackingName(materialPacking.getMaterialPackingName());
if (maps == null || maps.size() <= 0) {
// 数据不存在跳过或抛异常
continue;
}
HashMap<String, Object> hashMap = maps.get(0);
// 数据库中数量
BigDecimal materialquantity = (BigDecimal)hashMap.get("MATERIALQUANTITY");
// 前端传递数量
BigDecimal materialQuantityFont = BigDecimal.valueOf(materialPacking.getMaterialQuantity());
if (materialquantity.compareTo(materialQuantityFont) <= 0) {
updateList.add(materialPacking);
} else {
// 更新库存数量
costCenterService.updateQty(materialPacking.getMaterialPackingName(), materialQuantityFont, user);
}
}
// 更新入库凭证和库存状态
SDKMaterialPackingServiceImpl.updateUndoIdByList(updateList, undoId, makeEventInfo,opCode);
return AjaxResult.me().setResultObj(null);
}
@RequestMapping(value = "/DeleteTrackOutBox", method = RequestMethod.POST)
public AjaxResult DeleteTrackOutBox(@RequestBody JSONObject in ) throws Exception{
// 获取属性

View File

@ -6,7 +6,9 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -14,7 +16,7 @@ import java.util.Map;
@Mapper
public interface CostCenterDao {
List<CostCenter> getCostCenter();
List<CostCenter> getCostCenter(@Param("erpFactory") String erpFactory);
List<Map<String, Object>> getUserInfo();
void updatePacking(@Param("SALESHIPREQUESTNAME") String SALESHIPREQUESTNAME,
@ -54,12 +56,16 @@ public interface CostCenterDao {
MaterialInfo getMaterialInfo(@Param("materialSpecName") String materialSpecName);
List<HashMap<String, Object>> getMaterialPacking(@Param("materialSpecName") String materialSpecName,
@Param("siteName") String siteName,
@Param("erpFactory") String erpFactory,
@Param("erpLocation") String erpLocation,
@Param("location") String location,
@Param("nums") String nums);
List<LinkedHashMap<String, Object>> getMaterialPacking(@Param("materialSpecName") String materialSpecName,
@Param("siteName") String siteName,
@Param("erpFactory") String erpFactory,
@Param("erpLocation") String erpLocation,
@Param("location") String location,
@Param("nums") String nums);
List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId);
void updateQty(@Param("materialPackingName") String materialPackingName,
@Param("materialQuantityFont") BigDecimal materialQuantityFont,
@Param("user") String user);
}

View File

@ -108,5 +108,5 @@ public class LabelParameterObject {
private String item3;
private String item4;
private String item5;
private String locationcode;
}

View File

@ -54,6 +54,8 @@ public class LabelPrintPET {
private String stageCode;
//单位
private String mainUom;
//库位
private String locationcode;
public List<String> creatLabelPET(){
List<String> labelPETList = new ArrayList<>();
@ -80,6 +82,7 @@ public class LabelPrintPET {
labelPETList.add("specifications");
labelPETList.add("stageCode");
labelPETList.add("mainUom");
labelPETList.add("locationcode");
return labelPETList;
}
}

View File

@ -0,0 +1,45 @@
package com.cim.idm.model;
import lombok.Data;
import java.util.List;
import java.util.Map;
/**
* @Description
* @Author admin
* @Date 2025/5/28 9:32
*/
@Data
public class MaterialReceiveParam {
private String receiveRequestName;
private String siteName;
private String barCode;
private String user;
private String eventName;
private String receiveRequestType;
private String RECEIVEACTNO;
private String erpFactory;
private String erpLocation;
private String remark; //备注
private String commitDate;
private String opCode;
private String type;
private String STOCKORGNO;
private String MaterialPackingName;
private String materialSpecName;
private String materialQuantity;
private String materialQuantity2;
private String sdk_id;
private String phase;
private String CUSTOMNO;
private String truegg;
private String costName;
private String lifnr;
private String qtc;
/**销售订单*/
private String SALESHIPREQUESTNAME;
/**销售订单行号*/
private String SALESHIPREQUESTDETAILNAME;
private List<Map<String, Object>> boxList;
}

View File

@ -15,4 +15,5 @@ public class MaterialInfo {
private String phase;
private String width;
private String materialType;
private String descCn;
}

View File

@ -5,12 +5,14 @@ import com.cim.idm.model.CostCenter;
import com.cim.idm.model.MaterialPacking;
import com.cim.idm.model.vo.MaterialInfo;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public interface CostCenterService {
List<CostCenter> getCostCenter();
List<CostCenter> getCostCenter(String erpFactory);
List<Map<String, Object>> getUserInfo();
void updateCareerAssistanceNew(JSONObject in);
@ -23,7 +25,9 @@ public interface CostCenterService {
void editMaterialPackingName(MaterialPacking materialPacking);
MaterialInfo getMaterialInfo(String materialSpecName);
List<HashMap<String, Object>> getMaterialPacking(String materialSpecName, String siteName, String erpFactory, String erpLocation, String location, String nums);
List<LinkedHashMap<String, Object>> getMaterialPacking(String materialSpecName, String siteName, String erpFactory, String erpLocation, String location, String nums);
List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId);
void updateQty(String materialPackingName, BigDecimal materialQuantityFont, String user);
}

View File

@ -1854,7 +1854,7 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
pr.setPrintRequestID(UUID.randomUUID().toString());
LabelParameterObject obj = new LabelParameterObject();
List<Map<String, Object>> queryForListProduct = new ArrayList<>();
if ("PET标签-电晕.btw".equals(labelAddress)) {
if ("PET标签-电晕.btw".equals(labelAddress) || "PET标签-电晕-兴远泰.btw".equals(labelAddress) || "PET标签-涂布面.btw".equals(labelAddress) || "PET标签-涂布面-兴远泰.btw".equals(labelAddress)) {
params = new LabelPrintPET().creatLabelPET();
labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\WHRePrint\\" + labelAddress;
pr.setAbsolutePath(labelPath);
@ -1876,9 +1876,12 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
" LN.STAGECODE,\n" +
" LN.DEFINEITEM16,\n" +
" LN.MAINUOM,\n" +
" LN.DEFINEITEM9\n" +
" LN.DEFINEITEM9,\n" +
" MP.ERPLOCATION,\n" +
" MP.LOCATIONNAME" +
" FROM\n" +
" LABELPRINTINFO LN \n" +
" LEFT JOIN MATERIALPACKING MP ON LN.BARCODE = MP.MATERIALPACKINGNAME " +
" LEFT JOIN MATERIALSPEC MS ON LN.MATERIALCODE = MS.MATERIALSPECNAME\n" +
" WHERE\n" +
" LN.BARCODE =:MATERIALPACKINGNAME ";
@ -1900,9 +1903,12 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
"LN.STAGECODE,\n" +
"LN.DEFINEITEM16,\n" +
"LN.MAINUOM,\n" +
"LN.DEFINEITEM9 " +
"LN.DEFINEITEM9, " +
" MP.ERPLOCATION,\n" +
" MP.LOCATIONNAME" +
"FROM\n" +
"\tLABELPRINTINFO LN \n" +
" LEFT JOIN MATERIALPACKING MP ON LN.BARCODE = MP.MATERIALPACKINGNAME " +
"WHERE\n" +
"\tLN.BARCODE =:MATERIALPACKINGNAME ";
}
@ -1954,6 +1960,10 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
//单位
String mainUom = queryForListProduct.get(0).get("MAINUOM") == null ? "" : queryForListProduct.get(0).get("MAINUOM").toString();
labelPrintPET.setMainUom(mainUom);
//仓库编码+空格+货位编码
String erpLocation = queryForListProduct.get(0).get("ERPLOCATION") == null ? "" : queryForListProduct.get(0).get("ERPLOCATION").toString();
String locationname = queryForListProduct.get(0).get("LOCATIONNAME") == null ? "" : queryForListProduct.get(0).get("LOCATIONNAME").toString();
labelPrintPET.setLocationcode(erpLocation + " " + locationname);
labelPrintPET.setWide("");
labelPrintPET.setLength("");
labelPrintPET.setLineSpeed("");
@ -1967,8 +1977,8 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
throw new CustomException(CustomExceptionCode.DATA_ERROR, "要打印的PET标签信息不存在");
}
}else if ("Sdk2.btw".equals(labelAddress)){
labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\" + labelAddress;
}else if ("膜材标签-泗洪.btw".equals(labelAddress) || "膜材标签-太仓.btw".equals(labelAddress) || "膜材标签-东莞.btw".equals(labelAddress) || "膜材标签-重庆.btw".equals(labelAddress) || "膜材标签-越南.btw".equals(labelAddress)){
labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\WHRePrint\\" + labelAddress;
pr.setAbsolutePath(labelPath);
if (newMaterialSpecSwitch.equals("Y")){
qeuryLabelDatasql = " SELECT\n" +
@ -1983,7 +1993,8 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
" m.RECEIVEUSER operater,\n" +
" m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\n" +
" m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,\n" +
" TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater\n" +
" TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater," +
" m.ERPLOCATION,m.LOCATIONNAME \n" +
" FROM\n" +
" MATERIALPACKING m\n" +
" LEFT JOIN SDK_SPEC ss ON\n" +
@ -2007,7 +2018,8 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
" m.RECEIVEUSER operater,\r\n" +
" m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" +
" m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater\r\n" +
+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater," +
" m.ERPLOCATION,m.LOCATIONNAME\r\n" +
"FROM\r\n" +
" MATERIALPACKING m\r\n" +
"LEFT JOIN SDK_SPEC ss ON\r\n" +
@ -2064,12 +2076,15 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
obj.setMakedate(queryForListProduct.get(0).get("makedate") != null ? queryForListProduct.get(0).get("makedate").toString() : "");
obj.setSupplierno(queryForListProduct.get(0).get("supplierNo") != null ? queryForListProduct.get(0).get("supplierNo").toString() : "");
obj.setDescription(queryForListProduct.get(0).get("description") != null ? queryForListProduct.get(0).get("description").toString() : "");
String erpLocation = queryForListProduct.get(0).get("ERPLOCATION") == null ? "" : queryForListProduct.get(0).get("ERPLOCATION").toString();
String locationName = queryForListProduct.get(0).get("LOCATIONNAME") == null ? "" : queryForListProduct.get(0).get("LOCATIONNAME").toString();
obj.setLocationcode(erpLocation + " " + locationName);
log.info("***************************PrintLabel Assign params is : " + params.toString());
//labelUrl = labelPrintRabbitMQ(obj, requestUrl, pr, params);
labelUrl = labelPrint(obj, requestUrl, pr, params);
log.info("***************************PrintLabel Use URL is : " + requestUrl);
}else if ("胶水原材.btw".equals(labelAddress)){
labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\" + labelAddress;
}else if ("胶水标签.btw".equals(labelAddress)){
labelPath = "C:\\inetpub\\wwwroot\\BarTender\\wwwroot\\Templates\\WMS\\WHRePrint\\" + labelAddress;
pr.setAbsolutePath(labelPath);
if (newMaterialSpecSwitch.equals("Y")){
qeuryLabelDatasql = "SELECT\r\n" +
@ -2084,7 +2099,8 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
" m.RECEIVEUSER operater,\r\n" +
" m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" +
" m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater\r\n" +
+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater," +
" m.ERPLOCATION,m.LOCATIONNAME\r\n" +
"FROM\r\n" +
" MATERIALPACKING m\r\n" +
"LEFT JOIN SDK_SPEC ss ON\r\n" +
@ -2108,7 +2124,8 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
" m.RECEIVEUSER operater,\r\n" +
" m.CHARGE lotNo,NVL(m.suppliername,'') supplierNo,\r\n" +
" m.REMARK remark,TO_CHAR(m.RECEIVETIME,'YYYYMMDD') jumboRollBatch,"
+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater\r\n" +
+ "TO_CHAR(MAKEDATE,'YYYYMMDD') makedate, TO_CHAR(EXPIRINGDATE,'YYYYMMDD') expdate ,m.RECEIVEUSER opreater," +
" m.ERPLOCATION,m.LOCATIONNAME\r\n" +
"FROM\r\n" +
" MATERIALPACKING m\r\n" +
"LEFT JOIN SDK_SPEC ss ON\r\n" +
@ -2165,6 +2182,9 @@ public class BSLabelServiceImpl extends CommonServiceDAO<BSLabelKey, BSLabel> im
obj.setMakedate(queryForListProduct.get(0).get("makedate") != null ? queryForListProduct.get(0).get("makedate").toString() : "");
obj.setSupplierno(queryForListProduct.get(0).get("supplierNo") != null ? queryForListProduct.get(0).get("supplierNo").toString() : "");
obj.setDescription(queryForListProduct.get(0).get("description") != null ? queryForListProduct.get(0).get("description").toString() : "");
String erpLocation = queryForListProduct.get(0).get("ERPLOCATION") == null ? "" : queryForListProduct.get(0).get("ERPLOCATION").toString();
String locationName = queryForListProduct.get(0).get("LOCATIONNAME") == null ? "" : queryForListProduct.get(0).get("LOCATIONNAME").toString();
obj.setLocationcode(erpLocation + " " + locationName);
log.info("***************************PrintLabel Assign params is : " + params.toString());
//labelUrl = labelPrintRabbitMQ(obj, requestUrl, pr, params);
labelUrl = labelPrint(obj, requestUrl, pr, params);

View File

@ -22,10 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
@Service("CostCenterService")
@Slf4j
@ -37,8 +35,8 @@ public class CostCenterServiceImpl implements CostCenterService {
private ToSAPServiceImpl toSAPService;
@Override
public List<CostCenter> getCostCenter() {
return costCenterDao.getCostCenter();
public List<CostCenter> getCostCenter(String erpFactory) {
return costCenterDao.getCostCenter(erpFactory);
}
@Override
@ -163,7 +161,7 @@ public class CostCenterServiceImpl implements CostCenterService {
}
@Override
public List<HashMap<String, Object>> getMaterialPacking(String materialSpecName, String siteName, String erpFactory, String erpLocation, String location, String nums) {
public List<LinkedHashMap<String, Object>> getMaterialPacking(String materialSpecName, String siteName, String erpFactory, String erpLocation, String location, String nums) {
return costCenterDao.getMaterialPacking(materialSpecName,siteName,erpFactory,
erpLocation, location, nums);
}
@ -172,4 +170,9 @@ public class CostCenterServiceImpl implements CostCenterService {
public List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId) {
return costCenterDao.getByMaterialPackingName(newBoxId);
}
@Override
public void updateQty(String materialPackingName, BigDecimal materialQuantityFont, String user) {
costCenterDao.updateQty(materialPackingName, materialQuantityFont, user);
}
}

View File

@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;
@ -666,24 +667,49 @@ public class MESToWMSServiceImpl implements MESToWMSService {
log.info("Received work order request: {}", in.toJSONString());
List<Map<String, Object>> mapList = new ArrayList<>();
for (int i = 0; i < in.size(); i++) {
String line = "" + (i + 1) + "行,";
JSONObject jsonObject = in.getJSONObject(i);
Map<String, Object> map = new HashMap<>();
// 料号
String materialSpecname = jsonObject.getString("materialSpecname");
if (StringUtils.isEmpty(materialSpecname)) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).
setMessage(line + "料号-materialSpecname-不能为空");
}
// 组织
String WERKS = jsonObject.getString("WERKS");
if (StringUtils.isEmpty(WERKS)) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).
setMessage(line + "组织-WERKS-不能为空");
}
// 仓库
String LGORT = jsonObject.getString("LGORT");
String LGORT = jsonObject.getString("erpLocation");
if (StringUtils.isEmpty(LGORT)) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).
setMessage(line + "仓库-erpLocation-不能为空");
}
if (StringUtils.isEmpty(jsonObject.getString("MENGE"))) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).
setMessage(line + "数量-MENGE-不能为空");
}
// 数量
String MENGE = jsonObject.getString("MENGE");
BigDecimal MENGE = new BigDecimal(jsonObject.getString("MENGE"));
// 单位
String MEINS = jsonObject.getString("MEINS");
if (StringUtils.isEmpty(MEINS)) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).
setMessage(line + "单位-MEINS-不能为空");
}
// 自定义领料单号
String ZLLORDER = jsonObject.getString("ZLLORDER");
// 自定义领料单行号
String ZLLITEM = jsonObject.getString("ZLLITEM");
// 工单
String AUFNR = jsonObject.getString("AUFNR");
String AUFNR = jsonObject.getString("toOrder");
if (StringUtils.isEmpty(AUFNR)) {
return AjaxResult.me().setSuccess(false).setErrorCode(500).
setMessage(line + "工单-toOrder-不能为空");
}
map.put("MATNR", materialSpecname);
map.put("WERKS", WERKS);
@ -696,8 +722,19 @@ public class MESToWMSServiceImpl implements MESToWMSService {
mapList.add(map);
}
// 出库
String undoid = toSAPService.StockOutByOrder_new(mapList, "MES", "262");
return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + undoid);
String undoidOut = toSAPService.StockOutByOrder_new(mapList, "MES", "262");
// 入库
String undoidIn = toSAPService.StockOutByOrder_new(mapList, "MES", "261");
if (StringUtils.isEmpty(undoidIn)) {
// 冲销
String undo = invoiceService.cancelShipInter(undoidOut, "MES");
if (undo == null || undo.isEmpty()) {
throw new GlobalException("下发mes失败后冲销失败");
} else {
throw new GlobalException("发送到mes失败");
}
}
return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + undoidIn);
}
/**
* 接收MES请求工单请求

View File

@ -5,6 +5,8 @@
<select id="getCostCenter" resultType="com.cim.idm.model.CostCenter">
select id, cost_code costCode, cost_name costName, erp_factory erpFactory, department, division
from cost_center
where division = 'Y'
and erp_factory = #{erpFactory}
</select>
<select id="getUserInfo" resultType="java.util.Map">
@ -55,17 +57,27 @@
select * from MATERIALSPEC where MATERIALSPECNAME = #{materialSpecName}
</select>
<select id="getMaterialPacking" resultType="java.util.HashMap">
<select id="getMaterialPacking" resultType="java.util.LinkedHashMap">
select * from MATERIALPACKING
where MATERIALSPECNAME = #{materialSpecName}
AND SITENAME = #{siteName}
AND ERPFACTORY = #{erpFactory}
AND ERPLOCATION = #{erpLocation}
AND LOCATIONNAME = #{location}
<if test="location != null || location != ''">
AND LOCATIONNAME = #{location}
</if>
AND stockstate = 'Stocked'
order by CREATETIME
</select>
<select id="getByMaterialPackingName" resultType="java.util.HashMap" parameterType="java.lang.String">
select * from MATERIALPACKING
where MATERIALPACKINGNAME = #{newBoxId}
</select>
<update id="updateQty">
update MATERIALPACKING set MATERIALQUANTITY = MATERIALQUANTITY - #{materialQuantityFont},
LASTEVENTTIME = SYSDATE, LASTEVENTUSER = #{user}
where MATERIALPACKINGNAME = #{materialPackingName}
</update>
</mapper>