Merge remote-tracking branch 'origin/master'

赵嘉伟 4 years ago
commit 4148378a4b

@ -94,4 +94,13 @@ public interface DataImportConstant {
String NC_CODE_CATEGORY_FAILURE = "故障";
String NC_CODE_CATEGORY_DEFECT = "缺陷";
String NC_CODE_CATEGORY_REPAIR = "修复";
//物料类型-原始
String ITEM_MATERIAL_TYPE_ROH = "ROH";
//物料类型-半成品
String ITEM_MATERIAL_TYPE_HALB = "HALB";
//物料类型-已完成
String ITEM_MATERIAL_TYPE_FERT = "FERT";
//物料类型-包装
String ITEM_MATERIAL_TYPE_VERP = "VERP";
}

@ -6,5 +6,17 @@ spring:
wip:
driver-class-name: com.sap.db.jdbc.Driver
jndi-name: jdbc/jts/wipPool
activemq:
enabled: false
brokerUrl: tcp://localhost:61616?wireFormat.maxInactivityDuration=0
password: admin
user: admin
pool:
enabled: true
max-connections: 10
ftp:
host: 106.52.244.124
port: 21
username: zjw
password: zhaojiawei

@ -9,7 +9,7 @@ spring:
password: wip
driver-class-name: oracle.jdbc.OracleDriver
activemq:
enabled: true
enabled: false
brokerUrl: tcp://localhost:61616?wireFormat.maxInactivityDuration=0
password: admin
user: admin

