Merge remote-tracking branch 'origin/master'
# Conflicts: # mes/hd/nladmin-system/src/main/java/org/nl/wms/pda/service/impl/CacheLineHandServiceImpl.java
This commit is contained in:
@@ -183,17 +183,14 @@ public class ProduceWorkorderServiceImpl implements ProduceWorkorderService {
|
||||
public void deleteAll(String[] ids) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_produce_workorder");
|
||||
for (String workorder_id : ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("workorder_id", String.valueOf(workorder_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_id", currentUserId);
|
||||
param.put("update_name", nickName);
|
||||
param.put("update_time", DateUtil.now());
|
||||
wo.update(param);
|
||||
wo.update(param, "workorder_id = '" + workorder_id + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,8 +195,7 @@ public class CacheLineHandController{
|
||||
@ApiOperation("设置满框")
|
||||
public ResponseEntity<Object> setfullBox(@RequestBody JSONObject param) {
|
||||
log.info("海亮缓存线手持服务 [设置满框] 接口被请求, 请求参数-{}", param);
|
||||
cacheLineHandService.setfullBox(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return new ResponseEntity<>(cacheLineHandService.setfullBox(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/setEmptyBox")
|
||||
@@ -204,8 +203,7 @@ public class CacheLineHandController{
|
||||
@ApiOperation("设置空框")
|
||||
public ResponseEntity<Object> setEmptyBox(@RequestBody JSONObject param) {
|
||||
log.info("海亮缓存线手持服务 [设置空框] 接口被请求, 请求参数-{}", param);
|
||||
cacheLineHandService.setEmptyBox(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return new ResponseEntity<>(cacheLineHandService.setEmptyBox(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteBox")
|
||||
@@ -213,8 +211,7 @@ public class CacheLineHandController{
|
||||
@ApiOperation("删除箱子")
|
||||
public ResponseEntity<Object> deleteBox(@RequestBody JSONObject param) {
|
||||
log.info("海亮缓存线手持服务 [设置空框] 接口被请求, 请求参数-{}", param);
|
||||
cacheLineHandService.deleteBox(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
return new ResponseEntity<>(cacheLineHandService.deleteBox(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/agvInBoxExceptionQuery")
|
||||
|
||||
@@ -172,7 +172,7 @@ public interface CacheLineHandService{
|
||||
* @author gbx
|
||||
* @date 2023/3/24
|
||||
*/
|
||||
void setfullBox(JSONObject param);
|
||||
JSONObject setfullBox(JSONObject param);
|
||||
|
||||
/**
|
||||
* 设置空框
|
||||
@@ -181,7 +181,7 @@ public interface CacheLineHandService{
|
||||
* @author gbx
|
||||
* @date 2023/3/24
|
||||
*/
|
||||
void setEmptyBox(JSONObject param);
|
||||
JSONObject setEmptyBox(JSONObject param);
|
||||
|
||||
/**
|
||||
* AGV入箱异常-查询
|
||||
@@ -287,5 +287,5 @@ public interface CacheLineHandService{
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void deleteBox(JSONObject param);
|
||||
JSONObject deleteBox(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
private final RedisUtils redisUtils;
|
||||
@Autowired
|
||||
private LocalCache cache;
|
||||
|
||||
@Override
|
||||
public JSONArray dropdownListQuery(String param, String type) {
|
||||
//初始化下拉框列表1.物料规格2.工序3.指令状态4.设备
|
||||
@@ -322,7 +321,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void setfullBox(JSONObject param) {
|
||||
public JSONObject setfullBox(JSONObject param) {
|
||||
//物料ID
|
||||
String semimanufactures_uuid = param.getString("material_uuid");
|
||||
// 缓存线位置编码
|
||||
@@ -330,7 +329,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
// 料箱码
|
||||
String vehicle_code = param.getString("vehicle_code");
|
||||
//工序
|
||||
String workprocedure_code = param.getString("workprocedure_code");
|
||||
// String workprocedure_code = param.getString("workprocedure_code");
|
||||
// 缓存线
|
||||
String cacheLine_code = param.getString("wcsdevice_code");
|
||||
String weight = param.getString("weight");
|
||||
@@ -350,17 +349,18 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
//物料表
|
||||
WQLObject meTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
// 查询工序信息
|
||||
JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
|
||||
if(ObjectUtil.isEmpty(wpObj)) {
|
||||
throw new BadRequestException("工序查询错误,请检查工序");
|
||||
}
|
||||
// JSONObject wpObj = wpTab.query("workprocedure_code = '" + workprocedure_code + "'").uniqueResult(0);
|
||||
// if(ObjectUtil.isEmpty(wpObj)) {
|
||||
// throw new BadRequestException("工序查询错误,请检查工序");
|
||||
// }
|
||||
JSONObject meObj = meTab.query("material_id = '" + semimanufactures_uuid + "'").uniqueResult(0);
|
||||
if(ObjectUtil.isEmpty(meObj)) {
|
||||
throw new BadRequestException("物料查询错误,请检查物料");
|
||||
}
|
||||
String materialId = meObj.getString("material_id");
|
||||
vehiobj.put("vehicle_code", vehicle_code);
|
||||
//2.缓存线位置通过扫码绑定料箱条码
|
||||
positionTab.update(vehiobj);
|
||||
positionTab.update(vehiobj, "position_code = '" + position_code + "'");
|
||||
// 缓存线载具物料表
|
||||
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
//3.先删除料箱的所有关联信息,包括物料,工序,生产区域
|
||||
@@ -372,9 +372,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
json.put("cacheLine_code", cacheLine_code);
|
||||
json.put("material_id", meObj.getString("material_id"));
|
||||
json.put("weight", weight);
|
||||
json.put("material_id", materialId);
|
||||
json.put("quantity", quantity);
|
||||
json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
|
||||
json.put("workprocedure_name", wpObj.getString("workprocedure_name"));
|
||||
json.put("weight", weight);
|
||||
// json.put("workprocedure_code", wpObj.getString("workprocedure_code"));
|
||||
// json.put("workprocedure_name", wpObj.getString("workprocedure_name"));
|
||||
//有箱有料
|
||||
json.put("vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode());
|
||||
json.put("create_time", DateUtil.now());
|
||||
@@ -384,12 +386,13 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void setEmptyBox(
|
||||
JSONObject param) {
|
||||
public JSONObject setEmptyBox( JSONObject param) {
|
||||
// 缓存线位置编码
|
||||
String position_code = param.getString("position_code");
|
||||
// 载具条码
|
||||
String vehicle_code = param.getString("vehicle_code");
|
||||
// 缓存线
|
||||
String wcsdevice_code = param.getString("wcsdevice_code");
|
||||
// 缓存线载具物料表
|
||||
WQLObject ivtTab = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||
// 缓存线位置表
|
||||
@@ -400,17 +403,25 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
}
|
||||
//1.缓存线位置通过扫码绑定料箱条码
|
||||
vehiobj.put("vehicle_code", vehicle_code);
|
||||
positionTab.update(vehiobj);
|
||||
//2.清空
|
||||
JSONObject json = ivtTab.query("vehicle_code = '" + vehicle_code + "'").uniqueResult(0);
|
||||
positionTab.update(vehiobj, "position_code = '" + position_code + "'");
|
||||
//2.先删除料箱的所有关联信息,包括物料,工序,生产区域
|
||||
ivtTab.delete("vehicle_code = '" + vehicle_code + "'");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("vehmaterial_id", IdUtil.getStringId());
|
||||
json.put("vehicle_code", vehicle_code);
|
||||
json.put("cacheLine_code", wcsdevice_code);
|
||||
json.put("vehicle_status", StatusEnum.CACHE_VEL_EMT.getCode());
|
||||
json.put("material_id", "");
|
||||
json.put("weight", "0");
|
||||
json.put("quantity", "0");
|
||||
json.put("workprocedure_code", "");
|
||||
json.put("workprocedure_name", "");
|
||||
json.put("update_time", DateUtil.now());
|
||||
ivtTab.update(json);
|
||||
json.put("create_time", DateUtil.now());
|
||||
// 3.重新新建该缓存线位置上的料箱为空箱子,是空料箱没有放物料等其他信息
|
||||
ivtTab.insert(json);
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("message", "设置成功");
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -830,7 +841,9 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
// 指令标识
|
||||
String instruct_uuid = param.getString("instruct_uuid");
|
||||
// 指令点位表【sch_base_task】
|
||||
JSONObject instObj = WQLObject.getWQLObject("sch_base_task").query("task_id = '" + instruct_uuid + "'").uniqueResult(0);
|
||||
JSONObject instObj = WQLObject.getWQLObject("sch_base_task")
|
||||
.query("task_id = '" + instruct_uuid + "'")
|
||||
.uniqueResult(0);
|
||||
int putquantity = instObj.getInteger("material_qty");
|
||||
String producer = instObj.getString("point_code2");
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
@@ -856,7 +869,10 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
public JSONArray getCacheLine(JSONObject param) {
|
||||
// 生产区域
|
||||
String product_area = param.getString("product_area");
|
||||
JSONArray resultJSONArray = WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "7", "product_area", product_area)).process().getResultJSONArray(0);
|
||||
JSONArray resultJSONArray = WQL.getWO("PDA_QUERY")
|
||||
.addParamMap(MapOf.of("flag", "7", "product_area", product_area))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@@ -868,23 +884,36 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
|
||||
AtomicReference<JSONArray> res = new AtomicReference<>(new JSONArray());
|
||||
RedissonUtils.lock(() -> {
|
||||
// 生产区域
|
||||
res.set(WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "8", "product_area", productArea, "cacheLine_code", pointCode)).process().getResultJSONArray(0));
|
||||
res.set(WQL.getWO("PDA_QUERY")
|
||||
.addParamMap(MapOf.of("flag", "8",
|
||||
"product_area", productArea,
|
||||
"cacheLine_code", pointCode))
|
||||
.process()
|
||||
.getResultJSONArray(0));
|
||||
}, pointCode, 3);
|
||||
return res.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getProductArea() {
|
||||
JSONArray res = WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "9")).process().getResultJSONArray(0);
|
||||
JSONArray res = WQL.getWO("PDA_QUERY")
|
||||
.addParamMap(MapOf.of("flag", "9"))
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBox(JSONObject param) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject deleteBox(JSONObject param) {
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("message", "删除失败");
|
||||
WQLObject cvTab = WQLObject.getWQLObject("SCH_CacheLine_VehileMaterial");
|
||||
String vehicleCode = param.getString("vehicle_code");
|
||||
if(ObjectUtil.isNotEmpty(vehicleCode)) {
|
||||
cvTab.delete("vehicle_code = '" + vehicleCode + "'");
|
||||
res.put("message", "删除成功");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,16 +188,17 @@
|
||||
sch_cacheline_position.positionorder_no as seat_order_num,
|
||||
sch_cacheline_vehilematerial.workprocedure_code,
|
||||
sch_cacheline_vehilematerial.workprocedure_name,
|
||||
sch_cacheline_vehilematerial.material_id,
|
||||
sch_cacheline_vehilematerial.material_code,
|
||||
sch_cacheline_vehilematerial.material_name,
|
||||
sch_cacheline_vehilematerial.material_spec,
|
||||
sch_cacheline_vehilematerial.material_id as material_uuid,
|
||||
md_me_materialbase.material_code,
|
||||
md_me_materialbase.material_name,
|
||||
md_me_materialbase.material_spec,
|
||||
sch_cacheline_vehilematerial.quantity,
|
||||
sch_cacheline_vehilematerial.weight,
|
||||
IF(length(sch_cacheline_position.vehicle_code) > 0, IFNULL(sch_cacheline_vehilematerial.vehicle_status, 4), 5) AS vehicle_status
|
||||
FROM
|
||||
sch_cacheline_position
|
||||
LEFT JOIN sch_cacheline_vehilematerial ON sch_cacheline_position.vehicle_code = sch_cacheline_vehilematerial.vehicle_code
|
||||
LEFT JOIN md_me_materialbase ON md_me_materialbase.material_id = sch_cacheline_vehilematerial.material_id
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.product_area <> ""
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
package org.nl.wms.sch.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.wms.basedata.st.service.dto.StructattrDto;
|
||||
import org.nl.wms.basedata.st.service.impl.StructattrServiceImpl;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.nl.wms.sch.service.TaskService;
|
||||
import org.nl.wms.st.in.service.impl.ProductInServiceImpl;
|
||||
import org.nl.wms.st.in.service.impl.StorPublicServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Created by Lxy on 2023/03/30.
|
||||
*/
|
||||
public class ProductInTask extends AbstractAcsTask {
|
||||
|
||||
private final String THIS_CLASS = ProductInTask.class.getName();
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject taskObj, String status) {
|
||||
WQLObject disTab = WQLObject.getWQLObject("st_ivt_iostorinvdis"); // 出入库分配表
|
||||
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_IOStorInv"); // 出入库主表
|
||||
WQLObject dtlTab = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); // 出入库明细表
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
//1:执行中,2:完成 ,0:acs取消
|
||||
if (StrUtil.equals(status, "1")) {
|
||||
map.put("task_status", TaskStatusEnum.EXECUTING.getCode());
|
||||
//更新入库单分配任务状态
|
||||
HashMap<String, String> dis_map = new HashMap<>();
|
||||
dis_map.put("work_status", "02");
|
||||
dis_map.put("is_issued", "1");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "task_id = '" + taskObj.getString("task_id") + "'");
|
||||
}
|
||||
if (StrUtil.equals(status, "2")) {
|
||||
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
//调用入库分配确认方法
|
||||
ProductInServiceImpl productInService = SpringContextHolder.getBean(ProductInServiceImpl.class);
|
||||
JSONObject dis_form = new JSONObject();
|
||||
dis_form.put("task_id", taskObj.getString("task_id"));
|
||||
productInService.confirmDis(dis_form);
|
||||
}
|
||||
if (StrUtil.equals(status, "0")) {
|
||||
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||
|
||||
if (taskObj.getIntValue("task_status") > Integer.valueOf(TaskStatusEnum.ISSUE.getCode())) {
|
||||
throw new BadRequestException("任务已执行不能取消");
|
||||
}
|
||||
|
||||
// 更新任务表删除字段
|
||||
map.put("is_delete","1");
|
||||
|
||||
JSONObject jsonDis = disTab.query("task_id ='" + taskObj.getString("task_id") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonDis)) throw new BadRequestException("分配明细不存在");
|
||||
String iostorinv_id = jsonDis.getString("iostorinv_id");
|
||||
|
||||
// 解锁货位
|
||||
HashMap<String, String> unlock_map = new HashMap<>();
|
||||
unlock_map.put("lock_type", "1");
|
||||
unlock_map.put("taskdtl_type", "");
|
||||
unlock_map.put("taskdtl_id", "");
|
||||
unlock_map.put("task_code", "");
|
||||
unlock_map.put("inv_type", "");
|
||||
unlock_map.put("inv_id", "");
|
||||
unlock_map.put("inv_code", "");
|
||||
point_table.update(unlock_map, "point_code = '" + taskObj.get("point_code2") + "'");
|
||||
struct_table.update(unlock_map, "struct_code = '" + taskObj.get("point_code2") + "'");
|
||||
|
||||
//减去原货位的待入数
|
||||
JSONArray dis_rows = disTab.query("struct_code = '" + taskObj.get("point_code2") + "' AND work_status < '99'").getResultJSONArray(0);
|
||||
if (dis_rows.size() <= 0) {
|
||||
throw new BadRequestException("数据参数有误!");
|
||||
}
|
||||
|
||||
StructattrDto old_struct = new StructattrServiceImpl().findByCode(taskObj.getString("point_code2"));
|
||||
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + dis_rows.getJSONObject(0).getString("iostorinv_id") + "'").uniqueResult(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject i_form = new JSONObject();
|
||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||
i_form.put("struct_id", old_struct.getStruct_id());
|
||||
i_form.put("material_id", dis_row.getString("material_id"));
|
||||
i_form.put("quality_scode", dis_row.getString("quality_scode"));
|
||||
i_form.put("pcsn", dis_row.getString("pcsn"));
|
||||
i_form.put("ivt_level", dis_row.getString("ivt_level"));
|
||||
i_form.put("change_qty", dis_row.getString("plan_qty"));
|
||||
i_form.put("bill_type_scode", mst_jo.getString("bill_type"));
|
||||
i_form.put("inv_id", mst_jo.getString("iostorinv_id"));
|
||||
i_form.put("bill_code", mst_jo.getString("bill_code"));
|
||||
i_form.put("bill_table", "ST_IVT_IOStorInv");
|
||||
i_form.put("qty_unit_id", dis_row.getString("qty_unit_id"));
|
||||
i_form.put("qty_unit_name", dis_row.getString("qty_unit_name"));
|
||||
new StorPublicServiceImpl().IOStor(i_form,"32");
|
||||
}
|
||||
|
||||
// 修改主表状态为分配中:30
|
||||
JSONObject mstMap = new JSONObject();
|
||||
mstMap.put("bill_status", "30");
|
||||
mstMap.put("update_optid", currentUserId);
|
||||
mstMap.put("update_optname", nickName);
|
||||
mstMap.put("update_time", now);
|
||||
mstTab.update(mstMap,"iostorinv_id = '"+iostorinv_id+"'");
|
||||
|
||||
// 修改明细状态为生成:10
|
||||
JSONObject dtlMap = new JSONObject();
|
||||
dtlMap.put("bill_status", "10");
|
||||
dtlTab.update(dtlMap,"iostorinv_id = '"+iostorinv_id+"'");
|
||||
|
||||
// 更新分配明细为:未生成:00,清空对应字段
|
||||
JSONObject disMap = new JSONObject();
|
||||
disMap.put("work_status", "00");
|
||||
disMap.put("point_id", "");
|
||||
disMap.put("task_id", "");
|
||||
disMap.put("sect_id", "");
|
||||
disMap.put("sect_code", "");
|
||||
disMap.put("sect_name", "");
|
||||
disMap.put("struct_id", "");
|
||||
disMap.put("struct_code", "");
|
||||
disMap.put("struct_name", "");
|
||||
disTab.update(disMap,"task_id = '"+taskObj.getString("task_id")+"'");
|
||||
}
|
||||
map.put("update_optid", currentUserId);
|
||||
map.put("update_optname", nickName);
|
||||
map.put("update_time", now);
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").update(map, "task_id = '" + taskObj.getString("task_id") + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTask(JSONObject form) {
|
||||
|
||||
String task_type = form.getString("task_type");
|
||||
if (StrUtil.isBlank(task_type)) {
|
||||
throw new BadRequestException("业务类型不能为空");
|
||||
}
|
||||
String start_device_code = form.getString("start_device_code");
|
||||
if (StrUtil.isBlank(start_device_code)) {
|
||||
throw new BadRequestException("起点不能为空");
|
||||
}
|
||||
String next_device_code = form.getString("next_device_code");
|
||||
if (StrUtil.isBlank(next_device_code)) {
|
||||
throw new BadRequestException("终点不能为空");
|
||||
}
|
||||
String vehicle_code = form.getString("vehicle_code");
|
||||
if (StrUtil.isBlank(vehicle_code)) {
|
||||
throw new BadRequestException("载具号不能为空");
|
||||
}
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("task_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
json.put("task_code", IdUtil.getSnowflake(1,1).nextId());
|
||||
json.put("product_area", form.getString("product_area"));
|
||||
json.put("task_type", form.getString("task_type"));
|
||||
json.put("is_send", "1");
|
||||
json.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
json.put("point_code1", start_device_code);
|
||||
json.put("point_code2", next_device_code);
|
||||
json.put("vehicle_code", form.getString("vehicle_code"));
|
||||
json.put("handle_class", this.getClass().getName());
|
||||
json.put("create_id", currentUserId);
|
||||
json.put("create_name", currentUsername);
|
||||
json.put("create_time", DateUtil.now());
|
||||
json.put("update_id", currentUserId);
|
||||
json.put("update_name", currentUsername);
|
||||
json.put("update_time", DateUtil.now());
|
||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(json);
|
||||
|
||||
return json.getString("task_id");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, "0");
|
||||
}
|
||||
}
|
||||
@@ -118,18 +118,11 @@ public class ProductInController {
|
||||
@PostMapping("/divPoint")
|
||||
@Log("设置起点")
|
||||
@ApiOperation("设置起点")
|
||||
public ResponseEntity<Object> divPoint(@RequestBody Map whereJson) {
|
||||
public ResponseEntity<Object> divPoint(@RequestBody JSONObject whereJson) {
|
||||
productInService.divPoint(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/queryTask")
|
||||
@Log("查询任务")
|
||||
@ApiOperation("查询任务")
|
||||
public ResponseEntity<Object> queryTask(@RequestBody Map whereJson) {
|
||||
return new ResponseEntity<>(productInService.queryTask(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/delDis")
|
||||
@Log("删除分配")
|
||||
@ApiOperation("删除分配")
|
||||
@@ -153,38 +146,6 @@ public class ProductInController {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/delTask")
|
||||
@Log("删除任务")
|
||||
@ApiOperation("删除任务")
|
||||
public ResponseEntity<Object> delTask(@RequestBody Map whereJson) {
|
||||
productInService.delTask(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/reIssueTask")
|
||||
@Log("下发")
|
||||
@ApiOperation("下发")
|
||||
public ResponseEntity<Object> reIssueTask(@RequestBody Map whereJson) {
|
||||
productInService.reIssueTask(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/confirmTask")
|
||||
@Log("完成任务")
|
||||
@ApiOperation("完成任务")
|
||||
public ResponseEntity<Object> confirmTask(@RequestBody Map whereJson) {
|
||||
productInService.confirmTask(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/cancelTask")
|
||||
@Log("取消完成任务")
|
||||
@ApiOperation("取消完成任务")
|
||||
public ResponseEntity<Object> cancelTask(@RequestBody Map whereJson) {
|
||||
productInService.cancelTask(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/confirm")
|
||||
@Log("完成单据")
|
||||
@ApiOperation("完成单据")
|
||||
@@ -193,14 +154,6 @@ public class ProductInController {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/backConfirm")
|
||||
@Log("完成入库负单")
|
||||
@ApiOperation("完成入库负单")
|
||||
public ResponseEntity<Object> backConfirm(@RequestBody Map whereJson) {
|
||||
productInService.backConfirm(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/autoDis")
|
||||
@Log("自动分配")
|
||||
@ApiOperation("自动分配")
|
||||
@@ -208,4 +161,11 @@ public class ProductInController {
|
||||
productInService.autoDis(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping("/getDisTask")
|
||||
@Log("获取明细任务")
|
||||
@ApiOperation("获取明细任务")
|
||||
public ResponseEntity<Object> getDisTask(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(productInService.getDisTask(whereJson),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,22 +62,16 @@ public interface ProductInService {
|
||||
*/
|
||||
void unDivStruct(JSONObject whereJson);
|
||||
|
||||
void divPoint(Map whereJson);
|
||||
/**
|
||||
* 设置起点
|
||||
* @param whereJson /
|
||||
*/
|
||||
void divPoint(JSONObject whereJson);
|
||||
|
||||
void updateTask(Map whereJson);
|
||||
|
||||
void delTask(Map whereJson);
|
||||
|
||||
void reIssueTask(Map whereJson);
|
||||
|
||||
void confirmTask(Map whereJson);
|
||||
|
||||
void cancelTask(Map whereJson);
|
||||
|
||||
void confirm(Map whereJson);
|
||||
|
||||
void backConfirm(Map whereJson);
|
||||
|
||||
/**
|
||||
* 查询入库分配明细
|
||||
* @param whereJson /
|
||||
@@ -85,8 +79,6 @@ public interface ProductInService {
|
||||
*/
|
||||
JSONArray getDisDtl(JSONObject whereJson);
|
||||
|
||||
JSONArray queryTask(Map whereJson);
|
||||
|
||||
/**
|
||||
* 自动分配
|
||||
* @param whereJson /
|
||||
@@ -94,8 +86,6 @@ public interface ProductInService {
|
||||
*/
|
||||
JSONObject autoDis(JSONObject whereJson);
|
||||
|
||||
JSONObject autoDisMove(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 查询仓库
|
||||
* @return JSONArray
|
||||
@@ -107,4 +97,10 @@ public interface ProductInService {
|
||||
* @param whereJson /
|
||||
*/
|
||||
void confirmvehicle(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 获取分配明细任务
|
||||
* @param whereJson /
|
||||
*/
|
||||
JSONArray getDisTask(JSONObject whereJson);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ package org.nl.wms.st.in.service.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -21,17 +19,16 @@ import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.basedata.st.service.StorattrService;
|
||||
import org.nl.wms.basedata.st.service.StructattrService;
|
||||
import org.nl.wms.basedata.st.service.dto.StorattrDto;
|
||||
import org.nl.wms.basedata.st.service.dto.StructattrDto;
|
||||
import org.nl.wms.sch.service.PointService;
|
||||
import org.nl.wms.sch.service.dto.PointDto;
|
||||
import org.nl.wms.sch.tasks.ProductInTask;
|
||||
import org.nl.wms.st.in.service.ProductInService;
|
||||
import org.nl.wms.st.in.service.StorPublicService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -333,7 +330,8 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
@Override
|
||||
public JSONArray getIODtl(JSONObject whereJson) {
|
||||
String bill_code = whereJson.getString("bill_code");
|
||||
JSONArray ja = WQL.getWO("QST_IVT_PRODUCTIN_01").addParam("flag", "2").addParam("bill_code", bill_code)
|
||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
||||
JSONArray ja = WQL.getWO("QST_IVT_PRODUCTIN_01").addParam("flag", "2").addParam("bill_code", bill_code).addParam("iostorinv_id", iostorinv_id)
|
||||
.process().getResultJSONArray(0);
|
||||
return ja;
|
||||
}
|
||||
@@ -435,20 +433,20 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
jsonPoint1.put("lock_type", "2");
|
||||
pointTab.update(jsonPoint1);
|
||||
// 判断是否需要锁定两个货位
|
||||
if (is_length.equals("1")) {
|
||||
if (StrUtil.equals(is_length, "1")) {
|
||||
JSONObject jsonPoint2 = pointTab.query("point_id = '" + jsonPoint1.getString("control_point") + "'").uniqueResult(0);
|
||||
jsonPoint2.put("lock_type", "2");
|
||||
pointTab.update(jsonPoint2);
|
||||
}
|
||||
|
||||
// 更新分配明细
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinv_id = '" + map.get("iostorinv_id") + "'");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(dis_map, "iostorinvdtl_id = '" + map.get("iostorinvdtl_id") + "'");
|
||||
|
||||
/*
|
||||
* 更新库存
|
||||
*/
|
||||
//直接取出入库分配表的库存
|
||||
JSONArray dis_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").getResultJSONArray(0);
|
||||
JSONArray dis_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinvdtl_id = '" + map.get("iostorinvdtl_id") + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject dis_jo = dis_rows.getJSONObject(i);
|
||||
JSONObject i_form = new JSONObject();
|
||||
@@ -473,7 +471,7 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
if (disdiv_rows.size() == 0) {
|
||||
dtl_jo.put("bill_status", "30");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_jo);
|
||||
//判断主表下的明细是否都为40
|
||||
//判断主表下的明细是否都为30
|
||||
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + dis_jo.getString("iostorinv_id") + "' AND bill_status < '30'").getResultJSONArray(0);
|
||||
if (dtl_rows.size() == 0) {
|
||||
mst.put("bill_status", "30");
|
||||
@@ -554,12 +552,12 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
map.put("struct_code", "");
|
||||
map.put("struct_name", "");
|
||||
map.put("work_status", "00");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(map, "iostorinv_id = '" + mst_jo.get("iostorinv_id") + "'");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(map, "iostorinvdtl_id = '" + whereJson.getString("iostorinvdtl_id") + "'");
|
||||
|
||||
//修改明细状态
|
||||
HashMap<String, String> dtl_map = new HashMap<>();
|
||||
dtl_map.put("bill_status", "10");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_map, "iostorinv_id = '" + mst_jo.get("iostorinv_id") + "'");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_map, "iostorinvdtl_id = '" + whereJson.get("iostorinvdtl_id") + "'");
|
||||
|
||||
//更新主表状态
|
||||
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + mst_jo.get("iostorinv_id") + "' AND bill_status IN ('20','30')").getResultJSONArray(0);
|
||||
@@ -573,14 +571,11 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void divPoint(Map whereJson) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
public void divPoint(JSONObject whereJson) {
|
||||
|
||||
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableMater");
|
||||
String point_code = (String) whereJson.get("point_code");
|
||||
HashMap<String, String> map = rows.get(0);
|
||||
JSONArray rows = whereJson.getJSONArray("tableMater");
|
||||
String point_code = whereJson.getString("point_code");
|
||||
JSONObject map = rows.getJSONObject(0);
|
||||
|
||||
HashMap<String, String> point_map = new HashMap<>();
|
||||
PointDto pointDto = pointService.findByCode(point_code);
|
||||
@@ -588,65 +583,27 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
point_map.put("point_id", pointDto.getPoint_id() + "");
|
||||
point_map.put("point_name", pointDto.getPoint_name());
|
||||
|
||||
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.getString("iostorinv_id") + "'").uniqueResult(0);
|
||||
|
||||
//判断起点终点是否不为空
|
||||
JSONObject ios_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + map.get("iostorinv_id") + "' AND box_no = '" + map.get("box_no") + "'").uniqueResult(0);
|
||||
JSONObject ios_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinvdtl_id = '" + map.getString("iostorinvdtl_id") + "'").uniqueResult(0);
|
||||
if (StrUtil.isNotEmpty(ios_dis.getString("struct_code"))) {
|
||||
//创建任务
|
||||
// AbstractAcsTask task = new InTask();
|
||||
ProductInTask task = new ProductInTask();
|
||||
|
||||
JSONObject task_form = new JSONObject();
|
||||
task_form.put("task_type", "010501");
|
||||
task_form.put("start_device_code", point_code);
|
||||
task_form.put("next_device_code", ios_dis.getString("struct_code"));
|
||||
task_form.put("vehicle_code", map.get("box_no"));
|
||||
//查询主表信息
|
||||
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
||||
task_form.put("inv_type", mst.get("bill_type"));
|
||||
task_form.put("inv_id", mst.get("iostorinv_id"));
|
||||
task_form.put("inv_code", mst.get("bill_code"));
|
||||
/* String task_id = task.createTask(task_form);
|
||||
task_form.put("vehicle_code", map.getString("storagevehicle_code"));
|
||||
task_form.put("product_area", mst.getString("product_code"));
|
||||
|
||||
String task_id = task.createTask(task_form);
|
||||
point_map.put("task_id", task_id);
|
||||
point_map.put("work_status", "01");*/
|
||||
point_map.put("work_status", "01");
|
||||
}
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(point_map, "iostorinv_id = '" + map.get("iostorinv_id") + "' AND box_no = '" + map.get("box_no") + "'");
|
||||
|
||||
if (StrUtil.isNotEmpty(ios_dis.getString("struct_code"))) {
|
||||
//修改库存
|
||||
//直接取出入库分配表的库存
|
||||
JSONArray dis_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + map.get("iostorinv_id") + "' AND box_no = '" + map.get("box_no") + "'").getResultJSONArray(0);
|
||||
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject dis_jo = dis_rows.getJSONObject(i);
|
||||
//更新明细表状态
|
||||
JSONObject dtl_jo = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinvdtl_id = '" + dis_jo.getString("iostorinvdtl_id") + "'").uniqueResult(0);
|
||||
if (dtl_jo.getDoubleValue("unassign_qty") == 0) {
|
||||
//判断该明细下是否还存在未分配货位的分配明细
|
||||
JSONArray disdiv_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinvdtl_id = '" + dis_jo.getString("iostorinvdtl_id") + "' AND (struct_id = '' OR struct_id is null) AND (point_id = '' OR point_id is null)").getResultJSONArray(0);
|
||||
if (disdiv_rows.size() == 0) {
|
||||
dtl_jo.put("bill_status", "40");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(dtl_jo);
|
||||
//判断主表下的明细是否都为40
|
||||
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + dis_jo.getString("iostorinv_id") + "' AND bill_status < '40'").getResultJSONArray(0);
|
||||
if (dtl_rows.size() == 0) {
|
||||
mst_jo.put("bill_status", "40");
|
||||
mst_jo.put("dis_optid", currentUserId);
|
||||
mst_jo.put("dis_optname", nickName);
|
||||
mst_jo.put("dis_time", now);
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray queryTask(Map whereJson) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "5");
|
||||
map.put("iostorinvdtl_id", (String) whereJson.get("iostorinvdtl_id"));
|
||||
map.put("is_finish", (String) whereJson.get("checked"));
|
||||
JSONArray rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(map).process().getResultJSONArray(0);
|
||||
return rows;
|
||||
// 更新分配明细表
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(point_map, "iostorinvdtl_id = '" + map.getString("iostorinvdtl_id") + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -720,300 +677,6 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
return struct_jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject autoDisMove(JSONObject whereJson) {
|
||||
/*
|
||||
* 分配逻辑:
|
||||
* 1、先查找该木箱内属于什么物料、订单,定位到具体的块、排,查看是否存在空位
|
||||
* a、存在的话,优先放在这一块这一排中(遍历)
|
||||
* b、不存在则根据该订单物料大概数量、选择数量相近的一个空巷道
|
||||
* 1)存在空巷道
|
||||
* 2)不存在,则找一个双通有空位置、数量相近的巷道
|
||||
* */
|
||||
|
||||
|
||||
JSONObject struct_jo = new JSONObject();
|
||||
|
||||
String box_no = whereJson.getString("box_no");
|
||||
|
||||
String sect_id = whereJson.getString("sect_id");
|
||||
|
||||
String col_num = whereJson.getString("layer_num"); // 转库时用
|
||||
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + box_no + "' AND status < 3").uniqueResult(0);
|
||||
|
||||
String material_code = sub_jo.getString("product_name");
|
||||
|
||||
String sale_order_name = sub_jo.getString("sale_order_name");
|
||||
|
||||
HashMap<String, String> row_map = new HashMap<>();
|
||||
row_map.put("material_code", material_code);
|
||||
row_map.put("sale_order_name", sale_order_name);
|
||||
row_map.put("col_num", col_num);
|
||||
row_map.put("sect_id", sect_id);
|
||||
row_map.put("flag", "11");
|
||||
//查询到当前可用的巷道
|
||||
JSONArray rowArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
|
||||
for (int i = 0; i < rowArr.size(); i++) {
|
||||
JSONObject row_jo = rowArr.getJSONObject(i);
|
||||
|
||||
String block_num = row_jo.getString("block_num");
|
||||
String row_num = row_jo.getString("row_num");
|
||||
String placement_type = row_jo.getString("placement_type");
|
||||
|
||||
// 判断此排是否有除:入库锁、移入锁以外的锁
|
||||
JSONArray isLock = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(isLock)) {
|
||||
if (placement_type.equals("02")) {
|
||||
// 左通
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0);
|
||||
break;
|
||||
} else if (placement_type.equals("03")) {
|
||||
// 右通
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0);
|
||||
break;
|
||||
} else {
|
||||
// 双通
|
||||
|
||||
// 先倒序找到第一个木箱、判断上一个是否有货位
|
||||
JSONObject jsonDescBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
|
||||
|
||||
JSONObject jsonDescStruct = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonDescBox)) {
|
||||
String out_order_seq = jsonDescBox.getString("out_order_seq");
|
||||
jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0);
|
||||
} else {
|
||||
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
|
||||
JSONObject jsonDescEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) {
|
||||
String out_order_seq = jsonDescEmpStruct.getString("out_order_seq");
|
||||
jsonDescStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescStruct)) {
|
||||
struct_jo = jsonDescStruct;
|
||||
break;
|
||||
} else {
|
||||
// 没有就正序找到第一个物料、判断上一个是否有货位
|
||||
JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
|
||||
|
||||
JSONObject jsonAscStruct = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonAscBox)) {
|
||||
String out_order_seq2 = jsonAscBox.getString("out_order_seq");
|
||||
// 上一个货位顺序号
|
||||
jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0);
|
||||
} else {
|
||||
JSONObject jsonAscEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) {
|
||||
String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq");
|
||||
jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0);
|
||||
}
|
||||
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(jsonAscStruct)) {
|
||||
struct_jo = jsonAscStruct;
|
||||
break;
|
||||
} else {
|
||||
// 说明这排有任务在执行,新开一排
|
||||
//根据分切计划查询该订单物料大概还有多少未入
|
||||
row_map.put("flag", "12");
|
||||
JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(plan_rows)) {
|
||||
plan_rows = new JSONArray();
|
||||
}
|
||||
//查询该销售订单及行号有多少个生成状态的箱子
|
||||
row_map.put("flag", "27");
|
||||
JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(box_rows)) {
|
||||
box_rows = new JSONArray();
|
||||
}
|
||||
int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size();
|
||||
|
||||
//查询数量与订单物料箱子数量相近的一排
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num),block_num,row_num").process().uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||
String block_num2 = empty_row.getString("block_num");
|
||||
String row_num2 = empty_row.getString("row_num");
|
||||
String placement_type2 = empty_row.getString("placement_type");
|
||||
|
||||
if (placement_type.equals("02")) {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0);
|
||||
break;
|
||||
} else {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
//如果查询不到空的一排,则查询有空位双通的一排
|
||||
JSONArray haveArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().getResultJSONArray(0);
|
||||
|
||||
for (int j = 0; j < haveArr.size(); j++) {
|
||||
JSONObject have_row = haveArr.getJSONObject(j);
|
||||
|
||||
String block_num3 = have_row.getString("block_num");
|
||||
String row_num3 = have_row.getString("row_num");
|
||||
|
||||
JSONArray isLock2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(isLock2)) {
|
||||
// 先倒序找到第一个木箱、判断上一个是否有货位
|
||||
JSONObject jsonDescBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
|
||||
|
||||
JSONObject jsonDescStruct2 = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonDescBox2)) {
|
||||
String out_order_seq = jsonDescBox2.getString("out_order_seq");
|
||||
jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0);
|
||||
} else {
|
||||
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
|
||||
JSONObject jsonDescEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) {
|
||||
String out_order_seq = jsonDescEmpStruct.getString("out_order_seq");
|
||||
jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescStruct2)) {
|
||||
struct_jo = jsonDescStruct2;
|
||||
break;
|
||||
} else {
|
||||
// 没有就正序找到第一个物料、判断上一个是否有货位
|
||||
JSONObject jsonAscBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
|
||||
|
||||
JSONObject jsonAscStruct2 = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonAscBox2)) {
|
||||
String out_order_seq2 = jsonAscBox2.getString("out_order_seq");
|
||||
// 上一个货位顺序号
|
||||
jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0);
|
||||
} else {
|
||||
JSONObject jsonAscEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) {
|
||||
String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq");
|
||||
jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0);
|
||||
}
|
||||
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(jsonAscStruct2)) {
|
||||
struct_jo = jsonAscStruct2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(rowArr) || ObjectUtil.isEmpty(struct_jo)) {
|
||||
//如果不存在相同订单物料的巷道 或者未找到相同物料订单号巷道中的货位 则
|
||||
|
||||
//根据分切计划查询该订单物料大概还有多少未入
|
||||
row_map.put("flag", "12");
|
||||
JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(plan_rows)) {
|
||||
plan_rows = new JSONArray();
|
||||
}
|
||||
//查询该销售订单及行号有多少个生成状态的箱子
|
||||
row_map.put("flag", "27");
|
||||
JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
|
||||
if (ObjectUtil.isEmpty(box_rows)) {
|
||||
box_rows = new JSONArray();
|
||||
}
|
||||
int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size();
|
||||
|
||||
//查询数量与订单物料箱子数量相近的一排
|
||||
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num),block_num,row_num").process().uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(empty_row)) {
|
||||
String block_num = empty_row.getString("block_num");
|
||||
String row_num = empty_row.getString("row_num");
|
||||
String placement_type = empty_row.getString("placement_type");
|
||||
|
||||
if (placement_type.equals("02")) {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0);
|
||||
} else {
|
||||
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "' AND row_num = '" + row_num + "' AND placement_type = '" + placement_type + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0);
|
||||
}
|
||||
} else {
|
||||
|
||||
//如果查询不到空的一排,则查询有空位双通的一排
|
||||
JSONArray haveArr = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("col_num", col_num).addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().getResultJSONArray(0);
|
||||
for (int j = 0; j < haveArr.size(); j++) {
|
||||
JSONObject have_row = haveArr.getJSONObject(j);
|
||||
|
||||
String block_num3 = have_row.getString("block_num");
|
||||
String row_num3 = have_row.getString("row_num");
|
||||
|
||||
JSONArray isLock2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type not in ('1','2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1'").getResultJSONArray(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(isLock2)) {
|
||||
// 先倒序找到第一个木箱、判断上一个是否有货位
|
||||
JSONObject jsonDescBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq DESC").uniqueResult(0);
|
||||
|
||||
JSONObject jsonDescStruct2 = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonDescBox2)) {
|
||||
String out_order_seq = jsonDescBox2.getString("out_order_seq");
|
||||
jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0);
|
||||
} else {
|
||||
// 先倒序找到第一个入库锁或者移库锁、判断上一个是否有货位
|
||||
JSONObject jsonDescEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq DESC").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescEmpStruct)) {
|
||||
String out_order_seq = jsonDescEmpStruct.getString("out_order_seq");
|
||||
jsonDescStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq > '" + out_order_seq + "' order by out_order_seq ASC").uniqueResult(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDescStruct2)) {
|
||||
struct_jo = jsonDescStruct2;
|
||||
break;
|
||||
} else {
|
||||
// 没有就正序找到第一个物料、判断上一个是否有货位
|
||||
JSONObject jsonAscBox2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
|
||||
|
||||
JSONObject jsonAscStruct2 = new JSONObject();
|
||||
if (ObjectUtil.isNotEmpty(jsonAscBox2)) {
|
||||
String out_order_seq2 = jsonAscBox2.getString("out_order_seq");
|
||||
// 上一个货位顺序号
|
||||
jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0);
|
||||
} else {
|
||||
JSONObject jsonAscEmpStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type in ('2','7') AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq ASC").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonAscEmpStruct)) {
|
||||
String out_order_seq2 = jsonAscEmpStruct.getString("out_order_seq");
|
||||
jsonAscStruct2 = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq < '" + out_order_seq2 + "' order by out_order_seq DESC").uniqueResult(0);
|
||||
}
|
||||
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(jsonAscStruct2)) {
|
||||
struct_jo = jsonAscStruct2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||
throw new BadRequestException("未查询到可用的仓位!");
|
||||
}
|
||||
return struct_jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray queryStor() {
|
||||
WQLObject storTab = WQLObject.getWQLObject("st_ivt_bsrealstorattr");
|
||||
@@ -1045,6 +708,13 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getDisTask(JSONObject whereJson) {
|
||||
//查询该明细下的所有入库分配明细
|
||||
JSONArray resultJSONArray = WQL.getWO("QST_IVT_PRODUCTIN_01").addParam("flag", "4").addParam("iostorinvdtl_id", whereJson.get("iostorinvdtl_id")).process().getResultJSONArray(0);
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
public JSONObject queryEmpStruct(JSONObject whereJson) {
|
||||
JSONObject struct_jo = new JSONObject();
|
||||
String sect_id = whereJson.getString("sect_id");
|
||||
@@ -1200,192 +870,6 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delTask(Map whereJson) {
|
||||
WQLObject dis_wql = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
||||
WQLObject task_wql = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject point_table = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject struct_table = WQLObject.getWQLObject("ST_IVT_StructAttr");
|
||||
|
||||
|
||||
//判断指令状态,只能修改生成状态的任务
|
||||
/* String task_id = (String) whereJson.get("task_id");
|
||||
TaskDto taskDto = taskService.findByDtlId(task_id);
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
throw new BadRequestException("请输入正确的任务号!");
|
||||
}
|
||||
if (!taskDto.getTask_status().equals("01")) {
|
||||
throw new BadRequestException("只能修改任务状态为生成的任务!");
|
||||
}*/
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
//更新任务表状态为删除
|
||||
HashMap task_map = new HashMap<>();
|
||||
task_map.put("is_delete", "1");
|
||||
task_map.put("update_optid", currentUserId);
|
||||
task_map.put("update_optname", nickName);
|
||||
task_map.put("update_time", now);
|
||||
//修改分配表起点,任务表起点
|
||||
task_wql.update(task_map, "task_id = '" + whereJson.get("task_id") + "'");
|
||||
|
||||
//解锁原货位点位
|
||||
HashMap unlock_map = new HashMap();
|
||||
unlock_map.put("lock_type", "1");
|
||||
unlock_map.put("taskdtl_type", "");
|
||||
unlock_map.put("taskdtl_id", "");
|
||||
unlock_map.put("task_code", "");
|
||||
unlock_map.put("inv_type", "");
|
||||
unlock_map.put("inv_id", "");
|
||||
unlock_map.put("inv_code", "");
|
||||
point_table.update(unlock_map, "point_code = '" + whereJson.get("struct_code") + "'");
|
||||
struct_table.update(unlock_map, "struct_code = '" + whereJson.get("struct_code") + "'");
|
||||
|
||||
//减去原货位的待入数
|
||||
JSONArray dis_rows = dis_wql.query("task_id = '" + whereJson.get("task_id") + "'").getResultJSONArray(0);
|
||||
if (dis_rows.size() <= 0) {
|
||||
throw new BadRequestException("数据参数有误!");
|
||||
}
|
||||
StructattrDto old_struct = structattrService.findByCode((String) whereJson.get("struct_code"));
|
||||
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + dis_rows.getJSONObject(0).getString("iostorinv_id") + "'").uniqueResult(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject i_form = new JSONObject();
|
||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||
i_form.put("struct_id", old_struct.getStruct_id());
|
||||
i_form.put("material_id", dis_row.getString("material_id"));
|
||||
i_form.put("quality_scode", dis_row.getString("quality_scode"));
|
||||
i_form.put("pcsn", dis_row.getString("pcsn"));
|
||||
i_form.put("change_qty", dis_row.getString("plan_qty"));
|
||||
i_form.put("bill_type_scode", mst_jo.getString("bill_type"));
|
||||
i_form.put("inv_id", mst_jo.getString("iostorinv_id"));
|
||||
i_form.put("bill_code", mst_jo.getString("bill_code"));
|
||||
i_form.put("bill_table", "ST_IVT_IOStorInv");
|
||||
i_form.put("qty_unit_id", dis_row.getString("qty_unit_id"));
|
||||
i_form.put("qty_unit_name", dis_row.getString("qty_unit_name"));
|
||||
// storPublicService.IOStor(i_form, "32");
|
||||
|
||||
}
|
||||
//更新分配状态
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("point_id", "");
|
||||
map.put("sect_id", "");
|
||||
map.put("sect_code", "");
|
||||
map.put("sect_name", "");
|
||||
map.put("struct_id", "");
|
||||
map.put("struct_code", "");
|
||||
map.put("struct_name", "");
|
||||
map.put("task_id", "");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDis").update(map, "iostorinv_id = '" + mst_jo.get("iostorinv_id") + "' AND box_no = '" + whereJson.get("box_no") + "'");
|
||||
|
||||
//修改明细状态
|
||||
HashMap<String, String> dtl_map = new HashMap<>();
|
||||
map.put("bill_status", "10");
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").update(map, "iostorinv_id = '" + mst_jo.get("iostorinv_id") + "' AND box_no = '" + whereJson.get("box_no") + "'");
|
||||
|
||||
//更新主表状态
|
||||
JSONArray dtl_rows = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl").query("iostorinv_id = '" + mst_jo.get("iostorinv_id") + "' AND bill_status IN ('20','30')").getResultJSONArray(0);
|
||||
if (dtl_rows.size() > 0) {
|
||||
mst_jo.put("bill_status", "30");
|
||||
} else {
|
||||
mst_jo.put("bill_status", "10");
|
||||
}
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void reIssueTask(Map whereJson) {
|
||||
String task_id = (String) whereJson.get("task_id");
|
||||
//判断指令状态,只能下发生成、执行中状态的任务
|
||||
JSONObject task_jo = WQLObject.getWQLObject("sch_base_task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(task_jo)) {
|
||||
throw new BadRequestException("请输入正确的任务号!");
|
||||
}
|
||||
if (!task_jo.getString("task_status").equals("04")) {
|
||||
throw new BadRequestException("只能修改任务状态为未下发的任务!");
|
||||
}
|
||||
// AbstractAcsTask task = new InTask();
|
||||
//调用ACS接受任务接口
|
||||
/* JSONObject result = task.immediateNotifyAcs(task_id);
|
||||
if (ObjectUtil.isNotEmpty(result)) {
|
||||
String status = result.getString("status");
|
||||
if ("200".equals(status)) {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
//更新任务指令为下发
|
||||
JSONObject task_map = new JSONObject();
|
||||
task_map.put("task_id", task_id);
|
||||
task.updateTaskStatus(task_map, "1");
|
||||
} else {
|
||||
throw new BadRequestException("任务下发失败:" + result.getString("message"));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirmTask(Map whereJson) {
|
||||
//判断指令状态,只能下发生成、执行中状态的任务
|
||||
String task_code = (String) whereJson.get("task_code");
|
||||
JSONObject task_jo = WQLObject.getWQLObject("sch_base_task").query("task_code = '" + task_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(task_jo)) {
|
||||
throw new BadRequestException("请输入正确的任务号!");
|
||||
}
|
||||
/*if (!task_jo.getString("task_status").equals("03")) {
|
||||
throw new BadRequestException("只能修改任务状态为执行中的任务!");
|
||||
}*/
|
||||
|
||||
/* AbstractAcsTask task = new InTask();
|
||||
task.updateTaskStatus(task_jo, TaskStatusEnum.FINISHED.getCode());*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(Map whereJson) {
|
||||
WQLObject dis_wql = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
||||
WQLObject task_wql = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject dtl_wql = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
||||
|
||||
|
||||
//判断指令状态,只能取消完成状态的任务
|
||||
String task_code = (String) whereJson.get("task_code");
|
||||
/* TaskDto taskDto = taskService.findByCode(task_code);
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
throw new BadRequestException("请输入正确的任务号!");
|
||||
}
|
||||
if (!taskDto.getTask_status().equals("99")) {
|
||||
throw new BadRequestException("只能取消任务状态为完成中的任务!");
|
||||
}*/
|
||||
|
||||
//判断主表是否为99,如果为99不允许取消
|
||||
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + whereJson.get("iostorinv_id") + "'").uniqueResult(0);
|
||||
if (mst_jo.getString("bill_status").equals("99")) {
|
||||
throw new BadRequestException("单据已完成,无法进行取消任务操作!");
|
||||
}
|
||||
|
||||
//变更任务状态
|
||||
HashMap task_map = new HashMap();
|
||||
task_map.put("task_status", "01");
|
||||
task_wql.update(task_map, "taskdtl_id = '" + whereJson.get("task_id") + "'");
|
||||
|
||||
//更新实际数量
|
||||
JSONArray dis_rows = dis_wql.query("task_id = '" + whereJson.get("task_id") + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||
double real_qty = dis_row.getDoubleValue("real_qty");
|
||||
dis_row.put("real_qty", "0");
|
||||
dis_row.put("work_status", "01");
|
||||
dis_wql.update(dis_row);
|
||||
|
||||
//更新明细实际数量
|
||||
JSONObject dtl_jo = dtl_wql.query("iostorinvdtl_id = '" + dis_row.getString("iostorinvdtl_id") + "'").uniqueResult(0);
|
||||
double old_real_qty = dtl_jo.getDoubleValue("real_qty");
|
||||
dtl_jo.put("real_qty", NumberUtil.sub(old_real_qty, real_qty));
|
||||
dtl_wql.update(dtl_jo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirm(Map whereJson) {
|
||||
@@ -1413,55 +897,112 @@ public class ProductInServiceImpl implements ProductInService {
|
||||
// inbillService.confirmMst(JSONObject.parseObject(JSON.toJSONString(whereJson)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void backConfirm(Map whereJson) {
|
||||
WQLObject dtl_wql = WQLObject.getWQLObject("st_ivt_iostorinvdtl");
|
||||
WQLObject mst_wql = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
||||
public void confirmDis(JSONObject form) {
|
||||
WQLObject dis_table = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
||||
WQLObject dtl_table = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
||||
String task_id = form.getString("task_id");
|
||||
|
||||
//校验主表状态为生成
|
||||
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + whereJson.get("iostorinv_id") + "'").uniqueResult(0);
|
||||
if (!mst_jo.getString("bill_status").equals("10")) {
|
||||
throw new BadRequestException("主表状态必须为生成!");
|
||||
if (StrUtil.isEmpty(task_id)) {
|
||||
throw new BadRequestException("任务标识为空!");
|
||||
}
|
||||
|
||||
JSONObject mst_row = mst_wql.query("iostorinv_id = '" + whereJson.get("iostorinv_id") + "'").uniqueResult(0);
|
||||
JSONArray dtl_rows = dtl_wql.query("iostorinv_id = '" + whereJson.get("iostorinv_id") + "'").getResultJSONArray(0);
|
||||
JSONArray dis_rows = dis_table.query("task_id = '" + task_id + "'").getResultJSONArray(0);
|
||||
//回写入库分配表实际数量
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||
dis_row.put("work_status", "99");
|
||||
dis_table.update(dis_row);
|
||||
|
||||
//生成手工出库单
|
||||
String iostorinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
String bill_code = CodeUtil.getNewCode("IO_CODE");
|
||||
whereJson.put("iostorinv_id", iostorinv_id);
|
||||
whereJson.put("bill_code", bill_code);
|
||||
whereJson.put("io_type", "1");
|
||||
whereJson.put("bill_type", "010601");
|
||||
whereJson.put("buss_type", ((String) whereJson.get("bill_type")).substring(0, 4));
|
||||
mst_wql.insert(whereJson);
|
||||
for (int i = 0; i < dtl_rows.size(); i++) {
|
||||
JSONObject dtl_row = dtl_rows.getJSONObject(i);
|
||||
dtl_row.put("source_billdtl_id", dtl_row.getString("iostorinvdtl_id"));
|
||||
dtl_row.put("source_bill_type", mst_row.getString("bill_type"));
|
||||
dtl_row.put("source_bill_code", mst_row.getString("bill_code"));
|
||||
dtl_row.put("source_bill_table", "ST_IVT_IOStorInvDtl");
|
||||
dtl_row.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
dtl_row.put("iostorinv_id", iostorinv_id);
|
||||
dtl_row.put("bill_status", "10");
|
||||
dtl_wql.insert(dtl_row);
|
||||
JSONObject dtl_row = dtl_table.query("iostorinvdtl_id = '" + dis_row.getString("iostorinvdtl_id") + "'").uniqueResult(0);
|
||||
//该明细下的所有分配明细都执行完成且未分配数=0,将明细变为99
|
||||
JSONArray unfinish_dis = dis_table.query("iostorinvdtl_id = '" + dis_row.getString("iostorinvdtl_id") + "' AND work_status < '99'").getResultJSONArray(0);
|
||||
if (dtl_row.getDoubleValue("unassign_qty") == 0 && unfinish_dis.size() <= 0) {
|
||||
dtl_row.put("bill_status", "99");
|
||||
}
|
||||
dtl_table.update(dtl_row);
|
||||
|
||||
//判断主表是否改为完成
|
||||
JSONArray dtl_rows = dtl_table.query("iostorinv_id = '" + dtl_row.getString("iostorinv_id") + "' AND bill_status < '99'").getResultJSONArray(0);
|
||||
if (dtl_rows.size() == 0) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("iostorinv_id", dtl_row.getString("iostorinv_id"));
|
||||
this.confirmMst(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirmMst(JSONObject from) {
|
||||
WQLObject dtl_table = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
||||
WQLObject dis_table = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase");
|
||||
String iostorinv_id = from.getString("iostorinv_id");
|
||||
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
mst_row.put("bill_status", "99");
|
||||
mst_row.put("confirm_optid", currentUserId);
|
||||
mst_row.put("confirm_optname", nickName);
|
||||
mst_row.put("confirm_time", now);
|
||||
//更新主表状态为99
|
||||
mst_wql.update(mst_row);
|
||||
JSONObject mst_jo = WQLObject.getWQLObject("ST_IVT_IOStorInv").query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("bill_status", "99");
|
||||
dtl_wql.update(map, "iostorinv_id = '" + mst_row.get("iostorinv_id") + "'");
|
||||
//查询
|
||||
JSONArray dtl_rows = dtl_table.query("iostorinv_id = '" + iostorinv_id + "' AND bill_status < '99'").getResultJSONArray(0);
|
||||
|
||||
if (dtl_rows.size() > 0) {
|
||||
throw new BadRequestException("主表下存在未完成的明细!");
|
||||
}
|
||||
|
||||
//更新目的点位,仓位、加库存
|
||||
JSONArray dis_rows = dis_table.query("iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < dis_rows.size(); i++) {
|
||||
JSONObject dis_row = dis_rows.getJSONObject(i);
|
||||
|
||||
//更新终点
|
||||
JSONObject jsonPoint1 = pointTab.query("point_id = '" + dis_row.getString("struct_id") + "'").uniqueResult(0);
|
||||
jsonPoint1.put("vehicle_code", dis_row.getString("storagevehicle_code"));
|
||||
jsonPoint1.put("lock_type", "1");
|
||||
jsonPoint1.put("point_status", "2");
|
||||
pointTab.update(jsonPoint1);
|
||||
// 判断此物料是否占用了两个货位
|
||||
JSONObject jsonMater = materTab.query("material_id = '" + dis_row.getString("material_id") + "'").uniqueResult(0);
|
||||
|
||||
String length_up = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("MATERIAL_LENGTH_UP").getValue();
|
||||
double material_length = jsonMater.getDoubleValue("length");
|
||||
double material_length_up = Double.valueOf(length_up);
|
||||
|
||||
if (material_length > material_length_up) {
|
||||
// 找对应货位并更新
|
||||
JSONObject jsonPoint2 = pointTab.query("point_id = '" + jsonPoint1.getString("control_point") + "'").uniqueResult(0);
|
||||
jsonPoint2.put("vehicle_code", dis_row.getString("storagevehicle_code"));
|
||||
jsonPoint2.put("lock_type", "1");
|
||||
jsonPoint2.put("point_status", "2");
|
||||
pointTab.update(jsonPoint2);
|
||||
}
|
||||
|
||||
//加库存
|
||||
JSONObject i_form = new JSONObject();
|
||||
i_form.put("struct_id", dis_row.getString("struct_id"));
|
||||
i_form.put("material_id", dis_row.getString("material_id"));
|
||||
i_form.put("quality_scode", dis_row.getString("quality_scode"));
|
||||
i_form.put("pcsn", dis_row.getString("pcsn"));
|
||||
i_form.put("change_qty", dis_row.getString("plan_qty"));
|
||||
i_form.put("bill_type_scode", mst_jo.getString("bill_type"));
|
||||
i_form.put("inv_id", mst_jo.getString("iostorinv_id"));
|
||||
i_form.put("bill_code", mst_jo.getString("bill_code"));
|
||||
i_form.put("bill_table", "ST_IVT_IOStorInv");
|
||||
i_form.put("qty_unit_id", dis_row.getString("qty_unit_id"));
|
||||
i_form.put("qty_unit_name", dis_row.getString("qty_unit_name"));
|
||||
storPublicService.IOStor(i_form, "33");
|
||||
|
||||
}
|
||||
mst_jo.put("bill_status", "99");
|
||||
mst_jo.put("confirm_optid", currentUserId);
|
||||
mst_jo.put("confirm_optname", nickName);
|
||||
mst_jo.put("confirm_time", now);
|
||||
|
||||
//更新主表状态为99
|
||||
WQLObject.getWQLObject("ST_IVT_IOStorInv").update(mst_jo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
输入.bill_type TYPEAS s_string
|
||||
输入.bill_code TYPEAS s_string
|
||||
输入.iostorinvdtl_id TYPEAS s_string
|
||||
输入.iostorinv_id TYPEAS s_string
|
||||
|
||||
|
||||
[临时表]
|
||||
@@ -102,6 +103,10 @@
|
||||
mst.bill_code = 输入.bill_code
|
||||
ENDOPTION
|
||||
|
||||
OPTION 输入.iostorinv_id <> ""
|
||||
mst.iostorinv_id = 输入.iostorinv_id
|
||||
ENDOPTION
|
||||
|
||||
order by dtl.seq_no ASC
|
||||
|
||||
ENDSELECT
|
||||
@@ -127,6 +132,36 @@
|
||||
dis.iostorinvdtl_id = 输入.iostorinvdtl_id
|
||||
ENDOPTION
|
||||
|
||||
order by dis.seq_no ASC
|
||||
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
dis.*,
|
||||
mater.material_code,
|
||||
mater.material_name,
|
||||
mater.material_spec,
|
||||
point.point_code,
|
||||
task.point_code1,
|
||||
task.point_code2,
|
||||
task.task_code,
|
||||
task.task_type
|
||||
FROM
|
||||
ST_IVT_IOStorInvDis dis
|
||||
LEFT JOIN sch_base_point point ON point.point_id = dis.point_id
|
||||
LEFT JOIN md_me_materialbase mater ON mater.material_id = dis.material_id
|
||||
LEFT JOIN sch_base_task task ON task.task_id = dis.task_id
|
||||
WHERE
|
||||
1=1
|
||||
|
||||
OPTION 输入.iostorinvdtl_id <> ""
|
||||
dis.iostorinvdtl_id = 输入.iostorinvdtl_id
|
||||
ENDOPTION
|
||||
|
||||
order by dis.seq_no ASC
|
||||
|
||||
ENDSELECT
|
||||
|
||||
Reference in New Issue
Block a user