This commit is contained in:
2022-07-01 09:14:57 +08:00
parent 4d9d6fbe8f
commit 8c86db4f8f
21 changed files with 1919 additions and 209 deletions

View File

@@ -0,0 +1,45 @@
package org.nl.pda.sb.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.annotation.Log;
import org.nl.pda.sb.service.SparePartService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author ldjun
* @date 2021-07-26
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "手持工序任务")
@RequestMapping("api/pda/sb/")
@Slf4j
public class SparePartController {
private final SparePartService sparePartService;
@PostMapping("/queryReturnDis")
@Log("扫描工艺指令卡")
@ApiOperation("扫描工艺指令卡")
public ResponseEntity<Object> queryReturnDis(@RequestBody Map whereJson) {
return new ResponseEntity<>(sparePartService.queryReturnDis(whereJson),HttpStatus.OK);
}
@PostMapping("/confirmReturn")
@Log("扫描工艺指令卡")
@ApiOperation("扫描工艺指令卡")
public ResponseEntity<Object> confirmReturn(@RequestBody Map whereJson) {
return new ResponseEntity<>(sparePartService.confirmReturn(whereJson),HttpStatus.OK);
}
}

View File

@@ -0,0 +1,15 @@
package org.nl.pda.sb.service;
import java.util.Map;
public interface SparePartService {
/**
* 校验并查询载具信息
*
* @param jsonObject 条件
* @return Map
*/
Map<String, Object> queryReturnDis(Map jsonObject);
Map<String, Object> confirmReturn(Map jsonObject);
}

View File

