拣货逻辑调整

main
FOAM 2025-10-13 19:00:18 +08:00
parent 1bfbcf123f
commit 1eb8972a6a
12 changed files with 170 additions and 97 deletions

View File

@ -190,8 +190,12 @@ public class DateUtil {
}else if(day>28){
z="29-31";
}
if(month<=9){
return year+"-0"+month+"-"+z;
}else{
return year+"-"+month+"-"+z;
}
}
public static String formatChageDay(Date date, String type, int value) {
Calendar cal = new java.util.GregorianCalendar();

View File

@ -62,39 +62,45 @@ public class ImportPointServiceImpl implements ImportPointService {
List<String> pointcodes = dataList.stream().map(PointImport::getCode).collect(Collectors.toList());
pointcodes = pointcodes.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
Map<String, Point> exitPointMap = validatePoint(pointcodes);
//获取文件中所有的库区名称
List<String> areaNames = dataList.stream().map(PointImport::getAreaName).collect(Collectors.toList());
areaNames = areaNames.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
Map<String, Area> exitAreaMap = validateArea(areaNames);
List<Point> pointAll=pointRepository.findAll();
for(Point p:pointAll){
exitPointMap.put(p.getCode(),p);
}
//
// //获取文件中所有的库区名称
// List<String> areaNames = dataList.stream().map(PointImport::getAreaName).collect(Collectors.toList());
// areaNames = areaNames.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
// Map<String, Area> exitAreaMap = validateArea(areaNames);
for (PointImport data : dataList) {
log.info(data.getAreaName()+"===="+data.getCode());
Point point = exitPointMap.get(data.getCode());
if (point == null) {
point=new Point();
point.setCode(data.getCode());
point.setDept(UserUtils.getDept());
point.setCreateBy(SecurityUtils.getCurrentUsername());
point.setCreateTime(new Timestamp(new Date().getTime()));
point.setEnabled(Boolean.TRUE);
}
point.setArea(exitAreaMap.get(data.getAreaName()));
String lx = data.getType();
if (lx.equals("材管库位")) {
lx = BaseStatus.CH;
} else if (lx.equals("制造库位")) {
lx = BaseStatus.ZZKW;
}else if (lx.equals("缓存库位")) {
lx = BaseStatus.HCKW;
}
point.setType(lx);
point.setBeatCode(data.getNs());
point.setDescription(data.getBqlx());
point.setItemCode(data.getItemCode());
point.setZflx(data.getZflx());
point.setBqlx(data.getBqlx());
point.setGlzkw(data.getGlzkw());
point.setInvMin(Integer.parseInt(data.getKcxx()));
point.setCode(data.getAreaName());
// if (point == null) {
// point=new Point();
// point.setCode(data.getCode());
// point.setDept(UserUtils.getDept());
// point.setCreateBy(SecurityUtils.getCurrentUsername());
// point.setCreateTime(new Timestamp(new Date().getTime()));
// point.setEnabled(Boolean.TRUE);
// }
// point.setArea(exitAreaMap.get(data.getAreaName()));
// String lx = data.getType();
// if (lx.equals("材管库位")) {
// lx = BaseStatus.CH;
// } else if (lx.equals("制造库位")) {
// lx = BaseStatus.ZZKW;
// }else if (lx.equals("缓存库位")) {
// lx = BaseStatus.HCKW;
// }
// point.setType(lx);
// point.setBeatCode(data.getNs());
// point.setDescription(data.getBqlx());
// point.setItemCode(data.getItemCode());
// point.setZflx(data.getZflx());
// point.setBqlx(data.getBqlx());
// point.setGlzkw(data.getGlzkw());
// point.setInvMin(Integer.parseInt(data.getKcxx()));
pointRepository.save(point);
}
}
@ -125,12 +131,12 @@ public class ImportPointServiceImpl implements ImportPointService {
// 根据模板类型进行不同的处理
List<String> requiredColumns = Arrays.asList(
"库位号",
"库区",
"存储类型",
"品番",
"库存下限",
"纳所",
"标签类型"
"库区"
// "存储类型",
// "品番",
// "库存下限",
// "纳所",
// "标签类型"
// ,
// "总分类型",
// "关联总库位"

View File

@ -62,7 +62,7 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, Jpa
@Query(value = "SELECT * from data_inventory inv \n" +
"left join base_point p on inv.point_id=p.id\n" +
"WHERE inv.quantity>0 and p.type='CH' and inv.stock_code=:stockCode" , nativeQuery = true)
"WHERE inv.quantity-inv.queued_qty>0 and p.type='CH' and inv.stock_code=:stockCode" , nativeQuery = true)
List<Inventory> queryInvStockCode(String stockCode);
@Query(value = "SELECT inv.* from data_inventory inv \n" +

View File

@ -105,4 +105,8 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
*/
@Query(value = "select * from data_task t where t.plan_qty>t.move_qty and t.pick_detail_id is not null and t.item_key_id=1? ", nativeQuery = true)
List<Task> getItemKeyTask(Long id);
@Query(value = "select * from data_task t where t.task_type='PICK' and t.move_qty<t.plan_qty \n" +
" and t.dst_stock_code is not null and t.bill_code is null and t.dst_stock_code=:stockCode ", nativeQuery = true)
List<Task> getStockTasks(String stockCode);
}

View File

@ -389,7 +389,7 @@ public class AsnDetailController {
}
return new ResponseEntity("取消成功", HttpStatus.OK);
}
@Log("取消收货的操作")
@Log("的操作")
@ApiOperation("取消收货的操作")
@PostMapping("/rkAndQxButtonQX")
@PreAuthorize("@el.check('super:man')")
@ -437,7 +437,7 @@ public class AsnDetailController {
}
//生成库存日志
InventoryLog inventoryLog = invLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, null, ad.getPoint().getArea(), inve.getItemKey(),
InventoryLog inventoryLog = invLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, asn.getCode(), ad.getPoint().getArea(), inve.getItemKey(),
pointMapper.toEntity(inventoryDto.getPoint()) , dstPoint, ad.getStock(), ad.getStock(), ad.getReceivedQty(), ad.getReceivedQty(), null,null,BizStatus.ASN, ad.getId(), inventoryDto.getId(), ad.getRemark());
}
// }

