Commit cb301f9f LN

PN出库模糊查询修改

1 个父辈 85c2416e
...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists; ...@@ -6,6 +6,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.Constants; import com.neotel.smfcore.common.utils.Constants;
import com.neotel.smfcore.common.utils.QueryHelp;
import com.neotel.smfcore.common.utils.StringUtils; import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.common.utils.YmlUpdateUtil; import com.neotel.smfcore.common.utils.YmlUpdateUtil;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
...@@ -34,6 +35,8 @@ import org.springframework.stereotype.Repository; ...@@ -34,6 +35,8 @@ import org.springframework.stereotype.Repository;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* 缓存 * 缓存
...@@ -399,16 +402,57 @@ public class DataCache { ...@@ -399,16 +402,57 @@ public class DataCache {
/** /**
* 获取库存信息,key 为 PN * 获取库存信息,key 为 PN
*/ */
public Map<String,InventoryItem> getAllInventory(List<String> storageIds){ public Map<String,InventoryItem> getAllInventory(List<String> storageIds,String blurry) {
Map<String, Storage> allStorages = getAllStorage(); Map<String, Storage> allStorages = getAllStorage();
List<Storage> storages=Lists.newArrayList(); List<Storage> storages = Lists.newArrayList();
for (Storage storage : for (Storage storage :
allStorages.values()) { allStorages.values()) {
if(storageIds==null|| storageIds.contains(storage.getId())){ if (storageIds == null || storageIds.contains(storage.getId())) {
storages.add(storage); storages.add(storage);
} }
} }
return getInventory(storages); Map<String, InventoryItem> map = getInventory(storages);
if(ObjectUtil.isEmpty(blurry)){
return map;
}
Map<String, InventoryItem> resultMap = new HashMap<>();
for (InventoryItem item :
map.values()) {
boolean blurryOk = false;
if (ObjectUtil.isNotEmpty(blurry)) {
String[] blurrys = blurry.split(",");
String[] valueArray = new String[]{item.getPartNumber(),item.getStorageName()};
for (String s : blurrys) {
if (ObjectUtil.isNotEmpty(s)) {
for (String v :
valueArray) {
try {
Pattern pattern = Pattern.compile(QueryHelp.escapeExprSpecialWord(s), Pattern.CASE_INSENSITIVE);
Matcher m = pattern.matcher(v);
while (m.find()) {
blurryOk = true;
break;
}
if (blurryOk) break;
} catch (Exception ex) {
log.error(ex.toString());
}
}
if (blurryOk) break;
} else {
blurryOk = true;
}
}
} else {
blurryOk = true;
}
if (blurryOk) {
resultMap.put(item.getPartNumber(), item);
}
}
return resultMap;
} }
/** /**
......
...@@ -79,7 +79,7 @@ public class MaterialController { ...@@ -79,7 +79,7 @@ public class MaterialController {
@PreAuthorize("@el.check('tacticsOuput')") @PreAuthorize("@el.check('tacticsOuput')")
public void inventoryDownload(HttpServletResponse response, InventoryQueryCriteria criteria,Locale locale)throws IOException { public void inventoryDownload(HttpServletResponse response, InventoryQueryCriteria criteria,Locale locale)throws IOException {
Map<String, InventoryItem> inventoryItemMap = dataCache.getAllInventory(criteria.getStorageIdList()); Map<String, InventoryItem> inventoryItemMap = dataCache.getAllInventory(criteria.getStorageIdList(),criteria.getBlurry());
List<InventoryItem> list = Lists.newArrayList(inventoryItemMap.values()); List<InventoryItem> list = Lists.newArrayList(inventoryItemMap.values());
String partNumberStr= MessageUtils.getText("smfcore.inventory.partNumber",locale,"物料编号"); String partNumberStr= MessageUtils.getText("smfcore.inventory.partNumber",locale,"物料编号");
...@@ -107,7 +107,7 @@ public class MaterialController { ...@@ -107,7 +107,7 @@ public class MaterialController {
@PreAuthorize("@el.check('tacticsOuput')") @PreAuthorize("@el.check('tacticsOuput')")
public ResponseEntity<List<InventoryItemDto>> inventory(InventoryQueryCriteria criteria) { public ResponseEntity<List<InventoryItemDto>> inventory(InventoryQueryCriteria criteria) {
Map<String, InventoryItem> inventoryItemMap = dataCache.getAllInventory(criteria.getStorageIdList()); Map<String, InventoryItem> inventoryItemMap = dataCache.getAllInventory(criteria.getStorageIdList(),criteria.getBlurry());
List<InventoryItem> list = Lists.newArrayList(inventoryItemMap.values()); List<InventoryItem> list = Lists.newArrayList(inventoryItemMap.values());
return new ResponseEntity<>(inventoryItemMapper.toDto(list), HttpStatus.OK); return new ResponseEntity<>(inventoryItemMapper.toDto(list), HttpStatus.OK);
......
...@@ -8,6 +8,8 @@ import java.util.List; ...@@ -8,6 +8,8 @@ import java.util.List;
@Data @Data
public class InventoryQueryCriteria { public class InventoryQueryCriteria {
private String blurry;
@QueryCondition(isDBId =true) @QueryCondition(isDBId =true)
private String storageId; private String storageId;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!