diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls index e0cc1c651..bc5a57a9d 100644 Binary files a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls and b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls differ diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/ProductScrapController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/ProductScrapController.java new file mode 100644 index 000000000..34025866a --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/ProductScrapController.java @@ -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.ProductScrapService; +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/productscrap") +@Slf4j +public class ProductScrapController { + private final ProductScrapService productScrapService; + + @GetMapping + @Log("查询成品报废审核单") + @ApiOperation("查询成品报废审核单") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { + return new ResponseEntity<>(productScrapService.pageQuery(whereJson, page), HttpStatus.OK); + } + + @GetMapping("/getOutBillDtl") + @Log("查询明细") + @ApiOperation("查询明细") + public ResponseEntity getOutBillDtl(@RequestParam Map whereJson) { + return new ResponseEntity<>(productScrapService.getOutBillDtl(whereJson), HttpStatus.OK); + } + + @Log("删除") + @ApiOperation("删除") + @DeleteMapping + public ResponseEntity delete(@RequestBody Long[] ids) { + productScrapService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PutMapping + @Log("修改") + @ApiOperation("修改") + public ResponseEntity update(@RequestBody JSONObject whereJson) { + productScrapService.update(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @PostMapping() + @Log("新增") + @ApiOperation("新增") + public ResponseEntity insertDtl(@RequestBody JSONObject whereJson) { + productScrapService.insertDtl(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PostMapping("/auditPass") + @Log("审核通过") + @ApiOperation("审核通过") + public ResponseEntity auditPass(@RequestBody JSONObject whereJson) { + productScrapService.auditPass(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PostMapping("/auditOut") + @Log("不通过") + @ApiOperation("不通过") + public ResponseEntity auditOut(@RequestBody JSONObject whereJson) { + productScrapService.auditOut(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/ProductScrapService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/ProductScrapService.java new file mode 100644 index 000000000..b4452140e --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/ProductScrapService.java @@ -0,0 +1,52 @@ +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 ProductScrapService { + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map pageQuery(Map whereJson, Pageable page); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + /** + * 新增出库单 + * @param whereJson / + */ + void insertDtl (JSONObject whereJson); + /** + * 查询出库单明细 + * @param whereJson / + * @return + */ + JSONArray getOutBillDtl(Map whereJson); + /** + * 修改出库单 + * @param whereJson / + */ + void update(JSONObject whereJson); + + /** + * 审核通过 + * @param whereJson / + */ + void auditPass(JSONObject whereJson); + + /** + * 不通过 + * @param whereJson / + */ + void auditOut(JSONObject whereJson); +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java new file mode 100644 index 000000000..d0c1eb0ed --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java @@ -0,0 +1,287 @@ +package org.nl.wms.st.instor.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.common.utils.SecurityUtils; +import org.nl.modules.common.exception.BadRequestException; +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.basedata.st.service.impl.UserStorServiceImpl; +import org.nl.wms.st.inbill.service.CheckOutBillService; +import org.nl.wms.st.instor.service.ProductScrapService; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * PC端成品报废审核 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class ProductScrapServiceImpl implements ProductScrapService { + private final CheckOutBillService checkOutBillService; + + @Override + public Map pageQuery(Map whereJson, Pageable page) { + HashMap 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("pcsn"))) { + map.put("pcsn", (String) whereJson.get("pcsn")); + } + + //获取人员对应的仓库 + UserStorServiceImpl userStorService = new UserStorServiceImpl(); + String in_stor_id = userStorService.getInStor(); + + if (ObjectUtil.isNotEmpty(in_stor_id)) map.put("in_stor_id", in_stor_id); + + JSONObject jo = WQL.getWO("QST_IVT_PRODUCTSCRAP").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "scrap_code desc"); + return jo; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(Long[] ids) { + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("is_delete", "1"); + for (Long scrap_id : ids) { + wo_mst.update(jsonObject,"scrap_id = '"+scrap_id+"'"); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void insertDtl(JSONObject map) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + + JSONArray rows = map.getJSONArray("tableData"); + map.remove("tableData"); + String 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("scrap_id", changeinv_id); + mst_jo.put("scrap_code", CodeUtil.getNewCode("SCRAP_CODE")); + mst_jo.put("biz_date", DateUtil.today()); + mst_jo.put("stor_id", MapUtil.getStr(map, "stor_id")); + mst_jo.put("stor_code", MapUtil.getStr(map, "stor_code")); + mst_jo.put("stor_name", MapUtil.getStr(map, "stor_name")); + mst_jo.put("bill_status", "10"); + mst_jo.put("input_optid", currentUserId + ""); + mst_jo.put("input_optname", nickName); + mst_jo.put("input_time", now); + mst_jo.put("is_delete", "0"); + mst_jo.put("detail_count", rows.size()); + + //调用明细处理方法 + JSONObject ret = this.insertDtlByRows(mst_jo, rows); + mst_jo.put("total_qty", ret.getDoubleValue("total_qty")); + wo_mst.insert(mst_jo); + } + + /** + * 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细 + * + * @param rows + */ + @Transactional(rollbackFor = Exception.class) + JSONObject insertDtlByRows(JSONObject jsonMst, JSONArray rows) { + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); + + //定义返回数据 + JSONObject ret = new JSONObject(); + double total_qty = 0; + for (int i = 0; i < rows.size(); i++) { + JSONObject json = rows.getJSONObject(i); + + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("scrapdtl_id", IdUtil.getSnowflake(1, 1).nextId()); + jsonDtl.put("scrap_id", jsonMst.getLongValue("scrap_id")); + jsonDtl.put("seq_no", i); + jsonDtl.put("material_id", json.getLongValue("material_id")); + jsonDtl.put("pcsn", json.getString("pcsn")); + jsonDtl.put("package_box_sn", json.getString("storagevehicle_code")); + jsonDtl.put("fail_source", json.getString("fail_source")); + jsonDtl.put("qty_unit_id", json.getString("qty_unit_id")); + jsonDtl.put("qty_unit_name", json.getString("qty_unit_name")); + jsonDtl.put("qty", json.getDoubleValue("qty")); + jsonDtl.put("remark", json.getString("remark")); + wo_dtl.insert(jsonDtl); + + total_qty = NumberUtil.add(total_qty, json.getDoubleValue("qty")); + + } + ret.put("total_qty", total_qty); + return ret; + } + + @Override + public JSONArray getOutBillDtl(Map whereJson) { + whereJson.put("flag", "2"); + JSONArray jo = WQL.getWO("QST_IVT_PRODUCTSCRAP") + .addParamMap((HashMap) whereJson) + .process() + .getResultJSONArray(0); + return jo; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(JSONObject whereJson) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + //主表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); + + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + String scrap_id = (String) whereJson.get("scrap_id"); + //查询主表 + JSONObject jo_mst = wo_mst.query("scrap_id='" + scrap_id + "'").uniqueResult(0); + + //删除所有明细 + wo_dtl.delete("scrap_id = '"+scrap_id+"'"); + + //获取明细 + JSONArray rows = whereJson.getJSONArray("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", rows.size()); + 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 auditPass(JSONObject whereJson) { + /* + * 1.校验此些子卷是否都在库内并没有被锁定 + * 2.生成出库单 + * 3.更新单据 + */ + WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + WQLObject dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); + WQLObject ivt = WQLObject.getWQLObject("st_ivt_structivt"); + + // 查询所有明细 + JSONArray dtlArr = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0); + + // 查询库存中这些子卷是否存在 + String pcsnJoining = dtlArr.stream() + .map(row -> JSON.parseObject(row.toString())) + .map(row -> row.getString("pcsn")) + .collect(Collectors.joining("','")); + + List ivtList = ivt.query("pcsn in ('" + pcsnJoining + "') and canuse_qty > 0") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + if (dtlArr.size() != ivtList.size()) throw new BadRequestException("库存异常请检查!"); + + // 校验库存 + boolean is_pass = ivtList.stream() + .allMatch(row -> pcsnJoining.contains(row.getString("pcsn"))); + + if (!is_pass) throw new BadRequestException("库存异常请检查!"); + + /* List collect = ivtList.stream() + .filter(row -> !pcsnJoining.contains(row.getString("pcsn"))) + .map(row -> row.getString("pcsn")) + .collect(Collectors.toList()); + + if (ObjectUtil.isNotEmpty(collect)) { + throw new BadRequestException("子卷:"+collect.toString()+"异常请检查!"); + }*/ + + // 生成出库单 + JSONObject jsonOutMst = new JSONObject(); + jsonOutMst.put("stor_id",whereJson.getString("stor_id")); + jsonOutMst.put("stor_code", whereJson.getString("stor_code")); + jsonOutMst.put("stor_name", whereJson.getString("stor_name")); + jsonOutMst.put("detail_count", ivtList.size()); + jsonOutMst.put("bill_status", "10"); + jsonOutMst.put("create_mode", "03"); + jsonOutMst.put("biz_date", DateUtil.now()); + jsonOutMst.put("io_type", "1"); + jsonOutMst.put("buss_type", "1002"); + jsonOutMst.put("bill_type", "1002"); + jsonOutMst.put("source_name", "成品报废审核单"); + + JSONArray tableData = new JSONArray(); + for (int i = 0; i < dtlArr.size(); i++) { + JSONObject json = dtlArr.getJSONObject(i); + + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("pcsn", json.getString("pcsn")); + jsonDtl.put("box_no", json.getString("package_box_sn")); + jsonDtl.put("material_id", json.getString("material_id")); + jsonDtl.put("qty_unit_id", json.getLongValue("qty_unit_id")); + jsonDtl.put("qty_unit_name", json.getString("qty_unit_name")); + jsonDtl.put("plan_qty", json.getDoubleValue("qty")); + tableData.add(jsonDtl); + } + + // 调用出库新增并分配 + jsonOutMst.put("tableData", tableData); + String iostorinv_id = checkOutBillService.insertDtl(jsonOutMst); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("iostorinv_id", iostorinv_id); + checkOutBillService.allDiv(jsonObject); + + // 更新主表为完成 + JSONObject param = new JSONObject(); + param.put("bill_status", "99"); + param.put("confirm_optid", SecurityUtils.getCurrentUserId()); + param.put("confirm_optname", SecurityUtils.getCurrentNickName()); + param.put("confirm_time", DateUtil.now()); + mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'"); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void auditOut(JSONObject whereJson) { + WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + + // 更新主表为完成 + JSONObject param = new JSONObject(); + param.put("bill_status", "99"); + param.put("confirm_optid", SecurityUtils.getCurrentUserId()); + param.put("confirm_optname", SecurityUtils.getCurrentNickName()); + param.put("confirm_time", DateUtil.now()); + mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'"); + } + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_PRODUCTSCRAP.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_PRODUCTSCRAP.wql new file mode 100644 index 000000000..d3dcb1ca1 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_PRODUCTSCRAP.wql @@ -0,0 +1,112 @@ +[交易说明] + 交易名: 成品报废审核分页查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.material_code TYPEAS s_string + 输入.bill_status TYPEAS s_string + 输入.bill_code TYPEAS s_string + 输入.stor_id TYPEAS s_string + 输入.end_time TYPEAS s_string + 输入.begin_time TYPEAS s_string + 输入.pcsn TYPEAS s_string + 输入.scrap_id TYPEAS s_string + 输入.in_stor_id TYPEAS f_string +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + PAGEQUERY + SELECT DISTINCT + mst.* + FROM + ST_IVT_ProductScrapMst mst + LEFT JOIN ST_IVT_ProductScrapDtl dtl ON mst.scrap_id = dtl.scrap_id + WHERE + 1 = 1 + AND mst.is_delete = '0' + and mst.stor_id in 输入.in_stor_id + + OPTION 输入.bill_code <> "" + mst.scrap_code like 输入.bill_code + ENDOPTION + + OPTION 输入.pcsn <> "" + dtl.pcsn = 输入.pcsn + ENDOPTION + + OPTION 输入.stor_id <> "" + mst.stor_id = 输入.stor_id + ENDOPTION + + OPTION 输入.bill_status <> "" + mst.bill_status = 输入.bill_status + ENDOPTION + + OPTION 输入.begin_time <> "" + mst.input_time >= 输入.begin_time + ENDOPTION + + OPTION 输入.end_time <> "" + mst.input_time <= 输入.end_time + ENDOPTION + + ENDSELECT + ENDPAGEQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT DISTINCT + dtl.*, + dtl.package_box_sn AS storagevehicle_code, + mater.material_code, + mater.material_name + FROM + ST_IVT_ProductScrapDtl dtl + LEFT JOIN ST_IVT_ProductScrapMst mst ON mst.scrap_id = dtl.scrap_id + LEFT JOIN md_me_materialbase mater ON mater.material_id = dtl.material_id + WHERE + 1 = 1 + OPTION 输入.scrap_id <> "" + dtl.scrap_id = 输入.scrap_id + ENDOPTION + + OPTION 输入.scrapdtl_id <> "" + dtl.scrapdtl_id = 输入.scrapdtl_id + ENDOPTION + + order by dtl.seq_no + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDialog.vue new file mode 100644 index 000000000..07af0dd6f --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDialog.vue @@ -0,0 +1,476 @@ + + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDtl.vue new file mode 100644 index 000000000..a36dcb3ea --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDtl.vue @@ -0,0 +1,231 @@ + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/index.vue b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/index.vue new file mode 100644 index 000000000..6b8a33b65 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/index.vue @@ -0,0 +1,290 @@ + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/productscrap.js b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/productscrap.js new file mode 100644 index 000000000..f5d578e96 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/productscrap.js @@ -0,0 +1,55 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/productscrap', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/productscrap/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/productscrap', + method: 'put', + data + }) +} + +export function getOutBillDtl(params) { + return request({ + url: '/api/productscrap/getOutBillDtl', + method: 'get', + params + }) +} +export function insertDtl(data) { + return request({ + url: '/api/productscrap/insertDtl', + method: 'post', + data + }) +} +export function auditPass(data) { + return request({ + url: '/api/productscrap/auditPass', + method: 'post', + data + }) +} +export function auditOut(data) { + return request({ + url: '/api/productscrap/auditOut', + method: 'post', + data + }) +} +export default { add, edit, del, getOutBillDtl, auditPass, auditOut }