add:新增二期发货区监控功能
This commit is contained in:
@@ -609,42 +609,42 @@ public class StIvtIostorinvOutServiceImpl extends ServiceImpl<StIvtIostorinvOutM
|
||||
|
||||
StIvtIostorinv mstDao = this.getById(whereJson.getLongValue("iostorinv_id"));
|
||||
|
||||
// 查询此明细所有未生成的分配明细
|
||||
List<JSONObject> disDaoList = stIvtIostorinvdisMapper.getNotCreateDis(whereJson);
|
||||
|
||||
if (ObjectUtil.isEmpty(disDaoList)) {
|
||||
throw new BadRequestException("当前没有可设置的分配明细!");
|
||||
}
|
||||
|
||||
//判断是否有正在执行中的任务
|
||||
List<JSONObject> arr2 = taskService.query("handle_class = '" + TwoOutTask.class.getName() + "' and task_status < '" + TaskStatusEnum.FINISHED.getCode() + "' and is_delete ='0'")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
Map<String, List<JSONObject>> taskGroup = arr2.stream()
|
||||
.collect(Collectors.groupingBy(row -> row.getString("task_group_id")));
|
||||
|
||||
if (taskGroup.size() >= 3) {
|
||||
throw new BadRequestException("当前有三种不同规格的木箱正在出库,请稍后在试!");
|
||||
}
|
||||
|
||||
/*
|
||||
* 下发任务
|
||||
* 1.根据木箱 长、宽、高、订单号、物料分组
|
||||
* 2.相同木箱规格、订单号、物料的木箱一个任务组
|
||||
*/
|
||||
// 定义一个函数,将需要分组的元素映射到一个建的集合里
|
||||
Function<JSONObject, List<String>> compositeKey = row ->
|
||||
Arrays.asList(row.getString("box_length"), row.getString("box_width"),
|
||||
row.getString("box_high"),row.getString("sale_order_name"),
|
||||
row.getString("material_id")
|
||||
);
|
||||
|
||||
Map<List<String>, List<JSONObject>> groupingDisMap =
|
||||
disDaoList.stream().collect(Collectors.groupingBy(compositeKey, Collectors.toList()));
|
||||
|
||||
// 创建手动式事务
|
||||
ArrayList<String> arr = new ArrayList<>();
|
||||
TranUtil.openTransaction((req, allTransactionConsumer) -> {
|
||||
// 查询此明细所有未生成的分配明细
|
||||
List<JSONObject> disDaoList = stIvtIostorinvdisMapper.getNotCreateDis(whereJson);
|
||||
|
||||
if (ObjectUtil.isEmpty(disDaoList)) {
|
||||
throw new BadRequestException("当前没有可设置的分配明细!");
|
||||
}
|
||||
|
||||
//判断是否有正在执行中的任务
|
||||
List<JSONObject> arr2 = taskService.query("handle_class = '" + TwoOutTask.class.getName() + "' and task_status < '" + TaskStatusEnum.FINISHED.getCode() + "' and is_delete ='0'")
|
||||
.getResultJSONArray(0).toJavaList(JSONObject.class);
|
||||
|
||||
Map<String, List<JSONObject>> taskGroup = arr2.stream()
|
||||
.collect(Collectors.groupingBy(row -> row.getString("task_group_id")));
|
||||
|
||||
if (taskGroup.size() >= 3) {
|
||||
throw new BadRequestException("当前有三种不同规格的木箱正在出库,请稍后在试!");
|
||||
}
|
||||
|
||||
/*
|
||||
* 下发任务
|
||||
* 1.根据木箱 长、宽、高、订单号、物料分组
|
||||
* 2.相同木箱规格、订单号、物料的木箱一个任务组
|
||||
*/
|
||||
// 定义一个函数,将需要分组的元素映射到一个建的集合里
|
||||
Function<JSONObject, List<String>> compositeKey = row ->
|
||||
Arrays.asList(row.getString("box_length"), row.getString("box_width"),
|
||||
row.getString("box_high"),row.getString("sale_order_name"),
|
||||
row.getString("material_id")
|
||||
);
|
||||
|
||||
Map<List<String>, List<JSONObject>> groupingDisMap =
|
||||
disDaoList.stream().collect(Collectors.groupingBy(compositeKey, Collectors.toList()));
|
||||
|
||||
// 判断是否有异常任务
|
||||
String exceptionPointCode = exceptionPointCode(disDaoList);
|
||||
if (ObjectUtil.isNotEmpty(exceptionPointCode)) {
|
||||
|
||||
@@ -34,4 +34,9 @@ public interface AutoRiKuService {
|
||||
* 获取空托盘
|
||||
*/
|
||||
JSONObject getEmpPoint();
|
||||
|
||||
/**
|
||||
* 获取发货区(二期)
|
||||
*/
|
||||
JSONObject queryNumTwo(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -265,4 +265,20 @@ public class AutoRiKuServiceImpl implements AutoRiKuService {
|
||||
return jsonAll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryNumTwo(JSONObject whereJson) {
|
||||
WQLObject schBasePointService = WQLObject.getWQLObject("sch_base_point");
|
||||
|
||||
// 有货个数
|
||||
JSONArray haveMoney = schBasePointService.query("point_type = '8' and IFNULL(vehicle_code,'')<>'' and is_delete = '0' and is_used = '1' AND region_code = 'BFH01'").getResultJSONArray(0);
|
||||
|
||||
// 无货个数
|
||||
JSONArray unMoney = schBasePointService.query("point_type = '8' and IFNULL(vehicle_code,'')='' and is_delete = '0' and is_used = '1' AND region_code = 'BFH01'").getResultJSONArray(0);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("haveMoney", haveMoney.size());
|
||||
result.put("unMoney", unMoney.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,4 +42,11 @@ public class AutoWebSocketRiKu {
|
||||
public ResponseEntity<Object> queryNum(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(autoRiKuService.queryNum(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryNumTwo")
|
||||
@Log("查询发货区(二期)")
|
||||
|
||||
public ResponseEntity<Object> queryNumTwo(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(autoRiKuService.queryNumTwo(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,14 @@ public class StructattrController {
|
||||
return new ResponseEntity<>(structattrService.getStructByCodesFs(jsonArray), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getStructByCodesFsTwo")
|
||||
@Log("获取点位信息(二期)")
|
||||
|
||||
public ResponseEntity<Object> getStructByCodesFsTwo(@RequestBody String json) {
|
||||
JSONArray jsonArray = JSONArray.parseArray(json);
|
||||
return new ResponseEntity<>(structattrService.getStructByCodesFsTwo(jsonArray), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/unLockPoint")
|
||||
@Log("解锁点位")
|
||||
|
||||
@@ -95,6 +103,13 @@ public class StructattrController {
|
||||
return new ResponseEntity<>(structattrService.unLockPoint(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/unLockPointTwo")
|
||||
@Log("解锁点位(二期)")
|
||||
|
||||
public ResponseEntity<Object> unLockPointTwo(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(structattrService.unLockPointTwo(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/oneCreate")
|
||||
@Log("一键生成货位")
|
||||
public ResponseEntity<Object> oneCreate(@RequestBody JSONObject whereJson) {
|
||||
|
||||
@@ -90,6 +90,12 @@ public interface StructattrService {
|
||||
* @return
|
||||
*/
|
||||
JSONArray getStructByCodesFs(JSONArray json);
|
||||
/**
|
||||
* 获取点位信息(二期)
|
||||
*wo
|
||||
* @return
|
||||
*/
|
||||
JSONArray getStructByCodesFsTwo(JSONArray json);
|
||||
Map getStructByCodesFsAnNum(JSONArray json);
|
||||
|
||||
/**
|
||||
@@ -126,4 +132,11 @@ public interface StructattrService {
|
||||
* }
|
||||
*/
|
||||
void tunConfirm(JSONObject json);
|
||||
|
||||
/**
|
||||
* 点位解锁
|
||||
* @param whereJson:{点位信息}
|
||||
* @return 、
|
||||
*/
|
||||
JSONObject unLockPointTwo(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxlashboundService;
|
||||
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxlashbound;
|
||||
import org.nl.b_lms.storage_manage.database.service.dao.mapper.BstIvtBoxinfoMapper;
|
||||
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
|
||||
import org.nl.common.utils.MapOf;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
@@ -28,6 +32,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -48,6 +53,18 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
@Autowired
|
||||
private StorattrService storattrService;
|
||||
|
||||
/**
|
||||
* 木箱绑定服务
|
||||
*/
|
||||
@Autowired
|
||||
private IBstIvtBoxlashboundService iBstIvtBoxlashboundService;
|
||||
|
||||
/**
|
||||
* 木箱信息mapper
|
||||
*/
|
||||
@Resource
|
||||
private BstIvtBoxinfoMapper bstIvtBoxinfoMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String search = (String) whereJson.get("search");
|
||||
@@ -398,6 +415,86 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getStructByCodesFsTwo(JSONArray jsonArray) {
|
||||
WQLObject attrTab = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray arr = new JSONArray();
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject js = jsonArray.getJSONObject(i);
|
||||
String struct_id = js.getString("struct_id");
|
||||
if (ObjectUtil.isEmpty(struct_id)) {
|
||||
continue;
|
||||
}
|
||||
list.add(struct_id);
|
||||
}
|
||||
String sql = "('" + list.stream().collect(Collectors.joining("','")) + "')";
|
||||
JSONArray array = WQL
|
||||
.getWO("QST_STRUCTATTR")
|
||||
.addParamMap(MapOf.of("struct_ids", sql, "flag", "3"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
|
||||
Map<String, JSONObject> pointMap = array.stream().collect(HashMap::new, (BiConsumer<HashMap<String, JSONObject>, Object>) (m, o) -> {
|
||||
JSONObject item = (JSONObject) o;
|
||||
m.put(item.getString("point_id"), item);
|
||||
}, HashMap::putAll);
|
||||
|
||||
JSONArray attrs = attrTab.query("point_id in " + sql).getResultJSONArray(0);
|
||||
Map<String, JSONObject> attrMap = attrs.stream().collect(HashMap::new, (BiConsumer<HashMap<String, JSONObject>, Object>) (m, o) -> {
|
||||
JSONObject item = (JSONObject) o;
|
||||
m.put(item.getString("point_id"), item);
|
||||
}, HashMap::putAll);
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject obj = new JSONObject();
|
||||
JSONObject js = jsonArray.getJSONObject(i);
|
||||
String struct_id = js.getString("struct_id");
|
||||
|
||||
if (ObjectUtil.isEmpty(struct_id)) {
|
||||
continue;
|
||||
}
|
||||
int struct_status = 2;
|
||||
// 获取信息 1蓝色空载具 2黄色木箱 3绿色空位 4灰色禁用
|
||||
// 计算子卷净重
|
||||
JSONObject json = pointMap.get(struct_id);
|
||||
|
||||
List<JSONObject> pointList = array.toJavaList(JSONObject.class).stream()
|
||||
.filter(row -> row.getString("point_id").equals(struct_id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (ObjectUtil.isNotEmpty(json.getString("net_weight"))) {
|
||||
|
||||
BigDecimal container_weight = pointList.stream().map(row -> row.getBigDecimal("net_weight")).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
for (int j = 0; j < pointList.size(); j++) {
|
||||
JSONObject jsonObject = pointList.get(j);
|
||||
jsonObject.put("container_weight", container_weight);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject strInfo = attrMap.get(struct_id);
|
||||
if (strInfo !=null && ObjectUtil.isEmpty(strInfo.getString("vehicle_code"))) {
|
||||
// 空位
|
||||
struct_status = 3;
|
||||
}
|
||||
|
||||
if (strInfo !=null && strInfo.getString("is_used").equals(IOSEnum.IS_NOTANDYES.code("否"))) {
|
||||
// 未启用
|
||||
struct_status = 4;
|
||||
}
|
||||
|
||||
// 剩余层数货位信息没统计,统计可以用obj.put(key, value)返给前端,前端在initStatus()就可以遍历去获取,给节点赋值
|
||||
obj.put("data", pointList);
|
||||
obj.put("struct_status", struct_status);
|
||||
obj.put("struct_id", strInfo.getString("point_id"));
|
||||
obj.put("struct_code", strInfo.getString("point_code"));
|
||||
obj.put("id", js.getString("id")); // 设备不存在就只保留id,方便前端查看
|
||||
arr.add(obj);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getStructByCodesFsAnNum(JSONArray jsonArray) {
|
||||
WQLObject attrTab = WQLObject.getWQLObject("sch_base_point");
|
||||
@@ -705,4 +802,56 @@ public class StructattrServiceImpl implements StructattrService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject unLockPointTwo(JSONObject whereJson) {
|
||||
// 点位表
|
||||
WQLObject schBasePointService = WQLObject.getWQLObject("sch_base_point");
|
||||
|
||||
String box_no = whereJson.getString("vehicle_code");
|
||||
if (ObjectUtil.isEmpty(box_no)) {
|
||||
throw new BadRequestException("木箱不能为空");
|
||||
}
|
||||
|
||||
BstIvtBoxlashbound boundDao = iBstIvtBoxlashboundService.getOne(
|
||||
new QueryWrapper<BstIvtBoxlashbound>().lambda()
|
||||
.eq(BstIvtBoxlashbound::getBox_no, box_no)
|
||||
);
|
||||
|
||||
if (ObjectUtil.isEmpty(boundDao)) {
|
||||
throw new BadRequestException("此木箱没有经过自动捆扎,请在【点位管理】页面手动解绑!");
|
||||
}
|
||||
|
||||
// 查出所有捆绑在一起的木箱
|
||||
List<BstIvtBoxlashbound> boundDaoList = iBstIvtBoxlashboundService.list(
|
||||
new QueryWrapper<BstIvtBoxlashbound>().lambda()
|
||||
.eq(BstIvtBoxlashbound::getBound_id, boundDao.getBound_id())
|
||||
);
|
||||
|
||||
// 查询所在点位
|
||||
String box_in = boundDaoList.stream()
|
||||
.map(BstIvtBoxlashbound::getBox_no)
|
||||
.collect(Collectors.joining("','"));
|
||||
|
||||
JSONObject jsonPoint = schBasePointService.query("vehicle_code IN ('" + box_in + "') and is_delete = '0' and is_used = '1' and point_type = '8'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonPoint)) {
|
||||
throw new BadRequestException("请输入正确的木箱或查看点位是否存在");
|
||||
}
|
||||
|
||||
// 解锁点位
|
||||
jsonPoint.put("point_status", "1");
|
||||
jsonPoint.put("lock_type", "1");
|
||||
jsonPoint.put("vehicle_code", "");
|
||||
schBasePointService.update(jsonPoint);
|
||||
|
||||
// 删除木箱绑定关系
|
||||
iBstIvtBoxlashboundService.remove(
|
||||
new QueryWrapper<BstIvtBoxlashbound>().lambda()
|
||||
.eq(BstIvtBoxlashbound::getBound_id, boundDaoList.get(0).getBound_id())
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user