修改
This commit is contained in:
@@ -92,9 +92,6 @@ public class CustomerbaseServiceImpl implements CustomerbaseService {
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
ClassstandardDto classDto = classstandardService.findById(dto.getClass_id() + "");
|
||||
dto.setClass_code(classDto.getClass_code());
|
||||
dto.setClass_name(classDto.getClass_name());
|
||||
dto.setCust_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
|
||||
Binary file not shown.
@@ -19,14 +19,11 @@ import org.nl.wms.ext.mes.service.MesToLmsService;
|
||||
import org.nl.wms.log.LokiLog;
|
||||
import org.nl.wms.log.LokiLogType;
|
||||
import org.nl.wms.pda.mps.service.OutService;
|
||||
import org.nl.wms.pda.mps.service.impl.BakingServiceImpl;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.tasks.CoolCutTask;
|
||||
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
||||
import org.nl.wms.pda.mps.service.impl.BakingServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import sun.security.krb5.internal.crypto.Des;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -224,7 +221,7 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
result.put("RTDAT", null);
|
||||
} catch (Exception e) {
|
||||
result.put("RTYPE", "1");
|
||||
result.put("RTMSG", "操作失败!"+e.getMessage());
|
||||
result.put("RTMSG", "操作失败!" + e.getMessage());
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
}
|
||||
@@ -308,7 +305,7 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
result.put("RTDAT", null);
|
||||
} catch (Exception e) {
|
||||
result.put("RTYPE", "1");
|
||||
result.put("RTMSG", "操作失败!"+e.getMessage());
|
||||
result.put("RTMSG", "操作失败!" + e.getMessage());
|
||||
result.put("RTOAL", 1);
|
||||
result.put("RTDAT", null);
|
||||
}
|
||||
@@ -549,7 +546,7 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
String restruct_container_name = plan_jo.getString("restruct_container_name");
|
||||
|
||||
//查询该包装关系
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("container_name = '"+restruct_container_name+"'").uniqueResult(0);
|
||||
JSONObject sub_jo = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("container_name = '" + restruct_container_name + "'").uniqueResult(0);
|
||||
JSONObject struct = WQLObject.getWQLObject("st_ivt_structattr").query("storagevehicle_code = '" + package_box_sn + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(struct)) {
|
||||
throw new BadRequestException("该箱子已出库,不在库内!");
|
||||
@@ -572,21 +569,21 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
JSONObject dtl = new JSONObject();
|
||||
//查询该物料
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + sub_jo.getString("product_name") + "'").uniqueResult(0);
|
||||
dtl.put("material_id",mater_jo.getString("material_id"));
|
||||
dtl.put("pcsn",plan_jo.getString("restruct_container_name"));
|
||||
dtl.put("box_no",package_box_sn);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '"+mater_jo.getString("base_unit_id")+"'").uniqueResult(0);
|
||||
dtl.put("qty_unit_id",unit.getString("measure_unit_id"));
|
||||
dtl.put("qty_unit_name",unit.getString("unit_name"));
|
||||
dtl.put("plan_qty",sub_jo.getString("net_weight"));
|
||||
dtl.put("material_id", mater_jo.getString("material_id"));
|
||||
dtl.put("pcsn", plan_jo.getString("restruct_container_name"));
|
||||
dtl.put("box_no", package_box_sn);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
dtl.put("qty_unit_id", unit.getString("measure_unit_id"));
|
||||
dtl.put("qty_unit_name", unit.getString("unit_name"));
|
||||
dtl.put("plan_qty", sub_jo.getString("net_weight"));
|
||||
rows.add(dtl);
|
||||
mst_jo.put("tableData",rows);
|
||||
mst_jo.put("user","mes");
|
||||
mst_jo.put("tableData", rows);
|
||||
mst_jo.put("user", "mes");
|
||||
String iostorinv_id = checkOutBillService.insertDtl(mst_jo);
|
||||
|
||||
//调用自动分配
|
||||
JSONObject out_jo = new JSONObject();
|
||||
out_jo.put("iostorinv_id",iostorinv_id);
|
||||
out_jo.put("iostorinv_id", iostorinv_id);
|
||||
checkOutBillService.allDiv(out_jo);
|
||||
|
||||
}
|
||||
@@ -622,19 +619,19 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
if (StrUtil.equals(is_mesTolms, "1")) {
|
||||
String Status = param.getJSONObject(0).getString("Status");
|
||||
|
||||
if (Status.equals("1")){
|
||||
if (Status.equals("1")) {
|
||||
//更新分切计划表状态
|
||||
for (int i = 0; i < param.size(); i++) {
|
||||
JSONObject row = param.getJSONObject(i);
|
||||
JSONObject plan_jo = WQLObject.getWQLObject("pdm_bi_slittingproductionplan").query("container_name = '"+row.getString("ContainerGroup")+"'").uniqueResult(0);
|
||||
plan_jo.put("status","05");
|
||||
JSONObject plan_jo = WQLObject.getWQLObject("pdm_bi_slittingproductionplan").query("container_name = '" + row.getString("ContainerGroup") + "'").uniqueResult(0);
|
||||
plan_jo.put("status", "05");
|
||||
WQLObject.getWQLObject("pdm_bi_slittingproductionplan").update(plan_jo);
|
||||
}
|
||||
}
|
||||
|
||||
if (Status.equals("2")){
|
||||
if (Status.equals("2")) {
|
||||
String ResourceName = param.getJSONObject(0).getString("ResourceName");
|
||||
JSONObject cut_jo = WQLObject.getWQLObject("ST_IVT_CutPointIvt").query("ext_code = '"+ResourceName+"'").uniqueResult(0);
|
||||
JSONObject cut_jo = WQLObject.getWQLObject("ST_IVT_CutPointIvt").query("ext_code = '" + ResourceName + "'").uniqueResult(0);
|
||||
String up_point_code = cut_jo.getString("up_point_code");
|
||||
String down_point_code = cut_jo.getString("down_point_code");
|
||||
|
||||
@@ -643,27 +640,27 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
for (int i = 0; i < param.size(); i++) {
|
||||
JSONObject row = param.getJSONObject(i);
|
||||
//查询对应的分切计划
|
||||
JSONObject plan_jo = WQLObject.getWQLObject("pdm_bi_slittingproductionplan").query("container_name = '"+row.getString("ContainerGroup")+"'").uniqueResult(0);
|
||||
if (row.getString("ContainerPosition").equals("1")){
|
||||
JSONObject plan_jo = WQLObject.getWQLObject("pdm_bi_slittingproductionplan").query("container_name = '" + row.getString("ContainerGroup") + "'").uniqueResult(0);
|
||||
if (row.getString("ContainerPosition").equals("1")) {
|
||||
up_rows.add(plan_jo);
|
||||
}
|
||||
if (row.getString("ContainerPosition").equals("2")){
|
||||
if (row.getString("ContainerPosition").equals("2")) {
|
||||
down_rows.add(plan_jo);
|
||||
}
|
||||
}
|
||||
|
||||
if (up_rows.size()>0){
|
||||
if (up_rows.size() > 0) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("point_code",up_point_code);
|
||||
jo.put("cut_rows",up_rows);
|
||||
jo.put("is_last","0");
|
||||
jo.put("point_code", up_point_code);
|
||||
jo.put("cut_rows", up_rows);
|
||||
jo.put("is_last", "0");
|
||||
outService.confirm(jo);
|
||||
}
|
||||
if (down_rows.size()>0){
|
||||
if (down_rows.size() > 0) {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("point_code",down_point_code);
|
||||
jo.put("cut_rows",down_rows);
|
||||
jo.put("is_last","0");
|
||||
jo.put("point_code", down_point_code);
|
||||
jo.put("cut_rows", down_rows);
|
||||
jo.put("is_last", "0");
|
||||
outService.confirm(jo);
|
||||
}
|
||||
}
|
||||
@@ -775,7 +772,92 @@ public class MesToLmsServiceImpl implements MesToLmsService {
|
||||
log.info("inventoryTransferInfoSync接口输入参数为:-------------------" + param.toString());
|
||||
String is_mesTolms = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("is_mesTolms").getValue();
|
||||
if (StrUtil.equals(is_mesTolms, "1")) {
|
||||
try {
|
||||
JSONArray rows = param.getJSONArray("item");
|
||||
String SaleOrderItem = param.getString("SaleOrderItem");
|
||||
String CustomerName = param.getString("CustomerName");
|
||||
String DemandDate = param.getString("DemandDate");
|
||||
double total_qty = 0;
|
||||
double detail_count = 0;
|
||||
String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
if (rows.size() == 0) {
|
||||
throw new BadRequestException("item长度不能为0!");
|
||||
}
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject row = rows.getJSONObject(i);
|
||||
String PackageBoxSN = row.getString("PackageBoxSN");
|
||||
String isRePrintPackageBoxLabel = row.getString("isRePrintPackageBoxLabel");
|
||||
String isUnPackBox = row.getString("isUnPackBox");
|
||||
String UpdatedDateOfProduction = row.getString("UpdatedDateOfProduction");
|
||||
//查询该木箱内子卷数量
|
||||
JSONArray container_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + PackageBoxSN + "'").getResultJSONArray(0);
|
||||
for (int j = 0; j < container_rows.size(); j++) {
|
||||
JSONObject container_row = container_rows.getJSONObject(j);
|
||||
JSONObject change_jo = new JSONObject();
|
||||
change_jo.put("changeinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + "");
|
||||
change_jo.put("changeinv_id", changeinv_id);
|
||||
change_jo.put("seq_no", detail_count + 1);
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + container_row.getString("product_name") + "'").uniqueResult(0);
|
||||
change_jo.put("material_id", mater_jo.getString("material_id"));
|
||||
change_jo.put("pcsn", container_row.getString("container_name"));
|
||||
change_jo.put("package_box_sn", container_row.getString("package_box_sn"));
|
||||
change_jo.put("mfg_order_name", SaleOrderItem);
|
||||
change_jo.put("demand_date", DemandDate);
|
||||
change_jo.put("customer_name", CustomerName);
|
||||
//查询对应的客户
|
||||
JSONObject customer_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + CustomerName + "'").uniqueResult(0);
|
||||
change_jo.put("customer_description", customer_jo.getString("cust_name"));
|
||||
change_jo.put("isRePrintPackageBoxLabel", isRePrintPackageBoxLabel);
|
||||
change_jo.put("isUnPackBox", isUnPackBox);
|
||||
change_jo.put("UpdatedDateOfProduction", UpdatedDateOfProduction);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
change_jo.put("qty_unit_id", mater_jo.getString("base_unit_id"));
|
||||
change_jo.put("qty_unit_name", unit.getString("unit_name"));
|
||||
change_jo.put("qty", container_row.getString("net_weight"));
|
||||
WQLObject.getWQLObject("ST_IVT_StructIvtChangeDtl").insert(change_jo);
|
||||
total_qty += container_row.getDoubleValue("net_weight");
|
||||
detail_count += 1;
|
||||
}
|
||||
}
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
JSONObject mst_jo = new JSONObject();
|
||||
mst_jo.put("changeinv_id",changeinv_id);
|
||||
mst_jo.put("bill_code",CodeUtil.getNewCode("CHANGE_CODE"));
|
||||
mst_jo.put("buss_type","2001");
|
||||
mst_jo.put("bill_type","2001");
|
||||
mst_jo.put("biz_date", DateUtil.today());
|
||||
JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0);
|
||||
mst_jo.put("stor_id", stor.getString("stor_id"));
|
||||
mst_jo.put("stor_code", stor.getString("stor_code"));
|
||||
mst_jo.put("stor_name", stor.getString("stor_name"));
|
||||
mst_jo.put("total_qty", total_qty);
|
||||
mst_jo.put("detail_count", detail_count);
|
||||
mst_jo.put("bill_status", "10");
|
||||
mst_jo.put("create_mode", "03");
|
||||
mst_jo.put("input_optid", currentUserId + "");
|
||||
mst_jo.put("input_optname", nickName);
|
||||
mst_jo.put("input_time", now);
|
||||
mst_jo.put("update_optid", currentUserId + "");
|
||||
mst_jo.put("update_optname", nickName);
|
||||
mst_jo.put("update_time", now);
|
||||
mst_jo.put("is_delete", "0");
|
||||
mst_jo.put("is_upload", "0");
|
||||
Long deptId = SecurityUtils.getDeptId();
|
||||
mst_jo.put("sysdeptid", deptId + "");
|
||||
mst_jo.put("syscompanyid", deptId + "");
|
||||
WQLObject.getWQLObject("ST_IVT_StructIvtChange").insert(mst_jo);
|
||||
|
||||
} catch (Exception e) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("RTYPE", "E");
|
||||
result.put("RTMSG", "操作失败!," + e.getMessage());
|
||||
result.put("RTDAT", null);
|
||||
System.out.println(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
@@ -166,6 +166,8 @@ public class SapToLmsServiceImpl implements SapToLmsService {
|
||||
sub_jo.put("create_time", 0);
|
||||
sub_jo.put("status", "0");
|
||||
sub_jo.put("sap_pcsn", sap_pcsn);
|
||||
sub_jo.put("vbeln", json.getString("VBELN"));
|
||||
sub_jo.put("posnr", json.getString("POSNR"));
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelation").insert(sub_jo);
|
||||
} else {
|
||||
//不为空修改子卷包装关系
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,79 @@
|
||||
package org.nl.wms.st.instor.rest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.wms.st.instor.service.ChangeService;
|
||||
import org.nl.wms.st.instor.service.HandMoveStorService;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "库存变更")
|
||||
@RequestMapping("/api/change")
|
||||
@Slf4j
|
||||
public class ChangeController {
|
||||
private final ChangeService changeService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询库存变更单")
|
||||
@ApiOperation("查询库存变更单")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(changeService.pageQuery(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getOutBillDtl")
|
||||
@Log("查询移库单")
|
||||
@ApiOperation("查询移库单")
|
||||
public ResponseEntity<Object> getOutBillDtl(@RequestParam Map whereJson) {
|
||||
return new ResponseEntity<>(changeService.getOutBillDtl(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("删除移库单")
|
||||
@ApiOperation("删除移库单")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
changeService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改移库单")
|
||||
@ApiOperation("修改移库单")
|
||||
public ResponseEntity<Object> update(@RequestBody Map whereJson) {
|
||||
changeService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@PostMapping()
|
||||
@Log("新增移库单")
|
||||
@ApiOperation("新增移库单")
|
||||
public ResponseEntity<Object> insertDtl(@RequestBody Map whereJson) {
|
||||
changeService.insertDtl(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@GetMapping("/getStructIvt")
|
||||
@Log("查询可分配库存")
|
||||
@ApiOperation("查询可分配库存")
|
||||
public ResponseEntity<Object> getStructIvt(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(changeService.getStructIvt(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/confirm")
|
||||
@Log("移库单强制确认")
|
||||
@ApiOperation("移库单强制确认")
|
||||
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
|
||||
changeService.confirm(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.nl.wms.st.instor.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ChangeService {
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> pageQuery(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
/**
|
||||
* 新增出库单
|
||||
* @param whereJson /
|
||||
*/
|
||||
void insertDtl (Map whereJson);
|
||||
/**
|
||||
* 新增出库单2
|
||||
* @param whereJson /
|
||||
*/
|
||||
String insertDtl2 (JSONObject whereJson);
|
||||
/**
|
||||
* 查询出库单明细
|
||||
* @param whereJson /
|
||||
* @return
|
||||
*/
|
||||
JSONArray getOutBillDtl(Map whereJson);
|
||||
/**
|
||||
* 修改出库单
|
||||
* @param whereJson /
|
||||
*/
|
||||
void update(Map whereJson);
|
||||
/**
|
||||
* 全部取消
|
||||
* @param whereJson /
|
||||
*/
|
||||
void allCancel(JSONObject whereJson);
|
||||
/**
|
||||
* 查询可分配库存
|
||||
* @param whereJson /
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getStructIvt(Map whereJson, Pageable page);
|
||||
/**
|
||||
* 出库单强制确认
|
||||
* @param 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);
|
||||
}
|
||||
@@ -0,0 +1,920 @@
|
||||
package org.nl.wms.st.instor.service.impl;
|
||||
|
||||
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.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
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.HandMoveStorService;
|
||||
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
|
||||
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.Map;
|
||||
|
||||
/**
|
||||
* PC端出入库新增
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class ChangeServiceImpl implements ChangeService {
|
||||
private final StorPublicService storPublicService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
|
||||
HashMap<String, String> map = new HashMap<>(whereJson);
|
||||
map.put("flag", "1");
|
||||
if (StrUtil.isNotEmpty(map.get("bill_code"))) {
|
||||
map.put("bill_code", "%" + map.get("bill_code") + "%");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(map.get("material_code"))) {
|
||||
map.put("material_code", "%" + map.get("material_code") + "%");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(map.get("buss_type"))) {
|
||||
map.put("buss_type", whereJson.get("buss_type") + "%");
|
||||
}
|
||||
JSONObject jo = WQL.getWO("QST_IVT_CHANGE").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "bill_code desc");
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long moveinv_id : ids) {
|
||||
this.deleteById(moveinv_id + "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过moveinv_id删除明细,还原库存等操作
|
||||
*
|
||||
* @param moveinv_id
|
||||
*/
|
||||
void deleteById(String moveinv_id) {
|
||||
//明细表
|
||||
WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_MoveInvDtl");
|
||||
//主表
|
||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
||||
//任务表
|
||||
WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("is_delete", "1");
|
||||
map.put("update_optid", currentUserId + "");
|
||||
map.put("update_optname", nickName);
|
||||
map.put("update_time", now);
|
||||
JSONObject jo_mst = wo_mst.query("moveinv_id='" + moveinv_id + "'").uniqueResult(0);
|
||||
JSONArray ja = wo_dtl.query("moveinv_id='" + moveinv_id + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
//删除任务
|
||||
HashMap<String, String> task_map = new HashMap<>();
|
||||
task_map.put("is_delete", "1");
|
||||
wo_Task.update(task_map, "task_id='" + jo.getString("task_id") + "'");
|
||||
//解锁起点点位、仓位
|
||||
JSONObject from_start = new JSONObject();
|
||||
from_start.put("lock_type", "1");
|
||||
from_start.put("struct_id", jo.getString("turnout_struct_id"));
|
||||
storPublicService.updateStructAndPoint(from_start);
|
||||
//解锁终点点位、仓位
|
||||
from_start.put("struct_id", jo.getString("turnin_struct_id"));
|
||||
storPublicService.updateStructAndPoint(from_start);
|
||||
|
||||
//更新移出库存
|
||||
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", jo.getString("moveinvdtl_id"));
|
||||
jo.put("bill_code", jo_mst.getString("bill_code"));
|
||||
jo.put("bill_table", "ST_IVT_MoveInv");
|
||||
storPublicService.IOStor(jo, "12");
|
||||
//更新移入库存
|
||||
jo.put("struct_id", jo.getString("turnin_struct_id"));
|
||||
jo.put("bill_type_scode", jo_mst.getString("bill_type"));
|
||||
jo.put("inv_id", jo.getString("moveinvdtl_id"));
|
||||
jo.put("bill_code", jo_mst.getString("bill_code"));
|
||||
jo.put("bill_table", "ST_IVT_MoveInv");
|
||||
storPublicService.IOStor(jo, "32");
|
||||
//删除明细
|
||||
wo_dtl.delete("moveinvdtl_id='" + jo.getString("moveinvdtl_id") + "'");
|
||||
}
|
||||
//更新主表
|
||||
wo_mst.update(map, "moveinv_id='" + moveinv_id + "'");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void insertDtl(Map map) {
|
||||
//主表
|
||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
||||
ArrayList<HashMap> rows = (ArrayList<HashMap>) map.get("tableData");
|
||||
map.remove("tableData");
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject mst_jo = new JSONObject();
|
||||
mst_jo.put("changeinv_id", changeinv_id);
|
||||
mst_jo.put("bill_code", CodeUtil.getNewCode("CHANGE_CODE"));
|
||||
mst_jo.put("buss_type", "2002");
|
||||
mst_jo.put("bill_type", "2002");
|
||||
mst_jo.put("biz_date", DateUtil.today());
|
||||
JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_delete = '0' AND is_used = '1' AND is_productstore = '1'").uniqueResult(0);
|
||||
mst_jo.put("stor_id", stor.getString("stor_id"));
|
||||
mst_jo.put("stor_code", stor.getString("stor_code"));
|
||||
mst_jo.put("stor_name", stor.getString("stor_name"));
|
||||
mst_jo.put("bill_status", "10");
|
||||
mst_jo.put("create_mode", "03");
|
||||
mst_jo.put("input_optid", currentUserId + "");
|
||||
mst_jo.put("input_optname", nickName);
|
||||
mst_jo.put("input_time", now);
|
||||
mst_jo.put("update_optid", currentUserId + "");
|
||||
mst_jo.put("update_optname", nickName);
|
||||
mst_jo.put("update_time", now);
|
||||
mst_jo.put("is_delete", "0");
|
||||
mst_jo.put("is_upload", "0");
|
||||
Long deptId = SecurityUtils.getDeptId();
|
||||
mst_jo.put("sysdeptid", deptId + "");
|
||||
mst_jo.put("syscompanyid", deptId + "");
|
||||
//调用明细处理方法
|
||||
JSONObject ret = this.insertDtlByRows(mst_jo, rows);
|
||||
mst_jo.put("detail_count", ret.getString("detail_count"));
|
||||
mst_jo.put("total_qty", ret.getString("total_qty"));
|
||||
WQLObject.getWQLObject("ST_IVT_StructIvtChange").insert(mst_jo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细
|
||||
*
|
||||
* @param rows
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
JSONObject insertDtlByRows(JSONObject jo_mst, ArrayList<HashMap> rows) {
|
||||
//定义返回数据
|
||||
JSONObject ret = new JSONObject();
|
||||
double total_qty = 0;
|
||||
double detail_count = 0;
|
||||
//定义需要需要插入的库存集合
|
||||
for (int j = 0; j < rows.size(); j++) {
|
||||
HashMap row = rows.get(j);
|
||||
String SaleOrderItem = (String) row.get("new_sale_order_name");
|
||||
String DemandDate = (String) row.get("demand_date");
|
||||
String CustomerName = (String) row.get("new_customer_name");
|
||||
String isRePrintPackageBoxLabel = (String) row.get("isRePrintPackageBoxLabel");
|
||||
String isUnPackBox = (String) row.get("isUnPackBox");
|
||||
String UpdatedDateOfProduction = (String) row.get("date_of_FG_inbound");
|
||||
//查询该木箱内子卷数量
|
||||
JSONArray container_rows = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("package_box_sn = '" + row.get("storagevehicle_code") + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < container_rows.size(); i++) {
|
||||
JSONObject container_row = container_rows.getJSONObject(i);
|
||||
JSONObject change_jo = new JSONObject();
|
||||
change_jo.put("changeinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + "");
|
||||
change_jo.put("changeinv_id", jo_mst.getString("changeinv_id"));
|
||||
change_jo.put("seq_no", detail_count + 1);
|
||||
JSONObject mater_jo = WQLObject.getWQLObject("md_me_materialbase").query("material_code = '" + container_row.getString("product_name") + "'").uniqueResult(0);
|
||||
change_jo.put("material_id", mater_jo.getString("material_id"));
|
||||
change_jo.put("pcsn", container_row.getString("container_name"));
|
||||
change_jo.put("package_box_sn", container_row.getString("package_box_sn"));
|
||||
change_jo.put("mfg_order_name", SaleOrderItem);
|
||||
change_jo.put("demand_date", DemandDate);
|
||||
change_jo.put("customer_name", CustomerName);
|
||||
//查询对应的客户
|
||||
JSONObject customer_jo = WQLObject.getWQLObject("md_cs_customerbase").query("cust_code = '" + CustomerName + "'").uniqueResult(0);
|
||||
change_jo.put("customer_description", customer_jo.getString("cust_name"));
|
||||
change_jo.put("isRePrintPackageBoxLabel", isRePrintPackageBoxLabel);
|
||||
change_jo.put("isUnPackBox", isUnPackBox);
|
||||
change_jo.put("UpdatedDateOfProduction", UpdatedDateOfProduction);
|
||||
JSONObject unit = WQLObject.getWQLObject("md_pb_measureunit").query("measure_unit_id = '" + mater_jo.getString("base_unit_id") + "'").uniqueResult(0);
|
||||
change_jo.put("qty_unit_id", mater_jo.getString("base_unit_id"));
|
||||
change_jo.put("qty_unit_name", unit.getString("unit_name"));
|
||||
change_jo.put("qty", container_row.getString("net_weight"));
|
||||
WQLObject.getWQLObject("ST_IVT_StructIvtChangeDtl").insert(change_jo);
|
||||
total_qty += container_row.getDoubleValue("net_weight");
|
||||
detail_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
ret.put("total_qty", total_qty);
|
||||
ret.put("detail_count", detail_count);
|
||||
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");
|
||||
Long 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");
|
||||
|
||||
Long 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_HANDMOVESTOR")
|
||||
.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 || is_task.equals("0")) {
|
||||
jo.put("task_id", task.getString("task_id"));
|
||||
} else {
|
||||
task = new JSONObject();
|
||||
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
String task_code = CodeUtil.getNewCode("TASK_CODE");
|
||||
|
||||
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
|
||||
public JSONArray getOutBillDtl(Map whereJson) {
|
||||
whereJson.put("flag", "2");
|
||||
JSONArray jo = WQL.getWO("QST_IVT_HANDMOVESTOR")
|
||||
.addParamMap((HashMap) whereJson)
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Map whereJson) {
|
||||
//主表
|
||||
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
String moveinv_id = (String) whereJson.get("moveinv_id");
|
||||
//查询主表
|
||||
JSONObject jo_mst = wo_mst.query("moveinv_id='" + moveinv_id + "'").uniqueResult(0);
|
||||
//调用删除明细,还原库存方法
|
||||
this.deleteById(moveinv_id + "");
|
||||
//获取明细
|
||||
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableData");
|
||||
//调用明细处理方法
|
||||
JSONObject ret = this.insertDtlByRows(jo_mst, rows);
|
||||
jo_mst.put("remark", whereJson.get("remark"));
|
||||
jo_mst.put("biz_date", whereJson.get("biz_date"));
|
||||
jo_mst.put("detail_count", ret.getString("detail_count"));
|
||||
jo_mst.put("total_qty", ret.getString("total_qty"));
|
||||
jo_mst.put("update_optid", currentUserId + "");
|
||||
jo_mst.put("update_optname", nickName);
|
||||
jo_mst.put("update_time", now);
|
||||
//更新主表
|
||||
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
|
||||
public Map<String, Object> getStructIvt(Map whereJson, Pageable page) {
|
||||
HashMap<String, String> map = new HashMap<String, String>(whereJson);
|
||||
if (StrUtil.isNotEmpty(map.get("remark"))) {
|
||||
map.put("remark", "%" + map.get("remark") + "%");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(map.get("struct_code"))) {
|
||||
map.put("struct_code", "%" + map.get("struct_code") + "%");
|
||||
}
|
||||
if (StrUtil.isNotEmpty(map.get("pcsn"))) {
|
||||
map.put("pcsn", "%" + map.get("pcsn") + "%");
|
||||
}
|
||||
JSONObject jo = WQL.getWO("QST_IVT_HANDMOVESTOR")
|
||||
.addParam("flag", "3")
|
||||
.addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ivt2.struct_id");
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirm(JSONObject form) {
|
||||
//明细表
|
||||
WQLObject wo_dtl = WQLObject.getWQLObject("st_ivt_structivtchangedtl");
|
||||
//主表
|
||||
WQLObject wo_mst = WQLObject.getWQLObject("st_ivt_structivtchange");
|
||||
//任务表
|
||||
|
||||
String changeinv_id = form.getString("changeinv_id");
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
String now = DateUtil.now();
|
||||
//查询主表信息
|
||||
JSONObject jo_mst = wo_mst.query("changeinv_id = '" + changeinv_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jo_mst)) {
|
||||
throw new BadRequestException("未查到相关库存转单单");
|
||||
}
|
||||
JSONArray ja = wo_dtl.query("changeinv_id='" + changeinv_id + "'").getResultJSONArray(0);
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
HashMap<String,String> map = new HashMap<>();
|
||||
map.put("mfg_order_name",jo.getString("mfg_order_name"));
|
||||
map.put("customer_name",jo.getString("customer_name"));
|
||||
map.put("customer_description",jo.getString("customer_description"));
|
||||
map.put("isRePrintPackageBoxLabel",jo.getString("isRePrintPackageBoxLabel"));
|
||||
map.put("isUnPackBox",jo.getString("isUnPackBox"));
|
||||
String UpdatedDateOfProduction = jo.getString("isUnPackBox");
|
||||
String pcsn = jo.getString("pcsn");
|
||||
|
||||
JSONObject old_sub = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("container_name = '"+pcsn+"' AND status = '2'").uniqueResult(0);
|
||||
old_sub.put("change_type_scode","02");
|
||||
old_sub.put("change_order_id",jo_mst.getString("changeinv_id"));
|
||||
old_sub.put("change_order_code",jo_mst.getString("bill_code"));
|
||||
old_sub.put("create_id",currentUserId);
|
||||
old_sub.put("create_name",nickName);
|
||||
old_sub.put("change_time",DateUtil.now());
|
||||
old_sub.put("workorder_id",IdUtil.getSnowflake(1, 1).nextId() + "");
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelationChangeFlow").insert(old_sub);
|
||||
|
||||
if (StrUtil.isNotEmpty(UpdatedDateOfProduction)){
|
||||
map.put("date_of_FG_inbound",jo.getString("date_of_FG_inbound"));
|
||||
}
|
||||
WQLObject.getWQLObject("pdm_bi_subpackagerelation").update(map,"container_name = '"+pcsn+"' AND status = '2'");
|
||||
|
||||
JSONObject new_sub = WQLObject.getWQLObject("pdm_bi_subpackagerelation").query("container_name = '"+pcsn+"' AND status = '2'").uniqueResult(0);
|
||||
new_sub.put("change_type_scode","01");
|
||||
new_sub.put("change_order_id",jo_mst.getString("changeinv_id"));
|
||||
new_sub.put("change_order_code",jo_mst.getString("bill_code"));
|
||||
new_sub.put("create_id",currentUserId);
|
||||
new_sub.put("create_name",nickName);
|
||||
new_sub.put("change_time",DateUtil.now());
|
||||
old_sub.put("workorder_id",IdUtil.getSnowflake(1, 1).nextId() + "");
|
||||
WQLObject.getWQLObject("PDM_BI_SubPackageRelationChangeFlow").insert(new_sub);
|
||||
}
|
||||
HashMap<String, String> map_mst = new HashMap<>();
|
||||
map_mst.put("bill_status", "99");
|
||||
map_mst.put("confirm_optid", currentUserId + "");
|
||||
map_mst.put("confirm_optname", nickName);
|
||||
map_mst.put("confirm_time", now);
|
||||
//更新主表状态
|
||||
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");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
// OutTask checkOutBillAcsTask = new OutTask();
|
||||
String task_id = whereJson.getString("task_id");
|
||||
String taskdtl_id = whereJson.getString("taskdtl_id");
|
||||
// JSONObject result = checkOutBillAcsTask.notifyAcs(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");
|
||||
|
||||
Long 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>();
|
||||
Long 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 (jo_mst.getString("bill_status").equals("99")) {
|
||||
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();
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String moveinv_id = whereJson.getString("moveinv_id");
|
||||
//查询所有载具的库存
|
||||
JSONArray ja = WQL.getWO("QST_IVT_HANDMOVESTOR")
|
||||
.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");
|
||||
|
||||
Long 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
[交易说明]
|
||||
交易名: 基础点位分页查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.material_code TYPEAS s_string
|
||||
输入.bill_status TYPEAS s_string
|
||||
输入.bill_code TYPEAS s_string
|
||||
输入.create_mode TYPEAS s_string
|
||||
输入.bill_type TYPEAS s_string
|
||||
输入.stor_id TYPEAS s_string
|
||||
输入.moveinv_id TYPEAS s_string
|
||||
输入.buss_type TYPEAS s_string
|
||||
输入.work_status TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.material_id TYPEAS s_string
|
||||
输入.quality_scode TYPEAS s_string
|
||||
输入.pcsn TYPEAS s_string
|
||||
输入.ivt_level TYPEAS s_string
|
||||
输入.is_active TYPEAS s_string
|
||||
输入.sect_id TYPEAS s_string
|
||||
输入.moveinvdtl_id TYPEAS s_string
|
||||
输入.struct_id TYPEAS s_string
|
||||
输入.is_issued TYPEAS s_string
|
||||
输入.remark TYPEAS s_string
|
||||
输入.task_id TYPEAS s_string
|
||||
输入.struct_code TYPEAS s_string
|
||||
输入.ids TYPEAS f_string
|
||||
输入.deptIds TYPEAS f_string
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
cg.changeinv_id AS id,
|
||||
cg.*
|
||||
FROM
|
||||
st_ivt_structivtchange cg
|
||||
WHERE
|
||||
1 = 1
|
||||
AND cg.is_delete = '0'
|
||||
OPTION 输入.bill_code <> ""
|
||||
cg.bill_code like 输入.bill_code
|
||||
ENDOPTION
|
||||
OPTION 输入.buss_type <> ""
|
||||
cg.buss_type like 输入.buss_type
|
||||
ENDOPTION
|
||||
OPTION 输入.bill_type <> ""
|
||||
cg.bill_type = 输入.bill_type
|
||||
ENDOPTION
|
||||
OPTION 输入.stor_id <> ""
|
||||
cg.stor_id = 输入.stor_id
|
||||
ENDOPTION
|
||||
OPTION 输入.create_mode <> ""
|
||||
cg.create_mode = 输入.create_mode
|
||||
ENDOPTION
|
||||
OPTION 输入.bill_status <> ""
|
||||
cg.bill_status = 输入.bill_status
|
||||
ENDOPTION
|
||||
OPTION 输入.begin_time <> ""
|
||||
cg.input_time >= 输入.begin_time
|
||||
ENDOPTION
|
||||
OPTION 输入.end_time <> ""
|
||||
cg.input_time <= 输入.end_time
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
QUERY
|
||||
SELECT
|
||||
MoveInvDtl.*,
|
||||
mb.material_code,
|
||||
mb.material_name
|
||||
FROM
|
||||
ST_IVT_MoveInvDtl MoveInvDtl
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = MoveInvDtl.material_id
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.moveinv_id <> ""
|
||||
MoveInvDtl.moveinv_id = 输入.moveinv_id
|
||||
ENDOPTION
|
||||
OPTION 输入.moveinvdtl_id <> ""
|
||||
MoveInvDtl.moveinvdtl_id = 输入.moveinvdtl_id
|
||||
ENDOPTION
|
||||
OPTION 输入.work_status <> ""
|
||||
MoveInvDtl.work_status <= 输入.work_status
|
||||
ENDOPTION
|
||||
order by MoveInvDtl.seq_no
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "3"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
ivt2.stockrecord_id,
|
||||
ivt2.material_id,
|
||||
ivt2.pcsn,
|
||||
ivt2.quality_scode,
|
||||
ivt2.qty_unit_id,
|
||||
ivt2.ivt_qty AS qty,
|
||||
mb.material_code,
|
||||
mb.material_name,
|
||||
struct.struct_id AS turnout_struct_id,
|
||||
struct.struct_code AS turnout_struct_code,
|
||||
struct.struct_name AS turnout_struct_name,
|
||||
struct.sect_id AS turnout_sect_id,
|
||||
struct.sect_name AS turnout_sect_name,
|
||||
struct.sect_code AS turnout_sect_code,
|
||||
struct.storagevehicle_id,
|
||||
struct.storagevehicle_code,
|
||||
mu.unit_name AS qty_unit_name
|
||||
FROM
|
||||
st_ivt_structattr struct
|
||||
INNER JOIN ST_IVT_StructIvt ivt2 ON struct.struct_id = ivt2.struct_id
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt2.material_id
|
||||
LEFT JOIN md_pb_measureunit mu ON mu.measure_unit_id = ivt2.qty_unit_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND struct.lock_type = '1'
|
||||
OPTION 输入.material_id <> ""
|
||||
ivt2.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
OPTION 输入.remark <> ""
|
||||
(mb.material_code like 输入.remark or mb.material_name like 输入.remark)
|
||||
ENDOPTION
|
||||
OPTION 输入.ids <> ""
|
||||
struct.storagevehicle_code in (输入.ids)
|
||||
ENDOPTION
|
||||
OPTION 输入.struct_code <> ""
|
||||
struct.struct_code like 输入.struct_code
|
||||
ENDOPTION
|
||||
OPTION 输入.stor_id <> ""
|
||||
ivt2.stor_id = 输入.stor_id
|
||||
ENDOPTION
|
||||
OPTION 输入.sect_id <> ""
|
||||
struct.sect_id = 输入.sect_id
|
||||
ENDOPTION
|
||||
OPTION 输入.pcsn <> ""
|
||||
ivt2.pcsn like 输入.pcsn
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "33"
|
||||
QUERY
|
||||
SELECT
|
||||
ivt2.stockrecord_id,
|
||||
ivt2.material_id,
|
||||
ivt2.pcsn,
|
||||
ivt2.quality_scode,
|
||||
ivt2.qty_unit_id,
|
||||
mu.unit_name AS qty_unit_name,
|
||||
ivt2.ivt_qty AS qty,
|
||||
mb.material_code,
|
||||
mb.material_name,
|
||||
struct.struct_id AS turnout_struct_id,
|
||||
struct.struct_code AS turnout_struct_code,
|
||||
struct.struct_name AS turnout_struct_name,
|
||||
struct.sect_id AS turnout_sect_id,
|
||||
struct.sect_name AS turnout_sect_name,
|
||||
struct.sect_code AS turnout_sect_code,
|
||||
struct.storagevehicle_id,
|
||||
struct.storagevehicle_code,
|
||||
point.point_code AS start_point_code
|
||||
FROM
|
||||
st_ivt_structattr struct
|
||||
INNER JOIN ST_IVT_StructIvt ivt2 ON struct.struct_id = ivt2.struct_id
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt2.material_id
|
||||
LEFT JOIN SCH_BASE_Point point ON point.source_id = struct.struct_id
|
||||
LEFT JOIN md_pb_measureunit mu ON mu.measure_unit_id = mb.base_unit_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND struct.lock_type = '1'
|
||||
AND IFNULL(struct.storagevehicle_code,'') <> ''
|
||||
OPTION 输入.material_id <> ""
|
||||
ivt2.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
OPTION 输入.remark <> ""
|
||||
(mb.material_code like 输入.remark or mb.material_name like 输入.remark)
|
||||
ENDOPTION
|
||||
OPTION 输入.ids <> ""
|
||||
struct.storagevehicle_code in (输入.ids)
|
||||
ENDOPTION
|
||||
OPTION 输入.struct_code <> ""
|
||||
struct.struct_code like 输入.struct_code
|
||||
ENDOPTION
|
||||
OPTION 输入.stor_id <> ""
|
||||
ivt2.stor_id = 输入.stor_id
|
||||
ENDOPTION
|
||||
OPTION 输入.sect_id <> ""
|
||||
struct.sect_id = 输入.sect_id
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "4"
|
||||
QUERY
|
||||
SELECT
|
||||
DISTINCT(task.task_id)
|
||||
FROM
|
||||
ST_IVT_MoveInvDtl dtl
|
||||
INNER JOIN ST_IVT_MoveInv mst ON mst.moveinv_id = dtl.moveinv_id
|
||||
INNER JOIN SCH_BASE_Task task ON task.task_id = dtl.task_id
|
||||
WHERE
|
||||
1 = 1
|
||||
AND mst.bill_status = '10'
|
||||
AND dtl.work_status = '01'
|
||||
AND dtl.is_issued = '0'
|
||||
AND task.task_status = '01'
|
||||
AND mst.is_delete = '0'
|
||||
AND task.is_delete = '0'
|
||||
OPTION 输入.moveinv_id <> ""
|
||||
dtl.moveinv_id = 输入.moveinv_id
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
@@ -158,12 +158,16 @@
|
||||
struct.sect_code AS turnout_sect_code,
|
||||
struct.storagevehicle_id,
|
||||
struct.storagevehicle_code,
|
||||
mu.unit_name AS qty_unit_name
|
||||
mu.unit_name AS qty_unit_name,
|
||||
sub.sale_order_name,
|
||||
sub.customer_name,
|
||||
sub.customer_description
|
||||
FROM
|
||||
st_ivt_structattr struct
|
||||
INNER JOIN ST_IVT_StructIvt ivt2 ON struct.struct_id = ivt2.struct_id
|
||||
LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt2.material_id
|
||||
LEFT JOIN md_pb_measureunit mu ON mu.measure_unit_id = ivt2.qty_unit_id
|
||||
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = ivt2.pcsn
|
||||
WHERE
|
||||
1 = 1
|
||||
AND struct.lock_type = '1'
|
||||
|
||||
Reference in New Issue
Block a user