Commit d596dd3d sunke

解析条码时过滤唯一码重复的条码

PN导入功能
1 个父辈 22cb6d99
此文件类型无法预览
PN,W,H,QTY,SP,SPN
1267370610,13,8,50000,,
1267370613,13,8,50000,,
1275100970,15,56,150,,
......@@ -11,7 +11,7 @@ import java.util.*;
public class StorageConstants {
public final static String COMPONENT = "component";
public final static String COMPONENT_SEARCH_VIEW = "redirect:componentSearch.html";
public final static String COMPONENT_SEARCH_VIEW = "redirect:/component/componentSearch.html";
public final static String BARCODE_TYPE = "barcode";
public final static String BARCODE_SEARCH_VIEW = "redirect:/barcode/barcodeSearch.html";
public final static String STORAGE_TYPE = "storage";
......
......@@ -130,6 +130,25 @@ public class BaseFormController implements ServletContextAware {
return messages.getMessage(msgKey, args, locale);
}
public String getText(String msgKey, Locale locale,String defaultMsg) {
return getText(msgKey,null, locale,defaultMsg);
}
public String getText(String msgKey, String[] params, Locale locale, String defaultMsg) {
try{
if (params != null) {
return messages.getMessage(msgKey, params, locale);
} else {
return messages.getMessage(msgKey, locale);
}
}catch (Exception ex){
if(defaultMsg != null){
return defaultMsg;
}
return msgKey;
}
}
/**
* Convenience method to get the Configuration HashMap
* from the servlet context.
......
......@@ -146,7 +146,7 @@ public class FileUploadController extends BaseFormController {
log.info("Upload file type is: " + type);
try {
if (StorageConstants.COMPONENT.equals(type)) {
String message = handleComponent(fileURL);
String message = handleComponent(fileURL,request);
saveMessage(request,message);
} else if (StorageConstants.BARCODE_TYPE.equals(type)) {
......@@ -166,9 +166,9 @@ public class FileUploadController extends BaseFormController {
saveError(request, ve.getMessage());
} finally {
if (StorageConstants.COMPONENT.equals(type)) {
response.sendRedirect(request.getContextPath() + StorageConstants.COMPONENT_SEARCH_VIEW);
//return StorageConstants.COMPONENT_SEARCH_VIEW;
return null;
//response.sendRedirect(request.getContextPath() + StorageConstants.COMPONENT_SEARCH_VIEW);
return StorageConstants.COMPONENT_SEARCH_VIEW;
// return null;
} else if (StorageConstants.BARCODE_TYPE.equals(type)) {
return StorageConstants.BARCODE_SEARCH_VIEW;
} else if (StorageConstants.STORAGE_TYPE.equals(type)) {
......@@ -182,7 +182,7 @@ public class FileUploadController extends BaseFormController {
protected String handleComponent(String fileURL) throws ExcelParseException, IOException, ValidateException, IllegalAccessException, InvocationTargetException {
protected String handleComponent(String fileURL, HttpServletRequest request) throws ExcelParseException, IOException, ValidateException, IllegalAccessException, InvocationTargetException {
log.info("开始读取文件:" + fileURL);
CsvReader csvRead = new CsvReader(fileURL);
......@@ -192,30 +192,35 @@ public class FileUploadController extends BaseFormController {
int pnIndex = csvRead.getIndex("物编","PN");
if(pnIndex == -1){
log.info("未包含【物编】或【PN】列");
throw new ValidateException("必须包含【物编】或【PN】列");
String errorMsg = getText("error.file.culumn.required",new String[]{"PN"},request.getLocale(),"未包含【物编】或【PN】列");
throw new ValidateException(errorMsg);
}
int countIndex = csvRead.getIndex("数量","count");
if (countIndex == -1){
log.info("未包含【数量】或【count】列");
throw new ValidateException("必须包含【数量】或【count】列");
}
int wIndex = csvRead.getIndex("宽度","w");
int qtyIndex = csvRead.getIndex("数量","count","QTY");
// if (qtyIndex == -1){
// log.info("未包含【数量】或【count】列");
// throw new ValidateException("必须包含【数量】或【count】列");
// }
//
int wIndex = csvRead.getIndex("宽度","W");
if (wIndex == -1){
log.info("未包含【宽度】或【w】列");
throw new ValidateException("必须包含【宽度】或[w]列");
String errorMsg = getText("error.file.culumn.required",new String[]{"W"},request.getLocale(),"必须包含【宽度】或[W]列");
throw new ValidateException(errorMsg);
}
int hIndex = csvRead.getIndex("高度","h");
int hIndex = csvRead.getIndex("高度","H");
if (hIndex == -1){
log.info("未包含【高度】或【h】列");
throw new ValidateException("必须包含【高度】或[h]列");
String errorMsg = getText("error.file.culumn.required",new String[]{"H"},request.getLocale(),"必须包含【高度】或[H]列");
throw new ValidateException(errorMsg);
}
int supplierIndex = csvRead.getIndex("供应商","supplier");
if (supplierIndex == -1){
log.info("未包含【供应商】或【supplier】列");
throw new ValidateException("必须包含【供应商】或【supplier】列");
}
int supplierIndex = csvRead.getIndex("供应商","supplier","SP");
// if (supplierIndex == -1){
// log.info("未包含【供应商】或【supplier】列");
// throw new ValidateException("必须包含【供应商】或【supplier】列");
// }
int spnIndex = csvRead.getIndex("供应商PN","SPN");
// int typeIndex = csvRead.getIndex("类型","type");
// if (typeIndex == -1){
......@@ -227,21 +232,40 @@ public class FileUploadController extends BaseFormController {
while(csvRead.readRecord()){
String[] lineValues = csvRead.getValues();
String pn = lineValues[pnIndex];
String countStr = lineValues[countIndex];
String qtyStr = "1";
if(qtyIndex != -1){
qtyStr = lineValues[qtyIndex];
}
String spn = "";
if(spnIndex != -1){
spn = lineValues[spnIndex];
}
String wStr = lineValues[wIndex];
String hStr = lineValues[hIndex];
String supplier = lineValues[supplierIndex];
String supplier = "";
if(supplierIndex != -1){
supplier = lineValues[supplierIndex];
}
//String typeStr = lineValues[typeIndex];
if(pn.isEmpty() || countStr.isEmpty() || wStr.isEmpty() || hStr.isEmpty()){
log.warn("行[PN="+pn+"count="+countStr+"w="+wStr+" h="+hStr+"]中有空白内容,此行忽略");
if(pn.isEmpty() || wStr.isEmpty() || hStr.isEmpty()){
log.warn("行[PN="+pn+"w="+wStr+" h="+hStr+"]中有空白内容,此行忽略");
}else{
Component component = new Component();
component.setName(pn);
component.setPartNumber(pn);
component.setAmount(Integer.valueOf(countStr));
component.setAmount(Integer.valueOf(qtyStr));
component.setPlateSize(Integer.valueOf(wStr));
component.setHeight(Integer.valueOf(hStr));
component.setProvider(supplier);
component.setSupplierPn(spn);
//component.setType(Integer.valueOf(typeStr));
list.add(component);
}
......@@ -269,7 +293,10 @@ public class FileUploadController extends BaseFormController {
componentManager.save(component);
}
}
String msg = "读取到["+list.size()+"]个物料信息:新增【"+newRowCount+"】更新【" +updateRowCount +"】个";
String totalNumStr = String.valueOf(list.size());
String addNumStr = String.valueOf(newRowCount);
String updateNumStr = String.valueOf(updateRowCount);
String msg = getText("file.upload.result",new String[]{totalNumStr,addNumStr,updateNumStr},request.getLocale(),"读取到["+totalNumStr+"]个物料信息:新增【"+addNumStr+"】更新【" +updateNumStr +"】个");
log.info(msg);
return msg;
}
......
......@@ -408,7 +408,25 @@ public class DataCache{
if(codeBean == null){
continue;
}
codeBeans.add(codeBean);
boolean hasSameCode = false;
if(codeBean.isValid()){
//过滤唯一码重复的,防止即扫到二维码也扫到一维码会有多个条码的问题
for (CodeBean bean : codeBeans) {
if(bean.isValid()){
String reelId = codeBean.getBarcode().getBarcode();
if(reelId.equals(bean.getBarcode().getBarcode())){
hasSameCode = true;
log.info(reelId + "与已有效条码一样,忽略");
break;
}
}
}
}
if(!hasSameCode){
codeBeans.add(codeBean);
}
//统计非夹具的 partNubmer
// if(codeBean.isValid() && !codeBean.isFixtureCode()){
// String partNumber = codeBean.getBarcode().getPartNumber();
......@@ -460,7 +478,7 @@ public class DataCache{
}
if(barcode == null){
throw new ValidateException("error.barcode.invalid",new String[]{codeStr}, "无效的条码");
throw new ValidateException("error.barcode.noValidCode",new String[]{codeBeans.size()+"",codeStr}, "无效的条码");
}
return barcode;
}
......
......@@ -301,7 +301,7 @@ public class TaskService implements ITaskService {
serverExceptions.remove(storage.getCid());
} catch (ValidateException e) {
log.warn("入库到"+storage.getCid() + "失败:"+e.getMessage());
log.warn(statusBean.getCode() + "入库到"+storage.getCid() + "失败:"+e.getMessage());
statusBean.setMsg(e.getMessage());
serverExceptions.put(storage.getCid(),e);
} catch (Exception e) {
......@@ -335,7 +335,7 @@ public class TaskService implements ITaskService {
int codeSize = allBarcode.size();
if(codeSize == 0){
throw new ValidateException("error.barcode.invalid",new String[]{barcodeStr},barcodeStr + "不是有效的条码");
throw new ValidateException("error.barcode.noValidCode",new String[]{codeBeans.size()+"",barcodeStr},barcodeStr + "不是有效的条码");
}else if(codeSize > 1){
throw new ValidateException("error.barcode.many","找到多个有效条码,无法入库");
}
......@@ -499,6 +499,14 @@ public class TaskService implements ITaskService {
storagePos = storagePosManager.getEmptyPosByStorage(storage, barcode , operatingPosIds);
}else{
//throw new ValidateException(storage.getName() + "的 BOX-"+codeBoxId+" 不可用");
String statusStr = "";
for (BoxStatusBean boxStatusBean : statusBean.getBoxStatus().values()) {
//可正常使用,且未在出库执行中
int bid = boxStatusBean.getBoxId();
statusStr = statusStr + bid + "=" + boxStatusBean.getStatus();
}
log.info(barcode.getBarcode() + "入库失败,料仓不可用,当前状态:" + statusStr);
throw new ValidateException("error.storage.unavailable",new String[]{storageCid+"-"+codeBoxId},storage.getName() + "的 BOX-"+codeBoxId+" 不可用");
}
}else{
......
......@@ -421,7 +421,8 @@ error.pos.notExist=The location [{0}] in the storage is not exist.
error.pos.hasReel=There is already one reel in the location [{0}].
error.pos.wrong=The location [{0}] does not match the storage [{1}]
error.pos.sizeNotMatch=The size[{0}] is not matching the size [{2}]of the location {1}
error.barcode.invalid=The barcode [{0}] is invalid.
error.barcode.invalid=There is no valid barcode in the scaned code \: {0}
error.barcode.noValidCode=There is no valid barcode in the [{0}] scanned code \: {1}
error.barcode.expired=The reel is expired.
error.barcode.wrongQty=The quantity [{1}] of the reel[{0}] is invalid.
error.barcode.inStorage=The reel [{0}] is already in the location [{2}] of the stroage [1]
......@@ -437,6 +438,9 @@ msg.line.putIn=Put [{0}] into [{1}]
delete.confirm=Are you sure to delete?
barcode.error.used=Barcode is used.
error.file.culumn.required =The column {0} is required.
file.upload.result=Read [{0}] items\: add\u3010{1}\u3011items, update\u3010{2}\u3011items.
solderBox.btn.closeDoor=Close Door
solderBox.btn.openDoor=Open Door
solderBox.task.outTime=Estimated shipping time
......
......@@ -336,7 +336,7 @@ workOrder.supplementaryFinish=Replenishment finished
component.saveSuccess=Component saved
authority.bom.manage=BOM Management
order.inventory=Inventory
error.barcode.invalid=The barcode [{0}] is invalid.
error.barcode.invalid=There is no valid barcode in the scaned code \: {0}
user.search.subtitle=User Search
cabinet.error.noAuth=No authority, please contact the administrator
workOrder.date=Date
......@@ -420,3 +420,6 @@ storage.type.codeShelf=Code Shelf
storage.type.accShelf=Smart Shelf
storagePos.warmPos=Is Warm Location
order.error.executing=The task is executing.
error.barcode.noValidCode=There is no valid barcode in the [{0}] scanned code \: {1}
error.file.culumn.required=The column {0} is required.
file.upload.result=Read [{0}] items\: add\u3010{1}\u3011items, update\u3010{2}\u3011items.
......@@ -419,3 +419,6 @@ storage.type.codeShelf=Code Shelf
storage.type.accShelf=Smart Shelf
storagePos.warmPos=Is Warm Location
order.error.executing=The task is executing.
error.barcode.noValidCode={0} \u306F\u6709\u52B9\u306A\u30D0\u30FC\u30B3\u30FC\u30C9\u3067\u306F\u306A\u3044
error.file.culumn.required=\u6587\u4EF6\u672A\u5305\u542B{0}\u5217
file.upload.result=\u8BFB\u53D6\u5230[{0}]\u6761\u7269\u6599\u4FE1\u606F\:\u65B0\u589E\u3010{1}\u3011\u66F4\u65B0\u3010{2}\u3011
......@@ -338,7 +338,7 @@ workOrder.supplementaryFinish=\u8865\u6599\u5B8C\u6210
component.saveSuccess=\u6599\u4EF6\u4FDD\u5B58\u6210\u529F
order.inventory=\u5E93\u5B58
authority.bom.manage=BOM \u7BA1\u7406
error.barcode.invalid={0} \u4E0D\u662F\u6709\u6548\u7684\u6761\u7801
error.barcode.invalid=\u6761\u7801\u4E2D\u672A\u627E\u5230\u6709\u6548\u6761\u7801{0}
user.search.subtitle=\u67E5\u627E\u7528\u6237
workOrder.date=\u65E5\u671F
cabinet.error.noAuth=\u65E0\u6743\u64CD\u4F5C\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002
......@@ -420,3 +420,6 @@ storage.type.codeShelf=\u626B\u7801\u6599\u67B6
storage.type.accShelf=\u667A\u80FD\u6599\u67B6
storagePos.warmPos=\u662F\u5426\u662F\u56DE\u6E29\u5E93\u4F4D
order.error.executing=\u4EFB\u52A1\u6B63\u5728\u6267\u884C
error.barcode.noValidCode=\u626B\u5230\u7684{0}\u4E2A\u6761\u7801\u4E2D\u672A\u627E\u5230\u6709\u6548\u6761\u7801{1}
error.file.culumn.required=\u6587\u4EF6\u672A\u5305\u542B{0}\u5217
file.upload.result=\u8BFB\u53D6\u5230[{0}]\u6761\u7269\u6599\u4FE1\u606F\:\u65B0\u589E\u3010{1}\u3011\u66F4\u65B0\u3010{2}\u3011
......@@ -33,6 +33,12 @@
<fmt:message key="menu.product"/></small>
</h3>
<c:set var="fileType" value="<%=StorageConstants.COMPONENT%>"/>
<c:set var="fileParam" value="${storage.id}"/>
<%@ include file="/common/fileUpload.jsp" %>
<%@include file="/common/success.jsp" %>
<%@include file="/common/error.jsp" %>
<c:if test="${type != 1 && type !=2 && type !=4}">
......@@ -50,6 +56,9 @@
<div class="actions">
<a href="componentUpdate.html?type=${type}" class="btn btn-default btn-sm">
<i class="fa fa-plus"></i> <fmt:message key="button.add"/> </a>
<a class="btn btn-default btn-sm" data-toggle="modal" href="#basic"><i
class="fa fa-upload"></i><fmt:message
key="button.uploadFile"/></a>
</div>
</div>
<div class="portlet-body">
......@@ -360,4 +369,8 @@
<!-- END EXAMPLE TABLE PORTLET-->
</div>
</div>
</c:if>
\ No newline at end of file
</c:if>
<c:set var="fileParam" value="${type}"/>
<c:set var="fileType" value="<%=StorageConstants.COMPONENT%>"/>
<%@ include file="/common/fileUpload.jsp" %>
\ No newline at end of file
......@@ -1748,8 +1748,8 @@ Customized Bootstrap Close Icon
display: inline-block;
margin-top: 0px;
margin-right: 0px;
width: 9px;
height: 9px;
width: 29px;
height: 29px;
background-repeat: no-repeat !important;
text-indent: -10000px;
outline: none;
......
......@@ -17,23 +17,31 @@
<c:set var="fileParam" value="${fileUpload.param}"/>
</c:if>
<div class="modal-body">
<form method="post" action="${ctx}/storage/fileupload?type=${fileType}&param=${fileParam}"
enctype="multipart/form-data"
onsubmit="return validateFileUpload(this)" id="uploadForm" cssClass="well">
<%--<spring:bind path="fileUpload.name">--%>
<%--<spring:bind path="fileUpload.file">--%>
<div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
<%--</spring:bind>--%>
<label class="control-label col-md-2"><fmt:message key="uploadForm.file"/></label>
<input type="file" name="file" id="file" hidden/>
</div>
<%@include file="/common/success.jsp" %>
<%@include file="/common/error.jsp" %>
<form method="post" action="${ctx}/storage/fileupload"
enctype="multipart/form-data" id="uploadForm" cssClass="well">
<%--<spring:bind path="fileUpload.name">--%>
<%--<div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">--%>
<%--&lt;%&ndash;</spring:bind>&ndash;%&gt;--%>
<%--<appfuse:label key="uploadForm.name" styleClass="control-label"/>--%>
<%--<input cssClass="form-control" name="name" id="name" type="text"/>--%>
<%--</div>--%>
<%--<spring:bind path="fileUpload.file">--%>
<div class="form-group${(not empty status.errorMessage) ? ' has-error' : ''}">
<%--</spring:bind>--%>
<appfuse:label key="uploadForm.file" styleClass="control-label"/>
<input type="hidden" name="type" value="${fileType}"/>
<input type="hidden" name="param" value="${fileParam}"/>
<input type="file" name="file" id="file" hidden/>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="upload" class="btn btn-primary" onclick="bCancel=false">
<i class="icon-upload icon-white"></i> <fmt:message key="button.upload"/>
</button>
<%--<button type="submit" name="cancel" class="btn btn-default" onclick="bCancel=true">--%>
<%--<i class="icon-remove"></i> <fmt:message key="button.cancel"/>--%>
<%--<i class="icon-remove"></i> <fmt:message key="button.cancel"/>--%>
<%--</button>--%>
</div>
</form>
......
......@@ -40,7 +40,7 @@
<!-- END PAGE STYLES -->
<!-- BEGIN THEME STYLES -->
<!-- DOC: To use 'rounded corners' style just load 'components-rounded.css' stylesheet instead of 'components.css' in the below style tag -->
<link href="${ctx}/assets/global/css/components.css?id=3" id="style_components" rel="stylesheet" type="text/css"/>
<link href="${ctx}/assets/global/css/components.css?id=6" id="style_components" rel="stylesheet" type="text/css"/>
<link href="${ctx}/assets/global/css/plugins.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/assets/admin/layout/css/layout.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/assets/admin/layout/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!