检验任务

philip 4 years ago
parent 0d49a71fe4
commit 1e35a78537

@ -32,6 +32,11 @@ public interface Constants {
String SITE_ADMIN = "SITE_ADMIN";
//上料
String ACTION_CODE_LOAD="1";
//卸料
String ACTION_CODE_UNLOAD="2";
//--------------------检验项目|任务-----------------------------------------------------------------------------------
// 新建
String INSPECTION_TASK_STATUS_NEW="NEW";

@ -126,6 +126,9 @@ public enum HandleEnum {
/**检验任务明细**/
INSPECTION_TASK_DETAIL("InspectionTaskDetailBO:","InspectionTaskDetailBO:{0},{1}"),
/**上料**/
LOAD_INVENTORY("LoadInventoryBO:","LoadInventoryBO:{0},{1}"),
/**用户**/
USR("UserBo","UserBo:{0},{1}");

@ -2,6 +2,8 @@ package com.foreverwin.mesnac.common.service;
import com.foreverwin.mesnac.meapi.model.Operation;
import java.math.BigDecimal;
public interface CommonService {
/**
*
@ -16,4 +18,6 @@ public interface CommonService {
* @return
*/
Operation getOperationBySfcBo(String sfcBo);
void updateInventory(String site, String inventoryId, BigDecimal measuredQty);
}

@ -3,6 +3,7 @@ package com.foreverwin.mesnac.common.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.foreverwin.mesnac.common.service.CommonService;
import com.foreverwin.mesnac.common.util.ExceptionUtil;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.mapper.OperationMapper;
import com.foreverwin.mesnac.meapi.model.Operation;
@ -11,11 +12,17 @@ import com.foreverwin.mesnac.meapi.model.WorkCenterMember;
import com.foreverwin.mesnac.meapi.service.WorkCenterMemberService;
import com.foreverwin.mesnac.meapi.service.WorkCenterService;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.meext.MEServices;
import com.sap.me.inventory.InventoryIdentifier;
import com.sap.me.inventory.InventoryServiceInterface;
import com.sap.me.inventory.InventoryStatusEnum;
import com.sap.me.inventory.InventoryValidateAndUpdateRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
@Service
@Transactional(rollbackFor = Exception.class)
@ -59,4 +66,34 @@ public class CommonServiceImpl implements CommonService {
Operation operation = operationMapper.selectOperationBySfcBo(sfcBo, LocaleContextHolder.getLocale().getLanguage());
return operation;
}
@Override
public void updateInventory(String site, String inventoryId, BigDecimal measuredQty) {
try {
InventoryServiceInterface inventoryService = MEServices.create("com.sap.me.inventory", "InventoryService", site);
com.sap.me.inventory.Inventory inventory = inventoryService.findInventory(new InventoryIdentifier(inventoryId));
if (inventory != null) {
InventoryValidateAndUpdateRequest updateRequest = new InventoryValidateAndUpdateRequest();
updateRequest.setInventoryId(inventory.getInventoryId());
updateRequest.setItemRef(inventory.getItemRef());
updateRequest.setQuantityOnHand(measuredQty);
updateRequest.setStatus(InventoryStatusEnum.AVAILABLE);
updateRequest.setAssyDataTypeRef(inventory.getAssyDataTypeRef());
updateRequest.setOperationLocationRef(inventory.getOperationLocRef());
updateRequest.setOperationLocationReserve(inventory.isOperationLocRes());
updateRequest.setShopOrderLocationRef(inventory.getShopOrderLocRef());
updateRequest.setShopOrderLocationReserve(inventory.isShopOrderLocRes());
updateRequest.setWorkCenterLocationRef(inventory.getWorkCenterLocRef());
updateRequest.setWorkCenterLocationReserve(inventory.isWorkCenterLocRes());
updateRequest.setResourceLocationRef(inventory.getResourceLocRef());
updateRequest.setResourceLocationReserve(inventory.isResourceLocRes());
updateRequest.setStorageLocationRef(inventory.getStorageLocationRef());
updateRequest.setAssemblyDataList(inventory.getAssemblyDataList());
updateRequest.setModifiedDateTime(inventory.getModifiedDateTime());
inventoryService.validateAndUpdate(updateRequest);
}
} catch (Exception e) {
e.printStackTrace();
ExceptionUtil.throwException(e);
}
}
}

@ -666,7 +666,7 @@
<select id="pageByResrce" resultMap="FullResultMap">
SELECT S.SFC,S.QTY,IT.DESCRIPTION ITEM_DESCRIPTION FROM SFC S
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.HANDLE AND IT.LOCALE=#{locale}
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE=#{locale}
JOIN Z_SFC_DISPATCH zsd ON S.SFC=zsd.SFC AND S.SITE=zsd.SITE
JOIN Z_PROD_READY_TASK zprt ON ZPRT.SFC_DISPATCH_BO=zsd.HANDLE
WHERE S.SITE=#{ew.entity.site} AND ZSD.RESRCE=#{ew.entity.resrce} AND ZSD.DISPATCH_STATUS!='CANCEL'

@ -3,6 +3,7 @@ package com.foreverwin.mesnac.production.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.dto.WorkCenterDto;
import com.foreverwin.mesnac.production.dto.LoadInventoryDto;
import com.foreverwin.mesnac.production.model.LoadInventory;
import com.foreverwin.mesnac.production.service.LoadInventoryService;
import com.foreverwin.modular.core.util.FrontPage;
@ -11,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
*
@ -32,21 +34,32 @@ public class LoadInventoryController {
@ResponseBody
@GetMapping("/loadList")
public R getLoadList(WorkCenterDto workCenterDto){
List<LoadInventory> result;
Map<String, Object> result;
result = loadInventoryService.getLoadInventoryList(workCenterDto);
return R.ok(result);
}
/**
*
*
*
* @return
*/
@ResponseBody
@GetMapping("/loadInventory")
public R loadInventory(LoadInventory loadInventory){
List<LoadInventory> result;
result = loadInventoryService.loadInventory(loadInventory);
return R.ok(result);
loadInventoryService.loadInventory(loadInventory);
return R.ok("上料成功");
}
/**
*
*
* @return
*/
@ResponseBody
@PostMapping("/unLoadInventory")
public R loadInventory(@RequestBody List<LoadInventoryDto> inventoryDtoList){
loadInventoryService.unLoadInventory(inventoryDtoList);
return R.ok();
}
/**

@ -0,0 +1,42 @@
package com.foreverwin.mesnac.production.dto;
import com.foreverwin.mesnac.production.model.LoadInventory;
public class LoadInventoryDto extends LoadInventory {
private String dwgNo;
private String itemDesc;
private String textture;
private String matSpec;
public String getDwgNo() {
return dwgNo;
}
public void setDwgNo(String dwgNo) {
this.dwgNo = dwgNo;
}
public String getItemDesc() {
return itemDesc;
}
public void setItemDesc(String itemDesc) {
this.itemDesc = itemDesc;
}
public String getTextture() {
return textture;
}
public void setTextture(String textture) {
this.textture = textture;
}
public String getMatSpec() {
return matSpec;
}
public void setMatSpec(String matSpec) {
this.matSpec = matSpec;
}
}

@ -1,5 +1,6 @@
package com.foreverwin.mesnac.production.mapper;
import com.foreverwin.mesnac.production.dto.LoadInventoryDto;
import com.foreverwin.mesnac.production.model.LoadInventory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
@ -18,5 +19,5 @@ import java.util.List;
@Repository
public interface LoadInventoryMapper extends BaseMapper<LoadInventory> {
List<LoadInventory> getLoadInventoryList(@Param("site") String site,@Param("resrce") String resrce, @Param("language") String language);
List<LoadInventoryDto> getLoadInventoryList(@Param("site") String site, @Param("resrce") String resrce, @Param("language") String language);
}

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
@ -53,12 +54,12 @@ public class LoadInventory extends Model<LoadInventory> {
*
*/
@TableField("QTY_ON_HAND")
private Double qtyOnHand;
private BigDecimal qtyOnHand;
/**
*
*/
@TableField("LOAD_QTY")
private Double loadQty;
private BigDecimal loadQty;
/**
*
*/
@ -121,19 +122,19 @@ public class LoadInventory extends Model<LoadInventory> {
this.item = item;
}
public Double getQtyOnHand() {
public BigDecimal getQtyOnHand() {
return qtyOnHand;
}
public void setQtyOnHand(Double qtyOnHand) {
public void setQtyOnHand(BigDecimal qtyOnHand) {
this.qtyOnHand = qtyOnHand;
}
public Double getLoadQty() {
public BigDecimal getLoadQty() {
return loadQty;
}
public void setLoadQty(Double loadQty) {
public void setLoadQty(BigDecimal loadQty) {
this.loadQty = loadQty;
}

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
@ -58,12 +59,12 @@ public class LoadInventoryLog extends Model<LoadInventoryLog> {
*
*/
@TableField("QTY_ON_HAND")
private Double qtyOnHand;
private BigDecimal qtyOnHand;
/**
*
*/
@TableField("LOAD_QTY")
private Double loadQty;
private BigDecimal loadQty;
/**
*
*/
@ -124,19 +125,19 @@ public class LoadInventoryLog extends Model<LoadInventoryLog> {
this.actionCode = actionCode;
}
public Double getQtyOnHand() {
public BigDecimal getQtyOnHand() {
return qtyOnHand;
}
public void setQtyOnHand(Double qtyOnHand) {
public void setQtyOnHand(BigDecimal qtyOnHand) {
this.qtyOnHand = qtyOnHand;
}
public Double getLoadQty() {
public BigDecimal getLoadQty() {
return loadQty;
}
public void setLoadQty(Double loadQty) {
public void setLoadQty(BigDecimal loadQty) {
this.loadQty = loadQty;
}

@ -3,9 +3,11 @@ package com.foreverwin.mesnac.production.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.mesnac.meapi.dto.WorkCenterDto;
import com.foreverwin.mesnac.production.dto.LoadInventoryDto;
import com.foreverwin.mesnac.production.model.LoadInventory;
import com.foreverwin.modular.core.util.FrontPage;
import java.util.HashMap;
import java.util.List;
/**
@ -27,7 +29,9 @@ public interface LoadInventoryService extends IService<LoadInventory> {
List<LoadInventory> selectList(LoadInventory loadInventory);
List<LoadInventory> getLoadInventoryList(WorkCenterDto workCenterDto);
HashMap<String, Object> getLoadInventoryList(WorkCenterDto workCenterDto);
List<LoadInventory> loadInventory(LoadInventory loadInventory);
void loadInventory(LoadInventory loadInventory);
void unLoadInventory(List<LoadInventoryDto> inventoryDtoList);
}

@ -3,25 +3,36 @@ package com.foreverwin.mesnac.production.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.service.CommonService;
import com.foreverwin.mesnac.common.util.StringUtil;
import com.foreverwin.mesnac.meapi.dto.WorkCenterDto;
import com.foreverwin.mesnac.meapi.model.Inventory;
import com.foreverwin.mesnac.meapi.model.Resrce;
import com.foreverwin.mesnac.meapi.service.InventoryService;
import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.mesnac.production.dto.LoadInventoryDto;
import com.foreverwin.mesnac.production.mapper.LoadInventoryMapper;
import com.foreverwin.mesnac.production.model.LoadInventory;
import com.foreverwin.mesnac.production.model.LoadInventoryLog;
import com.foreverwin.mesnac.production.service.LoadInventoryLogService;
import com.foreverwin.mesnac.production.service.LoadInventoryService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
* <p>
*
@ -42,6 +53,8 @@ public class LoadInventoryServiceImpl extends ServiceImpl<LoadInventoryMapper, L
private InventoryService inventoryService;
@Autowired
private LoadInventoryMapper loadInventoryMapper;
@Autowired
private LoadInventoryLogService loadInventoryLogService;
@Override
public IPage<LoadInventory> selectPage(FrontPage<LoadInventory> frontPage, LoadInventory loadInventory) {
@ -58,7 +71,7 @@ public class LoadInventoryServiceImpl extends ServiceImpl<LoadInventoryMapper, L
}
@Override
public List<LoadInventory> getLoadInventoryList(WorkCenterDto workCenterDto) {
public HashMap<String, Object> getLoadInventoryList(WorkCenterDto workCenterDto) {
String site = CommonMethods.getSite();
String resrce = workCenterDto.getResrce();
String workCenter = workCenterDto.getWorkCenter();
@ -75,19 +88,87 @@ public class LoadInventoryServiceImpl extends ServiceImpl<LoadInventoryMapper, L
if (!workCenter.equals(StringUtil.trimHandle(workShopBo))) {
throw new BaseException("资源 " + resrce + " 与车间不匹配");
}
return loadInventoryMapper.getLoadInventoryList(site,resrce, LocaleContextHolder.getLocale().getLanguage());
String description = byId.getDescription();
List<LoadInventoryDto> loadInventoryList = loadInventoryMapper.getLoadInventoryList(site, resrce, LocaleContextHolder.getLocale().getLanguage());
HashMap<String, Object> map = new HashMap<>();
map.put("resrceDesc",description);
map.put("loadInventoryList",loadInventoryList);
return map;
}
@Override
public List<LoadInventory> loadInventory(LoadInventory loadInventory) {
public void loadInventory(LoadInventory loadInventory) {
String site = CommonMethods.getSite();
String resrce = loadInventory.getResrce();
String handle = HandleEnum.RESOURCE.getHandle(site, resrce);
Resrce byId = resrceService.getById(handle);
String inventoryId = loadInventory.getInventoryId();
BigDecimal loadQty = loadInventory.getLoadQty();
if (byId==null){
throw new BaseException("设备"+resrce+"不存在");
}
return null;
if (loadQty.doubleValue()<=0){
throw new BaseException("上料数量不能小于0");
}
Inventory inventory = inventoryService.getById(HandleEnum.INVENTORY.getHandle(site, inventoryId));
if (inventory==null){
throw new BaseException("库存"+inventoryId+"不存在");
}
if (inventory.getQtyOnHand().compareTo(loadQty)<0){
throw new BaseException("上料数量不能大于剩余数量"+inventory.getQtyOnHand());
}
BigDecimal remainQty = inventory.getQtyOnHand().subtract(loadQty);
//扣减库存
commonService.updateInventory(site,inventoryId,remainQty);
//保存上料数据
LocalDateTime now = LocalDateTime.now();
String user = CommonMethods.getUser();
loadInventory.setHandle(HandleEnum.LOAD_INVENTORY.getHandle(site, UUID.randomUUID().toString()));
loadInventory.setSite(site);
loadInventory.setResrce(resrce);
loadInventory.setItem(StringUtil.trimHandle(inventory.getItemBo()));
loadInventory.setQtyOnHand(loadInventory.getLoadQty());
loadInventory.setCreateUser(user);
loadInventory.setCreatedDateTime(now);
loadInventory.setModifyUser(user);
loadInventory.setModifiedDateTime(now);
save(loadInventory);
LoadInventoryLog loadInventoryLog=new LoadInventoryLog();
BeanUtils.copyProperties(loadInventory,loadInventoryLog);
loadInventoryLog.setActionCode(Constants.ACTION_CODE_LOAD);
loadInventoryLog.setHandle(UUID.randomUUID().toString());
loadInventoryLogService.save(loadInventoryLog);
}
@Override
public void unLoadInventory(List<LoadInventoryDto> inventoryDtoList) {
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
for (LoadInventoryDto loadInventoryDto: inventoryDtoList) {
String handle = loadInventoryDto.getHandle();
LoadInventory loadInventory = getById(handle);
String inventoryId = loadInventory.getInventoryId();
if(loadInventory==null){
throw new BaseException("未找到上料记录");
}
Inventory inventory = inventoryService.getById(HandleEnum.INVENTORY.getHandle(site, inventoryId));
if (inventory==null){
throw new BaseException("库存"+inventoryId+"不存在");
}
//增加库存
commonService.updateInventory(site,inventoryId,inventory.getQtyOnHand().add(loadInventory.getQtyOnHand()));
//删除卸料数据
removeById(handle);
LoadInventoryLog loadInventoryLog=new LoadInventoryLog();
BeanUtils.copyProperties(loadInventory,loadInventoryLog);
loadInventoryLog.setActionCode(Constants.ACTION_CODE_UNLOAD);
loadInventoryLog.setCreatedDateTime(LocalDateTime.now());
loadInventoryLog.setCreateUser(user);
loadInventoryLog.setHandle(UUID.randomUUID().toString());
loadInventoryLogService.save(loadInventoryLog);
}
}

@ -414,7 +414,13 @@
</foreach>)
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="getLoadInventoryList" resultMap="BaseResultMap">
<select id="getLoadInventoryList" resultType="com.foreverwin.mesnac.production.dto.LoadInventoryDto">
SELECT ZLI.*,it.DESCRIPTION ITEM_DESC,cf.VALUE DWG_NO,cf2.VALUE TEXTTURE,cf3.VALUE MAT_SPEC FROM Z_LOAD_INVENTORY ZLI
JOIN ITEM I ON zli.SITE=I.SITE AND zli.ITEM=I.ITEM AND I.CURRENT_REVISION='true'
LEFT JOIN ITEM_T IT ON I.HANDLE=IT.ITEM_BO AND IT.LOCALE='zh'
LEFT JOIN CUSTOM_FIELDS cf ON cf.HANDLE=IT.HANDLE AND CF."ATTRIBUTE"='DWG_NO'
LEFT JOIN CUSTOM_FIELDS cf2 ON cf.HANDLE=IT.HANDLE AND CF."ATTRIBUTE"='TEXTTURE'
LEFT JOIN CUSTOM_FIELDS cf3 ON cf.HANDLE=IT.HANDLE AND CF."ATTRIBUTE"='MAT_SPEC'
WHERE ZLI.RESRCE=#{resrce} AND ZLI.SITE=#{site} ORDER BY ZLI.CREATED_DATE_TIME
</select>
</mapper>

@ -135,7 +135,7 @@ WHERE sfc.site = #{site} and
WHEN SSTEP.QTY_IN_QUEUE > 0 THEN '排队中'
ELSE '新建' END STEP_STATUS
FROM SFC S
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.HANDLE AND IT.LOCALE='zh'
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE='zh'
INNER JOIN SFC_ROUTING SRI ON S.HANDLE=SRI.SFC_BO
INNER JOIN SFC_ROUTER SR ON SRI.HANDLE=SR.SFC_ROUTING_BO AND SR.IN_USE='true'
INNER JOIN ROUTER_STEP RS ON RS.ROUTER_BO=sr.ROUTER_BO
@ -154,7 +154,7 @@ WHERE sfc.site = #{site} and
SELECT ZSD.sfc,ZSD.operation,IT.DESCRIPTION item_Description,ST.STATUS,s.qty,ZSD.DISPATCH_NO,ZSD.STEP_ID
FROM Z_SFC_DISPATCH ZSD
JOIN SFC S ON ZSD.SFC=s.SFC AND ZSD.SITE=s.SITE
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.HANDLE AND IT.LOCALE=#{locale}
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE=#{locale}
INNER JOIN STATUS ST ON ST.HANDLE = S.STATUS_BO
WHERE zsd.SITE=#{site} AND zsd.DISPATCH_STATUS='START' AND ZSD.RESRCE=#{resrce}
</select>

Loading…
Cancel
Save