@@ -0,0 +1,206 @@
package org.nl.pda.sb.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.ext.acs.service.WmsToAcsService;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.pda.exception.PdaRequestException;
import org.nl.pda.pdm.service.PdmWorkTaskService;
import org.nl.pda.sb.service.SparePartService;
import org.nl.pda.st.vehicle.service.impl.EmptyVehicleServiceImpl;
import org.nl.utils.SecurityUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wms.basedata.master.service.ClassstandardService;
import org.nl.wms.basedata.st.service.StorattrService;
import org.nl.wms.basedata.st.service.dto.StorattrDto;
import org.nl.wms.sb.core.service.SparePartInService;
import org.nl.wms.sb.core.service.impl.SparePartInServiceImpl;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.st.core.task.InTask;
import org.nl.wms.st.vehicle.task.ProductTask;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
public class SparePartServiceImpl implements SparePartService {
@Autowired
private final StorattrService storattrService;
@Autowired
private final SparePartInServiceImpl sparePartInService;
@Override
public Map<String, Object> queryReturnDis(Map jsonObject) {
if (ObjectUtil.isEmpty(jsonObject)) {
throw new PdaRequestException("传入参数不能为空!");
}
JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject));
String sparepart_only_id = jo.getString("sparepart_only_id");
if (StrUtil.isEmpty(sparepart_only_id)) {
throw new PdaRequestException("备品备件不能为空!");
}
JSONObject spare_bom = WQLObject.getWQLObject("EM_BI_EquipmentSpareBOM").query("sparepart_only_id = '"+sparepart_only_id+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(spare_bom)){
throw new PdaRequestException("该备件未查询到设备档案BOM备件表");
}
String device_id = spare_bom.getString("devicerecord_id");
JSONObject row = WQL.getWO("QPDAEM_BI_SPAREPART").addParam("flag","1").addParam("device_id",device_id).addParam("sparepart_only_id",sparepart_only_id).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jo)){
if (ObjectUtil.isEmpty(spare_bom)){
throw new PdaRequestException("该备件未查询到相关领用出库记录!");
}
}
return row;
}
@Override
public Map<String, Object> confirmReturn(Map jsonObject) {
WQLObject mst_wql = WQLObject.getWQLObject("EM_BI_IOStorInv");
WQLObject dtl_wql = WQLObject.getWQLObject("EM_BI_IOStorInvDtl");
WQLObject dis_wql = WQLObject.getWQLObject("EM_BI_IOStorInvDis");
if (ObjectUtil.isEmpty(jsonObject)) {
throw new PdaRequestException("传入参数不能为空!");
}
JSONObject jo = JSONObject.parseObject(JSON.toJSONString(jsonObject));
JSONArray rows= jo.getJSONArray("rows");
String device_code = rows.getJSONObject(0).getString("device_code");
String device_id = rows.getJSONObject(0).getString("device_id");
String device_name = rows.getJSONObject(0).getString("device_name");
String stor_id = rows.getJSONObject(0).getString("stor_id");
String iostorinv_id = IdUtil.getSnowflake(1, 1).nextId() + "";
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
if (!row.getString("device_code").equals(device_code)){
throw new PdaRequestException("关联设备需相同!");
}
JSONObject dis_jo = new JSONObject();
//判断该分配是否存在明细
JSONObject dtl = dtl_wql.query("iostorinv_id = '"+iostorinv_id+"' AND material_id = '"+row.getString("material_id")+"'").uniqueResult(0);
if (ObjectUtil.isEmpty(dtl)){
//插入一条入库明细
dtl = new JSONObject();
dtl.put("iostorinvdtl_id", IdUtil.getSnowflake(1, 1).nextId() + "");
dtl.put("iostorinv_id", iostorinv_id);
JSONArray dtl_rows = dtl_wql.query("iostorinv_id = '"+iostorinv_id+"'").getResultJSONArray(0);
dtl.put("seq_no", (dtl_rows.size() + 1) + "");
dtl.put("bill_status", "99");
dtl.put("material_id",row.getString("material_id"));
dtl.put("pcsn",row.getString("pcsn"));
dtl.put("qty_unit_id",row.getString("qty_unit_id"));
dtl.put("qty_unit_name",row.getString("qty_unit_name"));
dtl.put("source_billdtl_id",row.getString("source_billdtl_id"));
dtl.put("base_billdtl_id",row.getString("source_billdtl_id"));
dtl.put("source_bill_type",row.getString("source_bill_type"));
dtl.put("base_bill_type",row.getString("source_bill_type"));
dtl.put("source_bill_code",row.getString("source_bill_code"));
dtl.put("base_bill_code",row.getString("source_bill_code"));
dtl.put("source_bill_table",row.getString("source_bill_table"));
dtl.put("base_bill_table",row.getString("source_bill_table"));
dtl.put("plan_qty","1");
dtl.put("real_qty","1");
WQLObject.getWQLObject("EM_BI_IOStorInvDtl").insert(dtl);
}else {
dtl.put("plan_qty",dtl.getDoubleValue("plan_qty")+1);
dtl.put("real_qty",dtl.getDoubleValue("real_qty")+1);
WQLObject.getWQLObject("EM_BI_IOStorInvDtl").update(dtl);
}
dis_jo.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
dis_jo.put("iostorinv_id", iostorinv_id);
dis_jo.put("iostorinvdtl_id", dtl.getString("iostorinvdtl_id"));
dis_jo.put("disseq_no", i + 1);
dis_jo.put("material_id", dtl.getString("material_id"));
dis_jo.put("pcsn", "999999");
dis_jo.put("real_qty", "1");
dis_jo.put("work_status", "01");
dis_jo.put("qty_unit_id", dtl.getString("qty_unit_id"));
dis_jo.put("qty_unit_name", dtl.getString("qty_unit_name"));
JSONObject stor = WQLObject.getWQLObject("st_ivt_bsrealstorattr").query("is_attachment = '1'").uniqueResult(0);
JSONObject struct = WQLObject.getWQLObject("st_ivt_structattr").query("stor_id = '"+stor.getString("stor_id")+"' order by sect_code").uniqueResult(0);
dis_jo.put("sect_id", struct.getString("sect_id"));
dis_jo.put("sect_code", struct.getString("sect_code"));
dis_jo.put("sect_name", struct.getString("sect_name"));
dis_jo.put("struct_id", struct.getString("struct_id"));
dis_jo.put("struct_code", struct.getString("struct_code"));
dis_jo.put("struct_name", struct.getString("struct_name"));
dis_jo.put("sparepart_only_id", row.getString("sparepart_only_id"));
dis_wql.insert(dis_jo);
//更新设备bom
WQLObject.getWQLObject("EM_BI_EquipmentSpareBOM").delete("sparepart_only_id = '"+row.getString("sparepart_only_id")+"' AND devicerecord_id = '"+device_id+"'");
}
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
//插入主表
JSONObject io_mst = new JSONObject();
String bill_code = CodeUtil.getNewCode("IO_CODE");
io_mst.put("iostorinv_id", iostorinv_id);
io_mst.put("bill_code", bill_code);
io_mst.put("buss_type","0008");
io_mst.put("io_type", "0");
io_mst.put("bill_type", "000801");
io_mst.put("biz_date", DateUtil.today());
StorattrDto storattrDto = storattrService.findById(Long.parseLong(stor_id));
String stor_code = storattrDto.getStor_code();
String stor_name = storattrDto.getStor_name();
io_mst.put("stor_id", stor_id);
io_mst.put("stor_code", stor_code);
io_mst.put("stor_name", stor_name);
JSONArray dis_num = dis_wql.query("iostorinv_id = '"+iostorinv_id+"'").getResultJSONArray(0);
io_mst.put("total_qty", dis_num.size());
JSONArray dtl_num = dtl_wql.query("iostorinv_id = '"+iostorinv_id+"'").getResultJSONArray(0);
io_mst.put("detail_count", dtl_num.size());
io_mst.put("bill_status", "40");
io_mst.put("create_mode", "01");
io_mst.put("input_optid", currentUserId + "");
io_mst.put("input_optname", nickName);
io_mst.put("input_time", now);
io_mst.put("update_optid", currentUserId + "");
io_mst.put("update_optname", nickName);
io_mst.put("update_time", now);
io_mst.put("device_id", device_id);
io_mst.put("device_code", device_code);
io_mst.put("device_name", device_name);
io_mst.put("is_delete", "0");
io_mst.put("is_upload", "0");
JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
Long deptId = currentUser.getDeptId();
io_mst.put("sysdeptid", deptId + "");
io_mst.put("syscompanyid", deptId + "");
io_mst.put("bizdeptid", deptId + "");
WQLObject.getWQLObject("EM_BI_IOStorInv").insert(io_mst);
//完成主表
sparePartInService.confirmMst(iostorinv_id);
return null;
}
}

