add:申请任务功能优化
This commit is contained in:
@@ -114,4 +114,7 @@ public interface IStructattrService extends IService<Structattr> {
|
|||||||
List<Structattr> inBoundSectDiv(StrategyStructParam param);
|
List<Structattr> inBoundSectDiv(StrategyStructParam param);
|
||||||
|
|
||||||
void changeStruct(StructattrChangeDto changeDto);
|
void changeStruct(StructattrChangeDto changeDto);
|
||||||
|
|
||||||
|
BigDecimal calculateSectOccupancyRate(String sect_code);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package org.nl.wms.basedata_manage.service.dao.mapper;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||||
import org.nl.wms.basedata_manage.service.dao.StructattrVechielDto;
|
import org.nl.wms.basedata_manage.service.dao.StructattrVechielDto;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -20,4 +22,6 @@ public interface StructattrMapper extends BaseMapper<Structattr>{
|
|||||||
|
|
||||||
List<JSONObject> collectVehicle2(Map query);
|
List<JSONObject> collectVehicle2(Map query);
|
||||||
|
|
||||||
|
BigDecimal calculateSectOccupancyRate(@Param("sect_code")String sect_code);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,4 +93,20 @@
|
|||||||
order by ${order_by}
|
order by ${order_by}
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="calculateSectOccupancyRate" resultType="java.math.BigDecimal">
|
||||||
|
SELECT
|
||||||
|
CASE
|
||||||
|
WHEN COALESCE(COUNT(*), 0) = 0 THEN 0
|
||||||
|
ELSE SUM(CASE WHEN ivt.storagevehicle_code IS NOT NULL THEN 1 ELSE 0 END) * 1.0 / COUNT(*)
|
||||||
|
END AS occupancy_rate
|
||||||
|
|
||||||
|
FROM
|
||||||
|
st_ivt_structattr ivt
|
||||||
|
<where>
|
||||||
|
<if test="sect_code != null and sect_code != ''">
|
||||||
|
AND ivt.sect_code = #{sect_code}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -427,4 +427,9 @@ public class StructattrServiceImpl extends ServiceImpl<StructattrMapper, Structa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BigDecimal calculateSectOccupancyRate(String sect_code) {
|
||||||
|
return structattrMapper.calculateSectOccupancyRate(sect_code);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,4 +42,15 @@ public class AcsToWmsController {
|
|||||||
return new ResponseEntity<>(acsToWmsService.acsApply(param), HttpStatus.OK);
|
return new ResponseEntity<>(acsToWmsService.acsApply(param), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getExecutingTask")
|
||||||
|
@Log("ACS向LMS查询正在执行的任务数据")
|
||||||
|
@SaIgnore
|
||||||
|
/**
|
||||||
|
* ACS向LMS查询正在执行的任务数据
|
||||||
|
*/
|
||||||
|
public ResponseEntity<Object> getExecutingTask() {
|
||||||
|
return new ResponseEntity<>(acsToWmsService.getExecutingTask(), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,4 +25,6 @@ public interface AcsToWmsService {
|
|||||||
|
|
||||||
/** ACS请求接口 */
|
/** ACS请求接口 */
|
||||||
Map<String, Object> acsApply(JSONObject param);
|
Map<String, Object> acsApply(JSONObject param);
|
||||||
|
|
||||||
|
Map<String, Object> getExecutingTask();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -73,8 +74,30 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
public Map<String, Object> receiveTaskStatusAcs(String string) {
|
public Map<String, Object> receiveTaskStatusAcs(String string) {
|
||||||
log.info("acs向lms反馈任务状态,请求参数:--------------------------------------" + string);
|
log.info("acs向lms反馈任务状态,请求参数:--------------------------------------" + string);
|
||||||
JSONArray array = JSONArray.parseArray(string);
|
JSONArray array = JSONArray.parseArray(string);
|
||||||
|
|
||||||
|
//先做校验
|
||||||
//返回处理失败的任务
|
//返回处理失败的任务
|
||||||
JSONArray errArr = new JSONArray();
|
JSONArray errArr = new JSONArray();
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JSONObject errorObject = new JSONObject();
|
||||||
|
JSONObject row = array.getJSONObject(i);
|
||||||
|
String task_id = row.getString("task_id");
|
||||||
|
SchBaseTask taskObj = iSchBaseTaskService.getById(task_id);
|
||||||
|
if (taskObj == null) {
|
||||||
|
errorObject.put("task_id", task_id);
|
||||||
|
errorObject.put("messgae", "不存在task_id = [" + task_id + "]的任务!");
|
||||||
|
errArr.add(errorObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errArr.size() > 0) {
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||||
|
result.put("message", "任务状态反馈失败!");
|
||||||
|
result.put("errArr", errArr);
|
||||||
|
log.info("acs向lms反馈任务状态,返回参数:--------------------------------------" + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
JSONObject row = array.getJSONObject(i);
|
JSONObject row = array.getJSONObject(i);
|
||||||
String task_id = row.getString("task_id");
|
String task_id = row.getString("task_id");
|
||||||
@@ -100,7 +123,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
// 根据配置编码执行相关配置内的方法
|
// 根据配置编码执行相关配置内的方法
|
||||||
AbstractTask task = taskFactory.getTask(taskObj.getConfig_code());
|
AbstractTask task = taskFactory.getTask(taskObj.getConfig_code());
|
||||||
task.updateTaskStatus(taskObj.getTask_code(),status);
|
task.updateTaskStatus(taskObj.getTask_code(),status);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException("任务标识为:" + task_id + "的任务正在操作中!");
|
throw new BadRequestException("任务标识为:" + task_id + "的任务正在操作中!");
|
||||||
}
|
}
|
||||||
@@ -113,9 +135,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
result.put("status", HttpStatus.OK.value());
|
result.put("status", HttpStatus.OK.value());
|
||||||
result.put("message", "任务状态反馈成功!");
|
result.put("message", "任务状态反馈成功!");
|
||||||
result.put("data", new JSONObject());
|
log.info("acs向lms反馈任务状态,返回参数:--------------------------------------" + result);
|
||||||
result.put("errArr", errArr);
|
|
||||||
log.info("acs向lms反馈任务状态,返回参数:--------------------------------------" + result.toString());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +157,21 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getExecutingTask() {
|
||||||
|
//查询正在执行的任务
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
result.put("status", HttpStatus.OK.value());
|
||||||
|
result.put("message", "查询成功!");
|
||||||
|
|
||||||
|
List<SchBaseTask> schBaseTaskList = iSchBaseTaskService.findUnFinishTasks();
|
||||||
|
data.put("detail", schBaseTaskList);
|
||||||
|
data.put("count", schBaseTaskList.size());
|
||||||
|
result.put("data", data);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 申请入库任务
|
* 申请入库任务
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class ErpToWmsServiceImpl implements ErpToWmsService {
|
|||||||
plate2.setQty_unit_id(unitDaoDtl.getMeasure_unit_id());
|
plate2.setQty_unit_id(unitDaoDtl.getMeasure_unit_id());
|
||||||
plate2.setQty_unit_name(unitDaoDtl.getUnit_name());
|
plate2.setQty_unit_name(unitDaoDtl.getUnit_name());
|
||||||
plate2.setQty(groupplateDto.getQty());
|
plate2.setQty(groupplateDto.getQty());
|
||||||
plate2.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("生成"));
|
plate2.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("组盘"));
|
||||||
plate2.setExt_code(jsonDtl.getCode());
|
plate2.setExt_code(jsonDtl.getCode());
|
||||||
plate2.setExt_type("0001");
|
plate2.setExt_type("0001");
|
||||||
plate2.setExt_id(jsonDtl.getId());
|
plate2.setExt_id(jsonDtl.getId());
|
||||||
@@ -234,7 +234,7 @@ public class ErpToWmsServiceImpl implements ErpToWmsService {
|
|||||||
plate.setQty_unit_id(unitDao.getMeasure_unit_id());
|
plate.setQty_unit_id(unitDao.getMeasure_unit_id());
|
||||||
plate.setQty_unit_name(unitDao.getUnit_name());
|
plate.setQty_unit_name(unitDao.getUnit_name());
|
||||||
plate.setQty(qty);
|
plate.setQty(qty);
|
||||||
plate.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("生成"));
|
plate.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("组盘"));
|
||||||
plate.setExt_code("H-"+value.get(0).getOrder_code());
|
plate.setExt_code("H-"+value.get(0).getOrder_code());
|
||||||
plate.setExt_type("0001");
|
plate.setExt_type("0001");
|
||||||
plate.setExt_id(jsonDtl.getId());
|
plate.setExt_id(jsonDtl.getId());
|
||||||
|
|||||||
@@ -78,4 +78,12 @@ public interface ISchBaseTaskService extends IService<SchBaseTask> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer findUnFinishTasksBySub_tray(String sub_tray);
|
Integer findUnFinishTasksBySub_tray(String sub_tray);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务号查询未完成的任务
|
||||||
|
* @param sub_tray
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SchBaseTask> findUnFinishTasks();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,5 +175,13 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
|
|||||||
return taskCount;
|
return taskCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SchBaseTask> findUnFinishTasks() {
|
||||||
|
LambdaQueryWrapper<SchBaseTask> lam = new LambdaQueryWrapper<>();
|
||||||
|
lam.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
|
||||||
|
.eq(SchBaseTask::getIs_delete, false);
|
||||||
|
return schBaseTaskMapper.selectList(lam);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,22 @@ public class StInTask extends AbstractTask {
|
|||||||
task.setGroup_id(json.getString("group_id"));
|
task.setGroup_id(json.getString("group_id"));
|
||||||
task.setRequest_param(json.toString());
|
task.setRequest_param(json.toString());
|
||||||
task.setPriority(json.getString("Priority"));
|
task.setPriority(json.getString("Priority"));
|
||||||
task.setCreate_id(SecurityUtils.getCurrentUserId());
|
String currentUserId,nickName;
|
||||||
task.setCreate_name(SecurityUtils.getCurrentNickName());
|
if (null == json.get("currentUserId")) {
|
||||||
|
currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
} else {
|
||||||
|
currentUserId = json.get("currentUserId").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == json.get("nickName")) {
|
||||||
|
nickName = SecurityUtils.getCurrentNickName();
|
||||||
|
} else {
|
||||||
|
nickName = json.get("nickName").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
task.setCreate_id(currentUserId);
|
||||||
|
task.setCreate_name(nickName);
|
||||||
|
|
||||||
task.setCreate_time(DateUtil.now());
|
task.setCreate_time(DateUtil.now());
|
||||||
taskService.save(task);
|
taskService.save(task);
|
||||||
return task.getTask_id();
|
return task.getTask_id();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.nl.wms.warehouse_manage.service.impl;
|
package org.nl.wms.warehouse_manage.service.impl;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
@@ -146,8 +148,18 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public String insertDtl(Map whereJson) {
|
public String insertDtl(Map whereJson) {
|
||||||
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableData");
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableData");
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
String currentUserId, nickName;
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
if (null == whereJson.get("currentUserId")) {
|
||||||
|
currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
} else {
|
||||||
|
currentUserId = whereJson.get("currentUserId").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == whereJson.get("nickName")) {
|
||||||
|
nickName = SecurityUtils.getCurrentNickName();
|
||||||
|
} else {
|
||||||
|
nickName = whereJson.get("nickName").toString();
|
||||||
|
}
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
BigDecimal total_qty = new BigDecimal(BigInteger.ZERO);
|
BigDecimal total_qty = new BigDecimal(BigInteger.ZERO);
|
||||||
JSONObject io_mst = new JSONObject();
|
JSONObject io_mst = new JSONObject();
|
||||||
@@ -353,8 +365,19 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|||||||
if (ioStorInvDis ==null){
|
if (ioStorInvDis ==null){
|
||||||
throw new BadRequestException("当前明细已经分配过库位");
|
throw new BadRequestException("当前明细已经分配过库位");
|
||||||
}
|
}
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
String currentUserId,nickName;
|
||||||
|
if (null == param.get("currentUserId")) {
|
||||||
|
currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
} else {
|
||||||
|
currentUserId = param.get("currentUserId").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null == param.get("nickName")) {
|
||||||
|
nickName = SecurityUtils.getCurrentNickName();
|
||||||
|
} else {
|
||||||
|
nickName = param.get("nickName").toString();
|
||||||
|
}
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
String sect_id = "";
|
String sect_id = "";
|
||||||
String sect_code = "";
|
String sect_code = "";
|
||||||
@@ -559,6 +582,8 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|||||||
task_form.put("PickingLocation", point_code);
|
task_form.put("PickingLocation", point_code);
|
||||||
task_form.put("PlacedLocation", ioStorInvDis.getStruct_code());
|
task_form.put("PlacedLocation", ioStorInvDis.getStruct_code());
|
||||||
task_form.put("vehicle_code", map.get("storagevehicle_code"));
|
task_form.put("vehicle_code", map.get("storagevehicle_code"));
|
||||||
|
task_form.put("currentUserId","3");
|
||||||
|
task_form.put("nickName","ACS");
|
||||||
StInTask stInTask = SpringContextHolder.getBean("STInTask");
|
StInTask stInTask = SpringContextHolder.getBean("STInTask");
|
||||||
|
|
||||||
String task_id = stInTask.create(task_form);
|
String task_id = stInTask.create(task_form);
|
||||||
@@ -782,11 +807,17 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|||||||
return ioStorInvDisMapper.getBillTaskDtl(iostorinvdtl_id);
|
return ioStorInvDisMapper.getBillTaskDtl(iostorinvdtl_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void AutoCreateBill(JSONObject param){
|
public void AutoCreateBill(JSONObject param){
|
||||||
String device_code = param.getString("device_code"); // 请求点
|
String device_code = param.getString("device_code"); // 请求点
|
||||||
String vehicle_code = param.getString("vehicle_code");//子托盘
|
String vehicle_code = param.getString("vehicle_code");//子托盘
|
||||||
List<GroupPlateDto> list = ioStorInvMapper.getGroupByPlate(param);
|
List<GroupPlateDto> list = ioStorInvMapper.getGroupByPlate(param);
|
||||||
|
ArrayList<LinkedHashMap> tableData = new ArrayList<>();
|
||||||
|
list.forEach(item -> {
|
||||||
|
item.setPlan_qty(item.getQty());
|
||||||
|
tableData.add(JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class));
|
||||||
|
});
|
||||||
|
|
||||||
JSONObject form = new JSONObject();
|
JSONObject form = new JSONObject();
|
||||||
// 查询仓库
|
// 查询仓库
|
||||||
@@ -794,23 +825,59 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|||||||
form.put("stor_id",storDao.getStor_id());
|
form.put("stor_id",storDao.getStor_id());
|
||||||
form.put("bill_type",IOSEnum.BILL_TYPE.code("生产入库"));
|
form.put("bill_type",IOSEnum.BILL_TYPE.code("生产入库"));
|
||||||
form.put("biz_date",DateUtil.now());
|
form.put("biz_date",DateUtil.now());
|
||||||
|
form.put("currentUserId","3");
|
||||||
|
form.put("nickName","ACS");
|
||||||
|
|
||||||
form.put("remark","");
|
form.put("remark","");
|
||||||
form.put("bill_status",IOSEnum.BILL_STATUS.code("生成"));
|
form.put("bill_status",IOSEnum.BILL_STATUS.code("生成"));
|
||||||
form.put("tableData",list);
|
form.put("tableData",tableData);
|
||||||
//新增入库单
|
//新增入库单
|
||||||
String iostorinv_id = this.insertDtl(form);
|
String iostorinv_id = this.insertDtl(form);
|
||||||
//根据分配明细分配仓位
|
//根据分配明细分配仓位
|
||||||
IOStorInvDis dis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
IOStorInvDis dis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||||
.eq(IOStorInvDis::getIostorinv_id,iostorinv_id));
|
.eq(IOStorInvDis::getIostorinv_id,iostorinv_id));
|
||||||
JSONObject dis_form = new JSONObject();
|
JSONObject dis_form = new JSONObject();
|
||||||
dis_form.put("tableMater",dis);
|
|
||||||
|
ArrayList<LinkedHashMap> tableMater = new ArrayList<>();
|
||||||
|
tableMater.add(JSONObject.parseObject(JSONObject.toJSONString(dis), LinkedHashMap.class));
|
||||||
|
dis_form.put("tableMater",tableMater);
|
||||||
dis_form.put("stor_code",storDao.getStor_code());
|
dis_form.put("stor_code",storDao.getStor_code());
|
||||||
//todo 需要指定一个库区
|
dis_form.put("currentUserId","3");
|
||||||
dis_form.put("sect_code","1582991348217286656");
|
dis_form.put("nickName","ACS");
|
||||||
|
dis_form.put("iostorinvdis_id",dis.getIostorinvdis_id());
|
||||||
|
|
||||||
|
// 查询所有库区
|
||||||
|
List<Sectattr> allSects = iSectattrService.list(new LambdaQueryWrapper<>(Sectattr.class)
|
||||||
|
.eq(Sectattr::getIs_delete,"0")
|
||||||
|
.ne(Sectattr::getSect_code,"SSX"));
|
||||||
|
if (CollectionUtils.isEmpty(allSects)) {
|
||||||
|
throw new BadRequestException("未找到可用的库区");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断库区货位占有率
|
||||||
|
Map<Sectattr, BigDecimal> sectOccupancyRateMap = new HashMap<>();
|
||||||
|
for (Sectattr sect : allSects) {
|
||||||
|
BigDecimal occupancyRate = iStructattrService.calculateSectOccupancyRate(sect.getSect_code());
|
||||||
|
sectOccupancyRateMap.put(sect, occupancyRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择占有率小的库区
|
||||||
|
Optional<Map.Entry<Sectattr, BigDecimal>> minEntry = sectOccupancyRateMap.entrySet().stream()
|
||||||
|
.min(Map.Entry.comparingByValue());
|
||||||
|
if (minEntry.isPresent()) {
|
||||||
|
dis_form.put("sect_id", minEntry.get().getKey().getSect_id());
|
||||||
|
dis_form.put("stor_id", minEntry.get().getKey().getStor_id());
|
||||||
|
dis_form.put("sect_code", minEntry.get().getKey().getSect_id());
|
||||||
|
dis_form.put("stor_code", minEntry.get().getKey().getStor_id());
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("无法选择合适的库区");
|
||||||
|
}
|
||||||
|
|
||||||
//分配货位
|
//分配货位
|
||||||
|
dis_form.put("checked",true);
|
||||||
this.divStruct(dis_form);
|
this.divStruct(dis_form);
|
||||||
dis_form.put("point_code",device_code);
|
dis_form.put("point_code",device_code);
|
||||||
|
dis_form.put("nickName",iostorinv_id);
|
||||||
//生成任务
|
//生成任务
|
||||||
this.divPoint(dis_form);;
|
this.divPoint(dis_form);;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user