Commit 03c2eac8 LN

出库单,入库单,退库单增加分页查询接口

1 个父辈 6d6187b8
...@@ -470,6 +470,9 @@ public class DataCache { ...@@ -470,6 +470,9 @@ public class DataCache {
Map<String, InventoryItem> resultMap = new HashMap<>(); Map<String, InventoryItem> resultMap = new HashMap<>();
for (InventoryItem item : map.values()) { for (InventoryItem item : map.values()) {
boolean add=true; boolean add=true;
if(ObjectUtil.isEmpty(item.getPartNumber())){
continue;
}
if (ObjectUtil.isNotEmpty(blurry)) { if (ObjectUtil.isNotEmpty(blurry)) {
if (item.getPartNumber().contains(blurry)||item.getWareHouseCode().contains(blurry)||item.getPartname().contains(blurry)) { if (item.getPartNumber().contains(blurry)||item.getWareHouseCode().contains(blurry)||item.getPartname().contains(blurry)) {
...@@ -478,13 +481,13 @@ public class DataCache { ...@@ -478,13 +481,13 @@ public class DataCache {
} }
} }
if(ObjectUtil.isNotEmpty(pn)){ if(ObjectUtil.isNotEmpty(pn)&&ObjectUtil.isNotEmpty(item.getPartNumber())){
if(!item.getPartNumber().contains(pn)){ if(!item.getPartNumber().contains(pn)){
add=false; add=false;
} }
} }
if(ObjectUtil.isNotEmpty(wCode)){ if(ObjectUtil.isNotEmpty(wCode)&&ObjectUtil.isNotEmpty(item.getWareHouseCode())){
if(!item.getWareHouseCode().contains(wCode)){ if(!item.getWareHouseCode().contains(wCode)){
add=false; add=false;
} }
......
package com.neotel.smfcore.custom.luxsan_sp.bean.query;
import com.neotel.smfcore.common.annotation.QueryCondition;
import com.neotel.smfcore.common.bean.BetweenData;
import lombok.Data;
import java.util.Date;
@Data
public class ListQueryCondition {
@QueryCondition(blurry = "orderNo,no")
private String blurry;
@QueryCondition(type = QueryCondition.Type.BETWEEN)
private BetweenData<Date> createDate;
//状态,0=所有,1=已关闭,2=未关闭
private Integer status;
}
...@@ -23,25 +23,14 @@ import com.neotel.smfcore.core.storage.service.po.Storage; ...@@ -23,25 +23,14 @@ import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
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.api.LuxsanSpApi;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.SpareInHourseRequest;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.SpareInHourseDetail;
import com.neotel.smfcore.custom.luxsan_sp.bean.*; import com.neotel.smfcore.custom.luxsan_sp.bean.*;
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.service.manager.IUnclaimedManager;
import com.neotel.smfcore.custom.luxsan_sp.util.CodeUtil; import com.neotel.smfcore.custom.luxsan_sp.util.CodeUtil;
import com.neotel.smfcore.custom.luxsan_sp.util.OrderNoCache; import com.neotel.smfcore.custom.luxsan_sp.util.OrderNoCache;
import com.neotel.smfcore.custom.luxsan_sp.util.SpBoxUtil; import com.neotel.smfcore.custom.luxsan_sp.util.SpBoxUtil;
import com.neotel.smfcore.custom.luxsan_sp.util.SpareNoCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
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;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
......
package com.neotel.smfcore.custom.luxsan_sp.controller; package com.neotel.smfcore.custom.luxsan_sp.controller;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
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.custom.luxsan_sp.api.LuxsanSpApi; import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetReturnInventoryRequest; import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetReturnInventoryRequest;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetReturnInventoryResult; import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetReturnInventoryResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo; import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.query.ListQueryCondition;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus; import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager; import com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager;
import com.neotel.smfcore.custom.luxsan_sp.util.ReturnNoCache; import com.neotel.smfcore.custom.luxsan_sp.util.ReturnNoCache;
...@@ -15,6 +19,9 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess; ...@@ -15,6 +19,9 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -69,6 +76,39 @@ public class SpReturnInventoryController { ...@@ -69,6 +76,39 @@ public class SpReturnInventoryController {
} }
@ApiOperation("获取退库单列表")
@RequestMapping("/getList")
@AnonymousAccess
public PageData<ReturnInventoryNo> getList(ListQueryCondition criteria, Pageable pageable) {
returnNoCache.LoadFromAPI();
Query query = QueryHelp.getQuery(criteria);
if (criteria.getStatus() != null) {
if (criteria.getStatus() == 1) {
//已关闭 状态=3 或者状态=2已确认
Criteria c = new Criteria();
c.orOperator(
Criteria.where("status").is("3"),
Criteria.where("status").is("2").and("isConfirmed").is(true)
);
query.addCriteria(c);
} else if (criteria.getStatus() == 2) {
//未关闭 状态=0,1,或者状态=2未确认
Criteria c = new Criteria();
c.orOperator(
Criteria.where("status").is("0"),
Criteria.where("status").is("1"),
Criteria.where("status").is("2").and("isConfirmed").is(false)
);
query.addCriteria(c);
}
}
PageData<ReturnInventoryNo> resultList = returnNoManager.findByPage(query, pageable);
return resultList;
}
@ApiOperation("选中退库单") @ApiOperation("选中退库单")
@RequestMapping("/checkReturnNo") @RequestMapping("/checkReturnNo")
@AnonymousAccess @AnonymousAccess
......
package com.neotel.smfcore.custom.luxsan_sp.controller; package com.neotel.smfcore.custom.luxsan_sp.controller;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
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.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
...@@ -14,6 +16,7 @@ import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult; ...@@ -14,6 +16,7 @@ import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoResult;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.SpareInHourseDetail; import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.SpareInHourseDetail;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo; 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.bean.SpareNoDetail;
import com.neotel.smfcore.custom.luxsan_sp.bean.query.ListQueryCondition;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus; 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.service.manager.ISpareNoManager;
import com.neotel.smfcore.custom.luxsan_sp.util.ReturnNoCache; import com.neotel.smfcore.custom.luxsan_sp.util.ReturnNoCache;
...@@ -22,10 +25,14 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess; ...@@ -22,10 +25,14 @@ import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -61,7 +68,6 @@ public class SpSpareNoController { ...@@ -61,7 +68,6 @@ public class SpSpareNoController {
return ResultBean.newOkResult(results); return ResultBean.newOkResult(results);
} }
@ApiOperation("获取入库单") @ApiOperation("获取入库单")
@RequestMapping("/getAllSpareNo") @RequestMapping("/getAllSpareNo")
@AnonymousAccess @AnonymousAccess
...@@ -89,6 +95,40 @@ public class SpSpareNoController { ...@@ -89,6 +95,40 @@ public class SpSpareNoController {
} }
@ApiOperation("获取入库单列表")
@RequestMapping("/getList")
@AnonymousAccess
public PageData<SpareNo> getList(ListQueryCondition criteria, Pageable pageable) {
spareNoCache.LoadFromAPI();
Query query = QueryHelp.getQuery(criteria);
if (criteria.getStatus() != null) {
if (criteria.getStatus() == 1) {
//已关闭 状态=3 或者状态=2已确认
Criteria c = new Criteria();
c.orOperator(
Criteria.where("status").is("3"),
Criteria.where("status").is("2").and("isConfirmed").is(true)
);
// query.addCriteria(Criteria.where("status").is("3").orOperator(Criteria.where("status").is("2").and("isConfirmed").is(true)));
query.addCriteria(c);
} else if (criteria.getStatus() == 2) {
//未关闭 状态=0,1,或者状态=2未确认
Criteria c = new Criteria();
c.orOperator(
Criteria.where("status").is("0"),
Criteria.where("status").is("1"),
Criteria.where("status").is("2").and("isConfirmed").is(false)
);
query.addCriteria(c);
}
}
PageData<SpareNo> resultList = spareNoManager.findByPage(query, pageable);
return resultList;
}
@ApiOperation("选中入库单") @ApiOperation("选中入库单")
@RequestMapping("/checkSpareNo") @RequestMapping("/checkSpareNo")
@AnonymousAccess @AnonymousAccess
......
package com.neotel.smfcore.custom.luxsan_sp.controller; package com.neotel.smfcore.custom.luxsan_sp.controller;
import com.neotel.smfcore.common.base.BasePo; import com.neotel.smfcore.common.base.BasePo;
import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
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.core.barcode.service.manager.IBarcodeManager; import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
...@@ -16,15 +18,19 @@ import com.neotel.smfcore.core.system.util.TaskService; ...@@ -16,15 +18,19 @@ import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi; import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetUnclaimedRequest; import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetUnclaimedRequest;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetUnclaimedResult; import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetUnclaimedResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed; import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed;
import com.neotel.smfcore.custom.luxsan_sp.bean.UnclaimedDetail; import com.neotel.smfcore.custom.luxsan_sp.bean.UnclaimedDetail;
import com.neotel.smfcore.custom.luxsan_sp.bean.query.ListQueryCondition;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus; import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IUnclaimedManager;
import com.neotel.smfcore.custom.luxsan_sp.util.OrderNoCache; import com.neotel.smfcore.custom.luxsan_sp.util.OrderNoCache;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -39,20 +45,20 @@ import java.util.stream.Collectors; ...@@ -39,20 +45,20 @@ import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/unclaimed") @RequestMapping("/unclaimed")
public class SpUnclaimedController { public class SpUnclaimedController {
@Autowired // @Autowired
private CodeResolve codeResolve; // private CodeResolve codeResolve;
//
@Autowired // @Autowired
private IStoragePosManager storagePosManager; // private IStoragePosManager storagePosManager;
//
@Autowired // @Autowired
private IBarcodeManager barcodeManager; // private IBarcodeManager barcodeManager;
@Autowired @Autowired
private OrderNoCache orderNoCache; private OrderNoCache orderNoCache;
@Autowired // @Autowired
private IUnclaimedManager unclaimedManager; // private IUnclaimedManager unclaimedManager;
@Autowired @Autowired
private ILiteOrderManager liteOrderManager; private ILiteOrderManager liteOrderManager;
...@@ -70,7 +76,14 @@ public class SpUnclaimedController { ...@@ -70,7 +76,14 @@ public class SpUnclaimedController {
@AnonymousAccess @AnonymousAccess
public ResultBean getActiveOrderNo() { public ResultBean getActiveOrderNo() {
List<Unclaimed> results = new ArrayList<>(); List<Unclaimed> results = new ArrayList<>();
results.add(orderNoCache.getExecutingOrderNo()); LiteOrder order= liteOrderCache.getExecutingOrder();
Unclaimed u=null;
if(order==null){
u=null;
}else{
u=OrderToUnclaimed(order);
}
results.add(u);
return ResultBean.newOkResult(results); return ResultBean.newOkResult(results);
} }
...@@ -146,6 +159,48 @@ public class SpUnclaimedController { ...@@ -146,6 +159,48 @@ public class SpUnclaimedController {
return ResultBean.newOkResult(resultLiteOrder); return ResultBean.newOkResult(resultLiteOrder);
} }
@ApiOperation("获取入库单列表")
@RequestMapping("/getList")
@AnonymousAccess
public PageData<Unclaimed> getList(ListQueryCondition criteria, Pageable pageable) {
orderNoCache.LoadFromAPI();
Query query = QueryHelp.getQuery(criteria);
if (criteria.getStatus() != null) {
if (criteria.getStatus() == 1) {
//已关闭 状态=3 或者状态=2已确认
Criteria c = new Criteria();
c.orOperator(
Criteria.where("status").is("3"),
Criteria.where("status").is("2").and("isConfirmed").is(true)
);
// query.addCriteria(Criteria.where("status").is("3").orOperator(Criteria.where("status").is("2").and("isConfirmed").is(true)));
query.addCriteria(c);
} else if (criteria.getStatus() == 2) {
//未关闭 状态=0,1,或者状态=2未确认
Criteria c = new Criteria();
c.orOperator(
Criteria.where("status").is("0"),
Criteria.where("status").is("1"),
Criteria.where("status").is("2").and("isConfirmed").is(false)
);
query.addCriteria(c);
}
}
PageData<LiteOrder> resultList = liteOrderManager.findByPage(query, pageable);
PageData<Unclaimed> data = new PageData<Unclaimed>();
data.setTotalElements(resultList.getTotalElements());
List<Unclaimed> list = new ArrayList<>();
for (LiteOrder order : resultList.getContent()
) {
list.add(OrderToUnclaimed(order));
}
data.setContent(list);
return data;
}
private Unclaimed OrderToUnclaimed(LiteOrder liteOrder){ private Unclaimed OrderToUnclaimed(LiteOrder liteOrder){
Unclaimed unclaimed = new Unclaimed(); Unclaimed unclaimed = new Unclaimed();
......
...@@ -5,9 +5,9 @@ import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed; ...@@ -5,9 +5,9 @@ import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed;
import java.util.List; import java.util.List;
public interface IUnclaimedManager extends IBaseManager<Unclaimed> { //public interface IUnclaimedManager extends IBaseManager<Unclaimed> {
Unclaimed getByOrderNo(String OrderNo); // Unclaimed getByOrderNo(String OrderNo);
//
List<Unclaimed> findAll(); // List<Unclaimed> findAll();
//
} //}
...@@ -3,11 +3,8 @@ package com.neotel.smfcore.custom.luxsan_sp.service.manager.impl; ...@@ -3,11 +3,8 @@ package com.neotel.smfcore.custom.luxsan_sp.service.manager.impl;
import com.neotel.smfcore.common.bean.PageData; import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException; import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo; import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed;
import com.neotel.smfcore.custom.luxsan_sp.service.dao.ReturnDao; import com.neotel.smfcore.custom.luxsan_sp.service.dao.ReturnDao;
import com.neotel.smfcore.custom.luxsan_sp.service.dao.UnclaimedDao;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager; import com.neotel.smfcore.custom.luxsan_sp.service.manager.IReturnNoManager;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IUnclaimedManager;
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.data.domain.Pageable; import org.springframework.data.domain.Pageable;
......
package com.neotel.smfcore.custom.luxsan_sp.service.manager.impl; //package com.neotel.smfcore.custom.luxsan_sp.service.manager.impl;
//
import com.neotel.smfcore.common.bean.PageData; //import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.exception.ValidateException; //import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed; //import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed;
import com.neotel.smfcore.custom.luxsan_sp.service.dao.UnclaimedDao; //import com.neotel.smfcore.custom.luxsan_sp.service.dao.UnclaimedDao;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IUnclaimedManager; //import com.neotel.smfcore.custom.luxsan_sp.service.manager.IUnclaimedManager;
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.data.domain.Pageable; //import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria; //import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; //import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; //import org.springframework.stereotype.Service;
//
import java.util.Collections; //import java.util.Collections;
import java.util.List; //import java.util.List;
@Slf4j //@Slf4j
@Service //@Service
public class UnclaimedManagerImpl implements IUnclaimedManager { //public class UnclaimedManagerImpl implements IUnclaimedManager {
@Autowired // @Autowired
private UnclaimedDao unclaimedDao; // private UnclaimedDao unclaimedDao;
//
@Override // @Override
public Unclaimed get(String id) { // public Unclaimed get(String id) {
return null; // return null;
} // }
//
@Override // @Override
public Unclaimed save(Unclaimed object) throws ValidateException { // public Unclaimed save(Unclaimed object) throws ValidateException {
return unclaimedDao.save(object); // return unclaimedDao.save(object);
} // }
//
@Override // @Override
public void delete(Unclaimed object) throws ValidateException { // public void delete(Unclaimed object) throws ValidateException {
//
} // }
//
@Override // @Override
public PageData<Unclaimed> findByPage(Query query, Pageable pageable) { // public PageData<Unclaimed> findByPage(Query query, Pageable pageable) {
return null; // return null;
} // }
//
@Override // @Override
public List<Unclaimed> findByQuery(Query query) { // public List<Unclaimed> findByQuery(Query query) {
return Collections.emptyList(); // return Collections.emptyList();
} // }
//
@Override // @Override
public Unclaimed getByOrderNo(String orderNo) { // public Unclaimed getByOrderNo(String orderNo) {
return unclaimedDao.findOne(new Query(Criteria.where("orderNo").is(orderNo))); // return unclaimedDao.findOne(new Query(Criteria.where("orderNo").is(orderNo)));
} // }
//
@Override // @Override
public List<Unclaimed> findAll() { // public List<Unclaimed> findAll() {
return unclaimedDao.findAll(); // return unclaimedDao.findAll();
} // }
} //}
package com.neotel.smfcore.custom.luxsan_sp.util; package com.neotel.smfcore.custom.luxsan_sp.util;
import com.neotel.smfcore.core.order.service.manager.ILiteOrderManager;
import com.neotel.smfcore.core.order.service.po.LiteOrder;
import com.neotel.smfcore.core.order.service.po.LiteOrderItem;
import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetUnclaimedRequest;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetUnclaimedResult; import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetUnclaimedResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed; import com.neotel.smfcore.custom.luxsan_sp.bean.Unclaimed;
import com.neotel.smfcore.custom.luxsan_sp.bean.UnclaimedDetail; import com.neotel.smfcore.custom.luxsan_sp.bean.UnclaimedDetail;
import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus; import com.neotel.smfcore.custom.luxsan_sp.enums.SpareNostatus;
import com.neotel.smfcore.custom.luxsan_sp.service.manager.IUnclaimedManager; import lombok.extern.slf4j.Slf4j;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap; import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.Collectors;
@Service @Service
@Slf4j
public class OrderNoCache { public class OrderNoCache {
public OrderNoCache(ApplicationContext applicationContext) { // public OrderNoCache(ApplicationContext applicationContext) {
IUnclaimedManager unclaimedManager = applicationContext.getBean(IUnclaimedManager.class); // IUnclaimedManager unclaimedManager = applicationContext.getBean(IUnclaimedManager.class);
// 刷新缓存 // // 刷新缓存
unclaimedManager.findAll().forEach( // unclaimedManager.findAll().forEach(
unclaimed -> cacheMap.put(unclaimed.getOrderNo(), unclaimed)); // unclaimed -> cacheMap.put(unclaimed.getOrderNo(), unclaimed));
} // }
@Autowired // @Autowired
private IUnclaimedManager unclaimedManager; // private IUnclaimedManager unclaimedManager;
Map<String, Unclaimed> cacheMap = new ConcurrentHashMap<>(); Map<String, Unclaimed> cacheMap = new ConcurrentHashMap<>();
public void addToMap(Unclaimed unclaimed){ private Long lasLoadTime=0L;
cacheMap.put(unclaimed.getOrderNo(),unclaimed);
}
private boolean NeedReLoad(){
public Unclaimed getByOrderNo(String orderNo) { //1分钟加载一次?
Unclaimed unclaimed = cacheMap.get(orderNo); long timeSpan=(new Date().getTime())-lasLoadTime;
if (unclaimed == null){ if(timeSpan<1*60*1000){
unclaimed = unclaimedManager.getByOrderNo(orderNo); return false;
if (unclaimed != null){
cacheMap.put(unclaimed.getOrderNo(), unclaimed);
}
} }
return unclaimed; return true;
} }
@Autowired
private ILiteOrderManager liteOrderManager;
public String getExecutingOrderNoStr(){ public void LoadFromAPI() {
for (String orderNo : cacheMap.keySet()) { if (!NeedReLoad()) {
Unclaimed unclaimed = cacheMap.get(orderNo); return;
if (unclaimed.getUnclaimedStatus() == SpareNostatus.EXECUTING_STATUS){
return orderNo;
} }
lasLoadTime = new Date().getTime();
List<GetUnclaimedResult> resultList = LuxsanSpApi.getUnclaimedDetails(new GetUnclaimedRequest(SpareNostatus.FORMAL_DEPT_ID, SpareNostatus.FUNCTION_DEPT));
List<String> newNos = resultList.stream().map(GetUnclaimedResult::getOrderNo).collect(Collectors.toList());
Criteria criteria = Criteria.where("orderNo").in(newNos.toArray());
List<LiteOrder> existList = liteOrderManager.findByQuery(new Query(criteria));
for (GetUnclaimedResult unclaimed : resultList) {
List<LiteOrder> hasList = existList.stream()
.filter(order -> unclaimed.getOrderNo().equals(order.getOrderNo()))
.collect(Collectors.toList());
if (hasList.size() <= 0) {
// Unclaimed unclaimed = orderNoCache.getOrderNoResultToUnclaimed(unclaimedResult);
// orderNoCache.addToMap(unclaimed);
LiteOrder liteOrder = new LiteOrder();
liteOrder.setOrderNo(unclaimed.getOrderNo());
liteOrder.setCreateDate(unclaimed.getCreateTime());
liteOrder.setSource(unclaimed.getFunctionDept());
List<LiteOrderItem> liteOrderItems = new ArrayList<>();
for (UnclaimedDetail unclaimedDetail : unclaimed.getSpareApplyDetail()) {
LiteOrderItem liteOrderItem = new LiteOrderItem();
liteOrderItem.setLine("s1");
liteOrderItem.setPn(unclaimedDetail.getPartno());
liteOrderItem.setNeedNum(unclaimedDetail.getApplyQty());
liteOrderItem.setPartname(unclaimedDetail.getPartname());
liteOrderItems.add(liteOrderItem);
} }
return null; log.info("创建出库单:" + liteOrder.getOrderNo());
liteOrder.setOrderItems(liteOrderItems);
liteOrderManager.createWithItems(liteOrder);
// resultLiteOrder.add(unclaimed);
} }
public Unclaimed getExecutingOrderNo(){
for (String orderNo : cacheMap.keySet()) {
Unclaimed unclaimed = cacheMap.get(orderNo);
if (Integer.parseInt(unclaimed.getStatus()) == SpareNostatus.EXECUTING_STATUS){
return unclaimed;
} }
} }
return null;
public void addToMap(Unclaimed unclaimed){
cacheMap.put(unclaimed.getOrderNo(),unclaimed);
} }
// public Unclaimed getByOrderNo(String orderNo) {
// Unclaimed unclaimed = cacheMap.get(orderNo);
// if (unclaimed == null){
// unclaimed = unclaimedManager.getByOrderNo(orderNo);
// if (unclaimed != null){
// cacheMap.put(unclaimed.getOrderNo(), unclaimed);
// }
// }
// return unclaimed;
// }
//
//
// public String getExecutingOrderNoStr(){
// for (String orderNo : cacheMap.keySet()) {
// Unclaimed unclaimed = cacheMap.get(orderNo);
// if (unclaimed.getUnclaimedStatus() == SpareNostatus.EXECUTING_STATUS){
// return orderNo;
// }
// }
// return null;
// }
// public Unclaimed getExecutingOrderNo(){
// for (String orderNo : cacheMap.keySet()) {
// Unclaimed unclaimed = cacheMap.get(orderNo);
// if (Integer.parseInt(unclaimed.getStatus()) == SpareNostatus.EXECUTING_STATUS){
// return unclaimed;
// }
// }
// return null;
// }
public Unclaimed getOrderNoResultToUnclaimed(GetUnclaimedResult result) { public Unclaimed getOrderNoResultToUnclaimed(GetUnclaimedResult result) {
Unclaimed unclaimed = new Unclaimed(); Unclaimed unclaimed = new Unclaimed();
...@@ -92,8 +155,8 @@ public class OrderNoCache { ...@@ -92,8 +155,8 @@ public class OrderNoCache {
return unclaimed; return unclaimed;
} }
public void updateCacheAndDB(String orderNo, Unclaimed unclaimed) { // public void updateCacheAndDB(String orderNo, Unclaimed unclaimed) {
cacheMap.put(orderNo, unclaimed); // cacheMap.put(orderNo, unclaimed);
unclaimedManager.save(unclaimed); // unclaimedManager.save(unclaimed);
} // }
} }
package com.neotel.smfcore.custom.luxsan_sp.util; package com.neotel.smfcore.custom.luxsan_sp.util;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.neotel.smfcore.common.utils.SecurityUtils; import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi;
import com.neotel.smfcore.core.barcode.enums.BARCODE_STATUS; import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.GetReturnInventoryRequest;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
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.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetReturnInventoryResult; import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetReturnInventoryResult;
import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo; import com.neotel.smfcore.custom.luxsan_sp.bean.ReturnInventoryNo;
import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail; import com.neotel.smfcore.custom.luxsan_sp.bean.SpareNoDetail;
...@@ -23,9 +13,12 @@ import org.ehcache.impl.internal.concurrent.ConcurrentHashMap; ...@@ -23,9 +13,12 @@ import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
...@@ -43,6 +36,40 @@ public class ReturnNoCache { ...@@ -43,6 +36,40 @@ public class ReturnNoCache {
Map<String, ReturnInventoryNo> cacheMap = new ConcurrentHashMap<>(); Map<String, ReturnInventoryNo> cacheMap = new ConcurrentHashMap<>();
private Long lasLoadTime=0L;
private boolean NeedReLoad(){
//三分钟加载一次?
long timeSpan=(new Date().getTime())-lasLoadTime;
if(timeSpan<1*60*1000){
return false;
}
return true;
}
public void LoadFromAPI(){
if(!NeedReLoad()){
return;
}
List<GetReturnInventoryResult> resultList = LuxsanSpApi.getReturnInventory(new GetReturnInventoryRequest(SpareNostatus.FUNCTION_DEPT, SpareNostatus.FORMAL_DEPT_ID));
lasLoadTime=new Date().getTime();
List<String> newSpNo=resultList.stream().map(GetReturnInventoryResult::getOrderNo).collect(Collectors.toList());
Criteria criteria=Criteria.where("spareNo").in(newSpNo.toArray());
List<ReturnInventoryNo> existList = returnNoManager.findByQuery(new Query(criteria));
for (GetReturnInventoryResult returnObj : resultList) {
List<ReturnInventoryNo> hasList= existList.stream()
.filter(obj -> returnObj.getOrderNo().equals(obj.getNo()))
.collect(Collectors.toList());
if(hasList.size()<=0){
ReturnInventoryNo newObj = getOrderNoResultToReturnInventoryNo(returnObj);
newObj= returnNoManager.save(newObj);
log.info("创建退库单:"+newObj.getOrderNo()+" ,"+newObj.getPartno());
addToMap(newObj);
}
}
}
public void addToMap(ReturnInventoryNo returnInventoryNo) { public void addToMap(ReturnInventoryNo returnInventoryNo) {
cacheMap.put(returnInventoryNo.getOrderNo(), returnInventoryNo); cacheMap.put(returnInventoryNo.getOrderNo(), returnInventoryNo);
} }
......
...@@ -14,6 +14,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos; ...@@ -14,6 +14,7 @@ import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.custom.luxsan_sp.api.LuxsanSpApi; 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.request.SpareInHourseRequest; import com.neotel.smfcore.custom.luxsan_sp.api.bean.request.SpareInHourseRequest;
import com.neotel.smfcore.custom.luxsan_sp.api.bean.result.GetSpareNoDetail; 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.api.bean.result.GetSpareNoResult;
...@@ -29,9 +30,12 @@ import lombok.extern.slf4j.Slf4j; ...@@ -29,9 +30,12 @@ import lombok.extern.slf4j.Slf4j;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap; import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
...@@ -44,6 +48,41 @@ public class SpareNoCache { ...@@ -44,6 +48,41 @@ public class SpareNoCache {
spareNo -> cacheMap.put(spareNo.getSpareNo(), spareNo)); spareNo -> cacheMap.put(spareNo.getSpareNo(), spareNo));
} }
private Long lasLoadTime=0L;
private boolean NeedReLoad(){
//三分钟加载一次?
long timeSpan=(new Date().getTime())-lasLoadTime;
if(timeSpan<1*60*1000){
return false;
}
return true;
}
public void LoadFromAPI(){
if(!NeedReLoad()){
return;
}
List<GetSpareNoResult> resultList = LuxsanSpApi.getSpareNo(new GetSpareNoRequest(SpareNostatus.FORMAL_DEPT_ID, SpareNostatus.FUNCTION_DEPT));
lasLoadTime=new Date().getTime();
List<String> newSpNo=resultList.stream().map(GetSpareNoResult::getSpareNo).collect(Collectors.toList());
Criteria criteria=Criteria.where("spareNo").in(newSpNo.toArray());
List<SpareNo> existList = spareNoManager.findByQuery(new Query(criteria));
for (GetSpareNoResult spareNoResult : resultList) {
List<SpareNo> hasList= existList.stream()
.filter(spareNo -> spareNoResult.getSpareNo().equals(spareNo.getNo()))
.collect(Collectors.toList());
if(hasList.size()<=0){
SpareNo newSpareNo = getSpareNoResultToSpareNo(spareNoResult);
newSpareNo= spareNoManager.save(newSpareNo);
log.info("创建入库单:"+newSpareNo.getSpareNo());
addToMap(newSpareNo);
}
}
}
@Autowired @Autowired
private ISpareNoManager spareNoManager; private ISpareNoManager spareNoManager;
...@@ -116,10 +155,10 @@ public class SpareNoCache { ...@@ -116,10 +155,10 @@ public class SpareNoCache {
return spareNo; return spareNo;
} }
public void updateCacheAndDB(String spareNoStr, SpareNo spareNo) { // public void updateCacheAndDB(String spareNoStr, SpareNo spareNo) {
cacheMap.put(spareNoStr, spareNo); // cacheMap.put(spareNoStr, spareNo);
spareNoManager.save(spareNo); // spareNoManager.save(spareNo);
} // }
@Autowired @Autowired
...@@ -208,6 +247,9 @@ public class SpareNoCache { ...@@ -208,6 +247,9 @@ public class SpareNoCache {
for (Barcode subBarcode : for (Barcode subBarcode :
boxBarcode.getSubCodeList()) { boxBarcode.getSubCodeList()) {
if (subBarcode.getPartNumber().equals(pn)) { if (subBarcode.getPartNumber().equals(pn)) {
if(ObjectUtil.isNotEmpty(detail.getPartname())) {
subBarcode.setPn(detail.getPartname());
}
subBarcode.setOut(false); subBarcode.setOut(false);
subBarcode.updateNeedInNum(detail.getInQty() ); subBarcode.updateNeedInNum(detail.getInQty() );
log.info("入库单" + orderNo + ", Pn=" + pn + ",查找到库位号=" + pos.getPosName() + ",料箱号=" + boxBarcode.getBarcode() + ",格口号=" + subBarcode.getBarcode() + ",需要入库数量=" + detail.getInQty()); log.info("入库单" + orderNo + ", Pn=" + pn + ",查找到库位号=" + pos.getPosName() + ",料箱号=" + boxBarcode.getBarcode() + ",格口号=" + subBarcode.getBarcode() + ",需要入库数量=" + detail.getInQty());
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!