fix:1.浅位优先出库策略逻辑优化;2.现场调试bug修复
This commit is contained in:
@@ -58,6 +58,30 @@
|
||||
<if test="inv_code != null and inv_code != ''">
|
||||
and gro.frozen_qty = 0 and ( ivt.lock_type = '0' or ivt.inv_code = #{inv_code})
|
||||
</if>
|
||||
<if test="row_nums != null and row_nums.size() > 0">
|
||||
AND ivt.row_num in
|
||||
<foreach collection="row_nums" item="value" index="key" open="(" close=")" separator=",">
|
||||
#{value}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="filterShallow != null and filterShallow == true">
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM st_ivt_structattr sub_ivt
|
||||
LEFT JOIN md_pb_groupplate sub_gro ON sub_ivt.storagevehicle_code = sub_gro.storagevehicle_code
|
||||
WHERE
|
||||
sub_ivt.row_num IN (2,3)
|
||||
AND sub_gro.material_id = gro.material_id
|
||||
AND sub_gro.pcsn = gro.pcsn
|
||||
AND sub_gro.qty > 0
|
||||
AND sub_ivt.stor_code = ivt.stor_code
|
||||
AND sub_ivt.sect_code = ivt.sect_code
|
||||
<if test="inv_code != null and inv_code != ''">
|
||||
AND (sub_ivt.lock_type = '0' OR sub_ivt.inv_code = #{inv_code})
|
||||
AND IFNULL(sub_gro.frozen_qty,0) = 0
|
||||
</if>
|
||||
)
|
||||
</if>
|
||||
<if test="order_by != null and order_by != ''">
|
||||
order by ${order_by}
|
||||
</if>
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
@@ -52,11 +53,21 @@ public class ShallowFirstRuleHandler extends Decisioner<StrategyStructMaterialVO
|
||||
, "plan_qty", planQty
|
||||
, "order_by", "case when ivt.row_num in (2,3) then 0 else 1 end asc, gro.update_time asc")
|
||||
);
|
||||
if (ObjectUtils.isEmpty(vechielDtos)) {
|
||||
throw new BadRequestException("当前出库策略:浅位优先,库存分配失败,失败原因:库存不足!");
|
||||
}
|
||||
// vechielDtos需要在做一层过滤:如果分配到深货位且浅货位有货的,需要过滤
|
||||
//1.先查所有淺货位库存
|
||||
List<StructattrVechielDto> shallowLocationVechielDtos =
|
||||
iStructattrService.collectVechicle(MapOf.of("material_id", strategyMater.getMaterial_id()
|
||||
, "pcsn", strategyMater.getPcsn()
|
||||
, "inv_code", param.getInv_code()
|
||||
, "stor_code", param.getStor_code()
|
||||
, "sect_code", param.getSect_code()
|
||||
, "plan_qty", planQty
|
||||
, "row_nums", Arrays.asList(2,3)
|
||||
, "order_by", "gro.update_time asc")
|
||||
);
|
||||
//2.做浅货位循环扣减
|
||||
List<StrategyStructMaterialVO> divStruct = new ArrayList<>();
|
||||
for (StructattrVechielDto vechielDto : vechielDtos) {
|
||||
for (StructattrVechielDto vechielDto : shallowLocationVechielDtos) {
|
||||
if (planQty.intValue()<=0){
|
||||
break;
|
||||
}
|
||||
@@ -72,6 +83,44 @@ public class ShallowFirstRuleHandler extends Decisioner<StrategyStructMaterialVO
|
||||
BeanUtils.copyProperties(vechielDto,materialVO);
|
||||
divStruct.add(materialVO);
|
||||
}
|
||||
//如果扣减后还有物料没被分配完,再去查深货位库存浅货位无货的
|
||||
if (planQty.intValue() > 0) {
|
||||
List<StructattrVechielDto> deepLocationVechielDtos =
|
||||
iStructattrService.collectVechicle(MapOf.of("material_id", strategyMater.getMaterial_id()
|
||||
, "pcsn", strategyMater.getPcsn()
|
||||
, "inv_code", param.getInv_code()
|
||||
, "stor_code", param.getStor_code()
|
||||
, "sect_code", param.getSect_code()
|
||||
, "plan_qty", planQty
|
||||
, "row_nums", Arrays.asList(1,4)
|
||||
, "filterShallow", true
|
||||
, "order_by", "gro.update_time asc")
|
||||
);
|
||||
if (ObjectUtils.isEmpty(deepLocationVechielDtos)) {
|
||||
throw new BadRequestException("当前出库策略:浅位优先,库存分配失败,失败原因:库存不足!");
|
||||
}
|
||||
//3.做循环扣减
|
||||
for (StructattrVechielDto vechielDto : deepLocationVechielDtos) {
|
||||
if (planQty.intValue()<=0){
|
||||
break;
|
||||
}
|
||||
BigDecimal qty = vechielDto.getQty();
|
||||
BigDecimal subQty = planQty.subtract(qty);
|
||||
if (subQty.doubleValue()>=0){
|
||||
vechielDto.setFrozen_qty(vechielDto.getQty());
|
||||
}else {
|
||||
vechielDto.setFrozen_qty(planQty);
|
||||
}
|
||||
planQty=subQty;
|
||||
StrategyStructMaterialVO materialVO = new StrategyStructMaterialVO();
|
||||
BeanUtils.copyProperties(vechielDto,materialVO);
|
||||
divStruct.add(materialVO);
|
||||
}
|
||||
//如果深货位扣减后还有物料没被分配完,则报错提示库存不足
|
||||
if (planQty.intValue() > 0) {
|
||||
throw new BadRequestException("当前出库策略:浅位优先,库存分配失败,失败原因:库存不足!");
|
||||
}
|
||||
}
|
||||
return divStruct;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public class VoiceCallbackService {
|
||||
StringBuilder result = new StringBuilder();
|
||||
result.append("入库") .append(inboundTaskRequest.getQty()).append(meMaterialbase.getQty_unit_name())
|
||||
.append(meMaterialbase.getMaterial_name()).append("到").append(targetStruct.getStruct_code())
|
||||
.append("货位完成;");
|
||||
.append("货位任务下发成功;");
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("result", result.toString());
|
||||
return resultJson;
|
||||
@@ -269,7 +269,7 @@ public class VoiceCallbackService {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (IOStorInvDisDto dis : disList) {
|
||||
result.append("从").append(dis.getSect_code()).append("出库")
|
||||
.append(dis.getPlan_qty().stripTrailingZeros()).append(dis.getQty_unit_name())
|
||||
.append(dis.getPlan_qty().stripTrailingZeros().toPlainString()).append(dis.getQty_unit_name())
|
||||
.append(dis.getMaterial_name()).append("任务下发成功;");
|
||||
}
|
||||
JSONObject resultJson = new JSONObject();
|
||||
@@ -324,7 +324,7 @@ public class VoiceCallbackService {
|
||||
item.put("qty", ivt.getQty());
|
||||
materials.add(item);
|
||||
result.append(location).append("库位").append("存有").append(ivt.getMaterial_name())
|
||||
.append(ivt.getQty().stripTrailingZeros()).append(ivt.getQty_unit_name()).append(";");
|
||||
.append(ivt.getQty().stripTrailingZeros().toPlainString()).append(ivt.getQty_unit_name()).append(";");
|
||||
}
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("result", result.toString());
|
||||
@@ -342,7 +342,7 @@ public class VoiceCallbackService {
|
||||
.filter(ObjectUtil::isNotEmpty)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("result", "库内总计" + mater.getMaterial_name() + totalQty.stripTrailingZeros() + mater.getQty_unit_name());
|
||||
resultJson.put("result", "库内总计" + mater.getMaterial_name() + totalQty.stripTrailingZeros().toPlainString() + mater.getQty_unit_name());
|
||||
return resultJson;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,10 +148,17 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
||||
@Override
|
||||
public String insertDtl(Map whereJson) {
|
||||
Object tableObj = whereJson.get("tableData");
|
||||
JSONArray jsonArray = (JSONArray) tableObj;
|
||||
List<HashMap> rowList = JSONArray.parseArray(jsonArray.toJSONString(), HashMap.class);
|
||||
ArrayList<HashMap> rows = new ArrayList<>(rowList);
|
||||
// ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableData");
|
||||
List<?> rawList = (List<?>) tableObj;
|
||||
List<Map<String,Object>> rowList = new ArrayList<>();
|
||||
for (Object item : rawList) {
|
||||
if(item instanceof JSONObject){
|
||||
rowList.add(((JSONObject) item));
|
||||
}else if(item instanceof Map){
|
||||
rowList.add((Map<String,Object>) item);
|
||||
}
|
||||
}
|
||||
ArrayList<Map<String,Object>> rows = new ArrayList<>(rowList);
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
@@ -186,7 +193,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
||||
io_mst.put("sysdeptid", deptId + "");
|
||||
io_mst.put("syscompanyid", deptId + "");
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
HashMap<String, Object> row = rows.get(i);
|
||||
Map<String, Object> row = rows.get(i);
|
||||
JSONObject ioStorInvDtl = new JSONObject();
|
||||
//判断是否存在相同批次、相同物料的物料明细存在
|
||||
IOStorInvDtl dtl_dto = ioStorInvDtlMapper.selectOne(new LambdaQueryWrapper<IOStorInvDtl>()
|
||||
@@ -543,12 +550,23 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void divPoint(Map whereJson) {
|
||||
Object tableObj = whereJson.get("tableMater");
|
||||
JSONArray jsonArray = (JSONArray) tableObj;
|
||||
List<HashMap> rowList = JSONArray.parseArray(jsonArray.toJSONString(), HashMap.class);
|
||||
ArrayList<HashMap> rows = new ArrayList<>(rowList);
|
||||
// ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableMater");
|
||||
if (!(tableObj instanceof List)) {
|
||||
throw new BadRequestException("tableMater参数必须是数组");
|
||||
}
|
||||
List<?> rawList = (List<?>) tableObj;
|
||||
List<Map<String, Object>> rowList = new ArrayList<>();
|
||||
for (Object item : rawList) {
|
||||
if (item instanceof JSONObject) {
|
||||
rowList.add((JSONObject) item);
|
||||
} else if (item instanceof Map) {
|
||||
rowList.add((Map<String, Object>) item);
|
||||
} else {
|
||||
throw new BadRequestException("tableMater明细数据格式错误");
|
||||
}
|
||||
}
|
||||
ArrayList<Map<String, Object>> rows = new ArrayList<>(rowList);
|
||||
String point_code = (String) whereJson.get("point_code");
|
||||
HashMap<String, String> map = rows.get(0);
|
||||
Map<String, Object> map = rows.get(0);
|
||||
|
||||
//判断是否已经分配好货位
|
||||
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
||||
@@ -580,7 +598,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
||||
|
||||
//分配明细表更新任务相关数据
|
||||
IOStorInvDis dis = new IOStorInvDis();
|
||||
dis.setIostorinvdis_id(map.get("iostorinvdis_id"));
|
||||
dis.setIostorinvdis_id((String) map.get("iostorinvdis_id"));
|
||||
dis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("生成"));
|
||||
dis.setTask_id(task_id);
|
||||
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
|
||||
@@ -139,4 +139,4 @@ lucene:
|
||||
index:
|
||||
path: D:\lms\lucene\index
|
||||
vc:
|
||||
base-url: http://127.0.0.1:5000
|
||||
base-url: http://192.168.1.16:5000
|
||||
|
||||
Reference in New Issue
Block a user