rev:修改自动叫料逻辑判断
This commit is contained in:
@@ -4,9 +4,12 @@ package org.nl.wms.pf.service;
|
|||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,6 +62,9 @@ public interface FlourworkService {
|
|||||||
*/
|
*/
|
||||||
void startWork(JSONObject whereJson);
|
void startWork(JSONObject whereJson);
|
||||||
|
|
||||||
|
@Async
|
||||||
|
void asyncdown(List<String> movinvs, Long userid, String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 出库确认
|
* 出库确认
|
||||||
* @param whereJson /
|
* @param whereJson /
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.nl.utils.FileUtil;
|
|||||||
import org.nl.utils.SecurityUtils;
|
import org.nl.utils.SecurityUtils;
|
||||||
import org.nl.utils.SpringContextHolder;
|
import org.nl.utils.SpringContextHolder;
|
||||||
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
|
||||||
|
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||||
import org.nl.wms.basedata.master.service.MaterialbaseService;
|
import org.nl.wms.basedata.master.service.MaterialbaseService;
|
||||||
import org.nl.wms.pdm.service.WorkTaskService;
|
import org.nl.wms.pdm.service.WorkTaskService;
|
||||||
import org.nl.wms.pf.service.FlourworkService;
|
import org.nl.wms.pf.service.FlourworkService;
|
||||||
@@ -33,6 +34,8 @@ import org.nl.wql.WQL;
|
|||||||
import org.nl.wql.core.bean.ResultBean;
|
import org.nl.wql.core.bean.ResultBean;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
import org.nl.wql.util.WqlUtil;
|
import org.nl.wql.util.WqlUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -40,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +60,11 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
private final HandPFOutIvtService handPFOutIvtService;
|
private final HandPFOutIvtService handPFOutIvtService;
|
||||||
private final MaterialbaseService materialbaseService;
|
private final MaterialbaseService materialbaseService;
|
||||||
private final WmsToAcsService wmsToAcsService;
|
private final WmsToAcsService wmsToAcsService;
|
||||||
|
private final ClassstandardService classstandardService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Lazy
|
||||||
|
private FlourworkService flourworkService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||||
@@ -198,6 +207,20 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
String taskNum = "0";
|
String taskNum = "0";
|
||||||
JSONArray dtlArr = formTabDtl.query("formula_id = '" + formula_id + "' and status <> '99' and is_need_move = '1' order by seq_no ASC").getResultJSONArray(0);
|
JSONArray dtlArr = formTabDtl.query("formula_id = '" + formula_id + "' and status <> '99' and is_need_move = '1' order by seq_no ASC").getResultJSONArray(0);
|
||||||
if (ObjectUtil.isEmpty(dtlArr)) throw new BadRequestException("没有需要叫料的物料");
|
if (ObjectUtil.isEmpty(dtlArr)) throw new BadRequestException("没有需要叫料的物料");
|
||||||
|
JSONArray jsonDeviceArr = devicePointTab.query("device_uuid = '" + device_id + "' and point_type = '03'").getResultJSONArray(0);
|
||||||
|
Set<String> set = classstandardService.getAllChildIdSet(MaterOptTypeEnum.GF.getClass_idStr());
|
||||||
|
String materials = "";
|
||||||
|
for (int i = 0; i < dtlArr.size(); i++) {
|
||||||
|
JSONObject jsonFormDtl = dtlArr.getJSONObject(i);
|
||||||
|
String material_id = jsonFormDtl.getString("material_id");
|
||||||
|
materials = materials+"'"+material_id+"',";
|
||||||
|
}
|
||||||
|
JSONArray md_me_materialbase = WQLObject.getWQLObject("md_me_materialbase").query("material_id in (" + materials.substring(0, materials.length() - 1) + ")").getResultJSONArray(0);
|
||||||
|
List<String> GFSet = md_me_materialbase.stream().filter(o -> {
|
||||||
|
JSONObject item = (JSONObject) o;
|
||||||
|
return set.contains(item.getString("material_type_id"));
|
||||||
|
}).map(a -> ((JSONObject) a).getString("material_id")).collect(Collectors.toList());
|
||||||
|
List<String> movList = new ArrayList<>();
|
||||||
for (int i = 0; i < dtlArr.size(); i++) {
|
for (int i = 0; i < dtlArr.size(); i++) {
|
||||||
JSONObject jsonFormDtl = dtlArr.getJSONObject(i);
|
JSONObject jsonFormDtl = dtlArr.getJSONObject(i);
|
||||||
String material_id = jsonFormDtl.getString("material_id");
|
String material_id = jsonFormDtl.getString("material_id");
|
||||||
@@ -209,7 +232,6 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
// 1.计算剩余需投料: 剩余需投料=此配方明细的重量-已投料重量
|
// 1.计算剩余需投料: 剩余需投料=此配方明细的重量-已投料重量
|
||||||
double subQty = NumberUtil.sub(jsonFormDtl.getDoubleValue("formula_qty"), jsonFormDtl.getDoubleValue("put_qty"));
|
double subQty = NumberUtil.sub(jsonFormDtl.getDoubleValue("formula_qty"), jsonFormDtl.getDoubleValue("put_qty"));
|
||||||
// 2.查询当前配粉工位的所有上料位
|
// 2.查询当前配粉工位的所有上料位
|
||||||
JSONArray jsonDeviceArr = devicePointTab.query("device_uuid = '" + device_id + "' and point_type = '03'").getResultJSONArray(0);
|
|
||||||
// 3.查询当前可用数:当前可用数=sum(此配粉工位点位仓位此物料可用数)
|
// 3.查询当前可用数:当前可用数=sum(此配粉工位点位仓位此物料可用数)
|
||||||
double canuse_qty = 0.0; // 总当前可用数
|
double canuse_qty = 0.0; // 总当前可用数
|
||||||
if (ObjectUtil.isNotEmpty(jsonDeviceArr)) {
|
if (ObjectUtil.isNotEmpty(jsonDeviceArr)) {
|
||||||
@@ -236,7 +258,7 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
// 5.计算未领重量:未领重量=剩余需投料 - 当前可用数 - 正在移库数
|
// 5.计算未领重量:未领重量=剩余需投料 - 当前可用数 - 正在移库数
|
||||||
double uncla_qty = Double.parseDouble(String.valueOf(NumberUtil.sub(subQty, canuse_qty, move_qty)));
|
double uncla_qty = Double.parseDouble(String.valueOf(NumberUtil.sub(subQty, canuse_qty, move_qty)));
|
||||||
// 6.判断物料是否为钴粉
|
// 6.判断物料是否为钴粉
|
||||||
boolean is_GF = materialbaseService.isAlongMaterType(MaterOptTypeEnum.GF.getCode(), material_id, null);
|
boolean is_GF = GFSet.contains(material_id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 对获取的物料未领重量生成配粉移库单
|
* 对获取的物料未领重量生成配粉移库单
|
||||||
@@ -305,9 +327,7 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
map.put("tableData", tableData);
|
map.put("tableData", tableData);
|
||||||
String moveinv_id = handMoveStorService.insertDtl2(map);
|
String moveinv_id = handMoveStorService.insertDtl2(map);
|
||||||
// 6.下发移库单
|
// 6.下发移库单
|
||||||
JSONObject jsonMoveParam = new JSONObject();
|
movList.add(moveinv_id);
|
||||||
jsonMoveParam.put("moveinv_id", moveinv_id);
|
|
||||||
handMoveStorService.handdown(jsonMoveParam);
|
|
||||||
// 7.下发移库单后减去未领重量
|
// 7.下发移库单后减去未领重量
|
||||||
uncla_qty = NumberUtil.sub(uncla_qty, canuse_qty1);
|
uncla_qty = NumberUtil.sub(uncla_qty, canuse_qty1);
|
||||||
// 回馈任务数
|
// 回馈任务数
|
||||||
@@ -367,9 +387,7 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
map.put("tableData", tableData);
|
map.put("tableData", tableData);
|
||||||
String moveinv_id = handMoveStorService.insertDtl2(map);
|
String moveinv_id = handMoveStorService.insertDtl2(map);
|
||||||
// 6.下发移库单
|
// 6.下发移库单
|
||||||
JSONObject jsonMoveParam = new JSONObject();
|
movList.add(moveinv_id);
|
||||||
jsonMoveParam.put("moveinv_id", moveinv_id);
|
|
||||||
handMoveStorService.handdown(jsonMoveParam);
|
|
||||||
// 回馈任务数
|
// 回馈任务数
|
||||||
taskNum = String.valueOf(NumberUtil.add(taskNum, "1"));
|
taskNum = String.valueOf(NumberUtil.add(taskNum, "1"));
|
||||||
} else {
|
} else {
|
||||||
@@ -381,9 +399,24 @@ public class FlourworkServiceImpl implements FlourworkService {
|
|||||||
if (dtlArr.size() == arr.size()) throw new BadRequestException("叫料失败,此配方明细没有符合的库存");
|
if (dtlArr.size() == arr.size()) throw new BadRequestException("叫料失败,此配方明细没有符合的库存");
|
||||||
if (dtlArr.size() == arr2.size()) throw new BadRequestException("叫料失败,配粉间没有空位");
|
if (dtlArr.size() == arr2.size()) throw new BadRequestException("叫料失败,配粉间没有空位");
|
||||||
result.put("task", taskNum);
|
result.put("task", taskNum);
|
||||||
|
flourworkService.asyncdown(movList,SecurityUtils.getCurrentUserId(),SecurityUtils.getNickName());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void asyncdown(List<String> movinvs,Long userid,String username){
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
for (String moveinv_id : movinvs) {
|
||||||
|
JSONObject param = new JSONObject();
|
||||||
|
param.put("moveinv_id", moveinv_id);
|
||||||
|
param.put("currentUserId", userid);
|
||||||
|
param.put("nickName", username);
|
||||||
|
handMoveStorService.handdown(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void startWork(JSONObject whereJson) {
|
public void startWork(JSONObject whereJson) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
import org.nl.modules.security.service.dto.JwtUserDto;
|
import org.nl.modules.security.service.dto.JwtUserDto;
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
import org.nl.modules.system.util.CodeUtil;
|
||||||
@@ -939,10 +940,15 @@ public class HandMoveStorServiceImpl implements HandMoveStorService {
|
|||||||
|
|
||||||
HandMoveStorAcsTask handMoveStorAcsTask = new HandMoveStorAcsTask();
|
HandMoveStorAcsTask handMoveStorAcsTask = new HandMoveStorAcsTask();
|
||||||
|
|
||||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
Long currentUserId = whereJson.getLong("currentUserId");
|
||||||
String nickName = SecurityUtils.getNickName();
|
String nickName = whereJson.getString("nickName");
|
||||||
|
if (currentUserId == null){
|
||||||
|
currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(nickName)){
|
||||||
|
SecurityUtils.getCurrentUserId();
|
||||||
|
}
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
|
|
||||||
String moveinv_id = whereJson.getString("moveinv_id");
|
String moveinv_id = whereJson.getString("moveinv_id");
|
||||||
//查询所有载具的库存
|
//查询所有载具的库存
|
||||||
JSONArray ja = WQL.getWO("QST_IVT_HANDMOVESTOR")
|
JSONArray ja = WQL.getWO("QST_IVT_HANDMOVESTOR")
|
||||||
|
|||||||
Reference in New Issue
Block a user