Commit 490bc827 zshaohui

1.料架增加不良品查询功能

1 个父辈 31b3eab4
...@@ -164,6 +164,19 @@ public class Settings extends BaseMongoBean { ...@@ -164,6 +164,19 @@ public class Settings extends BaseMongoBean {
*/ */
private String orderFileDir; private String orderFileDir;
/**
* 入库校验地址
*/
private String inCheckApi;
public String getInCheckApi() {
return inCheckApi;
}
public void setInCheckApi(String inCheckApi) {
this.inCheckApi = inCheckApi;
}
public Date getLastPcbCheckDate() { public Date getLastPcbCheckDate() {
return lastPcbCheckDate; return lastPcbCheckDate;
} }
......
package com.myproject.webapp.controller.storage; package com.myproject.webapp.controller.storage;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
...@@ -18,6 +19,7 @@ import com.myproject.util.StorageConstants; ...@@ -18,6 +19,7 @@ import com.myproject.util.StorageConstants;
import com.myproject.webapp.controller.webService.DataCache; import com.myproject.webapp.controller.webService.DataCache;
import com.myproject.webapp.controller.webService.ITaskService; import com.myproject.webapp.controller.webService.ITaskService;
import com.myproject.webapp.controller.webService.StorageDataController; import com.myproject.webapp.controller.webService.StorageDataController;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
...@@ -25,6 +27,13 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -25,6 +27,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -173,7 +182,6 @@ public class AccShelfController extends BaseController { ...@@ -173,7 +182,6 @@ public class AccShelfController extends BaseController {
if(storage.isAccShelf()){ if(storage.isAccShelf()){
Barcode barcode = codeBean.getBarcode(); Barcode barcode = codeBean.getBarcode();
try { try {
if(barcode.getPlateSize() == 1){ if(barcode.getPlateSize() == 1){
//长宽为1的需要弹框设置尺寸 //长宽为1的需要弹框设置尺寸
throw new ValidateException("error.barcode.errorSize","条码未设置尺寸"); throw new ValidateException("error.barcode.errorSize","条码未设置尺寸");
...@@ -192,15 +200,19 @@ public class AccShelfController extends BaseController { ...@@ -192,15 +200,19 @@ public class AccShelfController extends BaseController {
// return "该物料已在库位["+posName+"]中"; // return "该物料已在库位["+posName+"]中";
Collection<DataLog> allTasks = taskService.getQueueTasks(); Collection<DataLog> allTasks = taskService.getQueueTasks();
for (DataLog task : allTasks) { for (DataLog task : allTasks) {
if(task.getCid().equals(cid) && task.getBarcode() != null && task.getBarcode().equals(barcode.getBarcode())){ if(/*task.getCid().equals(cid) &&*/ task.getBarcode() != null && task.getBarcode().equals(barcode.getBarcode())){
taskService.addTaskToFinished(inPos,null,null); taskService.addTaskToFinished(inPos,null,null);
opPosLight("close",storage,inPos,null); Storage cacheStorage = dataCache.getStorage(task.getCid());
opPosLight("close",cacheStorage,inPos,null);
return "OK"+getText("shelf.msg.outConfirm",new String[]{inPos.getPosName()},request.getLocale(),"出库完成, 库位["+inPos.getPosName()+"]灭灯"); return "OK"+getText("shelf.msg.outConfirm",new String[]{inPos.getPosName()},request.getLocale(),"出库完成, 库位["+inPos.getPosName()+"]灭灯");
} }
} }
return getText("shelf.msg.noTask",new String[]{inPos.getPosName()},request.getLocale(),"操作失败,已在库位["+inPos.getPosName()+"]中,未找到对应的出库任务"); return getText("shelf.msg.noTask",new String[]{inPos.getPosName()},request.getLocale(),"操作失败,已在库位["+inPos.getPosName()+"]中,未找到对应的出库任务");
} }
//log.info("收到code信息为:"+code);
inCheck(code);
List<Storage> storageList = Lists.newArrayList(storage); List<Storage> storageList = Lists.newArrayList(storage);
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode); StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode);
int delayCloseTime = 30000; int delayCloseTime = 30000;
...@@ -268,4 +280,81 @@ public class AccShelfController extends BaseController { ...@@ -268,4 +280,81 @@ public class AccShelfController extends BaseController {
log.info("操作库位["+pos.getPosName()+"]" + opKey + " : " + opStr); log.info("操作库位["+pos.getPosName()+"]" + opKey + " : " + opStr);
} }
public void inCheck(String itemBarcode) throws ValidateException {
String inCheckApi = dataCache.getSettings().getInCheckApi();
if (StringUtils.isEmpty(inCheckApi)) {
return;
}
Map<String, String> paramMap = new HashMap<>();
paramMap.put("itemBarcode", itemBarcode);
log.info("料架请求是否可以入库,参数为:" + itemBarcode);
try {
String result = doGet(inCheckApi, paramMap);
log.info("料架请求是否可以入库,返回结果为:" + result);
ObjectMapper mapper = new ObjectMapper();
Map resultMap = mapper.readValue(result, Map.class);
String code = resultMap.get("code").toString();
if ("200".equals(code)){
Object resultStr = resultMap.get("result");
if (resultStr != null){
List<Map<String,String>> resultList = (List<Map<String, String>>) resultStr;
if (resultList != null && !resultList.isEmpty()){
for (Map<String, String> map : resultList) {
String banReason = map.get("banReason");
if (StringUtils.isNotEmpty(banReason)){
throw new Exception("条码验证不允许入库:"+banReason);
}
}
}
}
return;
} else {
throw new Exception("条码验证不允许入库:"+result);
}
} catch (Exception e) {
e.printStackTrace();
log.info("料架请求是否可以入库,异常:",e);
throw new ValidateException("smfcore.checkNg",new String[]{e.getMessage()});
}
}
/**
* 发送GET请求
* @param url 请求地址
* @param params 请求参数Map
* @return 响应内容字符串
* @throws Exception 网络异常
*/
public static String doGet(String url, Map<String, String> params) throws Exception {
// 构建带参数的URL
StringBuilder urlBuilder = new StringBuilder(url);
if (params != null && !params.isEmpty()) {
urlBuilder.append("?");
for (Map.Entry<String, String> entry : params.entrySet()) {
urlBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
.append("=")
.append(URLEncoder.encode(entry.getValue(), "UTF-8"))
.append("&");
}
urlBuilder.deleteCharAt(urlBuilder.length() - 1); // 删除最后一个"&"
}
HttpURLConnection conn = (HttpURLConnection) new URL(urlBuilder.toString()).openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setConnectTimeout(5000);
conn.setReadTimeout(10000);
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
return response.toString();
} finally {
conn.disconnect();
}
}
} }
package com.myproject.webapp.controller.storage; package com.myproject.webapp.controller.storage;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.myproject.bean.CodeBean; import com.myproject.bean.CodeBean;
...@@ -19,12 +20,9 @@ import com.myproject.util.StorageConstants; ...@@ -19,12 +20,9 @@ import com.myproject.util.StorageConstants;
import com.myproject.webapp.controller.webService.DataCache; import com.myproject.webapp.controller.webService.DataCache;
import com.myproject.webapp.controller.webService.ITaskService; import com.myproject.webapp.controller.webService.ITaskService;
import com.myproject.webapp.controller.webService.StorageDataController; import com.myproject.webapp.controller.webService.StorageDataController;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -32,8 +30,13 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -32,8 +30,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/** /**
...@@ -69,7 +72,7 @@ public class NLPShelfController extends BaseController { ...@@ -69,7 +72,7 @@ public class NLPShelfController extends BaseController {
/** /**
* * 扫码入库
*/ */
@RequestMapping("/service/store/nlp/putInCode") @RequestMapping("/service/store/nlp/putInCode")
@ResponseBody @ResponseBody
...@@ -93,7 +96,6 @@ public class NLPShelfController extends BaseController { ...@@ -93,7 +96,6 @@ public class NLPShelfController extends BaseController {
Barcode barcode = codeBean.getBarcode(); Barcode barcode = codeBean.getBarcode();
try { try {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
//5秒内同一个条码忽略 //5秒内同一个条码忽略
Date usedDate = barcode.getUsedDate(); Date usedDate = barcode.getUsedDate();
...@@ -114,6 +116,8 @@ public class NLPShelfController extends BaseController { ...@@ -114,6 +116,8 @@ public class NLPShelfController extends BaseController {
return getText("shelf.msg.noTask",new String[]{inPos.getPosName()},request.getLocale(),"操作失败,已在库位["+inPos.getPosName()+"]中,未找到对应的出库任务"); return getText("shelf.msg.noTask",new String[]{inPos.getPosName()},request.getLocale(),"操作失败,已在库位["+inPos.getPosName()+"]中,未找到对应的出库任务");
} }
inCheck(code);
List<Storage> storageList = Lists.newArrayList(storage); List<Storage> storageList = Lists.newArrayList(storage);
StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode); StoragePos pos = taskService.findEmptyPosForPutIn(storageList, barcode);
if(pos != null){ if(pos != null){
...@@ -570,4 +574,82 @@ public class NLPShelfController extends BaseController { ...@@ -570,4 +574,82 @@ public class NLPShelfController extends BaseController {
return null; return null;
} }
public void inCheck(String itemBarcode) throws ValidateException {
String inCheckApi = dataCache.getSettings().getInCheckApi();
if (StringUtils.isEmpty(inCheckApi)) {
return;
}
Map<String, String> paramMap = new HashMap<>();
paramMap.put("itemBarcode", itemBarcode);
log.info("料架请求是否可以入库,参数为:" + itemBarcode);
try {
String result = doGet(inCheckApi, paramMap);
log.info("料架请求是否可以入库,返回结果为:" + result);
ObjectMapper mapper = new ObjectMapper();
Map resultMap = mapper.readValue(result, Map.class);
String code = resultMap.get("code").toString();
if ("200".equals(code)){
Object resultStr = resultMap.get("result");
if (resultStr != null){
List<Map<String,String>> resultList = (List<Map<String, String>>) resultStr;
if (resultList != null && !resultList.isEmpty()){
for (Map<String, String> map : resultList) {
String banReason = map.get("banReason");
if (StringUtils.isNotEmpty(banReason)){
throw new Exception("条码验证不允许入库:"+banReason);
}
}
}
}
return;
} else {
throw new Exception("条码验证不允许入库:"+result);
}
} catch (Exception e) {
e.printStackTrace();
log.info("料架请求是否可以入库,异常:",e);
throw new ValidateException("smfcore.checkNg",new String[]{e.getMessage()});
}
}
/**
* 发送GET请求
* @param url 请求地址
* @param params 请求参数Map
* @return 响应内容字符串
* @throws Exception 网络异常
*/
public static String doGet(String url, Map<String, String> params) throws Exception {
// 构建带参数的URL
StringBuilder urlBuilder = new StringBuilder(url);
if (params != null && !params.isEmpty()) {
urlBuilder.append("?");
for (Map.Entry<String, String> entry : params.entrySet()) {
urlBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"))
.append("=")
.append(URLEncoder.encode(entry.getValue(), "UTF-8"))
.append("&");
}
urlBuilder.deleteCharAt(urlBuilder.length() - 1); // 删除最后一个"&"
}
HttpURLConnection conn = (HttpURLConnection) new URL(urlBuilder.toString()).openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setConnectTimeout(5000);
conn.setReadTimeout(10000);
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
return response.toString();
} finally {
conn.disconnect();
}
}
} }
...@@ -84,6 +84,8 @@ public class SettingsController extends BaseUpdateController { ...@@ -84,6 +84,8 @@ public class SettingsController extends BaseUpdateController {
oldSettings.setInactionDay(settings.getInactionDay()); oldSettings.setInactionDay(settings.getInactionDay());
oldSettings.setInCheckApi(settings.getInCheckApi());
dataCache.updateSettings(oldSettings); dataCache.updateSettings(oldSettings);
saveMessage(request, getText("storage.saveSuccess", request.getLocale())); saveMessage(request, getText("storage.saveSuccess", request.getLocale()));
return "redirect:/system/settings.html"; return "redirect:/system/settings.html";
......
...@@ -299,6 +299,7 @@ btn.test=Test ...@@ -299,6 +299,7 @@ btn.test=Test
settings.api=API Settings settings.api=API Settings
settings.api.inNotifaction=Material Receiving Notice settings.api.inNotifaction=Material Receiving Notice
settings.api.outNotifaction=Material Retrieval Notice settings.api.outNotifaction=Material Retrieval Notice
settings.api.inCheck=Material Inventory verification
settings.pcbEmail.everyday=Everyday settings.pcbEmail.everyday=Everyday
settings.pcbEmail.reminder=Remind settings.pcbEmail.reminder=Remind
settings.pcbEmail.reminderDay=Before Due settings.pcbEmail.reminderDay=Before Due
......
...@@ -257,6 +257,7 @@ btn.test=\u6D4B\u8BD5 ...@@ -257,6 +257,7 @@ btn.test=\u6D4B\u8BD5
settings.api=API \u8BBE\u7F6E settings.api=API \u8BBE\u7F6E
settings.api.inNotifaction=\u5165\u5E93\u901A\u77E5 settings.api.inNotifaction=\u5165\u5E93\u901A\u77E5
settings.api.outNotifaction=\u51FA\u5E93\u901A\u77E5 settings.api.outNotifaction=\u51FA\u5E93\u901A\u77E5
settings.api.inCheck=\u5165\u5E93\u9A8C\u8BC1
settings.pcbEmail.everyday=\u6BCF\u65E5 settings.pcbEmail.everyday=\u6BCF\u65E5
settings.pcbEmail.reminder=\u63D0\u9192 settings.pcbEmail.reminder=\u63D0\u9192
settings.pcbEmail.reminderDay=\u5929\u524D\u63D0\u9192 settings.pcbEmail.reminderDay=\u5929\u524D\u63D0\u9192
......
...@@ -433,4 +433,6 @@ solder.status.3=Waiting to stir ...@@ -433,4 +433,6 @@ solder.status.3=Waiting to stir
solder.status.4=Strring solder.status.4=Strring
solder.status.5=Waiting shipment solder.status.5=Waiting shipment
solder.status.6=Outting solder.status.6=Outting
solder.status.7=Retreat storage
\ No newline at end of file \ No newline at end of file
solder.status.7=Retreat storage
smfcore.checkNg=checking material is ng:{0}
\ No newline at end of file \ No newline at end of file
...@@ -427,3 +427,5 @@ solder.status.7=Retreat storage ...@@ -427,3 +427,5 @@ solder.status.7=Retreat storage
op.6=Rewarm Taking op.6=Rewarm Taking
op.7=Rewarm Putting op.7=Rewarm Putting
op.8=Mix op.8=Mix
smfcore.checkNg=checking material is ng:{0}
\ No newline at end of file \ No newline at end of file
...@@ -423,4 +423,5 @@ solder.status.7=\u9000\u5E93\u5B58\u50A8 ...@@ -423,4 +423,5 @@ solder.status.7=\u9000\u5E93\u5B58\u50A8
op.6=\u56DE\u6E29\u53D6\u6599 op.6=\u56DE\u6E29\u53D6\u6599
op.7=\u56DE\u6E29\u653E\u6599 op.7=\u56DE\u6E29\u653E\u6599
op.8=\u6405\u62CC op.8=\u6405\u62CC
delete.confirm=\u786E\u5B9A\u8981\u5220\u9664\u5417?
\ No newline at end of file \ No newline at end of file
delete.confirm=\u786E\u5B9A\u8981\u5220\u9664\u5417?
smfcore.checkNg=\u9A8C\u8BC1\u5931\u8D25:{0}
\ No newline at end of file \ No newline at end of file
...@@ -200,6 +200,15 @@ ...@@ -200,6 +200,15 @@
<form:input path="orderFileDir" cssClass="form-control form-control input-xlarge"/> <form:input path="orderFileDir" cssClass="form-control form-control input-xlarge"/>
</div> </div>
</div> </div>
<div class="form-group form-inline">
<div class="input-group margin-top-10"><fmt:message key="settings.api.inCheck"/>:</div>
<div class="input-group margin-top-10">
<form:input path="inCheckApi" cssClass="form-control form-control input-xlarge"/>
</div>
</div>
</div> </div>
</div> </div>
<div class="form-actions"> <div class="form-actions">
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!