Commit f4860b50 zshaohui

获取入库单功能提交

1 个父辈 183671cd
......@@ -124,10 +124,48 @@ public class LuxsanSpApi extends DefaultSmfApiListener {
public static List<GetSpareNoResult> getSpareNo(GetSpareNoRequest request) {
try {
log.info("获取入库单号请求为:" + JSON.toJSONString(request));
String url = GetSpareNoUrl + getQueryStr(request);
log.info("获取入库单号返回:" + JSON.toJSONString(request));
String resJsonStr = HttpHelper.sendGet(url);
log.info("获取入库单号请求为:" + url);
//String resJsonStr = HttpHelper.sendGet(url);
String resJsonStr = "{\n" +
" \"msg\": \"操作成功\",\n" +
" \"code\": 200,\n" +
" \"data\": [\n" +
" {\n" +
" \"createBy\": \"76049701\",\n" +
" \"createTime\": \"2024-05-22 14:16:05\",\n" +
" \"spareNo\": \"CL2024052100041B\",\n" +
" \"whCode\": \"MLB-MFG-003\",\n" +
" \"status\": \"0\",\n" +
" \"deptId\": 102,\n" +
" \"detailList\": [\n" +
" {\n" +
" \"partno\": \"1950090020044V\",\n" +
" \"partname\": \"稀释剂|HYUAN|1578|500ml/瓶\",\n" +
" \"inQty\": 20\n" +
" }\n" +
" ],\n" +
" \"whDesc\": \"B2 4F MLB日常耗材\"\n" +
" },\n" +
" {\n" +
" \"createBy\": \"76049701\",\n" +
" \"createTime\": \"2024-05-22 14:16:05\",\n" +
" \"spareNo\": \"111111\",\n" +
" \"whCode\": \"MLB-MFG-003\",\n" +
" \"status\": \"0\",\n" +
" \"deptId\": 102,\n" +
" \"detailList\": [\n" +
" {\n" +
" \"partno\": \"1950090020044V\",\n" +
" \"partname\": \"稀释剂|HYUAN|1578|500ml/瓶\",\n" +
" \"inQty\": 20\n" +
" }\n" +
" ],\n" +
" \"whDesc\": \"B2 4F MLB日常耗材\"\n" +
" }\n" +
" ]\n" +
"}";
log.info("获取入库单号返回:" + resJsonStr);
LuxsanSpApiResult lizhenApiResult = JSONObject.parseObject(resJsonStr, LuxsanSpApiResult.class);
if (lizhenApiResult.getCode() != 200) {
throw new Exception(String.format("获取入库单号接口请求失败, 错误代码[%d],错误原因[%s]",
......
......@@ -10,6 +10,4 @@ public class GetSpareNoDetail {
private String partname;
private int inQty;
private int putInQty;
}
package com.neotel.smfcore.custom.luxsan_sp.bean;
import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoDetail;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import lombok.Data;
import java.util.List;
......@@ -27,9 +27,15 @@ public class SpareNo extends BasePo {
private int deptId;
//料号明细
private List<GetSpareNoDetail> detailList;
private List<SpareNoDetail> detailList;
//仓库描述
private String whDesc;
private int spareNostatus;
public boolean isExecutIng(){
return spareNostatus == SpareNostatus.EXECUTING_STATUS;
}
}
package com.neotel.smfcore.custom.luxsan_sp.bean;
import lombok.Data;
@Data
public class SpareNoDetail {
private String partno;
private String partname;
private int inQty;
private int alrInQty; //已经放入数量
}
package com.neotel.smfcore.custom.luxsan_sp.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.custom.lizhen.agvBox.bean.Station;
import com.neotel.smfcore.custom.lizhen.agvBox.util.StationCacheUtil;
import com.neotel.smfcore.custom.luxsan_sp.util.SpBoxUtil;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ApiOperation("备件仓 料箱入库")
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(tags = "备件仓 料箱入库")
@RestController
@RequestMapping("/spBoxPutIn")
public class SpBoxPutInController {
@Autowired
private CodeResolve codeResolve;
@ApiOperation("获取当前工位的料箱信息")
@RequestMapping("/getStationInfo")
@AnonymousAccess
public ResultBean getStationInfo() {
//默认是s1 工位
Station station = StationCacheUtil.getStation("s1");
if (station == null){
return ResultBean.newErrorResult(-1,"","当前工位没有料箱信息");
}
String currentRfid = station.getCurrentRfid();
if (StringUtils.isEmpty(currentRfid)){
return ResultBean.newErrorResult(-1,"","当前工位上currentRfid为空");
}
Barcode barcode = codeResolve.resolveOneValideBarcode("=2x2=" + currentRfid);
if (barcode == null){
return ResultBean.newErrorResult(-1,"",currentRfid+"不是有效的条码");
}
String suffix = currentRfid.substring(currentRfid.length()-1);
String currentBox = barcode.getBarcode();
List<List<Object>> boxInfo = SpBoxUtil.getBoxInfo(barcode, suffix);
Map<String,Object> resultMap = new HashMap<>();
resultMap.put("currentBox",currentBox);
resultMap.put("boxInfo",boxInfo);
return ResultBean.newOkResult(resultMap);
}
}
package com.neotel.smfcore.custom.luxsan_sp.controller;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetSpareNoRequest;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.ISpareNoManager;
import com.neotel.smfcore.custom.luxsan_sp.util.SpareNoCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Slf4j
......@@ -22,6 +25,9 @@ import java.util.List;
public class SpSpareNoController {
@Autowired
private SpareNoCache spareNoCache;
@Autowired
private ISpareNoManager spareNoManager;
......@@ -30,19 +36,59 @@ public class SpSpareNoController {
@AnonymousAccess
public ResultBean getAllSpareNo(String deptId, String functionDept) {
List<GetSpareNoResult> resultList = LuxsanSpApi.getSpareNo(new GetSpareNoRequest(deptId, functionDept));
List<SpareNo> spareNoList = new ArrayList<>();
for (GetSpareNoResult result : resultList) {
SpareNo spareNo = spareNoManager.getBySpareNo(result.getSpareNo());
SpareNo spareNo = spareNoCache.getBySpareNo(result.getSpareNo());
if (spareNo == null) {
spareNo = spareNoCache.getSpareNoResultToSpareNo(result);
spareNoCache.addToMap(spareNo);
spareNoManager.save(spareNo);
}
return ResultBean.newOkResult(resultList);
spareNoList.add(spareNo);
}
return ResultBean.newOkResult(spareNoList);
}
@ApiOperation("选中入库单")
@RequestMapping("/checkSpareNo")
@AnonymousAccess
public ResultBean checkSpareNo(String spareNo) {
public ResultBean checkSpareNo(String spareNoStr) {
//判断有没有正在执行的任务单
String no = spareNoCache.getExecutIngSpareNo();
if (StringUtils.isNotEmpty(no)) {
return ResultBean.newErrorResult(-1, "", "有正在执行的入库单:" + no);
}
SpareNo spareNo = spareNoCache.getBySpareNo(spareNoStr);
if (spareNo == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的入库单信息");
}
spareNo.setSpareNostatus(SpareNostatus.EXECUTING_STATUS);
spareNoCache.addToMap(spareNo);
spareNoManager.save(spareNo);
return ResultBean.newOkResult("");
}
@ApiOperation("放弃入库单")
@RequestMapping("/abandonSpareNo")
@AnonymousAccess
public ResultBean abandonSpareNo(String spareNoStr) {
SpareNo spareNo = spareNoCache.getBySpareNo(spareNoStr);
if (spareNo == null) {
return ResultBean.newErrorResult(-1, "", "未找到对应的入库单信息");
}
if (!spareNo.isExecutIng()) {
return ResultBean.newErrorResult(-1, "", spareNoStr + "不是正在执行中,不允许放弃");
}
spareNo.setSpareNostatus(SpareNostatus.ABANDON_STATUS);
spareNoCache.addToMap(spareNo);
spareNoManager.save(spareNo);
return ResultBean.newOkResult("");
}
}
package com.neotel.smfcore.custom.luxsan_sp.enums;
public class SpareNostatus {
public static final int NEW_STATUS = 0;
public static final int EXECUTING_STATUS = 1;
public static final int CLOSE_STATUS = 2;
public static final int ABANDON_STATUS = 3;
}
......@@ -8,6 +8,7 @@ import com.neotel.smfcore.custom.luxsan_sp.service.manager.ISpareNoManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
......@@ -27,7 +28,7 @@ public class SpareNoManagerImpl implements ISpareNoManager {
@Override
public SpareNo save(SpareNo object) throws ValidateException {
return null;
return spareNoDao.save(object);
}
@Override
......@@ -47,6 +48,6 @@ public class SpareNoManagerImpl implements ISpareNoManager {
@Override
public SpareNo getBySpareNo(String spareNo) {
return null;
return spareNoDao.findOne(new Query(Criteria.where("spareNo").is(spareNo)));
}
}
......@@ -42,6 +42,105 @@ public class SpBoxUtil {
}
public static List<List<Object>> getBoxInfo(Barcode barcode, String suffix) {
List<List<Object>> resultList = new ArrayList<>();
List<Barcode> subCodeList = barcode.getSubCodeList();
String boxStr = barcode.getBarcode();
List<Object> par1 = new ArrayList<>();
par1.add(1); //隔口号
par1.add(getAmount(subCodeList,boxStr+"-01")); //数量
par1.add(getPartNumber(subCodeList,boxStr+"-01")); //料号
List<Object> par2 = new ArrayList<>();
par2.add(2);
par2.add(getAmount(subCodeList,boxStr+"-02"));
par2.add(getPartNumber(subCodeList,boxStr+"-02"));
List<Object> par3 = new ArrayList<>();
par3.add(3);
par3.add(getAmount(subCodeList,boxStr+"-03"));
par3.add(getPartNumber(subCodeList,boxStr+"-03"));
List<Object> par4 = new ArrayList<>();
par4.add(4);
par4.add(getAmount(subCodeList,boxStr+"-04"));
par4.add(getPartNumber(subCodeList,boxStr+"-04"));
List<Object> par5 = new ArrayList<>();
par5.add(5);
par5.add(getAmount(subCodeList,boxStr+"-05"));
par5.add(getPartNumber(subCodeList,boxStr+"-05"));
List<Object> par6 = new ArrayList<>();
par6.add(6);
par6.add(getAmount(subCodeList,boxStr+"-06"));
par6.add(getPartNumber(subCodeList,boxStr+"-06"));
if (boxStr.startsWith("CS")) {
if ("A".equals(suffix)) {
resultList.add(par2);
resultList.add(par4);
resultList.add(par6);
resultList.add(par1);
resultList.add(par3);
resultList.add(par5);
} else if ("B".equals(suffix)) {
resultList.add(par5);
resultList.add(par3);
resultList.add(par1);
resultList.add(par6);
resultList.add(par4);
resultList.add(par2);
}
} else if (boxStr.startsWith("CB")) {
if ("A".equals(suffix)) {
resultList.add(par2);
resultList.add(par4);
resultList.add(par1);
resultList.add(par3);
} else if ("B".equals(suffix)) {
resultList.add(par3);
resultList.add(par1);
resultList.add(par4);
resultList.add(par2);
}
} else if (boxStr.startsWith("CM")) {
if ("A".equals(suffix)) {
resultList.add(par1);
} else if ("B".equals(suffix)) {
resultList.add(par1);
}
}
return resultList;
}
public static int getAmount(List<Barcode> subCodeList,String reelId){
if (subCodeList != null && !subCodeList.isEmpty()){
for (Barcode barcode : subCodeList) {
if (reelId.equals(barcode.getBarcode())){
return barcode.getAmount();
}
}
}
return 0;
}
public static String getPartNumber(List<Barcode> subCodeList,String reelId){
if (subCodeList != null && !subCodeList.isEmpty()){
for (Barcode barcode : subCodeList) {
if (reelId.equals(barcode.getBarcode())){
return barcode.getPartNumber();
}
}
}
return "";
}
public static synchronized StoragePos locOnePos(Barcode boxBarcode) {
//判断信息是否在已经在库位中(出入库只改变料箱位置状态,不从StoragePos表中清除)
......
package com.neotel.smfcore.custom.luxsan_sp.util;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoDetail;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.ISpareNoManager;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class SpareNoCache {
@Autowired
private ISpareNoManager spareNoManager;
Map<String, SpareNo> cacheMap = new ConcurrentHashMap<>();
public void addToMap(SpareNo spareNo){
cacheMap.put(spareNo.getSpareNo(),spareNo);
}
public SpareNo getBySpareNo(String spareNoStr) {
SpareNo spareNo = cacheMap.get(spareNoStr);
if (spareNo == null){
spareNo = spareNoManager.getBySpareNo(spareNoStr);
if (spareNo != null){
cacheMap.put(spareNo.getSpareNo(),spareNo);
}
}
return spareNo;
}
public String getExecutIngSpareNo(){
for (String spareNoStr : cacheMap.keySet()) {
SpareNo spareNo = cacheMap.get(spareNoStr);
if (spareNo.getSpareNostatus() == SpareNostatus.EXECUTING_STATUS){
return spareNoStr;
}
}
return "";
}
public SpareNo getSpareNoResultToSpareNo(GetSpareNoResult result) {
SpareNo spareNo = new SpareNo();
spareNo.setCreateBy(result.getCreateBy());
spareNo.setCreateTime(result.getCreateTime());
spareNo.setSpareNo(result.getSpareNo());
spareNo.setWhCode(result.getWhCode());
spareNo.setStatus(result.getStatus());
spareNo.setDeptId(result.getDeptId());
spareNo.setWhDesc(result.getWhDesc());
spareNo.setSpareNostatus(SpareNostatus.NEW_STATUS);
List<SpareNoDetail> detailList = new ArrayList<>();
for (GetSpareNoDetail detail : result.getDetailList()) {
SpareNoDetail spareNoDetail = new SpareNoDetail();
spareNoDetail.setPartname(detail.getPartname());
spareNoDetail.setPartno(detail.getPartno());
spareNoDetail.setInQty(detail.getInQty());
spareNoDetail.setAlrInQty(0);
detailList.add(spareNoDetail);
}
spareNo.setDetailList(detailList);
return spareNo;
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!