Commit a5db80b8 LN

料盒操作功能

1 个父辈 1f8f5679
...@@ -515,7 +515,7 @@ public class BarcodeRule { ...@@ -515,7 +515,7 @@ public class BarcodeRule {
Barcode b = new Barcode(); Barcode b = new Barcode();
b.setFullCode(codeStr);
String reelId = ""; String reelId = "";
if(whole_reelId_item.hasThisField()){ if(whole_reelId_item.hasThisField()){
reelId = codeStr; reelId = codeStr;
......
package com.neotel.smfcore.core.barcode.rest.bean.dto; package com.neotel.smfcore.core.barcode.rest.bean.dto;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS; import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS; import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
...@@ -13,6 +12,9 @@ import org.springframework.data.annotation.Transient; ...@@ -13,6 +12,9 @@ import org.springframework.data.annotation.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
@Getter @Getter
@Setter @Setter
public class BarcodeDto implements Serializable { public class BarcodeDto implements Serializable {
...@@ -205,5 +207,8 @@ public class BarcodeDto implements Serializable { ...@@ -205,5 +207,8 @@ public class BarcodeDto implements Serializable {
return (""+plateSize+"X"+height); return (""+plateSize+"X"+height);
} }
/**
* 料箱中的物料信息
*/
private Map<String, BarcodeDto> subCodeMap;
} }
...@@ -3,7 +3,6 @@ package com.neotel.smfcore.core.barcode.service.po; ...@@ -3,7 +3,6 @@ package com.neotel.smfcore.core.barcode.service.po;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.neotel.smfcore.common.base.BasePo; import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.common.utils.StorageConstants;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS; import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE; import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS; import com.neotel.smfcore.core.barcode.enums.SOLDER_STATUS;
...@@ -13,8 +12,7 @@ import org.springframework.data.annotation.Transient; ...@@ -13,8 +12,7 @@ import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.*;
import java.util.List;
@Data @Data
@Document @Document
...@@ -23,6 +21,11 @@ public class Barcode extends BasePo implements Serializable { ...@@ -23,6 +21,11 @@ public class Barcode extends BasePo implements Serializable {
* 条码编号 * 条码编号
*/ */
private String barcode; private String barcode;
/**
* 扩展料盒的条码ID
*/
private String hostBarcodeId;
/** /**
* 物料类型:PCB,锡膏,或其他 * 物料类型:PCB,锡膏,或其他
*/ */
...@@ -42,9 +45,9 @@ public class Barcode extends BasePo implements Serializable { ...@@ -42,9 +45,9 @@ public class Barcode extends BasePo implements Serializable {
private Date expTime; private Date expTime;
/** /**
* 过期状态,-1未入库0在库,1已出库正常,2已出库且已过期 * 过期状态,-1未入库0在库,1已出库正常,2已出库且已过期
*/ */
private int status = BARCODE_STATUS.NEW; private int status = BARCODE_STATUS.NEW;
/** /**
* 锡膏状态 * 锡膏状态
...@@ -73,16 +76,16 @@ public class Barcode extends BasePo implements Serializable { ...@@ -73,16 +76,16 @@ public class Barcode extends BasePo implements Serializable {
/** /**
* 盘宽 * 盘宽
*/ */
private int plateSize=0; private int plateSize = 0;
/** /**
* 盘高 * 盘高
*/ */
private int height=0; private int height = 0;
private String provider; private String provider;
/** /**
* 批次 * 批次
*/ */
private String batch; private String batch="";
private String msl; private String msl;
//备用字段1(配套单号))或 family //备用字段1(配套单号))或 family
...@@ -156,19 +159,25 @@ public class Barcode extends BasePo implements Serializable { ...@@ -156,19 +159,25 @@ public class Barcode extends BasePo implements Serializable {
*/ */
@Transient @Transient
private List<String> relationCodes; private List<String> relationCodes;
/**
* 料盒条码:料盒内所有物料条码
*/
private Map<String, Barcode> subCodeMap;
/** /**
* 是否是锡膏 * 是否是锡膏
*/ */
public boolean isSolder(){ public boolean isSolder() {
return type == COMPONENT_TYPE.SOLDERPASTE; return type == COMPONENT_TYPE.SOLDERPASTE;
} }
public List<String> getRelationCodes() { public List<String> getRelationCodes() {
if (relationCodes == null) { if (relationCodes == null) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
return relationCodes; return relationCodes;
} }
/** /**
* 上次使用时间(出入库时更改) * 上次使用时间(出入库时更改)
*/ */
...@@ -197,6 +206,7 @@ public class Barcode extends BasePo implements Serializable { ...@@ -197,6 +206,7 @@ public class Barcode extends BasePo implements Serializable {
* 原始条码 * 原始条码
*/ */
private String fullCode; private String fullCode;
/** /**
* 添加相关联条码 * 添加相关联条码
* *
...@@ -208,12 +218,13 @@ public class Barcode extends BasePo implements Serializable { ...@@ -208,12 +218,13 @@ public class Barcode extends BasePo implements Serializable {
} }
relationCodes.add(relationCode); relationCodes.add(relationCode);
} }
public long getPutInTime() { public long getPutInTime() {
return putInTime; return putInTime;
} }
public void setPutInTime(long putInTime) { public void setPutInTime(long putInTime) {
if(this.putInTime == -1){ if (this.putInTime == -1) {
this.putInTime = putInTime; this.putInTime = putInTime;
this.putInDate = new Date(putInTime); this.putInDate = new Date(putInTime);
} }
...@@ -229,8 +240,8 @@ public class Barcode extends BasePo implements Serializable { ...@@ -229,8 +240,8 @@ public class Barcode extends BasePo implements Serializable {
return putInDate; return putInDate;
} }
public String getPutInDateStr(){ public String getPutInDateStr() {
if(putInDate == null){ if (putInDate == null) {
return ""; return "";
} }
return DateUtil.toDateTimeString(putInDate); return DateUtil.toDateTimeString(putInDate);
...@@ -240,13 +251,13 @@ public class Barcode extends BasePo implements Serializable { ...@@ -240,13 +251,13 @@ public class Barcode extends BasePo implements Serializable {
this.putInDate = putInDate; this.putInDate = putInDate;
} }
private void updateExpTime(){ private void updateExpTime() {
if(expTime == null && maxStorageTime != 0F && putInTime != -1){ if (expTime == null && maxStorageTime != 0F && putInTime != -1) {
Float maxStorageTimeMill = maxStorageTime * 60 * 60 * 1000; Float maxStorageTimeMill = maxStorageTime * 60 * 60 * 1000;
expTime = new Date(putInTime + maxStorageTimeMill.longValue()); expTime = new Date(putInTime + maxStorageTimeMill.longValue());
if(expireDate != null){ if (expireDate != null) {
//如果是在包装上的过期时间之前,使用包装上的过期时间 //如果是在包装上的过期时间之前,使用包装上的过期时间
if(expireDate.getTime()< expTime.getTime()){ if (expireDate.getTime() < expTime.getTime()) {
expTime = expireDate; expTime = expireDate;
} }
} }
...@@ -256,9 +267,9 @@ public class Barcode extends BasePo implements Serializable { ...@@ -256,9 +267,9 @@ public class Barcode extends BasePo implements Serializable {
/** /**
* 到达回温的时间 * 到达回温的时间
*/ */
public long getReachWarmTime(){ public long getReachWarmTime() {
long reachWarmTime = System.currentTimeMillis(); long reachWarmTime = System.currentTimeMillis();
if(COMPONENT_TYPE.SOLDERPASTE == type && putInTime != -1){ if (COMPONENT_TYPE.SOLDERPASTE == type && putInTime != -1) {
reachWarmTime = putInTime + warmTime * 60 * 60 * 1000; reachWarmTime = putInTime + warmTime * 60 * 60 * 1000;
} }
return reachWarmTime; return reachWarmTime;
...@@ -267,22 +278,22 @@ public class Barcode extends BasePo implements Serializable { ...@@ -267,22 +278,22 @@ public class Barcode extends BasePo implements Serializable {
/** /**
* 是否达到回温时间,只有锡膏才需要判定 * 是否达到回温时间,只有锡膏才需要判定
*/ */
public boolean isReachedWarmTime(){ public boolean isReachedWarmTime() {
return getReachWarmTime() <= System.currentTimeMillis(); return getReachWarmTime() <= System.currentTimeMillis();
} }
public long getInStoreHour(){ public long getInStoreHour() {
if(putInTime != -1){ if (putInTime != -1) {
return (System.currentTimeMillis() - putInTime) / 60 / 60 / 1000; return (System.currentTimeMillis() - putInTime) / 60 / 60 / 1000;
} }
return 0; return 0;
} }
public long getInStoreMiniute(){ public long getInStoreMiniute() {
if(putInTime != -1){ if (putInTime != -1) {
long minutes = (System.currentTimeMillis() - getPutInTime()) / 60000 % 60; long minutes = (System.currentTimeMillis() - getPutInTime()) / 60000 % 60;
if(minutes == 0){ if (minutes == 0) {
if(getInStoreHour() == 0){ if (getInStoreHour() == 0) {
minutes = 1; minutes = 1;
} }
} }
...@@ -290,44 +301,47 @@ public class Barcode extends BasePo implements Serializable { ...@@ -290,44 +301,47 @@ public class Barcode extends BasePo implements Serializable {
} }
return 0; return 0;
} }
public void setCheckOutDate(Date checkOutDate, String opor) { public void setCheckOutDate(Date checkOutDate, String opor) {
this.checkOutDate = checkOutDate; this.checkOutDate = checkOutDate;
this.outOpor = opor; this.outOpor = opor;
if(checkOutDate != null){//出库时判断是否过期 if (checkOutDate != null) {//出库时判断是否过期
updateExpTime(); updateExpTime();
if(expTime != null && checkOutDate.after(expTime)){ if (expTime != null && checkOutDate.after(expTime)) {
//过期时间小于出库时间,说明出库的时候已经过期了 //过期时间小于出库时间,说明出库的时候已经过期了
status = BARCODE_STATUS.OUT_EXPIRED; status = BARCODE_STATUS.OUT_EXPIRED;
}else{ } else {
status = BARCODE_STATUS.OUT_NORMAL; status = BARCODE_STATUS.OUT_NORMAL;
} }
} }
} }
public void setInOpor(String inOpor) { public void setInOpor(String inOpor) {
if(putInTime == -1){ if (putInTime == -1) {
this.inOpor = inOpor; this.inOpor = inOpor;
} }
} }
public int getSolderStatus() { public int getSolderStatus() {
if(solderStatus == SOLDER_STATUS.REWARMING){ if (solderStatus == SOLDER_STATUS.REWARMING) {
//如果状态是回温中,且回温时间已经大于warmTime,修改状态为待搅拌 //如果状态是回温中,且回温时间已经大于warmTime,修改状态为待搅拌
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if(startWarmTime - now > warmTime * 60 * 60 * 1000){ if (startWarmTime - now > warmTime * 60 * 60 * 1000) {
solderStatus = SOLDER_STATUS.TO_BE_MIXED; solderStatus = SOLDER_STATUS.TO_BE_MIXED;
} }
} }
return solderStatus; return solderStatus;
} }
public String getNeedOutDateStr(){
if(needOutDate == null){ public String getNeedOutDateStr() {
if (needOutDate == null) {
return ""; return "";
} }
return DateUtil.toDateTimeString(needOutDate); return DateUtil.toDateTimeString(needOutDate);
} }
public String getExpireDateStr(){ public String getExpireDateStr() {
if(expireDate != null){ if (expireDate != null) {
return DateUtil.toDateString(expireDate); return DateUtil.toDateString(expireDate);
} }
return ""; return "";
...@@ -336,8 +350,8 @@ public class Barcode extends BasePo implements Serializable { ...@@ -336,8 +350,8 @@ public class Barcode extends BasePo implements Serializable {
/** /**
* 是否已过期 * 是否已过期
*/ */
public boolean isExpired(){ public boolean isExpired() {
if(expireDate != null){ if (expireDate != null) {
return expireDate.before(new Date()); return expireDate.before(new Date());
} }
return false; return false;
...@@ -346,12 +360,12 @@ public class Barcode extends BasePo implements Serializable { ...@@ -346,12 +360,12 @@ public class Barcode extends BasePo implements Serializable {
/** /**
* 是否即将(3天内)过期,已过期后,此字段变为false * 是否即将(3天内)过期,已过期后,此字段变为false
*/ */
public boolean isWillExpired(){ public boolean isWillExpired() {
if(isExpired()){ if (isExpired()) {
return false; return false;
} }
if(expireDate != null){ if (expireDate != null) {
return expireDate.before(DateUtil.addDays(new Date(),3)); return expireDate.before(DateUtil.addDays(new Date(), 3));
} }
return false; return false;
} }
...@@ -359,10 +373,33 @@ public class Barcode extends BasePo implements Serializable { ...@@ -359,10 +373,33 @@ public class Barcode extends BasePo implements Serializable {
/** /**
* 是否是小料(7x8)的料 * 是否是小料(7x8)的料
*/ */
public boolean isSmallReel(){ public boolean isSmallReel() {
if(getPlateSize() == 7){ if (getPlateSize() == 7) {
return getHeight() == 8 || getHeight() == 12; return getHeight() == 8 || getHeight() == 12;
} }
return false; return false;
} }
public Barcode getSubCode(String pnStr) {
if (subCodeMap == null) {
return null;
}
return subCodeMap.get(pnStr);
}
public void UpdateSubCode(Barcode barcode) {
if (subCodeMap == null) {
subCodeMap = new HashMap<>();
}
if (barcode.getAmount() <= 0) {
if (subCodeMap.containsKey(barcode.getPartNumber())) {
subCodeMap.remove(barcode.getPartNumber());
}
} else {
subCodeMap.put(barcode.getPartNumber(), barcode);
}
}
} }
...@@ -6,6 +6,7 @@ import com.neotel.smfcore.common.exception.ValidateException; ...@@ -6,6 +6,7 @@ import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil; import com.neotel.smfcore.common.utils.DateUtil;
import com.neotel.smfcore.core.barcode.bean.BarcodeRule; import com.neotel.smfcore.core.barcode.bean.BarcodeRule;
import com.neotel.smfcore.core.barcode.bean.CodeBean; import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager; import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
...@@ -13,6 +14,7 @@ import com.neotel.smfcore.core.barcode.service.po.Component; ...@@ -13,6 +14,7 @@ import com.neotel.smfcore.core.barcode.service.po.Component;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.comments.CommentType;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
...@@ -42,10 +44,13 @@ public class CodeResolve { ...@@ -42,10 +44,13 @@ public class CodeResolve {
} }
} }
public CodeBean resolveSingleCode(String barcodeItemStr ){
return resolveSingleCode(barcodeItemStr, COMPONENT_TYPE.COMPONENT);
}
/** /**
* 解析条码为单个 Barcode,自动保存到数据库 * 解析条码为单个 Barcode,自动保存到数据库
*/ */
public CodeBean resolveSingleCode(String barcodeItemStr){ public CodeBean resolveSingleCode(String barcodeItemStr,int type){
if(barcodeRuleList == null || barcodeRuleList.isEmpty()){ if(barcodeRuleList == null || barcodeRuleList.isEmpty()){
CodeBean codeBean = new CodeBean(); CodeBean codeBean = new CodeBean();
...@@ -112,19 +117,19 @@ public class CodeResolve { ...@@ -112,19 +117,19 @@ public class CodeResolve {
barcode.setLabelAmount(currentLabelAmount); barcode.setLabelAmount(currentLabelAmount);
needUpdate = true; needUpdate = true;
} }
// Date produceDate = barcodeFromRule.getProduceDate(); Date produceDate = barcodeFromRule.getProduceDate();
// if(produceDate != null){ if(produceDate != null){
// //抓取到了生产日期,未抓取到过期日期,重新设置过期日期 //抓取到了生产日期,未抓取到过期日期,重新设置过期日期
// if(barcode.getExpireDate() == null){ if(barcode.getExpireDate() == null){
// if(validDay > 0){ if(validDay > 0){
// log.info("重新设置"+codeBeanFromRule.getCodeStr()+"生产日期和过期日期"); log.info("重新设置"+codeBeanFromRule.getCodeStr()+"生产日期和过期日期");
// Date expireDate = DateUtil.addDays(produceDate, validDay); Date expireDate = DateUtil.addDays(produceDate, validDay);
// barcode.setExpireDate(expireDate); barcode.setExpireDate(expireDate);
// barcode.setProduceDate(produceDate); barcode.setProduceDate(produceDate);
// needUpdate = true; needUpdate = true;
// } }
// } }
// } }
if(needUpdate){ if(needUpdate){
try { try {
...@@ -141,7 +146,20 @@ public class CodeResolve { ...@@ -141,7 +146,20 @@ public class CodeResolve {
return codeBeanFromRule; return codeBeanFromRule;
}else if(codeBeanFromRule.isValid()){//数据库中不存在,但解析成功 }else if(codeBeanFromRule.isValid()){//数据库中不存在,但解析成功
Barcode barcodeFromRule = codeBeanFromRule.getBarcode(); Barcode barcodeFromRule = codeBeanFromRule.getBarcode();
try{ try{
if(type== COMPONENT_TYPE.FIXTURE||type==COMPONENT_TYPE.OTHERS){
//夹具类型,默认设置尺寸,数量
if(!codeBeanFromRule.hasReelSizeInfo()){
codeBeanFromRule.setReelHeight(1);
codeBeanFromRule.setReelWidth(1);
barcodeFromRule.setAmount(1);
barcodeFromRule.setHeight(1);
barcodeFromRule.setPlateSize(1);
}
}
//如果有料盘尺寸,重新设置料盘尺寸信息,没有档案时自动添加档案 //如果有料盘尺寸,重新设置料盘尺寸信息,没有档案时自动添加档案
if(codeBeanFromRule.hasReelSizeInfo()){ if(codeBeanFromRule.hasReelSizeInfo()){
//log.info("料盘["+barcode.getBarcode()+"]的尺寸信息从["+barcode.getPlateSize()+"x"+barcode.getHeight()+"]设置为["+codeBeanFromRule.getReelWidth()+"x"+codeBeanFromRule.getReelHeight()+"]"); //log.info("料盘["+barcode.getBarcode()+"]的尺寸信息从["+barcode.getPlateSize()+"x"+barcode.getHeight()+"]设置为["+codeBeanFromRule.getReelWidth()+"x"+codeBeanFromRule.getReelHeight()+"]");
...@@ -192,7 +210,9 @@ public class CodeResolve { ...@@ -192,7 +210,9 @@ public class CodeResolve {
} }
} }
barcode = barcodeManager.save(barcodeFromRule); barcode = barcodeManager.save(barcodeFromRule);
codeBeanFromRule.setCodeStr(barcode.getBarcode()); codeBeanFromRule.setCodeStr(barcode.getBarcode());
codeBeanFromRule.setBarcode(barcode); codeBeanFromRule.setBarcode(barcode);
codeBeanFromRule.setError(null,null); codeBeanFromRule.setError(null,null);
...@@ -221,7 +241,6 @@ public class CodeResolve { ...@@ -221,7 +241,6 @@ public class CodeResolve {
} }
/** /**
* 解析条码为单个 Barcode * 解析条码为单个 Barcode
*/ */
......
...@@ -293,7 +293,7 @@ public class BoxKanbanController { ...@@ -293,7 +293,7 @@ public class BoxKanbanController {
} }
} }
int allCount = inTask + outTask; int allCount = inTask + outTask;
BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getCid(), storage.getName(), false, 0, BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0,
"0", "0", "", allCount, inTask, outTask, "0", "0", "", allCount, inTask, outTask,
0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>()); 0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>());
......
package com.neotel.smfcore.core.storage.rest;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.manager.IDataLogManager;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "物料管理:料盒操作")
@RequestMapping("api/materialBox")
public class MaterialBoxController {
@Autowired
IBarcodeManager barcodeManager;
@Autowired
IComponentManager componentManager;
@Autowired
IStoragePosManager storagePosManager;
@Autowired
private CodeResolve codeResolve;
@Autowired
private TaskService taskService;
@Autowired
private IDataLogManager dataLogManager;
@Autowired
private BarcodeMapper barcodeMapper;
@ApiOperation("查询料盒信息")
@PostMapping
@PreAuthorize("@el.check('materialBox')")
public BarcodeDto manualOut(@RequestBody String code) {
// String code = paramMap.get("barcode");
CodeBean codeBean = new CodeBean();
try {
codeBean = codeResolve.resolveSingleCode(code.trim(), COMPONENT_TYPE.FIXTURE);
} catch (ValidateException e) {
codeBean.setError(e.getMessage());
}
if (codeBean == null || codeBean.getBarcode() == null) {
throw new ValidateException("smfcode.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
}
if (codeBean.getErrorCode() != null) {
throw new ValidateException(codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
}
List<BarcodeDto> codeDtos = new ArrayList<BarcodeDto>();
Barcode barcode = codeBean.getBarcode();
//此处需要判断是否是料盒
Component component=componentManager.findOneByPN(barcode.getPartNumber() );
if(component==null||(component.getType()!=COMPONENT_TYPE.FIXTURE)){
throw new ValidateException("smfcode.materialBox.invalid", "未找到料盒信息{0}", new String[]{code});
}
BarcodeDto barcodeDto=barcodeMapper.toDto(barcode);
if(barcodeDto.getSubCodeMap()==null){
barcodeDto.setSubCodeMap(new HashMap<>());
}
return barcodeDto;
}
@ApiOperation("取出物料")
@PostMapping("exeOut")
@PreAuthorize("@el.check('materialBox')")
public ResultBean exeOut(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");//料盒条码
String subPN = paramMap.get("subPN");//物料条码
String qtyStr = paramMap.get("qty");//数量
Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcode.materialBox.invalid", "未找到料盒信息{0}", new String[]{code});
}
Barcode subBarcode = barcode.getSubCode(subPN);
if (subBarcode == null) {
throw new ValidateException("smfcode.materialBox.noReel", "料盒中未找到对应物料");
}
int opQty = Integer.valueOf(qtyStr);
int oldAmount = subBarcode.getAmount();
if (oldAmount < opQty) {
throw new ValidateException("smfcode.materialBox.quantityshort", "物料数量不足");
}
int newAmount = oldAmount - opQty;
subBarcode.setAmount(newAmount);
subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, OP.CHECKOUT, null, subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "从料盒[" + barcode.getPosName() + "]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount);
return ResultBean.newOkResult("");
}
@ApiOperation("取出全部物料")
@PostMapping("exeOutAll")
@PreAuthorize("@el.check('materialBox')")
public ResultBean exeOutAll(@RequestBody Map<String, String> paramMap){
String code = paramMap.get("barcode");//料盒条码
Barcode barcode=barcodeManager.findByBarcode(code);
if(barcode==null){
//料盒不存在
throw new ValidateException("smfcode.materialBox.invalid", "未找到料盒信息{0}", new String[]{code});
}
if(barcode.getSubCodeMap()==null||barcode.getSubCodeMap().size()<=0){
//料盒中未找到对应物料
throw new ValidateException("smfcode.materialBox.boxNoReel","料盒中无物料");
}
List<Barcode> barcodes=new ArrayList<>(barcode.getSubCodeMap().values()) ;
for (Barcode subBarcode :
barcodes) {
int opQty=subBarcode.getAmount();
subBarcode.setAmount(0);
subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, OP.CHECKOUT, null,subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "从料盒["+barcode.getPosName()+"]全部出库,物料数量:" + opQty);
}
return ResultBean.newOkResult("");
}
@ApiOperation("操作料盒内的物料信息")
@PostMapping(value = "/operatePos")
@PreAuthorize("@el.check('materialBox')")
public ResultBean operatePos(@RequestBody Map<String, String> paramMap) {
try{
String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息
DataLog currentTask=null;
Barcode barcode=barcodeManager.findByBarcode(code);
if(barcode==null){
throw new ValidateException("smfcode.materialBox.invalid", "未找到料盒信息{0}", new String[]{code});
}
//用+或-分割,如果最后几位是数量,按手动输入处理
String[] codeArray = operageStr.split("-");
String pnStr = "";
int opQty = 0;
int opType = OP.NON_OP;
if(codeArray.length == 2){
try{
opQty = Integer.valueOf(codeArray[1]);
pnStr = codeArray[0];
opType = OP .CHECKOUT;
}catch (Exception e){
}
}
if(opType == OP.NON_OP){
codeArray = operageStr.split("\\+");
if(codeArray.length == 2){
try{
opQty = Integer.valueOf(codeArray[1]);
pnStr = codeArray[0];
opType = OP.PUT_IN;
}catch (Exception e){
}
}
}
if(opType != OP.NON_OP){
//手动输入,按PN来处理
//先查找是否有相同的PN,没有创建一个
Component component = autoGetComponent(pnStr,opQty);
//查看该库位中是否有相同的物料,有的话,数量累加
Barcode subBarcode=barcode.getSubCode(pnStr);
if(opType == OP.PUT_IN) {
//入库
if (subBarcode != null) {
int oldAmount = subBarcode.getAmount();
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(oldAmount + opQty);
subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, opType, currentTask, subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + oldAmount + " + " + opQty + " = " + subBarcode.getAmount());
} else {
subBarcode=autoGetBarcode(barcode,component,pnStr,opQty);
finishTask(barcode, opType, currentTask, subBarcode, opQty);
log.info(barcode.getPartNumber() + "入库到料盒[" + barcode.getBarcode() + "],物料数量:" + barcode.getAmount());
}
}else {
//出库
if(subBarcode != null){
int oldAmount = subBarcode.getAmount();
if(oldAmount < opQty){
throw new ValidateException("smfcode.materialBox.quantityshort","物料数量不足");
}
int newAmount = oldAmount - opQty;
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newAmount);
subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, opType, currentTask,subBarcode, opQty);
log.info(subBarcode.getPartNumber() + "从料盒["+barcode.getPosName()+"]出库,物料数量:" + oldAmount + " - " + opQty + " = " + newAmount);
}else{
//无库存
throw new ValidateException("smfcode.materialBox.noReel","料盒中未找到对应物料");
}
}
}else {
String newCodeStr = "=1x1=" + operageStr;
CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr );
if (codeBean.isValid()) {
Barcode subBarcode = codeBean.getBarcode();
StoragePos pos = storagePosManager.getByBarcode(subBarcode.getBarcode());
if (pos != null) {
throw new ValidateException("smfcode.materialBox.inPos", "物料已在库位{0}中", new String[]{pos.getPosName()});
}
if (subBarcode.getHostBarcodeId() == null) {
//不存在,入库
opQty = OP.PUT_IN;
int newCount = subBarcode.getAmount() ;
if(newCount<=0){
newCount=1;
}
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newCount);
barcodeManager.saveBarcode(subBarcode);
finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount());
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
}
else if (subBarcode.getHostBarcodeId().equals(barcode.getId())) {
int qty = subBarcode.getAmount();
//出库
subBarcode.setAmount(0);
opQty = OP.CHECKOUT;
finishTask(barcode, opQty, currentTask, subBarcode, qty);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
} else {
//在别的料盒中
Barcode hostBarcode = barcodeManager.get(subBarcode.getHostBarcodeId());
if (hostBarcode != null) {
throw new ValidateException("smfcode.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
}
}
} else {
return ResultBean.newErrorResult(1, codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
}
}
}catch (Exception e){
// return "出入库操作出错:" + e.getMessage();
log.error(e.toString());
throw new ValidateException("smfcore.error","出错{0}",new String[]{e.toString()});
}
return ResultBean.newOkResult("");
}
private Component autoGetComponent(String pnStr,int opQty){
Component component = componentManager.findOneByPN(pnStr);
if(component == null){
component = new Component();
component.setHeight(1);
component.setPartNumber(pnStr);
component.setPlateSize(1);
component.setType(COMPONENT_TYPE.OTHERS);
component.setAmount(opQty);
component = componentManager.save(component);
}
return component;
}
private Barcode autoGetBarcode(Barcode barcode,Component component, String pnStr,int opQty){
//条码设置为P+PosId+C+ComponentId
String barcodeStr = "P" + barcode.getId() + "C" + component.getId();
Barcode subBarcode = barcodeManager.findByBarcode(barcodeStr);
if (subBarcode == null) {
//不存在,需要创建条码和库位
subBarcode = new Barcode();
subBarcode.setBarcode(barcodeStr);
subBarcode.setPlateSize(1);
subBarcode.setHeight(1);
subBarcode.setPartNumber(pnStr);
}
subBarcode.setAmount(opQty);
subBarcode.setUsedDate(new Date());
subBarcode.setPutInTime(System.currentTimeMillis());
subBarcode.setCheckOutDate(null, "");
subBarcode.setHostBarcodeId(barcode.getId());
subBarcode = barcodeManager.save(subBarcode);
return subBarcode;
}
/**
* 完成出入库任务
* @param pidBarcode 料箱
* @param currentTask 当前任务
* @param subBarcode 箱内物料
* @param opQty 数量
* @throws ValidateException
*/
private void finishTask(Barcode pidBarcode, int opType, DataLog currentTask, Barcode subBarcode, int opQty) throws ValidateException {
//更新barcode缓存
pidBarcode.UpdateSubCode(subBarcode);
if(opType==OP.CHECKOUT&&subBarcode.getAmount()<=0){
//数量为0直接删除
barcodeManager.delete(subBarcode);
}
barcodeManager.saveBarcode(pidBarcode);
DataLog task = null;
//先查看是否有相同类型且库位相同的任务
if(currentTask!=null) {
Collection<DataLog> queueTasks = taskService.getQueueTasks();
for (DataLog queueTask : queueTasks) {
if (queueTask.getType() == currentTask.getType()) {
if (queueTask.getPosName().equals(pidBarcode.getBarcode())) {
task = queueTask;
break;
}
}
}
}
if (task == null) {
task = new DataLog();
}
task.setStatus(OP_STATUS.FINISHED.name());
task.setPartNumber(subBarcode.getPartNumber());
task.setBarcode(subBarcode.getBarcode());
task.setNum(opQty);
task.setType(opType);
if (task.isCheckOutTask()) {
opQty = -opQty;
}
// Storage storage = dataCache.getStorage(currentTask.getCid());
// task.setCid(storage.getCid());
// task.setStorageId(storage.getId());
// task.setStorageName(storage.getName());
//
// task.setPosId(operatePos.getId());
// task.setPosName(operatePos.getPosName());
task.setCid(pidBarcode.getPartNumber());
// task.setStorageId(storage.getId());
task.setStorageName(pidBarcode.getBarcode());
// task.setPosId(operatePos.getId());
task.setPosName(pidBarcode.getBarcode());
task.setSourceName(SecurityUtils.getLoginUsername());
task = dataLogManager.save(task);
taskService.moveTaskToFinished(task);
// dataCache.updateInventoryAmount(task.getCid(), subBarcode.getPartNumber(), opQty);
}
}
...@@ -920,4 +920,8 @@ public class TaskService { ...@@ -920,4 +920,8 @@ public class TaskService {
} }
} }
public void moveTaskToFinished(DataLog task) {
taskMap.remove(task.getId());
theFinishedTaskMap.put(task.getId(), task);
}
} }
...@@ -127,8 +127,8 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen ...@@ -127,8 +127,8 @@ public class HellaServiceHandler extends IoHandlerAdapter implements ITaskListen
commandMap.put(command.getEventId(),command); commandMap.put(command.getEventId(),command);
log.info("发送检查物料条码请求:" + command.toReqMsg()); log.info("发送检查物料条码请求:" + command.toReqMsg());
ResultBean resultBean = HellaTcpClient.sendMsg(command.toReqMsg()); // ResultBean resultBean = HellaTcpClient.sendMsg(command.toReqMsg());
//ResultBean resultBean = testCheckOK(command); ResultBean resultBean = testCheckOK(command);
resultBean.setMsg("Check Material result:"+resultBean.getMsg()); resultBean.setMsg("Check Material result:"+resultBean.getMsg());
return resultBean; return resultBean;
} }
......
...@@ -115,6 +115,12 @@ smfcode.order.uploadOK=\u5DE5\u5355\u4E0A\u4F20\u6210\u529F ...@@ -115,6 +115,12 @@ smfcode.order.uploadOK=\u5DE5\u5355\u4E0A\u4F20\u6210\u529F
smfcode.order.ameExists=\u5DE5\u5355\u540D\u79F0[{0}]\u5DF2\u5B58\u5728 smfcode.order.ameExists=\u5DE5\u5355\u540D\u79F0[{0}]\u5DF2\u5B58\u5728
smfcode.order.hasClose=\u5DE5\u5355\u5DF2\u5173\u95ED smfcode.order.hasClose=\u5DE5\u5355\u5DF2\u5173\u95ED
smfcode.order.supplementOutFail=\u672A\u627E\u5230\u53EF\u4EE5\u51FA\u5E93\u7684\u8865\u6599 smfcode.order.supplementOutFail=\u672A\u627E\u5230\u53EF\u4EE5\u51FA\u5E93\u7684\u8865\u6599
smfcode.materialBox.quantityshort=\u7269\u6599\u6570\u91CF\u4E0D\u8DB3
smfcode.materialBox.invalid=\u672A\u627E\u5230\u6599\u76D2\u4FE1\u606F{0}
smfcode.materialBox.noReel=\u6599\u76D2\u4E2D\u672A\u627E\u5230\u5BF9\u5E94\u7269\u6599
smfcode.materialBox.boxNoReel=\u6599\u76D2\u4E2D\u65E0\u7269\u6599
smfcode.materialBox.inPos=\u7269\u6599\u5DF2\u5728\u5E93\u4F4D{0}\u4E2D
smfcode.materialBox.inOtherBox=\u7269\u6599\u5DF2\u5728\u6599\u76D2{0}\u4E2D
......
...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=Work order has been issued, can not modify the li ...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=Work order has been issued, can not modify the li
smfcode.order.uploadOK=Work order uploaded successfully smfcode.order.uploadOK=Work order uploaded successfully
smfcode.order.ameExists=Work order name [{0}] already exists smfcode.order.ameExists=Work order name [{0}] already exists
smfcode.order.hasClose=The work order is closed smfcode.order.hasClose=The work order is closed
smfcode.order.supplementOutFail=No replenishment material found that can be discharged
\ No newline at end of file \ No newline at end of file
smfcode.order.supplementOutFail=No replenishment material found that can be discharged
smfcode.materialBox.quantityshort=Insufficient quantity of materials
smfcode.materialBox.invalid=No information found for cartridge {0}
smfcode.materialBox.noReel=The corresponding material is not found in the material box
smfcode.materialBox.boxNoReel=No material in the cassette
smfcode.materialBox.inPos=The material is already in the storage space {0}
smfcode.materialBox.inOtherBox=The material is already in the cassette {0}
...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=\u4F5C\u696D\u6307\u793A\u66F8\u304C\u767A\u884C\ ...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=\u4F5C\u696D\u6307\u793A\u66F8\u304C\u767A\u884C\
smfcode.order.uploadOK=\u4F5C\u696D\u6307\u793A\u66F8\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u6210\u529F smfcode.order.uploadOK=\u4F5C\u696D\u6307\u793A\u66F8\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u6210\u529F
smfcode.order.ameExists=\u4F5C\u696D\u30AA\u30FC\u30C0\u30FC\u540D\u300C{0}\u300D\u306F\u65E2\u306B\u5B58\u5728\u3057\u3066\u3044\u307E\u3059 smfcode.order.ameExists=\u4F5C\u696D\u30AA\u30FC\u30C0\u30FC\u540D\u300C{0}\u300D\u306F\u65E2\u306B\u5B58\u5728\u3057\u3066\u3044\u307E\u3059
smfcode.order.hasClose=\u30EF\u30FC\u30AF\u30AA\u30FC\u30C0\u30FC\u306E\u7D42\u4E86 smfcode.order.hasClose=\u30EF\u30FC\u30AF\u30AA\u30FC\u30C0\u30FC\u306E\u7D42\u4E86
smfcode.order.supplementOutFail=\u6392\u51FA\u53EF\u80FD\u306A\u88DC\u5145\u54C1\u304C\u898B\u3064\u304B\u3089\u306A\u3044
\ No newline at end of file \ No newline at end of file
smfcode.order.supplementOutFail=\u6392\u51FA\u53EF\u80FD\u306A\u88DC\u5145\u54C1\u304C\u898B\u3064\u304B\u3089\u306A\u3044
smfcode.materialBox.quantityshort=\u7269\u6599\u6570\u91CF\u4E0D\u8DB3
smfcode.materialBox.invalid=\u96D1\u8A8C\u306E\u60C5\u5831\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F{0}
smfcode.materialBox.noReel=\u30AB\u30BB\u30C3\u30C8\u5185\u306B\u8A72\u5F53\u3059\u308B\u7D20\u6750\u304C\u898B\u3064\u304B\u3089\u306A\u3044
smfcode.materialBox.boxNoReel=\u30AB\u30BB\u30C3\u30C8\u306B\u7D20\u6750\u304C\u306A\u3044
smfcode.materialBox.inPos=\u3059\u3067\u306B\u5728\u5EAB\u306E\u3042\u308B\u7D20\u6750 {0}
smfcode.materialBox.inOtherBox=\u30AB\u30BB\u30C3\u30C8\u306B\u65E2\u306B\u5165\u3063\u3066\u3044\u308B\u7D20\u6750 {0}
\ No newline at end of file \ No newline at end of file
...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=\u5DE5\u5355\u5DF2\u51FA\u5E93\uFF0C\u4E0D\u80FD\ ...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=\u5DE5\u5355\u5DF2\u51FA\u5E93\uFF0C\u4E0D\u80FD\
smfcode.order.uploadOK=\u5DE5\u5355\u4E0A\u4F20\u6210\u529F smfcode.order.uploadOK=\u5DE5\u5355\u4E0A\u4F20\u6210\u529F
smfcode.order.ameExists=\u5DE5\u5355\u540D\u79F0[{0}]\u5DF2\u5B58\u5728 smfcode.order.ameExists=\u5DE5\u5355\u540D\u79F0[{0}]\u5DF2\u5B58\u5728
smfcode.order.hasClose=\u5DE5\u5355\u5DF2\u5173\u95ED smfcode.order.hasClose=\u5DE5\u5355\u5DF2\u5173\u95ED
smfcode.order.supplementOutFail=\u672A\u627E\u5230\u53EF\u4EE5\u51FA\u5E93\u7684\u8865\u6599
\ No newline at end of file \ No newline at end of file
smfcode.order.supplementOutFail=\u672A\u627E\u5230\u53EF\u4EE5\u51FA\u5E93\u7684\u8865\u6599
smfcode.materialBox.quantityshort=\u7269\u6599\u6570\u91CF\u4E0D\u8DB3
smfcode.materialBox.invalid=\u672A\u627E\u5230\u6599\u76D2\u4FE1\u606F{0}
smfcode.materialBox.noReel=\u6599\u76D2\u4E2D\u672A\u627E\u5230\u5BF9\u5E94\u7269\u6599
smfcode.materialBox.boxNoReel=\u6599\u76D2\u4E2D\u65E0\u7269\u6599
smfcode.materialBox.inPos=\u7269\u6599\u5DF2\u5728\u5E93\u4F4D{0}\u4E2D
smfcode.materialBox.inOtherBox=\u7269\u6599\u5DF2\u5728\u6599\u76D2{0}\u4E2D
\ No newline at end of file \ No newline at end of file
...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=\u5DE5\u55AE\u5DF2\u51FA\u5EAB\uFF0C\u4E0D\u80FD\ ...@@ -114,4 +114,10 @@ smfcode.order.cannotUpdateLine=\u5DE5\u55AE\u5DF2\u51FA\u5EAB\uFF0C\u4E0D\u80FD\
smfcode.order.uploadOK=\u5DE5\u55AE\u4E0A\u50B3\u6210\u529F smfcode.order.uploadOK=\u5DE5\u55AE\u4E0A\u50B3\u6210\u529F
smfcode.order.ameExists=\u5DE5\u55AE\u540D\u7A31[{0}]\u5DF2\u5B58\u5728 smfcode.order.ameExists=\u5DE5\u55AE\u540D\u7A31[{0}]\u5DF2\u5B58\u5728
smfcode.order.hasClose=\u5DE5\u55AE\u5DF2\u95DC\u9589 smfcode.order.hasClose=\u5DE5\u55AE\u5DF2\u95DC\u9589
smfcode.order.supplementOutFail=\u672A\u627E\u5230\u53EF\u4EE5\u51FA\u5EAB\u7684\u88DC\u6599
\ No newline at end of file \ No newline at end of file
smfcode.order.supplementOutFail=\u672A\u627E\u5230\u53EF\u4EE5\u51FA\u5EAB\u7684\u88DC\u6599
smfcode.materialBox.quantityshort=\u7269\u6599\u6570\u91CF\u4E0D\u8DB3
smfcode.materialBox.invalid=\u672A\u627E\u5230\u6599\u76D2\u4FE1\u606F{0}
smfcode.materialBox.noReel=\u6599\u76D2\u4E2D\u672A\u627E\u5230\u5C0D\u61C9\u7269\u6599
smfcode.materialBox.boxNoReel=\u6599\u76D2\u4E2D\u7121\u7269\u6599
smfcode.materialBox.inPos=\u7269\u6599\u5DF2\u5728\u5EAB\u4F4D{0}\u4E2D
smfcode.materialBox.inOtherBox=\u7269\u6599\u5DF2\u5728\u6599\u76D2{0}\u4E2D
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!