add:新增手持功能
This commit is contained in:
@@ -17,5 +17,5 @@ import java.util.List;
|
||||
*/
|
||||
public interface MdMeMaterialbaseMapper extends BaseMapper<MdMeMaterialbase> {
|
||||
|
||||
List<JSONObject> queryMaterials(@Param("param") JSONObject whereJson);
|
||||
List<JSONObject> selectAllMaters(@Param("param") JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.basedata.material.service.dao.mapper.MdMeMaterialbaseMapper">
|
||||
|
||||
<select id="queryMaterials" resultType="com.alibaba.fastjson.JSONObject">
|
||||
|
||||
<select id="selectAllMaters" resultType="com.alibaba.fastjson.JSONObject"
|
||||
parameterType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
u.unit_name as measure_unit_id
|
||||
FROM
|
||||
`md_me_materialbase` mater
|
||||
LEFT JOIN md_pb_measureunit u ON u.measure_unit_id = mater.measure_unit_id
|
||||
WHERE
|
||||
1=1
|
||||
<if test="param.blurry != null and param.blurry != ''">
|
||||
AND (mater.material_code = #{param.blurry} OR plan.material_name = #{param.blurry})
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -85,7 +85,7 @@ public class PdaTaskController {
|
||||
|
||||
@PostMapping("/comfirmGetting")
|
||||
@Log("确认取货")
|
||||
public ResponseEntity<PdaResponseVo> comfirmGetting(@RequestBody JSONObject whereJson) {
|
||||
public ResponseEntity<Object> comfirmGetting(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaTaskService.comfirmGetting(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -130,6 +130,13 @@ public class PdaTaskController {
|
||||
return new ResponseEntity<>(pdaTaskService.forceConfirm(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/selectRegionInfo")
|
||||
@Log("进入区域信息查询")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> selectRegionInfo(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(pdaTaskService.selectRegionInfo(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,11 +41,13 @@ public interface PdaTaskService {
|
||||
|
||||
PdaResponseVo lock(JSONObject whereJson);
|
||||
|
||||
PdaResponseVo comfirmGetting(JSONObject whereJson);
|
||||
JSONObject comfirmGetting(JSONObject whereJson);
|
||||
|
||||
JSONObject vehicleBinding(JSONObject whereJson);
|
||||
|
||||
JSONObject materialBinding(JSONObject whereJson);
|
||||
|
||||
List<JSONObject> getPointInfo(JSONObject whereJson);
|
||||
JSONObject getPointInfo(JSONObject whereJson);
|
||||
|
||||
JSONObject selectRegionInfo(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -18,6 +19,8 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata.master.unit.service.dao.Measureunit;
|
||||
import org.nl.wms.basedata.master.unit.service.dao.mapper.MeasureunitMapper;
|
||||
import org.nl.wms.basedata.material.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata.material.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata.material.service.dao.mapper.MdMeMaterialbaseMapper;
|
||||
@@ -27,8 +30,12 @@ import org.nl.wms.pda.task.service.dao.dto.MoveDto;
|
||||
import org.nl.wms.pda.task.service.dao.mapper.PdaMapper;
|
||||
import org.nl.wms.pda.task.service.dao.vo.PdaResponseVo;
|
||||
import org.nl.wms.pda.util.PdaResponse;
|
||||
import org.nl.wms.sch.group.service.IMdPbGroupplatedtlService;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlate;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
import org.nl.wms.sch.group.service.dao.mapper.MdPbGroupplateMapper;
|
||||
import org.nl.wms.sch.group.service.dao.mapper.MdPbGroupplatedtlMapper;
|
||||
import org.nl.wms.sch.group.service.enums.GroupStatus;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.point.service.dao.mapper.SchBasePointMapper;
|
||||
@@ -38,6 +45,7 @@ import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task.service.dao.mapper.SchBaseTaskMapper;
|
||||
import org.nl.wms.sch.task_manage.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
|
||||
import org.nl.wms.sch.tasks.PdaPointTask;
|
||||
import org.nl.wms.sch.tasks.netsl.NETSLTask;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
@@ -47,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -67,6 +76,10 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
private PdaPointTask pdaPointTask;
|
||||
@Autowired
|
||||
private MdPbGroupplateMapper groupplateMapper;
|
||||
@Autowired
|
||||
private IMdPbGroupplatedtlService groupplatedtlService;
|
||||
@Autowired
|
||||
private MeasureunitMapper measureunitMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -101,7 +114,6 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
param.put("device_code", point.getPoint_code());
|
||||
param.put("material_code", material_code);
|
||||
param.put("requestNo", IdUtil.simpleUUID());
|
||||
param.put("material_code", material_code);
|
||||
param.put("config_code", "NETSLTask");
|
||||
param.put("vehicle_qty", "1");
|
||||
param.put("user_id", "1");
|
||||
@@ -129,7 +141,7 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
|
||||
private SchBasePoint checkNextPoint(SchBasePoint schBasePoint, String region_code) {
|
||||
//如果是MB物料的上料点 需要下发二次分配点位
|
||||
if ("MB".equals(schBasePoint.getPoint_code())) {
|
||||
if ("MB".contains(schBasePoint.getPoint_code())) {
|
||||
if ("L1".equals(region_code)) {
|
||||
return getWaitPoint(region_code);
|
||||
} else {
|
||||
@@ -205,10 +217,10 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
throw new BadRequestException("点位" + point_code + "不存在!");
|
||||
}
|
||||
JSONObject jo = data.getJSONObject(0);
|
||||
String material_name = jo.getString("material_name");
|
||||
MdMeMaterialbase mdMeMaterialbase = mdMeMaterialbaseMapper.selectOne(new LambdaQueryWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_name, material_name));
|
||||
String material_code = jo.getString("material_code");
|
||||
MdMeMaterialbase mdMeMaterialbase = mdMeMaterialbaseMapper.selectOne(new LambdaQueryWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_code, material_code));
|
||||
if (mdMeMaterialbase == null) {
|
||||
throw new BadRequestException("当前物料不存在【"+material_name+"】");
|
||||
throw new BadRequestException("当前物料不存在【"+material_code+"】");
|
||||
}
|
||||
String vehicleCode = "TP" + TaskUtils.getDateTime("yyMMddHHmmss") + CodeUtil.getNewCode("VEHICLE_CODE");
|
||||
JSONObject param = new JSONObject();
|
||||
@@ -223,44 +235,71 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
param.put("vehicle_code", vehicleCode);
|
||||
param.put("vehicle_qty", "1");
|
||||
param.put("user_id", "1");
|
||||
param.put("region_code", region_code);
|
||||
taskService.apply(param);
|
||||
//维护物料信息
|
||||
packageData(data,point_code);
|
||||
packageData(data,point_code,vehicleCode);
|
||||
return PdaResponseVo.pdaResultOk("任务创建成功");
|
||||
}
|
||||
|
||||
private void packageData(JSONArray data,String point_code) {
|
||||
private void packageData(JSONArray data,String point_code,String vehicleCode) {
|
||||
JSONObject jo = data.getJSONObject(0);
|
||||
String material_name = jo.getString("material_name");
|
||||
MdMeMaterialbase mdMeMaterialbase = mdMeMaterialbaseMapper.selectOne(new LambdaQueryWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_name, material_name));
|
||||
if (mdMeMaterialbase == null) {
|
||||
throw new BadRequestException("当前物料不存在【"+material_name+"】");
|
||||
}
|
||||
String pscn = jo.getString("pscn");
|
||||
String measure_unit_id = jo.getString("measure_unit_id");
|
||||
Measureunit measureunit = measureunitMapper.selectOne(new LambdaQueryWrapper<Measureunit>().eq(Measureunit::getMeasure_unit_id, measure_unit_id));
|
||||
if(StrUtil.isEmpty(vehicleCode)) {
|
||||
vehicleCode = "TP" + TaskUtils.getDateTime("yyMMddHHmmss") + CodeUtil.getNewCode("VEHICLE_CODE");
|
||||
}
|
||||
String group_id = org.nl.common.utils.IdUtil.getStringId();
|
||||
List<String> list = new ArrayList<>();
|
||||
List<GroupPlatedtl> groupPlatedtls = new ArrayList<>();
|
||||
int qty = 0;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
JSONObject jsonObject = data.getJSONObject(i);
|
||||
String container_code = jsonObject.getString("container_code");
|
||||
qty += jsonObject.getIntValue("qty");
|
||||
GroupPlatedtl groupPlatedtlBuilder = GroupPlatedtl.builder()
|
||||
.groupdtl_id(org.nl.common.utils.IdUtil.getStringId())
|
||||
.group_id(group_id)
|
||||
.pcsn(jsonObject.getString("pcsn"))
|
||||
.container_code(container_code)
|
||||
.storagevehicle_code(vehicleCode)
|
||||
.qty(jsonObject.getIntValue("qty"))
|
||||
.material_code(mdMeMaterialbase.getMaterial_code())
|
||||
.material_name(mdMeMaterialbase.getMaterial_name())
|
||||
.measure_unit_id(measure_unit_id)
|
||||
.unit_name(measureunit.getUnit_name())
|
||||
.build();
|
||||
groupPlatedtls.add(groupPlatedtlBuilder);
|
||||
list.add(container_code);
|
||||
}
|
||||
String ext_code = String.join(",", list);
|
||||
String vehicleCode = "TP" + TaskUtils.getDateTime("yyMMddHHmmss") + CodeUtil.getNewCode("VEHICLE_CODE");
|
||||
|
||||
GroupPlate.GroupPlateBuilder groupPlateBuilder = GroupPlate.builder()
|
||||
.group_id(org.nl.common.utils.IdUtil.getStringId())
|
||||
groupplatedtlService.saveBatch(groupPlatedtls);
|
||||
//找到最小卷号
|
||||
String pscn = list.stream().min(String::compareTo).orElse("");
|
||||
GroupPlate groupPlateBuilder = GroupPlate.builder()
|
||||
.group_id(group_id)
|
||||
.material_code(mdMeMaterialbase.getMaterial_code())
|
||||
.material_name(mdMeMaterialbase.getMaterial_name())
|
||||
.pcsn(pscn)
|
||||
.qty(qty)
|
||||
.measure_unit_id(measure_unit_id)
|
||||
.unit_name(measureunit.getUnit_name())
|
||||
.storagevehicle_code(vehicleCode)
|
||||
.ext_code(ext_code)
|
||||
.create_id(SecurityUtils.getCurrentUserId())
|
||||
.create_name(SecurityUtils.getCurrentNickName())
|
||||
.create_time(DateUtil.now());
|
||||
groupplateMapper.insert(groupPlateBuilder.build());
|
||||
.create_time(DateUtil.now())
|
||||
.ext_code(list.toString())
|
||||
.build();
|
||||
groupplateMapper.insert(groupPlateBuilder);
|
||||
SchBasePoint point = pointMapper.selectOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, point_code));
|
||||
point.setStoragevehicle_code(vehicleCode);
|
||||
point.setMaterial_code(mdMeMaterialbase.getMaterial_code());
|
||||
point.setUpdate_time(DateUtil.now());
|
||||
point.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||
point.setPoint_status("2");
|
||||
pointMapper.updateById(point);
|
||||
}
|
||||
@@ -305,11 +344,7 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
|
||||
@Override
|
||||
public JSONObject selectMaterials(JSONObject whereJson) {
|
||||
List<MdMeMaterialbase> list = mdMeMaterialbaseMapper.selectList(
|
||||
new LambdaQueryWrapper<MdMeMaterialbase>().eq(ObjectUtil.isNotEmpty(whereJson.getString("blurry")), MdMeMaterialbase::getMaterial_id, whereJson.getString("blurry"))
|
||||
.or()
|
||||
.eq(ObjectUtil.isNotEmpty(whereJson.getString("blurry")), MdMeMaterialbase::getMaterial_code, whereJson.getString("blurry"))
|
||||
);
|
||||
List<JSONObject> list = mdMeMaterialbaseMapper.selectAllMaters(whereJson);
|
||||
JSONObject ret = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
ret.put("code", String.valueOf(HttpStatus.HTTP_OK));
|
||||
@@ -322,7 +357,43 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
|
||||
@Override
|
||||
public JSONObject getMaterialInfoByPoint(JSONObject whereJson) {
|
||||
return null;
|
||||
String point_code = whereJson.getString("point_code");
|
||||
if (ObjectUtil.isEmpty(point_code)){
|
||||
throw new BadRequestException("点位不能为空!");
|
||||
}
|
||||
SchBasePoint point = pointMapper.selectOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, point_code));
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
throw new BadRequestException("点位不存在!");
|
||||
}
|
||||
String storagevehicle_code = point.getStoragevehicle_code();
|
||||
List<GroupPlatedtl> list = new ArrayList<>();
|
||||
JSONArray arr = new JSONArray();
|
||||
if (ObjectUtil.isNotEmpty(storagevehicle_code)) {
|
||||
GroupPlate groupPlate = groupplateMapper.selectOne(new LambdaQueryWrapper<GroupPlate>()
|
||||
.eq(GroupPlate::getStoragevehicle_code, storagevehicle_code)
|
||||
.eq(GroupPlate::getStatus, GroupStatus.START.getCode()));
|
||||
if (ObjectUtil.isNotEmpty(groupPlate)) {
|
||||
String group_id = groupPlate.getGroup_id();
|
||||
list = groupplatedtlService.getGroupPlatedtlList(group_id);
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
Measureunit measureunit = measureunitMapper.selectOne(new LambdaQueryWrapper<Measureunit>().eq(Measureunit::getMeasure_unit_id, list.get(0).getMeasure_unit_id()));
|
||||
list.forEach(groupPlatedtl -> {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("container_code", groupPlatedtl.getContainer_code());
|
||||
jo.put("material_code", groupPlatedtl.getMaterial_code());
|
||||
jo.put("material_name", groupPlatedtl.getMaterial_name());
|
||||
jo.put("qty", groupPlatedtl.getQty());
|
||||
jo.put("measure_unit_id", measureunit.getUnit_name());
|
||||
arr.add(jo);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONObject ret = new JSONObject();
|
||||
ret.put("code", String.valueOf(HttpStatus.HTTP_OK));
|
||||
ret.put("message", "查询成功");
|
||||
ret.put("data", arr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -366,10 +437,26 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PdaResponseVo comfirmGetting(JSONObject whereJson) {
|
||||
public JSONObject comfirmGetting(JSONObject whereJson) {
|
||||
String point_code = whereJson.getString("point_code");
|
||||
|
||||
return PdaResponseVo.pdaResultOk("取货完成");
|
||||
if (ObjectUtil.isEmpty(point_code)){
|
||||
throw new BadRequestException("点位不能为空!");
|
||||
}
|
||||
SchBasePoint point = pointMapper.selectOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, point_code));
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
throw new BadRequestException("点位不存在!");
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(point.getStoragevehicle_code())){
|
||||
GroupPlate groupPlate = groupplateMapper.selectOne(new LambdaQueryWrapper<GroupPlate>().eq(GroupPlate::getStoragevehicle_code, point.getStoragevehicle_code()));
|
||||
groupPlate.setStatus(GroupStatus.OUT.getCode());
|
||||
}
|
||||
point.setPoint_status(PointStatusEnum.EMPTY_POINT.getCode());
|
||||
point.setStoragevehicle_code("");
|
||||
pointMapper.updateById(point);
|
||||
JSONObject ret = new JSONObject();
|
||||
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||
ret.put("message","操作成功");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -395,7 +482,7 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
if (ObjectUtil.isEmpty(data)){
|
||||
throw new BadRequestException("物料数据不能为空");
|
||||
}
|
||||
packageData(data,point_code);
|
||||
packageData(data,point_code,null);
|
||||
JSONObject ret = new JSONObject();
|
||||
ret.put("status", String.valueOf(HttpStatus.HTTP_OK));
|
||||
ret.put("message","物料绑定成功");
|
||||
@@ -403,9 +490,41 @@ public class PdaTaskServiceImpl implements PdaTaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getPointInfo(JSONObject whereJson) {
|
||||
public JSONObject getPointInfo(JSONObject whereJson) {
|
||||
List<JSONObject> list = pointMapper.queryPointInfo(whereJson);
|
||||
return list;
|
||||
JSONArray arr = new JSONArray();
|
||||
list.forEach(item -> {
|
||||
GroupPlate groupPlate = groupplateMapper.selectOne(new LambdaQueryWrapper<GroupPlate>()
|
||||
.eq(GroupPlate::getStoragevehicle_code, item.getString("storagevehicle_code"))
|
||||
.eq(GroupPlate::getStatus, GroupStatus.START.getCode()));
|
||||
if (ObjectUtil.isEmpty(groupPlate)){
|
||||
return;
|
||||
}
|
||||
List<GroupPlatedtl> groupPlatedtlList = groupplatedtlService.getGroupPlatedtlList(item.getString("group_id"));
|
||||
List<String> containerCodeList = groupPlatedtlList.stream()
|
||||
.map(GroupPlatedtl::getContainer_code)
|
||||
.collect(Collectors.toList());
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("point_code", item.getString("point_code"));
|
||||
jo.put("is_used", item.getString("is_used"));
|
||||
jo.put("material_code", item.getString("material_code"));
|
||||
jo.put("material_name", item.getString("material_name"));
|
||||
jo.put("qty", item.getString("qty"));
|
||||
jo.put("measure_unit_id", item.getString("unit_name"));
|
||||
jo.put("containers", containerCodeList);
|
||||
arr.add(jo);
|
||||
});
|
||||
JSONObject ret = new JSONObject();
|
||||
ret.put("code", String.valueOf(HttpStatus.HTTP_OK));
|
||||
ret.put("message", "查询成功");
|
||||
ret.put("data", arr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject selectRegionInfo(JSONObject whereJson) {
|
||||
PageHelper.startPage(whereJson.getIntValue("page"), whereJson.getIntValue("size"));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.nl.wms.sch.group.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -11,13 +13,20 @@ import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata.master.vehicle.service.IStoragevehicleinfoService;
|
||||
import org.nl.wms.basedata.master.vehicle.service.dao.Storagevehicleinfo;
|
||||
import org.nl.wms.basedata.material.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata.material.service.dao.mapper.MdMeMaterialbaseMapper;
|
||||
import org.nl.wms.sch.group.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.sch.group.service.IMdPbGroupplatedtlService;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlate;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
import org.nl.wms.sch.group.service.dao.mapper.MdPbGroupplateMapper;
|
||||
import org.nl.wms.sch.group.service.enums.GroupStatus;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -25,8 +34,11 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,6 +59,12 @@ public class GroupController {
|
||||
private final IMdPbGroupplateService iMdPbGroupplateService;
|
||||
@Autowired
|
||||
private final IStoragevehicleinfoService iStoragevehicleinfoService;
|
||||
@Autowired
|
||||
private MdMeMaterialbaseMapper mdMeMaterialbaseMapper;
|
||||
@Autowired
|
||||
private MdPbGroupplateMapper groupplateMapper;
|
||||
@Autowired
|
||||
private IMdPbGroupplatedtlService groupplatedtlService;
|
||||
|
||||
|
||||
@GetMapping
|
||||
@@ -59,19 +77,60 @@ public class GroupController {
|
||||
@PostMapping
|
||||
@Log("新增组盘组盘")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject group) {
|
||||
Assert.noNullElements(new Object[]{group,group.get("material_code"),group.get("storagevehicle_code"),group.get("qty")},"请求参数不能为空");
|
||||
GroupPlate groupPlate = group.toJavaObject(GroupPlate.class);
|
||||
Storagevehicleinfo one = iStoragevehicleinfoService.getOne(new LambdaQueryWrapper<Storagevehicleinfo>()
|
||||
.eq(Storagevehicleinfo::getStoragevehicle_code, groupPlate.getStoragevehicle_code()));
|
||||
if (one != null){
|
||||
throw new BadRequestException("当前载具组盘信息已存在");
|
||||
JSONArray tableData = group.getJSONArray("tableData");
|
||||
List<JSONObject> rows = tableData.stream()
|
||||
.map(row -> JSONObject.parseObject(JSON.toJSONString(row)))
|
||||
.collect(Collectors.toList());
|
||||
JSONObject jo = rows.get(0);
|
||||
String material_name = jo.getString("material_name");
|
||||
MdMeMaterialbase mdMeMaterialbase = mdMeMaterialbaseMapper.selectOne(new LambdaQueryWrapper<MdMeMaterialbase>().eq(MdMeMaterialbase::getMaterial_name, material_name));
|
||||
if (mdMeMaterialbase == null) {
|
||||
throw new BadRequestException("当前物料不存在【"+material_name+"】");
|
||||
}
|
||||
groupPlate.setGroup_id(IdUtil.getStringId());
|
||||
groupPlate.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
groupPlate.setCreate_name(SecurityUtils.getCurrentUsername());
|
||||
groupPlate.setCreate_time(DateUtil.now());
|
||||
groupPlate.setStatus(GroupStatus.START.getCode());
|
||||
iMdPbGroupplateService.save(groupPlate);
|
||||
String measure_unit_id = jo.getString("measure_unit_id");
|
||||
String unit_name = jo.getString("unit_name");
|
||||
String vehicleCode = "TP" + TaskUtils.getDateTime("yyMMddHHmmss") + CodeUtil.getNewCode("VEHICLE_CODE");
|
||||
String group_id = org.nl.common.utils.IdUtil.getStringId();
|
||||
List<String> list = new ArrayList<>();
|
||||
List<GroupPlatedtl> groupPlatedtls = new ArrayList<>();
|
||||
int qty = 0;
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jsonObject = rows.get(i);
|
||||
String container_code = jsonObject.getString("container_code");
|
||||
qty += jsonObject.getIntValue("qty");
|
||||
GroupPlatedtl groupPlatedtlBuilder = GroupPlatedtl.builder()
|
||||
.groupdtl_id(org.nl.common.utils.IdUtil.getStringId())
|
||||
.group_id(group_id)
|
||||
.pcsn(jsonObject.getString("pcsn"))
|
||||
.container_code(container_code)
|
||||
.storagevehicle_code(vehicleCode)
|
||||
.qty(jsonObject.getIntValue("qty"))
|
||||
.material_code(mdMeMaterialbase.getMaterial_code())
|
||||
.material_name(mdMeMaterialbase.getMaterial_name())
|
||||
.measure_unit_id(measure_unit_id)
|
||||
.unit_name(unit_name)
|
||||
.build();
|
||||
groupPlatedtls.add(groupPlatedtlBuilder);
|
||||
list.add(container_code);
|
||||
}
|
||||
groupplatedtlService.saveBatch(groupPlatedtls);
|
||||
//找到最小卷号
|
||||
String pscn = list.stream().min(String::compareTo).orElse("");
|
||||
GroupPlate groupPlateBuilder = GroupPlate.builder()
|
||||
.group_id(group_id)
|
||||
.material_code(mdMeMaterialbase.getMaterial_code())
|
||||
.material_name(mdMeMaterialbase.getMaterial_name())
|
||||
.pcsn(pscn)
|
||||
.qty(qty)
|
||||
.measure_unit_id(measure_unit_id)
|
||||
.unit_name(unit_name)
|
||||
.storagevehicle_code(vehicleCode)
|
||||
.create_id(SecurityUtils.getCurrentUserId())
|
||||
.create_name(SecurityUtils.getCurrentNickName())
|
||||
.create_time(DateUtil.now())
|
||||
.ext_code(list.toString())
|
||||
.build();
|
||||
groupplateMapper.insert(groupPlateBuilder);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -81,4 +140,11 @@ public class GroupController {
|
||||
iMdPbGroupplateService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getDtl")
|
||||
@Log("查询明细")
|
||||
|
||||
public ResponseEntity<Object> getOutBillDtl(@RequestParam Map whereJson) {
|
||||
return new ResponseEntity<>(iMdPbGroupplateService.getDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.wms.sch.group.controller;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/groupdtl")
|
||||
@Slf4j
|
||||
public class GroupdtlController {
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.sch.group.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -35,4 +36,5 @@ public interface IMdPbGroupplateService extends IService<GroupPlate> {
|
||||
void delete(Set<String> ids);
|
||||
|
||||
|
||||
JSONArray getDtl(Map whereJson);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.nl.wms.sch.group.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IMdPbGroupplatedtlService extends IService<GroupPlatedtl> {
|
||||
List<GroupPlatedtl> getGroupPlatedtlList(String groupId);
|
||||
}
|
||||
@@ -38,6 +38,11 @@ public class GroupPlate implements Serializable {
|
||||
*/
|
||||
private String material_code;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
private String material_name;
|
||||
|
||||
|
||||
/**
|
||||
* 批次
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package org.nl.wms.sch.group.service.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("md_pb_groupplatedtl")
|
||||
public class GroupPlatedtl {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 组盘明细标识
|
||||
*/
|
||||
@TableId("groupdtl_id")
|
||||
private String groupdtl_id;
|
||||
|
||||
/**
|
||||
* 组盘标识
|
||||
*/
|
||||
private String group_id;
|
||||
|
||||
/**
|
||||
* 载具编码
|
||||
*/
|
||||
private String storagevehicle_code;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String material_code;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
private String material_name;
|
||||
|
||||
/**
|
||||
* 卷号
|
||||
*/
|
||||
private String container_code;
|
||||
|
||||
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
private String pcsn;
|
||||
|
||||
/**
|
||||
* 计量单位标识
|
||||
*/
|
||||
private String measure_unit_id;
|
||||
|
||||
/**
|
||||
* 计量单位名称
|
||||
*/
|
||||
private String unit_name;
|
||||
|
||||
/**
|
||||
* 组盘数量
|
||||
*/
|
||||
private int qty;
|
||||
|
||||
/**
|
||||
* 冻结数量
|
||||
*/
|
||||
private int frozen_qty;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private int is_delete;
|
||||
|
||||
|
||||
/**
|
||||
* 组盘人
|
||||
*/
|
||||
private String create_id;
|
||||
|
||||
/**
|
||||
* 组盘人名称
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 组盘时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String update_id;
|
||||
|
||||
/**
|
||||
* 修改人姓名
|
||||
*/
|
||||
private String update_name;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private String update_time;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.wms.sch.group.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MdPbGroupplatedtlMapper extends BaseMapper<GroupPlatedtl> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.nl.wms.sch.group.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
|
||||
@Data
|
||||
public class GroupPlatedtlDto extends GroupPlatedtl {
|
||||
}
|
||||
@@ -7,7 +7,8 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum GroupStatus {
|
||||
START("1","生成");
|
||||
START("1","组盘入库"),
|
||||
OUT("2","出库");
|
||||
private String code;
|
||||
private String desc;
|
||||
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package org.nl.wms.sch.group.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.sch.group.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlate;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
import org.nl.wms.sch.group.service.dao.mapper.MdPbGroupplateMapper;
|
||||
import org.nl.wms.sch.group.service.dao.mapper.MdPbGroupplatedtlMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -25,6 +31,8 @@ import java.util.Set;
|
||||
*/
|
||||
@Service
|
||||
public class MdPbGroupplateServiceImpl extends ServiceImpl<MdPbGroupplateMapper, GroupPlate> implements IMdPbGroupplateService {
|
||||
@Autowired
|
||||
private MdPbGroupplatedtlMapper mdPbGroupplatedtlMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -39,5 +47,16 @@ public class MdPbGroupplateServiceImpl extends ServiceImpl<MdPbGroupplateMapper,
|
||||
this.baseMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDtl(Map whereJson) {
|
||||
String group_id = (String) whereJson.get("group_id");
|
||||
List<GroupPlatedtl> list = mdPbGroupplatedtlMapper.selectList(new LambdaQueryWrapper<GroupPlatedtl>().eq(GroupPlatedtl::getGroup_id, group_id));
|
||||
if (list != null){
|
||||
JSONArray arr = JSONArray.parseArray(JSON.toJSONString(list));
|
||||
return arr;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.wms.sch.group.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.wms.sch.group.service.IMdPbGroupplatedtlService;
|
||||
import org.nl.wms.sch.group.service.dao.GroupPlatedtl;
|
||||
import org.nl.wms.sch.group.service.dao.mapper.MdPbGroupplatedtlMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MdPbGroupplatedtlServiceImpl extends ServiceImpl<MdPbGroupplatedtlMapper, GroupPlatedtl> implements IMdPbGroupplatedtlService {
|
||||
|
||||
@Autowired
|
||||
private MdPbGroupplatedtlMapper mdpbGroupplatedtlMapper;
|
||||
@Override
|
||||
public List<GroupPlatedtl> getGroupPlatedtlList(String groupId) {
|
||||
List<GroupPlatedtl> list = mdpbGroupplatedtlMapper.selectList(new LambdaQueryWrapper<GroupPlatedtl>().eq(GroupPlatedtl::getGroup_id, groupId));
|
||||
return list.size() > 0 ? list : null;
|
||||
}
|
||||
}
|
||||
@@ -79,4 +79,10 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
|
||||
TableDataInfo<RegionStructIvtVo> queryStruct(RegionStructQuery query, PageQuery pageQuery);
|
||||
|
||||
SchBasePoint findByCode(String point_code);
|
||||
|
||||
List<SchBasePoint> getSamePoints(String regionCode, String material_code);
|
||||
|
||||
List<SchBasePoint> getPointByMaxCol(String regionCode, int col);
|
||||
|
||||
List<SchBasePoint> getEmptyPoints(String regionCode);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,8 @@ public interface SchBasePointMapper extends BaseMapper<SchBasePoint> {
|
||||
List<SchBasePoint> selectListByRegion(String region);
|
||||
|
||||
List<JSONObject> queryPointInfo(@Param("param") JSONObject whereJson);
|
||||
|
||||
List<SchBasePoint> getPointByMaxCol(@Param("regionCode") String regionCode, @Param("col") int col);
|
||||
|
||||
List<SchBasePoint> getEmptyPoints(@Param("regionCode") String regionCode);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
md_pb_groupplate.frozen_qty,
|
||||
md_pb_groupplate.unit_name,
|
||||
md_pb_groupplate.status,
|
||||
md_pb_groupplate.inbound_time,
|
||||
md_pb_groupplate.create_time as inbound_time,
|
||||
md_pb_groupplate.remark
|
||||
from sch_base_point
|
||||
inner join md_pb_groupplate on sch_base_point.storagevehicle_code = md_pb_groupplate.storagevehicle_code
|
||||
@@ -104,28 +104,83 @@
|
||||
<select id="queryPointInfo" resultType="com.alibaba.fastjson.JSONObject"
|
||||
parameterType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
p.point_code,
|
||||
CASE p.is_used
|
||||
WHEN 1 THEN '未锁定'
|
||||
WHEN 0 THEN '锁定'
|
||||
ELSE ''
|
||||
END AS is_used,
|
||||
p.storagevehicle_code,
|
||||
plate.unit_name ,
|
||||
plate.group_id,
|
||||
plate.storagevehicle_code,
|
||||
plate.qty_unit_name AS unit_code,
|
||||
plate.qty,
|
||||
plate.frozen_qty,
|
||||
mater.material_code,
|
||||
mater.material_name
|
||||
plate.material_code,
|
||||
plate.material_name,
|
||||
dtl.container_code
|
||||
FROM
|
||||
md_pb_groupplate plate
|
||||
LEFT JOIN md_me_materialbase mater ON mater.material_id = plate.material_id
|
||||
LEFT JOIN st_ivt_structattr struct ON struct.storagevehicle_code = plate.storagevehicle_code
|
||||
sch_base_point p
|
||||
LEFT JOIN md_pb_groupplate plate ON plate.storagevehicle_code = p.storagevehicle_code
|
||||
LEFT JOIN md_pb_groupplatedtl dtl ON dtl.group_id = plate.group_id
|
||||
WHERE
|
||||
1 =1
|
||||
and plate.status='02'
|
||||
and plate.qty > 0
|
||||
<if test="param.struct_code != null and param.struct_code != ''">
|
||||
plate.status='1'
|
||||
<if test="param.region_code != null and param.region_code != ''">
|
||||
AND
|
||||
struct.struct_code = #{param.struct_code}
|
||||
p.region_code = #{param.region_code}
|
||||
</if>
|
||||
<if test="param.vehicle_code != null and param.vehicle_code != ''">
|
||||
<if test="param.point_code != null and param.point_code != ''">
|
||||
AND
|
||||
plate.storagevehicle_code = #{param.vehicle_code}
|
||||
p.point_code = #{param.point_code}
|
||||
</if>
|
||||
<if test="param.material_code != null and param.material_code != ''">
|
||||
AND
|
||||
plate.material_code = #{param.material_code}
|
||||
</if>
|
||||
GROUP BY p.point_code
|
||||
</select>
|
||||
<select id="getPointByMaxCol" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
`sch_base_point`
|
||||
WHERE
|
||||
region_code = #{region_code}
|
||||
AND col_num = #{col}
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task
|
||||
WHERE (point_code1 = p.point_code
|
||||
OR point_code2 = p.point_code
|
||||
OR point_code3 = p.point_code
|
||||
OR point_code4 = p.point_code)
|
||||
AND task_status <![CDATA[<]]> '5'
|
||||
AND is_delete = '0'
|
||||
)
|
||||
AND point_type = '1'
|
||||
AND is_used = 1
|
||||
ORDER BY
|
||||
col_num DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
<select id="getEmptyPoints" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint"
|
||||
parameterType="java.lang.String">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
`sch_base_point`
|
||||
WHERE
|
||||
region_code = #{regionCode}
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task
|
||||
WHERE (point_code1 = p.point_code
|
||||
OR point_code2 = p.point_code
|
||||
OR point_code3 = p.point_code
|
||||
OR point_code4 = p.point_code)
|
||||
AND task_status <![CDATA[<]]> '5'
|
||||
)
|
||||
AND point_type = '1'
|
||||
AND is_used = 1
|
||||
AND point_stattus = '0'
|
||||
ORDER BY out_order_seq
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.sch.point.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -204,4 +205,35 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
SchBasePoint point = pointMapper.selectOne(new LambdaQueryWrapper<SchBasePoint>().eq(SchBasePoint::getPoint_code, point_code));
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBasePoint> getSamePoints(String regionCode, String material_code) {
|
||||
LambdaQueryWrapper<SchBasePoint> queryWrapper = new LambdaQueryWrapper<SchBasePoint>()
|
||||
.eq(SchBasePoint::getRegion_code, regionCode)
|
||||
.eq(SchBasePoint::getMaterial_code, material_code)
|
||||
.orderByAsc(SchBasePoint::getIn_order_seq);
|
||||
List<SchBasePoint> list = pointMapper.selectList(queryWrapper);
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBasePoint> getPointByMaxCol(String regionCode, int col) {
|
||||
List<SchBasePoint> list = pointMapper.getPointByMaxCol(regionCode, col);
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBasePoint> getEmptyPoints(String regionCode) {
|
||||
List<SchBasePoint> list = pointMapper.getEmptyPoints(regionCode);
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
return list;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,4 +113,12 @@ public interface ISchBaseTaskService extends IService<SchBaseTask> {
|
||||
* @return SchBaseTask
|
||||
*/
|
||||
SchBaseTask getByCode(String taskCode);
|
||||
|
||||
/**
|
||||
* 根据任务配置查询同台设备未完成的任务列表
|
||||
* @param config_code 任务配置
|
||||
* @param newPoint_code 设备
|
||||
* @return List<SchBaseTask>
|
||||
*/
|
||||
List<SchBaseTask> findUnFinishTasksByTaskConfigAndPointCode(String config_code, String newPoint_code);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public class SchBaseTask implements Serializable {
|
||||
|
||||
/** 更新时间 */
|
||||
private String update_time;
|
||||
private String request_param;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String task_type;
|
||||
|
||||
@@ -126,7 +126,7 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
Assert.notNull(config_code, "任务配置编码不能为空!");
|
||||
LambdaQueryWrapper<SchBaseTask> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq(SchBaseTask::getConfig_code, config_code)
|
||||
.ne(SchBaseTask::getIs_delete, true)
|
||||
.ne(SchBaseTask::getIs_delete, false)
|
||||
.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode());
|
||||
List<SchBaseTask> schBaseTasks = schBaseTaskMapper.selectList(lam);
|
||||
return schBaseTasks;
|
||||
@@ -262,4 +262,22 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
||||
return this.getOne(lam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBaseTask> findUnFinishTasksByTaskConfigAndPointCode(String config_code, String newPoint_code) {
|
||||
Assert.notNull(config_code, "任务配置编码不能为空!");
|
||||
LambdaQueryWrapper<SchBaseTask> lam = new LambdaQueryWrapper<>();
|
||||
lam.eq(SchBaseTask::getConfig_code, config_code)
|
||||
.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
|
||||
.and(la -> la.eq(SchBaseTask::getPoint_code1, newPoint_code)
|
||||
.or()
|
||||
.eq(SchBaseTask::getPoint_code2, newPoint_code)
|
||||
.or()
|
||||
.eq(SchBaseTask::getPoint_code3, newPoint_code)
|
||||
.or()
|
||||
.eq(SchBaseTask::getPoint_code4, newPoint_code))
|
||||
.eq(SchBaseTask::getIs_delete, false);
|
||||
List<SchBaseTask> schBaseTasks = schBaseTaskMapper.selectList(lam);
|
||||
return schBaseTasks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.nl.config.SpringContextHolder;
|
||||
import org.nl.config.language.LangProcess;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
@@ -300,6 +301,7 @@ AbstractTask {
|
||||
task.setVehicle_type(vehicleType);
|
||||
task.setMaterial_code(material_code);
|
||||
task.setTask_status(TaskStatus.APPLY.getCode());
|
||||
task.setRequest_param(JSONObject.toJSONString(param));
|
||||
// 将所有参数存到表中,后续需要可以提取
|
||||
TaskUtils.setCreateByAcsOrPda(task, param);
|
||||
setTaskPoint(taskConfig, task, param.getString("device_code"));
|
||||
|
||||
@@ -31,7 +31,7 @@ public class AutoCreateTask {
|
||||
private Map<Class<?>, Method> methodCache = new HashMap<>();
|
||||
// 类加载时候执行扫描
|
||||
static {
|
||||
Reflections reflections = new Reflections("org.nl.wms.sch.task_manage.task.tasks");
|
||||
Reflections reflections = new Reflections("org.nl.wms.sch.tasks");
|
||||
subTypes = reflections.getSubTypesOf(AbstractTask.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,8 +112,9 @@ public class PdaPointTask extends AbstractTask {
|
||||
|
||||
private SchBasePoint findStartPoint(List<String> startRegionStr) {
|
||||
// 钢托盘缓存区域的空盘是1 状态不同
|
||||
List<SchBasePoint> points = NETXLMapper.findPointForNETXL(startRegionStr);
|
||||
return ObjectUtil.isNotEmpty(points) ? points.get(0) : null;
|
||||
// List<SchBasePoint> points = NETXLMapper.findPointForNETXL(startRegionStr);
|
||||
// return ObjectUtil.isNotEmpty(points) ? points.get(0) : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,14 @@
|
||||
WHERE (
|
||||
(p.point_type = '1' AND p.region_code = #{startRegionStr[0]})
|
||||
)
|
||||
AND (p.ing_task_code = '' OR p.ing_task_code IS NULL)
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task
|
||||
WHERE (point_code1 = p.point_code
|
||||
OR point_code2 = p.point_code)
|
||||
AND task_status <![CDATA[<]]> '5'
|
||||
AND is_delete = '0'
|
||||
)
|
||||
AND g.material_code = #{material_code}
|
||||
AND p.point_status = '2'
|
||||
AND p.is_used = 1
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.nl.wms.sch.tasks.netxl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
@@ -24,6 +26,7 @@ import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -44,7 +47,7 @@ public class NETXLTask extends AbstractTask {
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
@Autowired
|
||||
private NETXLMapper NETXLMapper;
|
||||
private NETXLMapper netxlMapper;
|
||||
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
@@ -55,10 +58,13 @@ public class NETXLTask extends AbstractTask {
|
||||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
||||
for (SchBaseTask task : tasks) {
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(","))
|
||||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(","))
|
||||
.collect(Collectors.toList());
|
||||
// 找终点
|
||||
SchBasePoint point = findStartPoint(startRegionStr);
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject jsonObject = JSONObject.parseObject(requestParam);
|
||||
String regionCode = jsonObject.getString("region_code");
|
||||
SchBasePoint point = findNextPoint(nextRegionStr, regionCode, task.getMaterial_code());
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
task.setRemark("未找到所需点位!");
|
||||
taskService.updateById(task);
|
||||
@@ -68,8 +74,12 @@ public class NETXLTask extends AbstractTask {
|
||||
continue;
|
||||
}
|
||||
// 设置终点并修改创建成功状态
|
||||
task.setPoint_code1(point.getPoint_code());
|
||||
task.setPoint_code2(point.getPoint_code());
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
if ("E2".equals(regionCode)) {
|
||||
//设置等待点
|
||||
task.setPoint_code3(point.getParent_point_code());
|
||||
}
|
||||
task.setRemark("");
|
||||
taskService.updateById(task);
|
||||
|
||||
@@ -86,18 +96,25 @@ public class NETXLTask extends AbstractTask {
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(","))
|
||||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(","))
|
||||
.collect(Collectors.toList());
|
||||
// 找起点
|
||||
SchBasePoint point = findStartPoint(startRegionStr);
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject jsonObject = JSONObject.parseObject(requestParam);
|
||||
String regionCode = jsonObject.getString("region_code");
|
||||
SchBasePoint point = findNextPoint(nextRegionStr, regionCode, task.getMaterial_code());
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
// 消息通知
|
||||
noticeService.createNotice("货架暂无托盘!", TASK_CONFIG_CODE + task.getPoint_code2(),
|
||||
noticeService.createNotice("E反保管区没有空闲的点位!", TASK_CONFIG_CODE + task.getPoint_code1(),
|
||||
NoticeTypeEnum.WARN.getCode());
|
||||
throw new BadRequestException("货架暂无托盘!");
|
||||
throw new BadRequestException("E反保管区没有空闲的点位!");
|
||||
}
|
||||
// 设置终点并修改创建成功状态
|
||||
task.setPoint_code1(point.getPoint_code());
|
||||
task.setPoint_code2(point.getPoint_code());
|
||||
if ("E2".equals(regionCode)) {
|
||||
//设置等待点
|
||||
task.setPoint_code3(point.getParent_point_code());
|
||||
}
|
||||
task.setRemark("");
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
taskService.save(task);
|
||||
@@ -107,12 +124,91 @@ public class NETXLTask extends AbstractTask {
|
||||
pointService.updateById(point);
|
||||
}
|
||||
|
||||
private SchBasePoint findStartPoint(List<String> startRegionStr) {
|
||||
// 钢托盘缓存区域的空盘是1 状态不同
|
||||
List<SchBasePoint> points = NETXLMapper.findPointForNETXL(startRegionStr);
|
||||
return ObjectUtil.isNotEmpty(points) ? points.get(0) : null;
|
||||
private SchBasePoint findNextPoint(List<String> nextRegionStr, String regionCode, String material_code) {
|
||||
// 找到同一个区域下物料相同的所有点位
|
||||
if ("E2".equals(regionCode)) {
|
||||
List<SchBasePoint> list = pointService.getSamePoints(regionCode, material_code);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SchBasePoint point = list.get(0);
|
||||
int col_num = point.getCol_num();
|
||||
if (col_num == 1) {
|
||||
continue;
|
||||
}
|
||||
SchBasePoint newPoint;
|
||||
String newPoint_code = "";
|
||||
int new_col = col_num-1;
|
||||
// 校验当前点位相邻的点是否空闲
|
||||
for (int j = 0; j < (col_num - 1); j++) {
|
||||
newPoint_code = forametDevice_code(point.getPoint_code(), new_col);
|
||||
newPoint = pointService.findByCode(newPoint_code);
|
||||
Boolean result = this.checkIsFree(newPoint_code);
|
||||
if (!result) {
|
||||
col_num = col_num - 1;
|
||||
point = newPoint;
|
||||
continue;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
}
|
||||
} else if (CollectionUtils.isEmpty(list)){
|
||||
//找一排都是空的点位
|
||||
//找最大列为空且没有任务的点位
|
||||
List<SchBasePoint> points = pointService.getPointByMaxCol(regionCode, 3);
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
SchBasePoint thirdColPoint = points.get(0);
|
||||
String firstColPointCode = thirdColPoint.getPoint_code().substring(0, thirdColPoint.getPoint_code().length() - 1) + "1";
|
||||
String secondColPointCode = thirdColPoint.getPoint_code().substring(0, thirdColPoint.getPoint_code().length() - 1) + "2";
|
||||
|
||||
// 查询第一列和第二列点位
|
||||
SchBasePoint firstColPoint = pointService.findByCode(firstColPointCode);
|
||||
SchBasePoint secondColPoint = pointService.findByCode(secondColPointCode);
|
||||
// 判断第一列和第二列点位是否为空且没有任务
|
||||
boolean isFirstColFree = checkIsEmpty(firstColPoint);
|
||||
boolean isSecondColFree = checkIsEmpty(secondColPoint);
|
||||
// 如果第一列和第二列都为空,则返回这个第三列点位
|
||||
if (isFirstColFree && isSecondColFree) {
|
||||
return thirdColPoint;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
//E1
|
||||
List<SchBasePoint> points = netxlMapper.findPointForNETXL(nextRegionStr, regionCode);
|
||||
return ObjectUtil.isNotEmpty(points) ? points.get(0) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkIsEmpty(SchBasePoint point) {
|
||||
if (point.getPoint_status().equals(PointStatusEnum.EMPTY_POINT.getCode()) && StrUtil.isEmpty(point.getIng_task_code())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Boolean checkIsFree(String point_code) {
|
||||
SchBasePoint newPoint = pointService.findByCode(point_code);
|
||||
// 判断点位是否有货
|
||||
if (newPoint.getPoint_status().equals(PointStatusEnum.EMPTY_VEHICLE.getCode())) {
|
||||
return false;
|
||||
}
|
||||
List<SchBaseTask> list = taskService.findUnFinishTasksByTaskConfigAndPointCode("NETSLTask", point_code);
|
||||
if (list.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private String forametDevice_code(String point_code, int col_num) {
|
||||
return point_code.substring(0, point_code.length() - 1) + (col_num);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateStatus(String task_code, TaskStatus status) {
|
||||
// 校验任务
|
||||
@@ -167,8 +263,7 @@ public class NETXLTask extends AbstractTask {
|
||||
PointUtils.setUpdateByType(startPointObj, taskFinishedType);
|
||||
PointUtils.clearPoint(startPointObj);
|
||||
endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode());
|
||||
// endPointObj.setVehicle_type(GeneralDefinition.STEEL_TRAY);
|
||||
// endPointObj.setVehicle_qty(taskObj.getVehicle_qty());
|
||||
endPointObj.setStoragevehicle_code(taskObj.getVehicle_code());
|
||||
endPointObj.setUpdate_time(DateUtil.now());
|
||||
PointUtils.setUpdateByType(endPointObj, taskFinishedType);
|
||||
pointService.updateById(endPointObj);
|
||||
|
||||
@@ -5,5 +5,5 @@ import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import java.util.List;
|
||||
|
||||
public interface NETXLMapper {
|
||||
List<SchBasePoint> findPointForNETXL(List<String> startRegionStr);
|
||||
List<SchBasePoint> findPointForNETXL(List<String> nextRegionStrs,String regionCode);
|
||||
}
|
||||
|
||||
@@ -4,17 +4,24 @@
|
||||
<select id="findPointForNETXL" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
|
||||
SELECT p.*
|
||||
FROM `sch_base_point` p
|
||||
WHERE (
|
||||
(p.point_type = '1' AND p.region_code = #{regionCode[0]})
|
||||
WHERE
|
||||
p.point_type = '1'
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task
|
||||
WHERE (point_code1 = p.point_code
|
||||
OR point_code2 = p.point_code)
|
||||
AND task_status <![CDATA[<]]> '5'
|
||||
AND is_delete = '0'
|
||||
)
|
||||
AND (p.ing_task_code = '' OR p.ing_task_code IS NULL)
|
||||
AND p.point_status = '2'
|
||||
AND p.point_status = '1'
|
||||
AND p.is_used = 1
|
||||
AND p.region_code = #{regionCode}
|
||||
AND p.region_code IN
|
||||
<foreach collection="regionCode" item="code" separator="," open="(" close=")">
|
||||
<foreach collection="nextRegionStrs" item="code" separator="," open="(" close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
ORDER BY
|
||||
p.out_empty_seq ASC
|
||||
p.in_order_seq ASC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.sch.tasks.thsl;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
@@ -63,7 +64,7 @@ public class THSLTask extends AbstractTask {
|
||||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(","))
|
||||
.collect(Collectors.toList());
|
||||
// 找起点
|
||||
SchBasePoint point = findStartPoint(startRegionStr, task.getMaterial_code());
|
||||
SchBasePoint point = findStartPoint(startRegionStr,task.getMaterial_code());
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
task.setRemark("未找到所需点位!");
|
||||
taskService.updateById(task);
|
||||
@@ -116,7 +117,7 @@ public class THSLTask extends AbstractTask {
|
||||
|
||||
private SchBasePoint findStartPoint(List<String> startRegionStr, String material_code) {
|
||||
|
||||
// 钢托盘缓存区域的空盘是1 状态不同
|
||||
// 根据物料和区域找到无任务的点位
|
||||
List<SchBasePointDto> points = thslMapper.findPointForTHSL(startRegionStr, material_code);
|
||||
//找到最小PCSN的点位
|
||||
SchBasePointDto schBasePointDto = points.stream()
|
||||
@@ -126,24 +127,25 @@ public class THSLTask extends AbstractTask {
|
||||
}
|
||||
String region_code = schBasePointDto.getRegion_code();
|
||||
String point_code = schBasePointDto.getPoint_code();
|
||||
SchBasePoint point = pointService.findByCode(point_code);
|
||||
if ("E2".equals(region_code)) {
|
||||
return getWaitPoint(point_code);
|
||||
return getWaitPoint(point);
|
||||
} else if ("H1".equals(schBasePointDto.getRegion_code())) {
|
||||
return getWaitPoint(point_code);
|
||||
return getWaitPoint(point);
|
||||
} else if ("H2".equals(schBasePointDto.getRegion_code())) {
|
||||
return getWaitPoint(point_code);
|
||||
return getWaitPoint(point);
|
||||
}else {
|
||||
return ObjectUtil.isNotEmpty(schBasePointDto) ? Convert.convert(SchBasePoint.class, schBasePointDto) : null;
|
||||
}
|
||||
}
|
||||
|
||||
private SchBasePoint getWaitPoint(String point_code) {
|
||||
private SchBasePoint getWaitPoint(SchBasePoint point) {
|
||||
//查找该区域空闲的等待点
|
||||
SchBasePoint point = pointService.findByCode(point_code.substring(0, point_code.length() - 2) + "00");
|
||||
if (ObjectUtil.isEmpty(point)){
|
||||
throw new BadRequestException("未找到点位编码为【" + point_code + "】所需的等待点位!");
|
||||
SchBasePoint waitPoint = pointService.findByCode(point.getParent_point_code());
|
||||
if (ObjectUtil.isEmpty(waitPoint)){
|
||||
throw new BadRequestException("未找到点位编码为【" + point.getParent_point_code() + "】所需的等待点位!");
|
||||
}
|
||||
return point;
|
||||
return waitPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -200,8 +202,7 @@ public class THSLTask extends AbstractTask {
|
||||
PointUtils.setUpdateByType(startPointObj, taskFinishedType);
|
||||
PointUtils.clearPoint(startPointObj);
|
||||
endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode());
|
||||
// endPointObj.setVehicle_type(GeneralDefinition.STEEL_TRAY);
|
||||
// endPointObj.setVehicle_qty(taskObj.getVehicle_qty());
|
||||
endPointObj.setStoragevehicle_code(taskObj.getVehicle_code());
|
||||
endPointObj.setUpdate_time(DateUtil.now());
|
||||
PointUtils.setUpdateByType(endPointObj, taskFinishedType);
|
||||
pointService.updateById(endPointObj);
|
||||
|
||||
@@ -10,7 +10,14 @@
|
||||
WHERE (
|
||||
(p.point_type = '1' AND p.region_code = #{startRegionStr[0]})
|
||||
)
|
||||
AND (p.ing_task_code = '' OR p.ing_task_code IS NULL)
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task
|
||||
WHERE (point_code1 = p.point_code
|
||||
OR point_code2 = p.point_code)
|
||||
AND task_status <![CDATA[<]]> '5'
|
||||
AND is_delete = '0'
|
||||
)
|
||||
AND g.material_code = #{material_code}
|
||||
AND p.point_status = '2'
|
||||
AND p.is_used = 1
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.nl.wms.sch.tasks.thxl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
@@ -19,11 +21,13 @@ import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.task.TaskType;
|
||||
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
||||
import org.nl.wms.sch.tasks.netxl.mapper.NETXLMapper;
|
||||
import org.nl.wms.sch.tasks.thxl.mapper.THXLMapper;
|
||||
import org.nl.wms.util.PointUtils;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -43,7 +47,7 @@ public class THXLTask extends AbstractTask {
|
||||
@Autowired
|
||||
private ISysNoticeService noticeService;
|
||||
@Autowired
|
||||
private NETXLMapper NETXLMapper;
|
||||
private THXLMapper thxlMapper;
|
||||
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
@@ -54,10 +58,13 @@ public class THXLTask extends AbstractTask {
|
||||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
||||
for (SchBaseTask task : tasks) {
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(","))
|
||||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(","))
|
||||
.collect(Collectors.toList());
|
||||
// 找终点
|
||||
SchBasePoint point = findStartPoint(startRegionStr);
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject jsonObject = JSONObject.parseObject(requestParam);
|
||||
String regionCode = jsonObject.getString("region_code");
|
||||
SchBasePoint point = findNextPoint(nextRegionStr,regionCode,task.getMaterial_code());
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
task.setRemark("未找到所需点位!");
|
||||
taskService.updateById(task);
|
||||
@@ -67,7 +74,7 @@ public class THXLTask extends AbstractTask {
|
||||
continue;
|
||||
}
|
||||
// 设置终点并修改创建成功状态
|
||||
task.setPoint_code1(point.getPoint_code());
|
||||
task.setPoint_code2(point.getPoint_code());
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
task.setRemark("");
|
||||
taskService.updateById(task);
|
||||
@@ -85,18 +92,23 @@ public class THXLTask extends AbstractTask {
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
|
||||
TaskUtils.setUpdateByAcs(task);
|
||||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(","))
|
||||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(","))
|
||||
.collect(Collectors.toList());
|
||||
// 找起点
|
||||
SchBasePoint point = findStartPoint(startRegionStr);
|
||||
// 找终点
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject jsonObject = JSONObject.parseObject(requestParam);
|
||||
String regionCode = jsonObject.getString("region_code");
|
||||
SchBasePoint point = findNextPoint(nextRegionStr,regionCode,task.getMaterial_code());
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
// 消息通知
|
||||
noticeService.createNotice("货架暂无托盘!", TASK_CONFIG_CODE + task.getPoint_code2(),
|
||||
noticeService.createNotice("待捆包区域无空闲点位!", TASK_CONFIG_CODE + task.getPoint_code1(),
|
||||
NoticeTypeEnum.WARN.getCode());
|
||||
throw new BadRequestException("货架暂无托盘!");
|
||||
throw new BadRequestException("待捆包区域无空闲点位!");
|
||||
}
|
||||
// 设置终点并修改创建成功状态
|
||||
task.setPoint_code1(point.getPoint_code());
|
||||
task.setPoint_code2(point.getPoint_code());
|
||||
//设置等待点
|
||||
task.setPoint_code3(point.getParent_point_code());
|
||||
task.setRemark("");
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
taskService.save(task);
|
||||
@@ -106,10 +118,52 @@ public class THXLTask extends AbstractTask {
|
||||
pointService.updateById(point);
|
||||
}
|
||||
|
||||
private SchBasePoint findStartPoint(List<String> startRegionStr) {
|
||||
// 钢托盘缓存区域的空盘是1 状态不同
|
||||
List<SchBasePoint> points = NETXLMapper.findPointForNETXL(startRegionStr);
|
||||
return ObjectUtil.isNotEmpty(points) ? points.get(0) : null;
|
||||
private SchBasePoint findNextPoint(List<String> nextRegionStr, String regionCode, String material_code) {
|
||||
List<SchBasePoint> list = pointService.getSamePoints(regionCode, material_code);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SchBasePoint point = list.get(0);
|
||||
int col_num = point.getCol_num();
|
||||
if (col_num == 1) {
|
||||
continue;
|
||||
}
|
||||
SchBasePoint newPoint;
|
||||
String newPoint_code = "";
|
||||
int new_col = col_num-1;
|
||||
// 校验当前点位相邻的点是否空闲
|
||||
for (int j = 0; j < (col_num - 1); j++) {
|
||||
newPoint_code = forametDevice_code(point.getPoint_code(), new_col);
|
||||
newPoint = pointService.findByCode(newPoint_code);
|
||||
Boolean result = this.checkIsFree(newPoint_code);
|
||||
if (!result) {
|
||||
col_num = col_num - 1;
|
||||
point = newPoint;
|
||||
continue;
|
||||
}
|
||||
return point;
|
||||
}
|
||||
}
|
||||
} else if (CollectionUtils.isEmpty(list)){
|
||||
//找一排都是空的点位
|
||||
//找最大列为空且没有任务的点位
|
||||
List<SchBasePoint> points = pointService.getPointByMaxCol(regionCode, 3);
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
SchBasePoint twoColPoint = points.get(0);
|
||||
String firstColPointCode = twoColPoint.getPoint_code().substring(0, twoColPoint.getPoint_code().length() - 1) + "1";
|
||||
// 查询第一列
|
||||
SchBasePoint firstColPoint = pointService.findByCode(firstColPointCode);
|
||||
// 判断第一列否为空且没有任务
|
||||
boolean isFirstColFree = checkIsEmpty(firstColPoint);
|
||||
// 如果第一列为空,则返回这个第二列点位
|
||||
if (isFirstColFree) {
|
||||
return twoColPoint;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,6 +192,32 @@ public class THXLTask extends AbstractTask {
|
||||
}
|
||||
|
||||
|
||||
private boolean checkIsEmpty(SchBasePoint point) {
|
||||
if (point.getPoint_status().equals(PointStatusEnum.EMPTY_POINT.getCode()) && StrUtil.isEmpty(point.getIng_task_code())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Boolean checkIsFree(String point_code) {
|
||||
SchBasePoint newPoint = pointService.findByCode(point_code);
|
||||
// 判断点位是否有货
|
||||
if (newPoint.getPoint_status().equals(PointStatusEnum.EMPTY_VEHICLE.getCode())) {
|
||||
return false;
|
||||
}
|
||||
List<SchBaseTask> list = taskService.findUnFinishTasksByTaskConfigAndPointCode("NETSLTask", point_code);
|
||||
if (list.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private String forametDevice_code(String point_code, int col_num) {
|
||||
return point_code.substring(0, point_code.length() - 1) + (col_num);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void forceFinish(String task_code) {
|
||||
SchBaseTask taskObj = taskService.getByCode(task_code);
|
||||
@@ -165,9 +245,9 @@ public class THXLTask extends AbstractTask {
|
||||
if (ObjectUtil.isNotEmpty(startPointObj)) {
|
||||
PointUtils.setUpdateByType(startPointObj, taskFinishedType);
|
||||
PointUtils.clearPoint(startPointObj);
|
||||
|
||||
endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode());
|
||||
// endPointObj.setVehicle_type(GeneralDefinition.STEEL_TRAY);
|
||||
// endPointObj.setVehicle_qty(taskObj.getVehicle_qty());
|
||||
endPointObj.setStoragevehicle_code(taskObj.getVehicle_code());
|
||||
endPointObj.setUpdate_time(DateUtil.now());
|
||||
PointUtils.setUpdateByType(endPointObj, taskFinishedType);
|
||||
pointService.updateById(endPointObj);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.nl.wms.sch.tasks.thxl.mapper;
|
||||
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface THXLMapper {
|
||||
List<SchBasePoint> findPointForTHXL(List<String> nextRegionStrs, String regionCode);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.wms.sch.tasks.thxl.mapper.THXLMapper">
|
||||
<select id="findPointForTHXL" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
|
||||
SELECT p.*
|
||||
FROM `sch_base_point` p
|
||||
WHERE (
|
||||
p.point_type = '1'
|
||||
)
|
||||
AND 0 = (
|
||||
SELECT COUNT(*)
|
||||
FROM sch_base_task
|
||||
WHERE (point_code1 = p.point_code
|
||||
OR point_code2 = p.point_code
|
||||
OR point_code3 = p.point_code )
|
||||
AND task_status <![CDATA[<]]> '5'
|
||||
AND is_delete = '0'
|
||||
)
|
||||
AND p.point_status = '1'
|
||||
AND p.is_used = 1
|
||||
AND p.region_code = #{regionCode}
|
||||
AND p.region_code IN
|
||||
<foreach collection="nextRegionStrs" item="code" separator="," open="(" close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
ORDER BY
|
||||
p.out_empty_seq ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -49,6 +49,7 @@ public class PointUtils {
|
||||
point.setPoint_status(PointStatusEnum.EMPTY_POINT.getCode());
|
||||
point.setVehicle_type("");
|
||||
point.setStoragevehicle_code("");
|
||||
point.setMaterial_code("");
|
||||
point.setIng_task_code("");
|
||||
point.setVehicle_qty(0);
|
||||
point.setUpdate_time(DateUtil.now());
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
server:
|
||||
port: 8011
|
||||
port: 8010
|
||||
# 项目配置
|
||||
nl:
|
||||
config:
|
||||
mysql:
|
||||
ip: 192.168.81.251
|
||||
ip: 127.0.0.1
|
||||
port: 3306
|
||||
username: root
|
||||
password: P@ssw0rd.
|
||||
database: lms_standardv1
|
||||
password: 123456
|
||||
database: fengtiandl_lms
|
||||
redis:
|
||||
ip: 127.0.0.1
|
||||
port: 6379
|
||||
|
||||
@@ -57,7 +57,7 @@ spring:
|
||||
datasource:
|
||||
mysql:
|
||||
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:${nl.config.mysql.ip}}:${DB_PORT:${nl.config.mysql.port}}/${DB_NAME:${nl.config.mysql.database}}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:${nl.config.mysql.ip}}:${DB_PORT:${nl.config.mysql.port}}/${DB_NAME:${nl.config.mysql.database}}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
username: ${DB_USER:${nl.config.mysql.username}}
|
||||
password: ${DB_PWD:${nl.config.mysql.password}}
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
||||
Reference in New Issue
Block a user