feat: 原辅料直接入库
This commit is contained in:
@@ -34,6 +34,7 @@ public interface ISectattrService extends IService<Sectattr> {
|
|||||||
* @return Sectattr
|
* @return Sectattr
|
||||||
*/
|
*/
|
||||||
Sectattr findById(String sect_id);
|
Sectattr findById(String sect_id);
|
||||||
|
Sectattr findByCode(String sect_code, Boolean flag);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ public class SectattrServiceImpl extends ServiceImpl<SectattrMapper, Sectattr> i
|
|||||||
return sectattr;
|
return sectattr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sectattr findByCode(String sect_code, Boolean flag) {
|
||||||
|
LambdaQueryWrapper<Sectattr> queryWrapper = new LambdaQueryWrapper<>(Sectattr.class)
|
||||||
|
.eq(Sectattr::getSect_code, sect_code)
|
||||||
|
.eq(flag, Sectattr::getIs_delete, BaseDataEnum.IS_YES_NOT.code("否"));
|
||||||
|
return sectattrMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(Sectattr dto) {
|
public void create(Sectattr dto) {
|
||||||
|
|||||||
@@ -1,18 +1,34 @@
|
|||||||
package org.nl.wms.pda.general_management.service.impl;
|
package org.nl.wms.pda.general_management.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.common.exception.BadRequestException;
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.wms.basedata_manage.service.ISectattrService;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.Sectattr;
|
||||||
import org.nl.wms.pda.general_management.service.PdaPreTreatmentService;
|
import org.nl.wms.pda.general_management.service.PdaPreTreatmentService;
|
||||||
import org.nl.wms.pda.util.PdaResponse;
|
import org.nl.wms.pda.util.PdaResponse;
|
||||||
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
import org.nl.wms.sch_manage.service.ISchBasePointService;
|
||||||
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
||||||
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService;
|
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService;
|
||||||
|
import org.nl.wms.warehouse_management.service.IRawAssistIStorService;
|
||||||
|
import org.nl.wms.warehouse_management.service.dao.IOStorInvDis;
|
||||||
|
import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl;
|
||||||
|
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper;
|
||||||
|
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper;
|
||||||
|
import org.nl.wms.warehouse_management.service.dto.IOStorInvDisDto;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: lyd
|
* @Author: lyd
|
||||||
@@ -25,6 +41,16 @@ public class PdaPreTreatmentServiceImpl implements PdaPreTreatmentService {
|
|||||||
private ISchBasePointService pointService;
|
private ISchBasePointService pointService;
|
||||||
@Resource
|
@Resource
|
||||||
private IMdPbGroupplateService groupplateService;
|
private IMdPbGroupplateService groupplateService;
|
||||||
|
@Resource
|
||||||
|
private IRawAssistIStorService rawAssistIStorService;
|
||||||
|
@Resource
|
||||||
|
private ISectattrService sectattrService;
|
||||||
|
@Resource
|
||||||
|
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||||
|
@Resource
|
||||||
|
private IOStorInvDtlMapper ioStorInvDtlMapper;
|
||||||
|
@Resource
|
||||||
|
private RedissonClient redissonClient;
|
||||||
@Override
|
@Override
|
||||||
public PdaResponse getPalletAssembly(JSONObject param) {
|
public PdaResponse getPalletAssembly(JSONObject param) {
|
||||||
String search = param.getString("search");
|
String search = param.getString("search");
|
||||||
@@ -42,24 +68,110 @@ public class PdaPreTreatmentServiceImpl implements PdaPreTreatmentService {
|
|||||||
return PdaResponse.requestParamOk(groups);
|
return PdaResponse.requestParamOk(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public PdaResponse confirmPalletAssemblyIn(JSONObject param) {
|
public PdaResponse confirmPalletAssemblyIn(JSONObject param) {
|
||||||
log.info("拆包缓冲间确认入库:{}", param);
|
log.info("拆包缓冲间确认入库:{}", param);
|
||||||
// param:search(点位), rows
|
RLock lock = redissonClient.getLock("lock:confirmPalletAssemblyIn");
|
||||||
String search = param.getString("search");
|
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||||
if (ObjectUtil.isEmpty(search)) {
|
try {
|
||||||
throw new BadRequestException("请输入点位编码!");
|
if (tryLock) {
|
||||||
|
// param:search(点位), rows
|
||||||
|
String search = param.getString("search");
|
||||||
|
if (ObjectUtil.isEmpty(search)) {
|
||||||
|
throw new BadRequestException("请输入点位编码!");
|
||||||
|
}
|
||||||
|
SchBasePoint startPoint = pointService.getByPointCode(search, true);
|
||||||
|
if (ObjectUtil.isEmpty(startPoint)) {
|
||||||
|
throw new BadRequestException("输入的点位不存在或者点位已被禁用, 请检查输入点位是否正确或是否被禁用!");
|
||||||
|
}
|
||||||
|
Sectattr sectattr = sectattrService.findByCode("WYL01", true);
|
||||||
|
if (ObjectUtil.isEmpty(sectattr)) {
|
||||||
|
throw new BadRequestException("库区【物料室原料区】不存在或者被禁用!");
|
||||||
|
}
|
||||||
|
// 1 创建入库单、明细、分配明细
|
||||||
|
Map<String, Object> invObj = doBuildInvObj(param.getJSONArray("rows"));
|
||||||
|
String invId = rawAssistIStorService.insertDtl(invObj);
|
||||||
|
// 2 调用分配 (WYL01)
|
||||||
|
Map<String, Object> divObj = buildDivStructData(sectattr, invId);
|
||||||
|
rawAssistIStorService.divStruct(divObj);
|
||||||
|
// 3 创建任务
|
||||||
|
Map<String, Object> jsonMst = buildTaskData(startPoint, invId);
|
||||||
|
rawAssistIStorService.divPoint(jsonMst);
|
||||||
|
} else {
|
||||||
|
throw new BadRequestException("速度太快啦,稍后再试...");
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (tryLock) {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SchBasePoint startPoint = pointService.getByPointCode(search, true);
|
|
||||||
if (ObjectUtil.isEmpty(startPoint)) {
|
|
||||||
throw new BadRequestException("输入的点位不存在或者点位已被禁用, 请检查输入点位是否正确或是否被禁用!");
|
|
||||||
}
|
|
||||||
// 1 创建入库单、明细、分配明细
|
|
||||||
JSONObject insertInvObj = new JSONObject();
|
|
||||||
|
|
||||||
// 2 调用分配
|
|
||||||
|
|
||||||
// 3 创建任务
|
|
||||||
return PdaResponse.requestOk();
|
return PdaResponse.requestOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> buildTaskData(SchBasePoint startPoint, String invId) {
|
||||||
|
Map<String, Object> jsonMst = new HashMap<>();
|
||||||
|
jsonMst.put("point_code", startPoint.getPoint_code());
|
||||||
|
// 组织明细数据
|
||||||
|
IOStorInvDtl dtlDao = ioStorInvDtlMapper.selectOne(
|
||||||
|
new QueryWrapper<IOStorInvDtl>().lambda()
|
||||||
|
.eq(IOStorInvDtl::getIostorinv_id, invId)
|
||||||
|
);
|
||||||
|
// 查找分配明细
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("iostorinvdtl_id",dtlDao.getIostorinvdtl_id());
|
||||||
|
List<IOStorInvDisDto> disDtl = rawAssistIStorService.getDisDtl(map);
|
||||||
|
// 类型转换
|
||||||
|
ArrayList<LinkedHashMap> tableMater = new ArrayList<>();
|
||||||
|
disDtl.forEach(item -> tableMater.add(JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class)));
|
||||||
|
jsonMst.put("tableMater", tableMater);
|
||||||
|
return jsonMst;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> buildDivStructData(Sectattr sect, String invId) {
|
||||||
|
Map<String, Object> divObj = new HashMap<>();
|
||||||
|
divObj.put("sect_code", sect.getSect_code());
|
||||||
|
divObj.put("stor_code", sect.getStor_id());
|
||||||
|
divObj.put("checked", true);
|
||||||
|
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<IOStorInvDis>()
|
||||||
|
.eq(IOStorInvDis::getIostorinv_id, invId));
|
||||||
|
if (ioStorInvDis.size() == 0) {
|
||||||
|
throw new BadRequestException("分配明细不存在!");
|
||||||
|
}
|
||||||
|
// 类型转换
|
||||||
|
ArrayList<LinkedHashMap> tables = new ArrayList<>();
|
||||||
|
ioStorInvDis.forEach(item -> tables.add(JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class)));
|
||||||
|
divObj.put("tableMater", tables);
|
||||||
|
return divObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> doBuildInvObj(JSONArray rows) {
|
||||||
|
Map<String, Object> res = new HashMap<>();
|
||||||
|
ArrayList<HashMap> tableData = new ArrayList<>();
|
||||||
|
res.put("tableData", tableData);
|
||||||
|
// 物料室仓库
|
||||||
|
res.put("stor_id", "1582991156504039424");
|
||||||
|
res.put("bill_status", "10");
|
||||||
|
res.put("detail_count", rows.size());
|
||||||
|
res.put("bill_type", "0011");
|
||||||
|
res.put("biz_date", DateUtil.format(new Date(), "yyyy-MM-dd"));
|
||||||
|
for (int i = 0; i < rows.size(); i++) {
|
||||||
|
HashMap<String, Object> table = new HashMap<>();
|
||||||
|
JSONObject row = rows.getJSONObject(i);
|
||||||
|
table.put("group_id", row.getString("group_id"));
|
||||||
|
table.put("storagevehicle_code", row.getString(""));
|
||||||
|
table.put("material_id", row.getString("material_id"));
|
||||||
|
table.put("pcsn", row.getString("pcsn"));
|
||||||
|
table.put("qty", row.getBigDecimal("qty"));
|
||||||
|
table.put("qty_unit_id", row.getString("qty_unit_id"));
|
||||||
|
table.put("qty_unit_name", row.getString("qty_unit_name"));
|
||||||
|
table.put("status", "01");
|
||||||
|
table.put("bag_no", row.getString("bag_no"));
|
||||||
|
table.put("material_code", row.getString("material_code"));
|
||||||
|
table.put("material_name", row.getString("material_name"));
|
||||||
|
table.put("material_spec", row.getString("material_spec"));
|
||||||
|
tableData.add(table);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user