@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.*;
import com.foreverwin.mesnac.dispatch.service.CallItemService;
import com.foreverwin.mesnac.dispatch.model.CallItem;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
@ -174,10 +176,10 @@ public class CallItemController {
issueItemDto.setDispatchNo(dispatchNo);
issueItemDto.setMatchResource(matchResource);
if (StringUtil.notBlank(requiredFromDate)) {
issueItemDto.setRequiredFromDT(LocalDateTime.parse(requiredFromDate));
issueItemDto.setRequiredFromDT(LocalDate.parse(requiredFromDate, DateTimeFormatter.ISO_DATE));
}
if (StringUtil.notBlank(requiredToDate)) {
issueItemDto.setRequiredToDT(LocalDateTime.parse(requiredToDate));
issueItemDto.setRequiredToDT(LocalDate.parse(requiredToDate, DateTimeFormatter.ISO_DATE));
}
result = callItemService.findIssueItemList(issueItemDto);

@ -1,17 +1,14 @@
package com.foreverwin.mesnac.dispatch.controller;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.R;
import com.foreverwin.modular.core.util.FrontPage;
import com.foreverwin.modular.core.util.CommonMethods;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.foreverwin.mesnac.dispatch.service.IssueItemService;
import com.foreverwin.mesnac.dispatch.model.IssueItem;
import java.util.List;
/**
*
@ -37,4 +34,23 @@ public class IssueItemController {
return R.ok();
}
@ResponseBody
@PostMapping("/issueItem")
public R issueItem(@RequestBody JSONObject jsonObject){
try {
if (jsonObject == null) {
throw BusinessException.build("请添加发料清单!");
}
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
issueItemService.issueItem(site, user, jsonObject);
} catch (Exception e) {
return R.failed(e.getMessage());
}
return R.ok();
}
}

@ -71,6 +71,6 @@ public class SurplusItemReturnController {
return R.failed(e.getMessage());
}
return R.ok("物料条码【" +inventory+ "】余料退回操作成功!");
return R.ok(0,"物料条码【" +inventory+ "】余料退回操作成功!");
}
}

@ -1,18 +1,21 @@
package com.foreverwin.mesnac.dispatch.dto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
public class IssueItemDto implements Serializable {
private String site;
private String item;
private String resource;
private String workCenter;
private String shopOrder;
private String dispatchNo;
private Boolean matchResource;
private LocalDateTime requiredFromDT;
private LocalDateTime requiredToDT;
private LocalDate requiredFromDT;
private LocalDate requiredToDT;
public String getSite() {
return site;
@ -22,6 +25,14 @@ public class IssueItemDto implements Serializable {
this.site = site;
}
public String getItem() {
return item;
}
public void setItem(String item) {
this.item = item;
}
public String getResource() {
return resource;
}
@ -62,19 +73,19 @@ public class IssueItemDto implements Serializable {
this.matchResource = matchResource;
}
public LocalDateTime getRequiredFromDT() {
public LocalDate getRequiredFromDT() {
return requiredFromDT;
}
public void setRequiredFromDT(LocalDateTime requiredFromDT) {
public void setRequiredFromDT(LocalDate requiredFromDT) {
this.requiredFromDT = requiredFromDT;
}
public LocalDateTime getRequiredToDT() {
public LocalDate getRequiredToDT() {
return requiredToDT;
}
public void setRequiredToDT(LocalDateTime requiredToDT) {
public void setRequiredToDT(LocalDate requiredToDT) {
this.requiredToDT = requiredToDT;
}
}

@ -4,6 +4,8 @@ import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
@ -63,7 +65,7 @@ public class IssueItem extends Model<IssueItem> {
*
*/
@TableField("QTY")
private Double qty;
private BigDecimal qty;
/**
*
*/
@ -142,11 +144,11 @@ public class IssueItem extends Model<IssueItem> {
this.inventory = inventory;
}
public Double getQty() {
public BigDecimal getQty() {
return qty;
}
public void setQty(Double qty) {
public void setQty(BigDecimal qty) {
this.qty = qty;
}

@ -1,8 +1,11 @@
package com.foreverwin.mesnac.dispatch.service;
;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.mesnac.dispatch.dto.IssueItemDto;
import com.foreverwin.mesnac.dispatch.model.IssueItem;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
@ -17,4 +20,6 @@ import java.util.Map;
public interface IssueItemService extends IService<IssueItem> {
Map<String, Object> scanIssueInventory(String site, String item, String inventory);
void issueItem(String site, String user, JSONObject jsonObject);
}

@ -1,6 +1,10 @@
package com.foreverwin.mesnac.dispatch.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.foreverwin.mesnac.common.constant.DataImportConstant;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.util.ExceptionUtil;
import com.foreverwin.mesnac.dispatch.model.IssueItem;
import com.foreverwin.mesnac.dispatch.mapper.IssueItemMapper;
import com.foreverwin.mesnac.dispatch.model.ItemBatch;
@ -12,14 +16,17 @@ import com.foreverwin.mesnac.meapi.model.Item;
import com.foreverwin.mesnac.meapi.service.InventoryService;
import com.foreverwin.mesnac.meapi.service.ItemService;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.meext.MEServices;
import com.sap.me.common.MaterialType;
import com.sap.me.common.ObjectReference;
import com.sap.me.inventory.*;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
/**
@ -37,8 +44,6 @@ public class IssueItemServiceImpl extends ServiceImpl<IssueItemMapper, IssueItem
@Autowired
private ItemService itemService;
@Autowired
private IssueItemMapper issueItemMapper;
@Autowired
private ItemBatchService itemBatchService;
@Autowired
private InventoryService inventoryService;
@ -78,4 +83,101 @@ public class IssueItemServiceImpl extends ServiceImpl<IssueItemMapper, IssueItem
return map;
}
@Override
public void issueItem(String site, String user, JSONObject jsonObject) {
JSONArray jsonArray = jsonObject.getJSONArray("inventoryItems");
if (jsonArray == null || jsonArray.size() <= 0) {
throw BusinessException.build("发料清单不能为空!");
}
String item = jsonObject.getString("item");
Item itemModel = itemService.selectCurrent(site, item);
if (itemModel == null) {
throw BusinessException.build("物料{0}没有维护当前版本!", item);
}
String itemBo = itemModel.getHandle();
String materialType = itemModel.getMaterialType();
Boolean oddments = jsonObject.getBoolean("oddments");
LocalDateTime dateTime = LocalDateTime.now();
List<IssueItem> issueItemList = new ArrayList<>();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (!oddments) {
//非余料发料 原材料-创建库存,计算发料数量; 半成品-只计算发料数量
InventoryServiceInterface meInventoryService;
try {
meInventoryService = MEServices.create("com.sap.me.inventory", "InventoryService", site);
} catch (Exception e) {
throw BusinessException.build("获取标准库存操作服务失败:" + e.getMessage());
}
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject _jsonObject = jsonArray.getJSONObject(i);
String inventory = _jsonObject.getString("inventory");
String qty = _jsonObject.getString("qty");
BigDecimal qtyOnHand = new BigDecimal(qty);
if (MaterialType.RAW.value().equals(materialType)) {
List<ItemBatch> itemBatchList = itemBatchService.findItemBatch(site, item, inventory);
if (itemBatchList == null || itemBatchList.size() <= 0) {
throw BusinessException.build("扫描的物料条码【 " + inventory + " 】不存在!");
}
try {
//查询库存是否存在
ObjectReference objectReference = new ObjectReference();
String inventoryBo = HandleEnum.INVENTORY.getHandle(site, inventory);
objectReference.setRef(inventoryBo);
com.sap.me.inventory.Inventory inventoryModel = meInventoryService.findInventoryByRef(objectReference);
if (inventoryModel == null) {
//库存创建
InventoryValidateAndAddRequest request = new InventoryValidateAndAddRequest();
request.setItemRef(itemBo);
request.setInventoryId(inventory);
request.setQuantityOnHand(qtyOnHand);
meInventoryService.validateAndAdd(request);
} else {
qtyOnHand = qtyOnHand.add(inventoryModel.getQtyOnHand());
//库存修改
InventoryValidateAndUpdateWithReceiveQuantityOverrideRequest request = new InventoryValidateAndUpdateWithReceiveQuantityOverrideRequest();
request.setItemRef(itemBo);
request.setInventoryId(inventory);
request.setReceiveQty(qtyOnHand);
request.setQuantityOnHand(qtyOnHand);
request.setModifiedDateTime(inventoryModel.getModifiedDateTime());
meInventoryService.validateAndUpdateWithReceiveQtyOverride(request);
}
} catch (Exception e) {
ExceptionUtil.throwException(e);
}
}
//发料明细记录
IssueItem issueItem = new IssueItem();
issueItem.setHandle("IssueItemBO:" + site + "," + UUID.randomUUID().toString());
issueItem.setSite(site);
issueItem.setCallItemNo("");
issueItem.setShopOrder("");
issueItem.setSfc("");
issueItem.setItem(item);
issueItem.setInventory(inventory);
issueItem.setQty(new BigDecimal(qty));
issueItem.setCreateUser(user);
issueItem.setCreatedDateTime(dateTime);
issueItem.setModifyUser(user);
issueItem.setModifiedDateTime(dateTime);
issueItemList.add(issueItem);
}//end for
}// end if
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (issueItemList != null && issueItemList.size() > 0) {
this.saveBatch(issueItemList);
}
}
}
Loading…
Cancel
Save