View File

@ -176,6 +176,7 @@ public class PickDetailController {
@Log("修改pickDetail")
@ApiOperation("修改pickDetail")
@PreAuthorize("@el.check('super:man')")
@Transactional
public ResponseEntity<Object> updatePickDetail(@Validated @RequestBody PickDetail resources) {
if(resources.getAllocatedQty()>0){
throw new BadRequestException("已出单,不能修改");
@ -188,6 +189,7 @@ public class PickDetailController {
@Log("删除pickDetail")
@ApiOperation("删除pickDetail")
@PreAuthorize("@el.check('super:man')")
@Transactional
public ResponseEntity<Object> deletePickDetail(@RequestBody Long[] ids) {
//删除时需判断是否有分配
for(Long id:ids){
@ -207,6 +209,7 @@ public class PickDetailController {
@ApiOperation("制造叫料App")
@PreAuthorize("@el.check('super:man')")
@AnonymousAccess
@Transactional
@DuplicateSubmission(5)
public ResponseEntity<Object> zzjlApp(@RequestBody CxjlDto cxjldto) throws Exception {
String ewm=cxjldto.getEwm();
@ -223,6 +226,7 @@ public class PickDetailController {
if(point==null||!point.getType().equals("ZZKW")){
throw new BadRequestException("制造库位错误");
}
//查询BOM寻找收容数
cxjldto.setRk_id(point.getArea().getId());
cxjldto.setItem_id(item.getId());
cxjldto.setZzkw_id(point.getId());
@ -242,6 +246,10 @@ public class PickDetailController {
PickDetail pickDetail = pickDetailService.cxjlCreate(cxjldto);
//自动分配
pickDetailService.allocate(pickDetail.getId(), pickDetail.getOrderQty() - pickDetail.getAllocatedQty(), pickDetail.getPo(), BaseStatus.ZZJL);
int qh_qty=pickDetail.getOrderQty().intValue()-pickDetail.getAllocatedQty().intValue();
if(qh_qty>0){
throw new BadRequestException(pickDetail.getItem().getCode()+"库存缺货,仅有"+pickDetail.getAllocatedQty().intValue()+",请汇报上级");
}
}else if(type.equals("cxjl_003")){//制造入库APP
//解析二维码内容
String[] str=ewm.split("]");
@ -275,6 +283,7 @@ public class PickDetailController {
@ApiOperation("制造叫料")
@PreAuthorize("@el.check('super:man')")
@AnonymousAccess
@Transactional
@DuplicateSubmission(5)
public ResponseEntity<Object> zzjl(@RequestBody CxjlDto cxjldto) throws Exception {
PickDetail pickDetail=pickDetailService.cxjlCreate(cxjldto);
@ -282,6 +291,10 @@ public class PickDetailController {
cxjldto.setBonded(bomAccount.getBonded());
//自动分配
pickDetailService.allocate(pickDetail.getId(), pickDetail.getOrderQty() - pickDetail.getAllocatedQty(),pickDetail.getPo(),BaseStatus.ZZJL);
int qh_qty=pickDetail.getOrderQty().intValue()-pickDetail.getAllocatedQty().intValue();
if(qh_qty>0){
throw new BadRequestException(pickDetail.getItem().getCode()+"库存缺货,仅有"+pickDetail.getAllocatedQty().intValue()+",请汇报上级");
}
return new ResponseEntity<>(HttpStatus.OK);
}
@ -341,7 +354,7 @@ public class PickDetailController {
if(tasks.size()>=0){
for(Task t:tasks){
ZzjlPickDetail detail=new ZzjlPickDetail();
detail.setStock_code("");
detail.setStock_code(t.getDstStockCode()==null?"":t.getDstStockCode());
detail.setPoint_code(t.getSrcPoint().getCode());
detail.setPch(t.getItemKey().getPropC1());
detail.setItem_code(t.getItemKey().getItem().getCode());
@ -349,25 +362,30 @@ public class PickDetailController {
detail.setBonded(pickDetail.getPropC2());
detail.setQty(t.getPlanQty()+"");
detail_list.add(detail);
view_type="02";
view_name="现品票";
}
}
if(tasks.size()==0){
List<XdInventory> invs= inventoryService.queryInvForPickDetail(pickDetail.getId());
for(XdInventory inv:invs) {
ZzjlPickDetail detail=new ZzjlPickDetail();
detail.setStock_code(inv.getStockCode());
detail.setPoint_code(inv.getPointCode());
detail.setPch(inv.getPropC1());
detail.setItem_code(inv.getItemCode());
detail.setItem_name(inv.getItemName());
detail.setBonded(inv.getBonded());
detail.setQty(inv.getInvQty());
detail_list.add(detail);
if(t.getDstStockCode()!=null){
view_type="03";
view_name="箱单号";
}else {
view_type = "02";
view_name = "现品票";
}
}
}
// if(tasks.size()==0){
// List<XdInventory> invs= inventoryService.queryInvForPickDetail(pickDetail.getId());
// for(XdInventory inv:invs) {
// ZzjlPickDetail detail=new ZzjlPickDetail();
// detail.setStock_code(inv.getStockCode());
// detail.setPoint_code(inv.getPointCode());
// detail.setPch(inv.getPropC1());
// detail.setItem_code(inv.getItemCode());
// detail.setItem_name(inv.getItemName());
// detail.setBonded(inv.getBonded());
// detail.setQty(inv.getInvQty());
// detail_list.add(detail);
// view_type="03";
// }
// }
if(pickDetail.getBeXdPf()){
view_name="箱单(品番)";
view_type="04";
@ -393,11 +411,27 @@ public class PickDetailController {
}
PickDetail pickDetail=pickDetailRepository.getById(zzjlPick.getDetail_id());
if(stock_code!=null&&(zzjlPick.getView_type().equals("03")||zzjlPick.getView_type().equals("04"))){
if(!pickDetail.getBeXdPf()){//箱单出库
if(!pickDetail.getBeXdPf()){//箱单出库,按照锁定箱单出库
//先把符合数据的箱单全部拣货完成,剩余的再挂靠拣货
List<Task> ts=taskRepository.getStockTasks(stock_code);
boolean no_exits=true;
for(Task task:ts) {
if (task.getPickDetail().getId().equals(pickDetail.getId())) {
no_exits = false;
}
}
if(no_exits){
throw new BadRequestException( "扫描箱单号不正确");
}
for(Task task:ts){
pickTicketService.pickForTask(task.getId(), task.getSrcStockCode(), task.getPlanQty()-task.getMoveQty(), null, SecurityUtils.getCurrentUsername());
}
List<Inventory> invs = inventoryRepository.queryInvStockCode(stock_code);
for (Inventory inv : invs) {
double ky_qty=inv.getQuantity()-inv.getQueuedQty();
//生成Task生成出库扣减库存
Task task = taskService.storeTask(null,pickDetail,inv.getArea(),inv.getItemKey(),inv.getPoint(),null,inv.getQuantity(),inv.getStockCode());
Task task = taskService.storeTask(null,pickDetail,inv.getArea(),inv.getItemKey(),inv.getPoint(),null,ky_qty,inv.getStockCode());
task.setBillCode(pickDetail.getItem().getCode()+"关联箱单出库"+pickDetail.getId());
task.setTaskType(BizStatus.XD_PICK);
taskRepository.save(task);
@ -462,6 +496,7 @@ public class PickDetailController {
@Log("制造叫料分配审核")
@ApiOperation("制造叫料分配审核")
@AnonymousAccess
@Transactional
public synchronized ResponseEntity<Object> allocatePickDetail(@RequestBody Long[] ids) throws Exception {
List<Long> pickDetailIds = Arrays.asList(ids);
Collections.sort(pickDetailIds);//升序排序
@ -480,6 +515,7 @@ public class PickDetailController {
@Log("制造叫料取消分配")
@ApiOperation("制造叫料取消分配")
@AnonymousAccess
@Transactional
public synchronized ResponseEntity<Object> cancelAllocatePickDetail(@RequestBody Long[] ids) throws Exception {
List<Long> pickDetailIds = Arrays.asList(ids);
Collections.sort(pickDetailIds);//升序排序
@ -501,6 +537,7 @@ public class PickDetailController {
@Log("设变")
@ApiOperation("设变")
@AnonymousAccess
@Transactional
public ResponseEntity<Object> sbPickdetail(@RequestBody HashMap<String,Object> map) {
Long pdId=Long.parseLong(map.get("pdId").toString());
Double sbQty=Double.parseDouble(map.get("sbQty").toString());
@ -609,6 +646,7 @@ public class PickDetailController {
@Log("退拣")
@ApiOperation("退拣")
@AnonymousAccess
@Transactional
public synchronized ResponseEntity<Object> pickBarBack(@RequestBody Long pickDetailId) throws Exception {
//查询已完成的拣货任务
List<Task> Tasks = taskService.getPickAllTask(pickDetailId);
@ -631,6 +669,7 @@ public class PickDetailController {
@ApiOperation("指示残-波次补料")
@PreAuthorize("@el.check('super:man')")
@AnonymousAccess
@Transactional
public ResponseEntity<Object> autoBcbl(@RequestBody HashMap<String,Object> map) {
BillType bt=billTypeRepository.findByName(BaseStatus.BT_BCBL);
if(bt==null){

View File

@ -818,6 +818,7 @@ public class XppRecordController {
@Log("删除xppRecord")
@ApiOperation("删除xppRecord")
@PreAuthorize("@el.check('super:man')")
@Transactional
public ResponseEntity<Object> deleteXppRecord(@RequestBody Long[] ids) {
for (Long id : ids) {
//查找对应的入库明细是否收货

View File

@ -55,13 +55,17 @@ public class InventoryLogQueryCriteria{
@Query(joinName = "itemKey>", propName="propC2",type = Query.Type.EQUAL)
private String bonded;
/** 源点位号 */
@Query(type = Query.Type.EQUAL)
private String srcPointCode;
//
// /** 源点位号 */
// @Query(type = Query.Type.EQUAL)
// private String srcPointCode;
@Query(joinName = "area",propName = "code",type = Query.Type.EQUAL)
private String areaCode;
/** 源库位 */
@Query(joinName = "srcPoint",propName = "code",type = Query.Type.INNER_LIKE)
private String srcPointCode;
}

View File

@ -154,13 +154,15 @@ public class AsnDetailServiceImpl implements AsnDetailService {
if(asn!=null){
xdh=asn.getCusCode();
}
Inventory inventory=inventoryService.getInventory(t.getItemKey(),xppRecord.getArea(),srcPoint,t.getAsnDetail().getPoint(),t.getArea().getDept(),BizStatus.RECEIVING_CANCEL,xdh);
Inventory inventory=inventoryService.getInventory(t.getItemKey(),srcPoint.getArea(),srcPoint,t.getAsnDetail().getPoint(),t.getArea().getDept(),BizStatus.RECEIVING_CANCEL,xdh);
if(inventory==null){
throw new BadRequestException("找不到对应库存");
}
if((inventory.getQuantity().intValue()- inventory.getQueuedQty().intValue())<t.getPlanQty().intValue()){
if(!inventory.getArea().getBexb()) {
if ((inventory.getQuantity().intValue() - inventory.getQueuedQty().intValue()) < t.getPlanQty().intValue()) {
throw new BadRequestException("库存不足");
}
}
double srcQty= inventory.getQuantity();
inventory.setQuantity(inventory.getQuantity()-t.getPlanQty());
inventoryService.update(inventory);
@ -172,7 +174,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
InventoryLog log=inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL,BizStatus.REDUCE,null,t.getArea(),t.getItemKey(),t.getDstPoint(),t.getSrcPoint(),null,null,srcQty,t.getPlanQty(),
null,ewm, BizStatus.ASN,inventory.getId(),inventory.getId(),"取消上架");
taskRepository.delete(t);
if(d!=null){
if(xppRecord!=null&&d!=null){
this.delete(d.getId());
}
}

View File

@ -183,7 +183,7 @@ public class InventoryServiceImpl implements InventoryService {
hql+=" and inv.itemKey.propC2='"+propC2+"'";
}
hql+= " order by inv.itemKey.propC1 asc ";
hql+= " order by inv.itemKey.propC1 asc,inv.stockCode asc ";
Query query = entityManager.createQuery(hql);
List<Inventory> inventoryList = query.getResultList();
return inventoryList;

View File

@ -147,23 +147,25 @@ public class PickDetailServiceImpl implements PickDetailService {
//扣主表的订单数量
PickDetail detail = pickDetailRepository.getById(id);
PickTicket pt=detail.getPickTicket();
Boolean bcbl=Boolean.FALSE;
if(pt.getBillType().getName().equals(BaseStatus.BT_BCBL)){
bcbl=Boolean.TRUE;
if(pt!=null) {
Boolean bcbl = Boolean.FALSE;
if (pt.getBillType().getName().equals(BaseStatus.BT_BCBL)) {
bcbl = Boolean.TRUE;
}
if(detail.getAllocatedQty()+detail.getBcQty()>0){
if (detail.getAllocatedQty() + detail.getBcQty() > 0) {
throw new BadRequestException("已出单,不能删除");
}
if(bcbl){
PickDetail oldDetail=pickDetailRepository.getById(detail.getSourceId());
if(oldDetail!=null){
oldDetail.setBcQty(oldDetail.getBcQty()- detail.getOrderQty());
if (bcbl) {
PickDetail oldDetail = pickDetailRepository.getById(detail.getSourceId());
if (oldDetail != null) {
oldDetail.setBcQty(oldDetail.getBcQty() - detail.getOrderQty());
this.update(oldDetail);
}
}
pt.setOrderQuantity(pt.getOrderQuantity()-detail.getOrderQty());
pt.setOrderQuantity(pt.getOrderQuantity() - detail.getOrderQty());
// pickTicketService.update(pt);
pickTicketRepository.save(pt);
}
pickDetailRepository.deleteById(id);
}
@ -228,14 +230,15 @@ public class PickDetailServiceImpl implements PickDetailService {
double srs=item.getExtendD3();
Map<String,String> map=new HashMap<>();
for (Inventory inv : invs) {
if(inv.getStockCode()!=null&&pd.getPo()==null&&!type.equals(BaseStatus.QTCK)){
//回写推荐托盘即可
pd.setStatus(BizStatus.ALLOCATE);
pd.setArea(inv.getArea());
pd.setCkPoint(inv.getPoint());
map.put(inv.getId()+"",inv.getStockCode()+"]"+inv.getItemKey().getPropC1()+"]"+inv.getPoint().getCode()+"]"+inv.getQuantity());
continue;
}
//推荐箱单功能暂时不使用,直接锁库
// if(inv.getStockCode()!=null&&pd.getPo()==null&&!type.equals(BaseStatus.QTCK)){
// //回写推荐托盘即可
// pd.setStatus(BizStatus.ALLOCATE);
// pd.setArea(inv.getArea());
// pd.setCkPoint(inv.getPoint());
// map.put(inv.getId()+"",inv.getStockCode()+"]"+inv.getItemKey().getPropC1()+"]"+inv.getPoint().getCode()+"]"+inv.getQuantity());
// continue;
// }
Point startPoint = inv.getPoint();//原库位
// String areaCode=BaseStatus.DEFAULT_AREA;
// Point endPoint = pointService.getPoint(null, null, BaseStatus.BHZC, areaCode);//目标库位
@ -288,6 +291,7 @@ public class PickDetailServiceImpl implements PickDetailService {
}
pd.setArea(inv.getArea());
pd.setCkPoint(inv.getPoint());
pd.setPo(inv.getStockCode());
pickDetailRepository.save(pd);
Task task = taskService.storeTask(null,pd,inv.getArea(),inv.getItemKey(),startPoint,endPoint,allocateQty,inv.getStockCode());
//修改占用数,写入日志
@ -304,6 +308,11 @@ public class PickDetailServiceImpl implements PickDetailService {
}
}else{
log.info("无库存。。。。");
// if(!type.equals(BaseStatus.QTCK)) {
// throw new BadRequestException("无库存,请汇报上级!");
// }else{
// log.info("无库存。。。。");
// }
}
} else {
throw new BadRequestException("已分配,请勿重复操作!");
@ -426,7 +435,7 @@ public class PickDetailServiceImpl implements PickDetailService {
" left join base_area a on a.id=d.area_id\n" +
" left join base_area s on s.id=d.sh_area_id\n" +
" left join base_point ck_point on ck_point.id=d.ck_point_id\n" +
" where 1=1 and d.type='ZZJL' and d.picked_qty=0 ";
" where 1=1 and d.type='ZZJL' and d.order_qty>0 and d.picked_qty<d.order_qty and d.status!='PICK_ALL' ";
if(areaName!=null&&!areaName.equals("")){
if(areaName.equals("材管库位无库存")){
@ -456,9 +465,9 @@ public class PickDetailServiceImpl implements PickDetailService {
String sql="SELECT IFNULL(ck_area.name,\"材管库位无库存\") area_name,sum(d.order_qty) order_qty,sum(d.allocated_qty) allocated_qty ,count(d.id) count_qty\n" +
"from data_pick_detail d\n" +
"left join base_area ck_area on ck_Area.id=d.area_id\n" +
"where d.picked_qty<d.order_qty and d.type='ZZJL' " +
"GROUP BY ck_area.name \n" +
"ORDER BY ck_area.name desc";
"where d.picked_qty<d.order_qty and d.type='ZZJL' and d.order_qty>0 and d.status!='PICK_ALL'" +
" GROUP BY ck_area.name \n" +
" ORDER BY ck_area.name desc";
Query query = entityManager.createNativeQuery(sql);
List ts= query
.unwrap(SQLQuery.class)

View File

@ -556,8 +556,12 @@ public class PickTicketServiceImpl implements PickTicketService {
inventoryService.update(dstInv); **/
pd.setPickedQty(pd.getPickedQty() + pickQty);
if(pd.getPickedQty()>0){
pd.setStatus(BizStatus.PICKUP);
if(pd.getPickedQty()>=pd.getOrderQty()){
pd.setStatus(BizStatus.PICK_ALL);
}
}
pickDetailRepository.save(pd);
if(pt!=null) {
//拣货数量