opt:库存变更单代码优化,去除弃用的代码
This commit is contained in:
@@ -30,13 +30,6 @@ public interface ChangeService {
|
|||||||
*/
|
*/
|
||||||
void insertDtl(Map whereJson);
|
void insertDtl(Map whereJson);
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增出库单2
|
|
||||||
*
|
|
||||||
* @param whereJson /
|
|
||||||
*/
|
|
||||||
String insertDtl2(JSONObject whereJson);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询出库单明细
|
* 查询出库单明细
|
||||||
*
|
*
|
||||||
@@ -52,13 +45,6 @@ public interface ChangeService {
|
|||||||
*/
|
*/
|
||||||
void update(Map whereJson);
|
void update(Map whereJson);
|
||||||
|
|
||||||
/**
|
|
||||||
* 全部取消
|
|
||||||
*
|
|
||||||
* @param whereJson /
|
|
||||||
*/
|
|
||||||
void allCancel(JSONObject whereJson);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询可分配库存
|
* 查询可分配库存
|
||||||
*
|
*
|
||||||
@@ -74,38 +60,4 @@ public interface ChangeService {
|
|||||||
*/
|
*/
|
||||||
void confirm(JSONObject whereJson);
|
void confirm(JSONObject whereJson);
|
||||||
|
|
||||||
/**
|
|
||||||
* 出库任务下发
|
|
||||||
*
|
|
||||||
* @param whereJson /
|
|
||||||
*/
|
|
||||||
void issueTask(JSONObject whereJson);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 出库任务手动完成
|
|
||||||
*
|
|
||||||
* @param whereJson /
|
|
||||||
*/
|
|
||||||
void finishTask(JSONObject whereJson);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 出库任务手动取消完成
|
|
||||||
*
|
|
||||||
* @param whereJson /
|
|
||||||
*/
|
|
||||||
void cancleTaskfinish(JSONObject whereJson);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询单据字段
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
JSONArray getInvTypes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移库单手动下发
|
|
||||||
*
|
|
||||||
* @param whereJson /
|
|
||||||
*/
|
|
||||||
void handdown(JSONObject whereJson);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,11 @@ import org.nl.modules.wql.util.WqlUtil;
|
|||||||
import org.nl.wms.basedata.master.customer.service.dao.Customerbase;
|
import org.nl.wms.basedata.master.customer.service.dao.Customerbase;
|
||||||
import org.nl.wms.basedata.master.customer.service.dao.mapper.CustomerbaseMapper;
|
import org.nl.wms.basedata.master.customer.service.dao.mapper.CustomerbaseMapper;
|
||||||
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl;
|
import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl;
|
||||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
|
||||||
import org.nl.wms.st.inbill.service.StorPublicService;
|
|
||||||
import org.nl.wms.st.instor.service.ChangeService;
|
import org.nl.wms.st.instor.service.ChangeService;
|
||||||
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -39,7 +35,6 @@ import java.util.Map;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ChangeServiceImpl implements ChangeService {
|
public class ChangeServiceImpl implements ChangeService {
|
||||||
private final StorPublicService storPublicService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomerbaseMapper customerbaseMapper;
|
private CustomerbaseMapper customerbaseMapper;
|
||||||
@@ -116,7 +111,6 @@ public class ChangeServiceImpl implements ChangeService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void insertDtl(Map map) {
|
public void insertDtl(Map map) {
|
||||||
//主表
|
//主表
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
|
||||||
ArrayList<HashMap> rows = (ArrayList<HashMap>) map.get("tableData");
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) map.get("tableData");
|
||||||
map.remove("tableData");
|
map.remove("tableData");
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
@@ -227,175 +221,6 @@ public class ChangeServiceImpl implements ChangeService {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public String insertDtl2(JSONObject json) {
|
|
||||||
//主表
|
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
|
||||||
JSONArray rows = json.getJSONArray("tableData");
|
|
||||||
json.remove("tableData");
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
String now = DateUtil.now();
|
|
||||||
String moveinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
|
||||||
String bill_code = CodeUtil.getNewCode("MOVE_CODE");
|
|
||||||
json.put("moveinv_id", moveinv_id);
|
|
||||||
json.put("bill_code", bill_code);
|
|
||||||
json.put("buss_type", "");
|
|
||||||
json.put("create_mode", "01");
|
|
||||||
json.put("input_optid", currentUserId + "");
|
|
||||||
json.put("input_optname", nickName);
|
|
||||||
json.put("input_time", now);
|
|
||||||
json.put("update_optid", currentUserId + "");
|
|
||||||
json.put("update_optname", nickName);
|
|
||||||
json.put("update_time", now);
|
|
||||||
json.put("is_delete", "0");
|
|
||||||
json.put("is_upload", "0");
|
|
||||||
Long deptId = SecurityUtils.getDeptId();
|
|
||||||
json.put("sysdeptid", deptId);
|
|
||||||
json.put("syscompanyid", deptId);
|
|
||||||
//调用明细处理方法
|
|
||||||
JSONObject ret = this.insertDtlByRows2(json, rows);
|
|
||||||
json.put("detail_count", ret.getString("detail_count"));
|
|
||||||
json.put("total_qty", ret.getString("total_qty"));
|
|
||||||
wo_mst.insert(json);
|
|
||||||
return moveinv_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
JSONObject insertDtlByRows2(JSONObject jo_mst, JSONArray rows) {
|
|
||||||
//明细表
|
|
||||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_MoveInvDtl");
|
|
||||||
//主表
|
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
|
||||||
//任务表
|
|
||||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
//点位表
|
|
||||||
WQLObject wo_Point = WQLObject.getWQLObject("SCH_BASE_Point");
|
|
||||||
//定义返回数据
|
|
||||||
JSONObject ret = new JSONObject();
|
|
||||||
|
|
||||||
String is_task = jo_mst.getString("is_task");
|
|
||||||
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
String now = DateUtil.now();
|
|
||||||
//定义需要需要插入的库存集合
|
|
||||||
HashMap<String, JSONObject> Struct_map = new HashMap<String, JSONObject>();
|
|
||||||
StringBuffer ids = new StringBuffer();
|
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
|
||||||
JSONObject row = rows.getJSONObject(i);
|
|
||||||
String storagevehicle_code = row.getString("storagevehicle_code");
|
|
||||||
ids.append("'");
|
|
||||||
if (!Struct_map.containsKey(storagevehicle_code)) {
|
|
||||||
Struct_map.put(storagevehicle_code, row);
|
|
||||||
}
|
|
||||||
if (i != 0) {
|
|
||||||
ids.append("','");
|
|
||||||
}
|
|
||||||
ids.append(storagevehicle_code);
|
|
||||||
}
|
|
||||||
ids.append("'");
|
|
||||||
//查询所有载具的库存
|
|
||||||
JSONArray ja = WQL.getWO("QST_IVT_CHANGE")
|
|
||||||
.addParam("flag", "33")
|
|
||||||
.addParam("ids", ids.toString())
|
|
||||||
.process().getResultJSONArray(0);
|
|
||||||
if (ja.size() == 0) {
|
|
||||||
throw new BadRequestException("当前所有载具无可移库库存!");
|
|
||||||
}
|
|
||||||
double total_qty = 0;
|
|
||||||
for (int i = 0; i < ja.size(); i++) {
|
|
||||||
JSONObject jo = ja.getJSONObject(i);
|
|
||||||
String moveinvdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
|
||||||
total_qty = total_qty + jo.getDoubleValue("qty");
|
|
||||||
jo.put("moveinvdtl_id", moveinvdtl_id);
|
|
||||||
jo.put("moveinv_id", jo_mst.getString("moveinv_id"));
|
|
||||||
jo.put("seq_no", (i + 1) + "");
|
|
||||||
jo.put("work_status", "01");
|
|
||||||
jo.put("is_issued", "0");
|
|
||||||
JSONObject row = (JSONObject) Struct_map.get(jo.getString("storagevehicle_code"));
|
|
||||||
String turnin_struct_id = row.getString("turnin_struct_id");
|
|
||||||
jo.put("turnin_sect_id", row.getString("turnin_sect_id"));
|
|
||||||
jo.put("turnin_sect_code", row.getString("turnin_sect_code"));
|
|
||||||
jo.put("turnin_sect_name", row.getString("turnin_sect_name"));
|
|
||||||
jo.put("turnin_struct_id", turnin_struct_id);
|
|
||||||
jo.put("turnin_struct_code", row.getString("turnin_struct_code"));
|
|
||||||
jo.put("turnin_struct_name", row.getString("turnin_struct_name"));
|
|
||||||
//查询移入点位
|
|
||||||
JSONObject point = wo_Point.query("source_id='" + turnin_struct_id + "'").uniqueResult(0);
|
|
||||||
if (point == null) {
|
|
||||||
throw new BadRequestException(row.getString("turnin_struct_code") + "仓位数据异常,找不到对应点位!");
|
|
||||||
}
|
|
||||||
//判断是否已生成过了任务,无未生成则插入任务
|
|
||||||
JSONObject task = wo_Task.query("is_delete = '0' and task_status='04' and point_code1 ='" + jo.getString("start_point_code") + "'").uniqueResult(0);
|
|
||||||
if (task != null || "0".equals(is_task)) {
|
|
||||||
jo.put("task_id", task.getString("task_id"));
|
|
||||||
} else {
|
|
||||||
task = new JSONObject();
|
|
||||||
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
|
||||||
String task_code = IdUtil.getSnowflake(1, 1).nextId() + "";
|
|
||||||
|
|
||||||
task.put("taskdtl_id", task_id);
|
|
||||||
task.put("task_id", task_id);
|
|
||||||
task.put("task_code", task_code);
|
|
||||||
task.put("task_type", "05");
|
|
||||||
task.put("taskdtl_type", "07");
|
|
||||||
task.put("task_status", "01");
|
|
||||||
task.put("start_point_code", jo.getString("start_point_code"));
|
|
||||||
task.put("next_point_code", point.getString("point_code"));
|
|
||||||
task.put("vehicle_code", jo.getString("storagevehicle_code"));
|
|
||||||
task.put("handle_class", HandMoveStorAcsTask.class.getName());
|
|
||||||
task.put("finished_type", "");
|
|
||||||
task.put("is_delete", "0");
|
|
||||||
task.put("create_id", currentUserId);
|
|
||||||
task.put("create_name", nickName);
|
|
||||||
task.put("create_time", now);
|
|
||||||
task.put("update_optid", currentUserId);
|
|
||||||
task.put("update_optname", nickName);
|
|
||||||
task.put("update_time", now);
|
|
||||||
task.put("priority", "1");
|
|
||||||
wo_Task.insert(task);
|
|
||||||
jo.put("task_id", task_id);
|
|
||||||
}
|
|
||||||
//插入明细表
|
|
||||||
wo_dtl.insert(jo);
|
|
||||||
|
|
||||||
//更新移出库存
|
|
||||||
jo.put("struct_id", jo.getString("turnout_struct_id"));
|
|
||||||
jo.put("change_qty", jo.getDoubleValue("qty"));
|
|
||||||
jo.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
||||||
jo.put("inv_id", moveinvdtl_id);
|
|
||||||
jo.put("bill_code", jo_mst.getString("bill_code"));
|
|
||||||
jo.put("bill_table", "ST_IVT_MoveInv");
|
|
||||||
storPublicService.IOStor(jo, "11");
|
|
||||||
//更新移入库存
|
|
||||||
jo.put("struct_id", turnin_struct_id);
|
|
||||||
jo.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
||||||
jo.put("inv_id", moveinvdtl_id);
|
|
||||||
jo.put("bill_code", jo_mst.getString("bill_code"));
|
|
||||||
jo.put("bill_table", "ST_IVT_MoveInv");
|
|
||||||
storPublicService.IOStor(jo, "31");
|
|
||||||
//锁定起点点位、仓位
|
|
||||||
JSONObject from_start = new JSONObject();
|
|
||||||
from_start.put("lock_type", "03");
|
|
||||||
from_start.put("struct_id", jo.getString("turnout_struct_id"));
|
|
||||||
from_start.put("inv_type", jo_mst.getString("bill_type"));
|
|
||||||
from_start.put("inv_id", jo_mst.getString("moveinv_id"));
|
|
||||||
from_start.put("inv_code", jo_mst.getString("bill_code"));
|
|
||||||
from_start.put("taskdtl_type", task.getString("taskdtl_type"));
|
|
||||||
from_start.put("taskdtl_id", task.getString("taskdtl_id"));
|
|
||||||
from_start.put("task_code", task.getString("task_code"));
|
|
||||||
storPublicService.updateStructAndPoint(from_start);
|
|
||||||
//锁定终点点位、仓位
|
|
||||||
from_start.put("struct_id", turnin_struct_id);
|
|
||||||
storPublicService.updateStructAndPoint(from_start);
|
|
||||||
}
|
|
||||||
ret.put("total_qty", total_qty);
|
|
||||||
ret.put("detail_count", ja.size());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONArray getOutBillDtl(Map whereJson) {
|
public JSONArray getOutBillDtl(Map whereJson) {
|
||||||
whereJson.put("flag", "2");
|
whereJson.put("flag", "2");
|
||||||
@@ -435,113 +260,6 @@ public class ChangeServiceImpl implements ChangeService {
|
|||||||
wo_mst.update(jo_mst);
|
wo_mst.update(jo_mst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void allCancel(JSONObject whereJson) {
|
|
||||||
//出库分配表
|
|
||||||
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
||||||
//出库明细表
|
|
||||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
|
||||||
//出库主表
|
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
||||||
//任务表
|
|
||||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
|
|
||||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
|
||||||
//查询主表信息
|
|
||||||
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
||||||
//查询未生成和生成未下发的分配记录
|
|
||||||
JSONArray diss = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
||||||
.addParam("flag", "5")
|
|
||||||
.addParam("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id"))
|
|
||||||
.addParam("iostorinvdis_id", whereJson.getString("iostorinvdis_id"))
|
|
||||||
.addParam("iostorinv_id", iostorinv_id)
|
|
||||||
.addParam("bill_status", "01")
|
|
||||||
.addParam("is_issued", "0")
|
|
||||||
.process()
|
|
||||||
.getResultJSONArray(0);
|
|
||||||
if (ObjectUtil.isEmpty(diss)) {
|
|
||||||
throw new BadRequestException("不存在可以取消的出库分配明细");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < diss.size(); i++) {
|
|
||||||
JSONObject dis = diss.getJSONObject(i);
|
|
||||||
HashMap<String, String> map = new HashMap<>();
|
|
||||||
|
|
||||||
String iostorinvdtl_id = dis.getString("iostorinvdtl_id");
|
|
||||||
//统计【出入库单分配表】执行状态大于等于执行中,或【任务指令表】任务状态大于等于下发时的记录和
|
|
||||||
JSONArray dtl = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
||||||
.addParam("flag", "4")
|
|
||||||
.addParam("iostorinvdtl_id", iostorinvdtl_id)
|
|
||||||
.process()
|
|
||||||
.getResultJSONArray(0);
|
|
||||||
//若存在记录,则不可取消该出库明细对应的任何分配记录
|
|
||||||
if (dtl.size() != 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
double plan_qty = dis.getDoubleValue("plan_qty");
|
|
||||||
//更新库存
|
|
||||||
dis.put("change_qty", plan_qty + "");
|
|
||||||
dis.put("bill_type_scode", jo_mst.getString("bill_type"));
|
|
||||||
dis.put("inv_id", iostorinv_id);
|
|
||||||
dis.put("bill_code", jo_mst.getString("bill_code"));
|
|
||||||
dis.put("bill_table", "ST_IVT_IOStorInv");
|
|
||||||
storPublicService.IOStor(dis, "12");
|
|
||||||
//删除【出入库单分配表】中分配记录
|
|
||||||
wo_dis.delete("iostorinvdis_id='" + dis.getString("iostorinvdis_id") + "'");
|
|
||||||
//更新【出入库单明细表】中分配记录
|
|
||||||
JSONObject jo_dtl = wo_dtl.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0);
|
|
||||||
|
|
||||||
jo_dtl.put("assign_qty", jo_dtl.getDoubleValue("assign_qty") - plan_qty);
|
|
||||||
jo_dtl.put("unassign_qty", jo_dtl.getDoubleValue("unassign_qty") + plan_qty);
|
|
||||||
|
|
||||||
if (Double.valueOf(jo_dtl.getDoubleValue("unassign_qty")).equals(jo_dtl.getDoubleValue("plan_qty"))) {
|
|
||||||
jo_dtl.put("bill_status", "10");
|
|
||||||
} else {
|
|
||||||
jo_dtl.put("bill_status", "30");
|
|
||||||
}
|
|
||||||
wo_dtl.update(jo_dtl);
|
|
||||||
//更新主表状态
|
|
||||||
this.updateMststatus(iostorinv_id);
|
|
||||||
//判断是否存在同单据的同起点仓位的分配
|
|
||||||
JSONArray flag = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
||||||
.addParam("flag", "5")
|
|
||||||
.addParam("is_issued", "0")
|
|
||||||
.addParam("struct_id", dis.getString("struct_id"))
|
|
||||||
.addParam("iostorinv_id", iostorinv_id)
|
|
||||||
.addParam("bill_status", "01")
|
|
||||||
.process()
|
|
||||||
.getResultJSONArray(0);
|
|
||||||
if (flag.size() == 0) {//仓位载具冻结数为0
|
|
||||||
//任务号不为空
|
|
||||||
if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) {
|
|
||||||
//更新对应任务为删除
|
|
||||||
map.put("is_delete", "1");
|
|
||||||
wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'");
|
|
||||||
}
|
|
||||||
//解锁起点仓位点位
|
|
||||||
JSONObject from_start = new JSONObject();
|
|
||||||
from_start.put("struct_id", dis.getString("struct_id"));
|
|
||||||
from_start.put("lock_type", "1");
|
|
||||||
storPublicService.updateStructAndPoint(from_start);
|
|
||||||
//解锁终点仓位点位
|
|
||||||
if (StrUtil.isNotEmpty(dis.getString("point_code"))) {
|
|
||||||
JSONObject from_end = new JSONObject();
|
|
||||||
from_end.put("point_code", dis.getString("point_code"));
|
|
||||||
from_end.put("lock_type", "1");
|
|
||||||
storPublicService.updateStructAndPoint(from_end);
|
|
||||||
}
|
|
||||||
} else {//仓位载具扔有冻结数,需改任务类型为拣选出库
|
|
||||||
//任务号不为空
|
|
||||||
if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) {
|
|
||||||
//更新对应任务为拣选出库
|
|
||||||
map.put("taskdtl_type", "05");
|
|
||||||
wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getStructIvt(Map whereJson, Pageable page) {
|
public Map<String, Object> getStructIvt(Map whereJson, Pageable page) {
|
||||||
HashMap<String, String> map = new HashMap<String, String>(whereJson);
|
HashMap<String, String> map = new HashMap<String, String>(whereJson);
|
||||||
@@ -627,303 +345,4 @@ public class ChangeServiceImpl implements ChangeService {
|
|||||||
//更新主表状态
|
//更新主表状态
|
||||||
wo_mst.update(map_mst, "changeinv_id='" + changeinv_id + "'");
|
wo_mst.update(map_mst, "changeinv_id='" + changeinv_id + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void issueTask(JSONObject whereJson) {
|
|
||||||
//出库分配表
|
|
||||||
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
||||||
//任务表
|
|
||||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
String now = DateUtil.now();
|
|
||||||
|
|
||||||
String task_id = whereJson.getString("task_id");
|
|
||||||
String taskdtl_id = whereJson.getString("taskdtl_id");
|
|
||||||
JSONObject result = null;
|
|
||||||
if (ObjectUtil.isNotEmpty(result)) {
|
|
||||||
String status = result.getString("status");
|
|
||||||
if ("200".equals(status)) {
|
|
||||||
HashMap<String, String> map = new HashMap<>();
|
|
||||||
//更新分配表
|
|
||||||
map.put("is_issued", "1");
|
|
||||||
wo_dis.update(map, "task_id='" + task_id + "'");
|
|
||||||
//更新任务为已下发
|
|
||||||
map.put("task_status", "02");
|
|
||||||
map.put("update_optid", currentUserId + "");
|
|
||||||
map.put("update_optname", nickName);
|
|
||||||
map.put("update_time", now);
|
|
||||||
wo_Task.update(map, "taskdtl_id='" + taskdtl_id + "'");
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("任务下发失败,请稍后重试!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("任务下发失败,请稍后重试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void finishTask(JSONObject whereJson) {
|
|
||||||
//出库分配表
|
|
||||||
WQLObject wo_dis = WQLObject.getWQLObject("st_ivt_moveinvdtl");
|
|
||||||
//任务表
|
|
||||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
String task_id = whereJson.getString("task_id");
|
|
||||||
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
String now = DateUtil.now();
|
|
||||||
|
|
||||||
JSONObject task = wo_Task.query("task_status<>'99' and task_id='" + task_id + "'").uniqueResult(0);
|
|
||||||
if (task == null) {
|
|
||||||
throw new BadRequestException("查询不到操作的任务记录!");
|
|
||||||
}
|
|
||||||
String taskdtl_type = task.getString("taskdtl_type");
|
|
||||||
HashMap<String, String> map = new HashMap<>();
|
|
||||||
//更新任务为完成
|
|
||||||
map.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
|
||||||
map.put("finished_type", "01");
|
|
||||||
map.put("update_optid", currentUserId + "");
|
|
||||||
map.put("update_optname", nickName);
|
|
||||||
map.put("update_time", now);
|
|
||||||
wo_Task.update(map, "task_id='" + task_id + "'");
|
|
||||||
map.put("work_status", "99");
|
|
||||||
wo_dis.update(map, "task_id='" + task_id + "'");
|
|
||||||
JSONObject dis = wo_dis.query("task_id='" + task_id + "'").uniqueResult(0);
|
|
||||||
//判断是否还有未完成的分配
|
|
||||||
JSONArray ja = wo_dis.query("work_status<>'99' and moveinv_id='" + dis.getString("moveinv_id") + "'").getResultJSONArray(0);
|
|
||||||
if (ja.size() == 0) {
|
|
||||||
this.confirm(dis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void cancleTaskfinish(JSONObject whereJson) {
|
|
||||||
//出库明细表
|
|
||||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
|
||||||
//出库分配表
|
|
||||||
WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis");
|
|
||||||
//出库分配明细表
|
|
||||||
WQLObject wo_DisDtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDisDtl");
|
|
||||||
//任务表
|
|
||||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
//出库主表
|
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
||||||
//桶物料变动记录表
|
|
||||||
WQLObject wo_BucketChangeFlow = WQLObject.getWQLObject("MD_PB_BucketChangeFlow");
|
|
||||||
//桶记录表
|
|
||||||
WQLObject wo_BucketRecord = WQLObject.getWQLObject("MD_PB_BucketRecord");
|
|
||||||
|
|
||||||
String iostorinv_id = whereJson.getString("iostorinv_id");
|
|
||||||
String taskdtl_id = whereJson.getString("taskdtl_id");
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
|
|
||||||
String now = DateUtil.now();
|
|
||||||
//查询主表信息
|
|
||||||
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isEmpty(jo_mst)) {
|
|
||||||
throw new BadRequestException("未查到相关出库单");
|
|
||||||
}
|
|
||||||
if ("99".equals(jo_mst.getString("bill_status"))) {
|
|
||||||
throw new BadRequestException("已审核单据不允许取消完成!");
|
|
||||||
}
|
|
||||||
JSONObject task = wo_Task.query("taskdtl_id='" + taskdtl_id + "'").uniqueResult(0);
|
|
||||||
String taskdtl_type = task.getString("taskdtl_type");
|
|
||||||
String task_id = task.getString("task_id");
|
|
||||||
if ("05".contains(taskdtl_type)) {
|
|
||||||
//查询拣选出库对应的拣选回库有没有先取消完成
|
|
||||||
JSONObject task06 = wo_Task.query("task_status='99' and taskdtl_type='06' and task_id='" + task_id + "'").uniqueResult(0);
|
|
||||||
if (task06 != null) {
|
|
||||||
throw new BadRequestException("请先取消拣选出库对应的拣选回库指令!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//如果为拣选出库05
|
|
||||||
if ("05,02".contains(taskdtl_type)) {
|
|
||||||
//更新任务为已下发
|
|
||||||
map.put("task_status", "01");
|
|
||||||
map.put("finished_type", "");
|
|
||||||
map.put("update_optid", currentUserId + "");
|
|
||||||
map.put("update_optname", nickName);
|
|
||||||
map.put("update_time", now);
|
|
||||||
wo_Task.update(map, "taskdtl_type='" + taskdtl_type + "' and task_id='" + task_id + "'");
|
|
||||||
//查询生成和未分配完的明细
|
|
||||||
JSONArray disdtls = WQL.getWO("QST_IVT_CHECKOUTBILL")
|
|
||||||
.addParam("flag", "8")
|
|
||||||
.addParam("task_id", task_id)
|
|
||||||
.process()
|
|
||||||
.getResultJSONArray(0);
|
|
||||||
if (disdtls.size() != 0) {
|
|
||||||
for (int i = 0; i < disdtls.size(); i++) {
|
|
||||||
JSONObject disdtl = disdtls.getJSONObject(i);
|
|
||||||
//更新桶记录相关表
|
|
||||||
double real_qty_disDtl = disdtl.getDoubleValue("real_qty");
|
|
||||||
String bucketunique = disdtl.getString("bucketunique");
|
|
||||||
//查询桶记录
|
|
||||||
JSONObject bucket = wo_BucketRecord.query("status='04' and bucketunique='" + bucketunique + "'").uniqueResult(0);
|
|
||||||
double storage_qty = bucket.getDoubleValue("storage_qty");
|
|
||||||
//重量加回去
|
|
||||||
storage_qty = storage_qty + real_qty_disDtl;
|
|
||||||
bucket.put("storage_qty", storage_qty);
|
|
||||||
bucket.put("outstor_optid", currentUserId);
|
|
||||||
bucket.put("outstor_optname", nickName);
|
|
||||||
bucket.put("outstor_time", now);
|
|
||||||
//更新桶记录表
|
|
||||||
wo_BucketRecord.update(bucket);
|
|
||||||
//插入一条变动记录
|
|
||||||
bucket.put("change_id", IdUtil.getSnowflake(1, 1).nextId() + "");
|
|
||||||
bucket.put("bucket_code", bucketunique);
|
|
||||||
bucket.put("change_type_scode", "01");
|
|
||||||
bucket.put("change_time", now);
|
|
||||||
bucket.put("rec_person", currentUserId);
|
|
||||||
bucket.put("change_qty", real_qty_disDtl);
|
|
||||||
bucket.put("result_qty", storage_qty);
|
|
||||||
wo_BucketChangeFlow.insert(bucket);
|
|
||||||
//清空分配明细表
|
|
||||||
wo_DisDtl.delete("iostorinvdisdtl_id='" + disdtl.getString("iostorinvdisdtl_id") + "'");
|
|
||||||
//倒推明细表、分配表实际数量
|
|
||||||
JSONObject dis = wo_dis.query("iostorinvdis_id='" + disdtl.getString("iostorinvdis_id") + "'").uniqueResult(0);
|
|
||||||
dis.put("real_qty", dis.getDoubleValue("real_qty") - real_qty_disDtl);
|
|
||||||
dis.put("work_status", "01");
|
|
||||||
dis.put("is_issued", "0");
|
|
||||||
wo_dis.update(dis);
|
|
||||||
|
|
||||||
JSONObject dtl = wo_dtl.query("iostorinvdtl_id='" + disdtl.getString("iostorinvdtl_id") + "'").uniqueResult(0);
|
|
||||||
double real_qty = dtl.getDoubleValue("real_qty") - real_qty_disDtl;
|
|
||||||
if (real_qty == 0) {
|
|
||||||
dtl.put("bill_status", "40");
|
|
||||||
}
|
|
||||||
wo_dtl.update(dtl);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
map.put("work_status", "01");
|
|
||||||
map.put("is_issued", "0");
|
|
||||||
wo_dis.update(map, "task_id='" + task_id + "'");
|
|
||||||
}
|
|
||||||
//更新主表状态
|
|
||||||
this.updateMststatus(whereJson.getString("iostorinv_id"));
|
|
||||||
} else if ("06".equals(taskdtl_type)) {//如果为拣选回库
|
|
||||||
//更新任务为已下发
|
|
||||||
map.put("task_status", "01");
|
|
||||||
map.put("finished_type", "");
|
|
||||||
map.put("update_optid", currentUserId + "");
|
|
||||||
map.put("update_optname", nickName);
|
|
||||||
map.put("update_time", now);
|
|
||||||
wo_Task.update(map, "taskdtl_type='06' and task_id='" + task_id + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void handdown(JSONObject whereJson) {
|
|
||||||
//移库单主表
|
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
|
||||||
//移库单明细表
|
|
||||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_MoveInvDtl");
|
|
||||||
//任务表
|
|
||||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
|
||||||
|
|
||||||
HandMoveStorAcsTask handMoveStorAcsTask = new HandMoveStorAcsTask();
|
|
||||||
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
String now = DateUtil.now();
|
|
||||||
|
|
||||||
String moveinv_id = whereJson.getString("moveinv_id");
|
|
||||||
//查询所有载具的库存
|
|
||||||
JSONArray ja = WQL.getWO("QST_IVT_CHANGE")
|
|
||||||
.addParam("flag", "4")
|
|
||||||
.addParam("moveinv_id", moveinv_id)
|
|
||||||
.process().getResultJSONArray(0);
|
|
||||||
if (ja.size() == 0) {
|
|
||||||
throw new BadRequestException("当前移库单无可下发任务!");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < ja.size(); i++) {
|
|
||||||
JSONObject jo = ja.getJSONObject(i);
|
|
||||||
String task_id = jo.getString("task_id");
|
|
||||||
JSONObject result = handMoveStorAcsTask.notifyAcs(task_id);
|
|
||||||
JSONObject task = wo_Task.query("task_id='" + task_id + "'").uniqueResult(0);
|
|
||||||
if (ObjectUtil.isNotEmpty(result)) {
|
|
||||||
String status = result.getString("status");
|
|
||||||
if ("200".equals(status)) {
|
|
||||||
HashMap<String, String> map = new HashMap<>();
|
|
||||||
//更新分配表
|
|
||||||
map.put("is_issued", "1");
|
|
||||||
map.put("work_status", "02");
|
|
||||||
wo_dtl.update(map, "is_issued='0' and task_id='" + task.getString("task_id") + "'");
|
|
||||||
//更新任务为已下发
|
|
||||||
map.put("task_status", "02");
|
|
||||||
map.put("update_optid", currentUserId + "");
|
|
||||||
map.put("update_optname", nickName);
|
|
||||||
map.put("update_time", now);
|
|
||||||
wo_Task.update(map, "is_delete ='0' and task_status='01' and task_id='" + task_id + "'");
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("任务下发失败,请稍后重试!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new BadRequestException("任务下发失败,请稍后重试!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HashMap<String, String> map = new HashMap<>();
|
|
||||||
map.put("bill_status", "20");
|
|
||||||
wo_mst.update(map, "moveinv_id='" + moveinv_id + "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JSONArray getInvTypes() {
|
|
||||||
//查询单据字段类型
|
|
||||||
JSONArray ja = WQL.getWO("ST_PUB_QUERY_01")
|
|
||||||
.addParam("flag", "4")
|
|
||||||
.process()
|
|
||||||
.getResultJSONArray(0);
|
|
||||||
return ja;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新主表状态
|
|
||||||
*
|
|
||||||
* @param iostorinv_id
|
|
||||||
*/
|
|
||||||
void updateMststatus(String iostorinv_id) {
|
|
||||||
//出库主表
|
|
||||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
||||||
//出库明细表
|
|
||||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl");
|
|
||||||
|
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
|
||||||
String now = DateUtil.now();
|
|
||||||
//查询主表信息
|
|
||||||
JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
|
|
||||||
jo_mst.put("update_optid", currentUserId + "");
|
|
||||||
jo_mst.put("update_optname", nickName);
|
|
||||||
jo_mst.put("update_time", now);
|
|
||||||
//更新主表状态
|
|
||||||
JSONArray dtls_40 = wo_dtl.query("bill_status='40' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
|
||||||
//已分配完明细数小于总明细数
|
|
||||||
if (dtls_40.size() < jo_mst.getInteger("detail_count")) {
|
|
||||||
|
|
||||||
JSONArray dtls_30 = wo_dtl.query("bill_status='30' and iostorinv_id = '" + iostorinv_id + "'").getResultJSONArray(0);
|
|
||||||
//存在分配完的明细
|
|
||||||
if (dtls_40.size() != 0) {//分配中明细数不为0
|
|
||||||
jo_mst.put("bill_status", "30");
|
|
||||||
} else if (dtls_40.size() == 0) {
|
|
||||||
//不存在分配中和分配完的明细
|
|
||||||
if (dtls_30.size() == 0) {
|
|
||||||
jo_mst.put("bill_status", "10");
|
|
||||||
}//存在分配中的明细
|
|
||||||
else if (dtls_30.size() != 0) {
|
|
||||||
jo_mst.put("bill_status", "30");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {//已分配完明细数等于总明细数
|
|
||||||
jo_mst.put("bill_status", "40");
|
|
||||||
}
|
|
||||||
wo_mst.update(jo_mst);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ export function getOutBillDtl(params) {
|
|||||||
params
|
params
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function getInvTypes() {
|
|
||||||
return request({
|
|
||||||
url: '/api/change/getInvTypes',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export function insertDtl(data) {
|
export function insertDtl(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/api/change/insertDtl',
|
url: '/api/change/insertDtl',
|
||||||
@@ -58,11 +52,4 @@ export function confirm(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function handdown(data) {
|
export default { add, edit, del, getOutBillDtl, getStructIvt, confirm }
|
||||||
return request({
|
|
||||||
url: '/api/change/handdown',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export default { add, edit, del, getOutBillDtl, getStructIvt, confirm, getInvTypes, handdown }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user