View File

@@ -0,0 +1,79 @@
[交易说明]
交易名: 库区分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.device_id TYPEAS s_string
输入.sparepart_only_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
dis.sparepart_only_id,
mb.material_name,
mb.material_model,
mb.material_spec,
dis.qty_unit_name,
dis.qty_unit_id,
dtl.iostorinvdtl_id AS source_billdtl_id,
mst.bill_type AS source_bill_type,
mst.bill_code AS source_bill_code,
'EM_BI_IOStorInv' AS source_bill_table,
'领用出库' AS source_type_name,
dis.material_id,
file.device_code
FROM
em_bi_iostorinvdis dis
LEFT JOIN em_bi_iostorinv mst ON mst.iostorinv_id = dis.iostorinv_id
LEFT JOIN em_bi_iostorinvdtl dtl ON dtl.iostorinvdtl_id = dis.iostorinvdtl_id
LEFT JOIN md_me_materialbase mb ON mb.material_id = dis.material_id
LEFT JOIN em_bi_equipmentfile file ON file.devicerecord_id = mst.device_id
LEFT JOIN
WHERE
dis.sparepart_only_id = 输入.sparepart_only_id
AND mst.device_id = 输入.device_id
AND mst.bill_status = '99'
AND mst.is_delete = '0'
AND dis.work_status = '99'
ORDER BY
mst.biz_date DESC
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -93,12 +93,12 @@ public class SparePartOutController {
return new ResponseEntity<>(sparePartOutService.getIvt(whereJson), HttpStatus.OK);
}
@PostMapping("/createCode")
@PostMapping("/insertDis")
@Log("生成备件码")
@ApiOperation("分配货位")
//@PreAuthorize("@el.check('materialtype:list')")
public ResponseEntity<Object> createCode(@RequestBody JSONObject jo) {
sparePartOutService.createCode(jo);
public ResponseEntity<Object> insertDis(@RequestBody JSONObject jo) {
sparePartOutService.insertDis(jo);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

View File

@@ -0,0 +1,36 @@
package org.nl.wms.sb.core.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.annotation.Log;
import org.nl.wms.sb.core.service.SparePartOutService;
import org.nl.wms.sb.core.service.SparePartReturnService;
import org.springframework.beans.factory.annotation.Autowired;
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/sb/return")
@Slf4j
public class SparePartReturnController {
@Autowired
private SparePartReturnService sparePartReturnService;
@GetMapping
@Log("查询备件出库")
@ApiOperation("查询原辅料入库单据")
//@PreAuthorize("@el.check('checkoutbill:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(sparePartReturnService.pageQuery(whereJson,page), HttpStatus.OK);
}
}

View File

@@ -25,7 +25,7 @@ public interface SparePartOutService {
JSONArray getIODtl(Map whereJson);
void createCode(JSONObject jo);
void insertDis(JSONObject jo);
void cancelCreate(JSONObject whereJson);

View File

@@ -0,0 +1,19 @@
package org.nl.wms.sb.core.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Pageable;
import java.util.Map;
public interface SparePartReturnService {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
Map<String, Object> pageQuery(Map whereJson, Pageable page);
}

View File

@@ -93,6 +93,10 @@ public class SparePartOutServiceImpl implements SparePartOutService {
String stor_code = storattrDto.getStor_code();
String stor_name = storattrDto.getStor_name();
io_mst.put("stor_id", whereJson.get("stor_id"));
io_mst.put("bizdeptid", whereJson.get("bizdeptid"));
io_mst.put("device_id", whereJson.get("device_id"));
io_mst.put("device_code", whereJson.get("device_code"));
io_mst.put("device_name", whereJson.get("device_name"));
io_mst.put("stor_code", stor_code);
io_mst.put("stor_name", stor_name);
io_mst.put("total_qty", whereJson.get("total_qty"));
@@ -199,7 +203,7 @@ public class SparePartOutServiceImpl implements SparePartOutService {
String search = whereJson.getString("search");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "11");
if (StrUtil.isNotEmpty(search)){
if (StrUtil.isNotEmpty(search)) {
map.put("search", search);
}
JSONArray dtl_rows = WQL.getWO("QEM_BI_SPAREPARTOUT").addParamMap(map).process().getResultJSONArray(0);
@@ -212,7 +216,7 @@ public class SparePartOutServiceImpl implements SparePartOutService {
HashMap<String, String> map = new HashMap<>();
map.put("flag", "12");
map.put("material_id", whereJson.getString("material_id"));
if (StrUtil.isNotEmpty(search)){
if (StrUtil.isNotEmpty(search)) {
map.put("search", search);
}
JSONArray dtl_rows = WQL.getWO("QEM_BI_SPAREPARTOUT").addParamMap(map).process().getResultJSONArray(0);
@@ -221,53 +225,58 @@ public class SparePartOutServiceImpl implements SparePartOutService {
@Transactional(rollbackFor = Exception.class)
@Override
public void createCode(JSONObject form) {
public void insertDis(JSONObject form) {
WQLObject mst_wql = WQLObject.getWQLObject("EM_BI_IOStorInv");
WQLObject dtl_wql = WQLObject.getWQLObject("EM_BI_IOStorInvDtl");
WQLObject dis_wql = WQLObject.getWQLObject("EM_BI_IOStorInvDis");
WQLObject struct_wql = WQLObject.getWQLObject("st_ivt_structattr");
JSONObject jo = form.getJSONObject("dtl_row");
String sect_id = form.getString("sect_id");
String stor_id = form.getString("stor_id");
JSONObject jo = form.getJSONObject("row");
JSONArray rows = form.getJSONArray("rows");
String iostorinvdtl_id = jo.getString("iostorinvdtl_id");
JSONObject dtl_jo = dtl_wql.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0);
if (!dtl_jo.getString("bill_status").equals("10")) {
throw new BadRequestException("明细状态必须为生成!");
if (!dtl_jo.getString("bill_status").equals("10") && !dtl_jo.getString("bill_status").equals("20") && !dtl_jo.getString("bill_status").equals("30")) {
throw new BadRequestException("明细状态必须为生成、提交、分配中!");
}
JSONObject struct = struct_wql.query("sect_id = '" + sect_id + "' AND stor_id = '" + stor_id + "' AND is_delete = '0' AND is_used = '1' order by struct_code").uniqueResult(0);
if (ObjectUtil.isEmpty(struct)) {
throw new BadRequestException("未查询到该库区下存在可分配的仓位!");
if (rows.size() == 0) {
throw new BadRequestException("至少选择一条分配记录!");
}
int num = dtl_jo.getInteger("plan_qty");
//备件实例化插入分配表
for (int i = 0; i < num; i++) {
for (int i = 0; i < rows.size(); i++) {
JSONObject dis_row = rows.getJSONObject(i);
JSONObject dis_jo = new JSONObject();
dis_jo.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId());
dis_jo.put("iostorinv_id", dtl_jo.getString("iostorinv_id"));
dis_jo.put("iostorinvdtl_id", dtl_jo.getString("iostorinvdtl_id"));
dis_jo.put("disseq_no", i + 1);
dis_jo.put("material_id", dtl_jo.getString("material_id"));
JSONArray ass_dis = dis_wql.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").getResultJSONArray(0);
dis_jo.put("disseq_no", ass_dis.size() + 1);
dis_jo.put("material_id", dis_row.getString("material_id"));
dis_jo.put("pcsn", "999999");
dis_jo.put("real_qty", "1");
dis_jo.put("work_status", "10");
dis_jo.put("qty_unit_id", dtl_jo.getString("qty_unit_id"));
dis_jo.put("qty_unit_name", dtl_jo.getString("qty_unit_name"));
dis_jo.put("sect_id", struct.getString("sect_id"));
dis_jo.put("sect_code", struct.getString("sect_code"));
dis_jo.put("sect_name", struct.getString("sect_name"));
dis_jo.put("struct_id", struct.getString("struct_id"));
dis_jo.put("struct_code", struct.getString("struct_code"));
dis_jo.put("struct_name", struct.getString("struct_name"));
dis_jo.put("sparepart_only_id", CodeUtil.getNewCode("SPARE_CODE"));
dis_jo.put("work_status", "01");
dis_jo.put("qty_unit_id", dis_row.getString("qty_unit_id"));
dis_jo.put("qty_unit_name", dis_row.getString("qty_unit_name"));
dis_jo.put("sect_id", dis_row.getString("sect_id"));
dis_jo.put("sect_code", dis_row.getString("sect_code"));
dis_jo.put("sect_name", dis_row.getString("sect_name"));
dis_jo.put("struct_id", dis_row.getString("struct_id"));
dis_jo.put("struct_code", dis_row.getString("struct_code"));
dis_jo.put("struct_name", dis_row.getString("struct_name"));
dis_jo.put("sparepart_only_id", dis_row.getString("sparepart_only_id"));
dis_wql.insert(dis_jo);
}
//修改明细状态
double plan_qty = dtl_jo.getDoubleValue("plan_qty");
HashMap<String, String> dtl_map = new HashMap<>();
dtl_map.put("bill_status", "40");
if (plan_qty <= rows.size()) {
dtl_map.put("bill_status", "40");
} else {
dtl_map.put("bill_status", "30");
}
dtl_wql.update(dtl_map, "iostorinvdtl_id = '" + iostorinvdtl_id + "'");
//修改主表状态
@@ -294,23 +303,35 @@ public class SparePartOutServiceImpl implements SparePartOutService {
WQLObject dtl_wql = WQLObject.getWQLObject("EM_BI_IOStorInvDtl");
WQLObject dis_wql = WQLObject.getWQLObject("EM_BI_IOStorInvDis");
String iostorinvdtl_id = whereJson.getString("iostorinvdtl_id");
JSONObject dtl_jo = dtl_wql.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0);
if (!dtl_jo.getString("bill_status").equals("40")) {
throw new BadRequestException("明细状态必须为分配完!");
JSONObject dtl_jo = whereJson.getJSONObject("row");
String iostorinvdtl_id = dtl_jo.getString("iostorinvdtl_id");
JSONArray rows = whereJson.getJSONArray("rows");
if (rows.size() == 0) {
throw new BadRequestException("至少选择一条分配记录!");
}
JSONObject finish_dis = dis_wql.query("iostorinvdtl_id = '" + dtl_jo.getString("iostorinvdtl_id") + "' AND work_status = '99'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(finish_dis)) {
throw new BadRequestException("存在已经入库完成的备件!");
for (int i = 0; i < rows.size(); i++) {
JSONObject row = rows.getJSONObject(i);
String iostorinvdis_id = row.getString("iostorinvdis_id");
JSONObject dis_jo = dis_wql.query("iostorinvdis_id = '" + iostorinvdis_id + "'").uniqueResult(0);
if (!dis_jo.getString("work_status").equals("01")) {
throw new BadRequestException("请选择状态为生成的分配记录!");
}
dis_wql.delete("iostorinvdis_id = '" + iostorinvdis_id + "'");
}
dis_wql.delete("iostorinvdtl_id = '" + dtl_jo.getString("iostorinvdtl_id") + "'");
//修改明细状态
JSONArray dis_rows = dis_wql.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").getResultJSONArray(0);
HashMap<String, String> dtl_map = new HashMap<>();
dtl_map.put("bill_status", "10");
if (dis_rows.size() > 0) {
dtl_map.put("bill_status", "30");
} else {
dtl_map.put("bill_status", "10");
}
dtl_wql.update(dtl_map, "iostorinvdtl_id = '" + iostorinvdtl_id + "'");
//修改主表状态
@@ -438,23 +459,11 @@ public class SparePartOutServiceImpl implements SparePartOutService {
for (int i = 0; i < dis_rows.size(); i++) {
JSONObject row = dis_rows.getJSONObject(i);
//插入库存表
JSONObject ivt_jo = new JSONObject();
ivt_jo.put("stockrecord_id", IdUtil.getSnowflake(1, 1).nextId());
ivt_jo.put("sparepart_only_id", row.getString("sparepart_only_id"));
ivt_jo.put("material_id", row.getString("material_id"));
ivt_jo.put("pcsn", row.getString("pcsn"));
JSONObject struct = WQLObject.getWQLObject("st_ivt_structattr").query("struct_id = '" + row.getString("struct_id") + "'").uniqueResult(0);
ivt_jo.put("stor_id", struct.getString("stor_id"));
ivt_jo.put("stor_name", struct.getString("stor_name"));
ivt_jo.put("struct_id", row.getString("struct_id"));
ivt_jo.put("struct_code", row.getString("struct_code"));
ivt_jo.put("struct_name", row.getString("struct_name"));
ivt_jo.put("qty_unit_id", row.getString("qty_unit_id"));
ivt_jo.put("qty_unit_name", row.getString("qty_unit_name"));
ivt_jo.put("ivt_qty", "1");
ivt_jo.put("instorage_time", now);
WQLObject.getWQLObject("EM_BI_DeviceSparePartIvt").insert(ivt_jo);
//删除库存表
JSONObject ivt_jo = new JSONObject();
WQLObject.getWQLObject("EM_BI_DeviceSparePartIvt").delete("sparepart_only_id = '" + row.getString("sparepart_only_id") + "'");
//插入出入库记录表
JSONObject record_jo = new JSONObject();
@@ -479,6 +488,19 @@ public class SparePartOutServiceImpl implements SparePartOutService {
record_jo.put("source_bill_code", mst.getString("bill_code"));
record_jo.put("source_bill_table", "EM_BI_IOStorInv");
WQLObject.getWQLObject("EM_BI_DeviceSparePartIOStorInvRecord").insert(record_jo);
if (StrUtil.isNotEmpty(mst.getString("device_id")) && mst.getString("bill_type").equals("010901")) {
JSONObject bom = new JSONObject();
bom.put("device_file_spare_id", IdUtil.getSnowflake(1, 1).nextId());
bom.put("devicerecord_id", mst.getString("device_id"));
bom.put("sparepart_only_id", row.getString("sparepart_only_id"));
bom.put("material_id", row.getString("material_id"));
bom.put("pcsn", row.getString("pcsn"));
bom.put("qty_unit_id", row.getString("qty_unit_id"));
bom.put("qty_unit_name", row.getString("qty_unit_name"));
bom.put("qty", "1");
WQLObject.getWQLObject("EM_BI_EquipmentSpareBOM").insert(bom);
}
}
}
}

View File

@@ -0,0 +1,72 @@
package org.nl.wms.sb.core.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.st.service.StorattrService;
import org.nl.wms.basedata.st.service.dto.StorattrDto;
import org.nl.wms.common.util.DataAuthUtil;
import org.nl.wms.sb.core.service.SparePartInService;
import org.nl.wms.sb.core.service.SparePartReturnService;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
import org.springframework.beans.factory.annotation.Autowired;
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 SparePartReturnServiceImpl implements SparePartReturnService {
@Override
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
map.put("buss_type", (String) whereJson.get("buss_type"));
map.put("stor_id", (String) whereJson.get("stor_id"));
map.put("bill_type", (String) whereJson.get("bill_type"));
map.put("create_mode", (String) whereJson.get("create_mode"));
map.put("bill_status", (String) whereJson.get("bill_status"));
String bill_code = MapUtil.getStr(whereJson, "bill_code");
if (!ObjectUtil.isEmpty(bill_code)) {
map.put("bill_code", "%" + bill_code + "%");
}
String begin_time = (String) whereJson.get("begin_time");
//根据系统参数判断是否需要使用部门进行数据权限过滤
String deptIds = DataAuthUtil.getDeptStr();
map.put("deptIds", deptIds);
if (!StrUtil.isEmpty(begin_time)) {
map.put("begin_time", begin_time);
}
String end_time = (String) whereJson.get("end_time");
if (!StrUtil.isEmpty(end_time)) {
map.put("end_time", end_time);
}
JSONObject jo = WQL.getWO("QEM_BI_SPAREPART").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "input_time desc");
return jo;
}
}

View File

@@ -189,7 +189,7 @@
IF 输入.flag = "4"
QUERY
SELECT
(case when dis.work_status = '10' then '生成' when dis.work_status = '99' then '完成' end) AS status_name,
(case when dis.work_status = '01' then '生成' when dis.work_status = '99' then '完成' end) AS status_name,
dis.sparepart_only_id,
mb.material_name,
dis.pcsn,

View File

@@ -16,6 +16,7 @@
输入.flag TYPEAS s_string
输入.bill_code TYPEAS s_string
输入.material_search TYPEAS s_string
输入.search TYPEAS s_string
输入.end_time TYPEAS s_string
输入.begin_time TYPEAS s_string
输入.bill_status TYPEAS s_string
@@ -190,7 +191,7 @@
IF 输入.flag = "4"
QUERY
SELECT
(case when dis.work_status = '10' then '生成' when dis.work_status = '99' then '完成' end) AS status_name,
(case when dis.work_status = '01' then '生成' when dis.work_status = '99' then '完成' end) AS status_name,
dis.sparepart_only_id,
mb.material_name,
dis.pcsn,
@@ -449,7 +450,27 @@
MAX( qty_unit_id ) AS qty_unit_id,
SUM( ivt_qty ) AS sum_qty
FROM
EM_BI_DeviceSparePartIvt b
(
SELECT
material_id,
qty_unit_name,
qty_unit_id,
ivt_qty
FROM
EM_BI_DeviceSparePartIvt ivt
WHERE
ivt.sparepart_only_id NOT IN (
SELECT
dis.sparepart_only_id
FROM
EM_BI_IOStorInv mst
LEFT JOIN EM_BI_IOStorInvDis dis ON mst.iostorinv_id = dis.iostorinv_id
WHERE
io_type = '1'
AND bill_status <> '99'
AND dis.iostorinvdis_id IS NOT NULL
)
) c
GROUP BY
material_id
) a ON a.material_id = mb.material_id
@@ -469,20 +490,47 @@
QUERY
SELECT
sa.sect_name,
sa.struct_name,
ivt.sparepart_only_id,
mb.material_code,
mb.material_name,
ivt.pcsn,
ivt.ivt_qty,
ivt.qty_unit_name,
ivt.instorage_time
sa.sect_id,
sa.sect_code,
sa.struct_id,
sa.struct_code,
sa.struct_name,
ivt.sparepart_only_id,
mb.material_code,
mb.material_name,
ivt.pcsn,
ivt.ivt_qty,
ivt.qty_unit_id,
ivt.qty_unit_name,
ivt.instorage_time,
ivt.material_id
FROM
em_bi_devicesparepartivt ivt
LEFT JOIN st_ivt_structattr sa ON sa.struct_id = ivt.struct_id
LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt.material_id
WHERE
ivt.material_id = 输入.material_id
OPTION 输入.search <> ""
(ivt.sparepart_only_id = 输入.search OR sa.struct_code = 输入.search OR sa.struct_name = 输入.search)
ENDOPTION
OPTION 输入.stor_id <> ""
sa.stor_id = 输入.stor_id
ENDOPTION
OPTION 输入.sect_id <> ""
sa.sect_id = 输入.sect_id
ENDOPTION
AND
ivt.sparepart_only_id NOT IN (
SELECT
dis.sparepart_only_id
FROM
EM_BI_IOStorInv mst
LEFT JOIN EM_BI_IOStorInvDis dis ON mst.iostorinv_id = dis.iostorinv_id
WHERE
io_type = '1'
AND bill_status <> '99'
AND dis.iostorinvdis_id IS NOT NULL
)
ENDSELECT
ENDQUERY
ENDIF