diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/CheckController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/CheckController.java new file mode 100644 index 000000000..cbe299d34 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/CheckController.java @@ -0,0 +1,128 @@ +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.annotation.Log; +import org.nl.wms.st.instor.service.CheckService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Map; + +@RestController +@RequiredArgsConstructor +@Api(tags = "盘点") +@RequestMapping("/api/check") +@Slf4j +public class CheckController { + private final CheckService checkService; + + @GetMapping + @Log("查询手工移库单") + @ApiOperation("查询手工移库单") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(checkService.pageQuery(whereJson,page), HttpStatus.OK); + } + + @GetMapping("/getOutBillDtl") + @Log("查询移库单") + @ApiOperation("查询移库单") + public ResponseEntity getOutBillDtl(@RequestParam Map whereJson){ + return new ResponseEntity<>(checkService.getOutBillDtl(whereJson), HttpStatus.OK); + } + + @GetMapping("/getOutBillDtl2") + @Log("查询移库单") + @ApiOperation("查询移库单") + public ResponseEntity getOutBillDtl2(@RequestParam Map whereJson){ + return new ResponseEntity<>(checkService.getOutBillDtl2(whereJson), HttpStatus.OK); + } + + @GetMapping("/getOutBillDis") + @Log("查询移库单") + @ApiOperation("查询移库单") + public ResponseEntity getOutBillDis(@RequestParam Map whereJson){ + return new ResponseEntity<>(checkService.getOutBillDis(whereJson), HttpStatus.OK); + } + @Log("删除移库单") + @ApiOperation("删除移库单") + @DeleteMapping + public ResponseEntity delete(@RequestBody Long[] ids) { + checkService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PutMapping + @Log("修改移库单") + @ApiOperation("修改移库单") + public ResponseEntity update(@RequestBody Map whereJson){ + checkService.update(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @PostMapping() + @Log("新增移库单") + @ApiOperation("新增移库单") + public ResponseEntity insertDtl(@RequestBody Map whereJson){ + checkService.insertDtl(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + @GetMapping("/getStructIvt") + @Log("查询可分配库存") + @ApiOperation("查询可分配库存") + public ResponseEntity getStructIvt(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(checkService.getStructIvt(whereJson,page), HttpStatus.OK); + } + @PostMapping("/confirm") + @Log("移库单强制确认") + @ApiOperation("移库单强制确认") + public ResponseEntity confirm(@RequestBody JSONObject whereJson) { + checkService.confirm(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @GetMapping("/getInvTypes") + @Log("查询单据字段") + @ApiOperation("查询单据字段") + public ResponseEntity getInvTypes(){ + return new ResponseEntity<>(checkService.getInvTypes(), HttpStatus.OK); + } + @PostMapping("/handdown") + @Log("移库单手动下发") + @ApiOperation("移库单手动下发") + public ResponseEntity handdown(@RequestBody JSONObject whereJson) { + checkService.handdown(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @PostMapping("/saveCheck") + @Log("盘点保存") + @ApiOperation("盘点保存") + public ResponseEntity saveCheck(@RequestBody JSONObject whereJson) { + checkService.saveCheck(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @PostMapping("/process0") + @Log("财务为准") + @ApiOperation("财务为准") + public ResponseEntity process0(@RequestBody JSONObject whereJson) { + checkService.process0(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @PostMapping("/process1") + @Log("实物为准") + @ApiOperation("实物为准") + public ResponseEntity process1(@RequestBody JSONObject whereJson) { + checkService.process1(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @ApiOperation("导出数据") + @GetMapping(value = "/download") + public void download(HttpServletResponse response,@RequestParam Map whereJson) throws IOException { + checkService.download(checkService.getOutBillDtl(whereJson), response); + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/HandMoveStorController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/HandMoveStorController.java new file mode 100644 index 000000000..936341ab0 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/HandMoveStorController.java @@ -0,0 +1,86 @@ +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.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/handmovestor") +@Slf4j +public class HandMoveStorController { + private final HandMoveStorService handMoveStorService; + + @GetMapping + @Log("查询手工移库单") + @ApiOperation("查询手工移库单") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(handMoveStorService.pageQuery(whereJson,page), HttpStatus.OK); + } + + @GetMapping("/getOutBillDtl") + @Log("查询移库单") + @ApiOperation("查询移库单") + public ResponseEntity getOutBillDtl(@RequestParam Map whereJson){ + return new ResponseEntity<>(handMoveStorService.getOutBillDtl(whereJson), HttpStatus.OK); + } + @Log("删除移库单") + @ApiOperation("删除移库单") + @DeleteMapping + public ResponseEntity delete(@RequestBody Long[] ids) { + handMoveStorService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PutMapping + @Log("修改移库单") + @ApiOperation("修改移库单") + public ResponseEntity update(@RequestBody Map whereJson){ + handMoveStorService.update(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @PostMapping() + @Log("新增移库单") + @ApiOperation("新增移库单") + public ResponseEntity insertDtl(@RequestBody Map whereJson){ + handMoveStorService.insertDtl(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + @GetMapping("/getStructIvt") + @Log("查询可分配库存") + @ApiOperation("查询可分配库存") + public ResponseEntity getStructIvt(@RequestParam Map whereJson, Pageable page){ + return new ResponseEntity<>(handMoveStorService.getStructIvt(whereJson,page), HttpStatus.OK); + } + @PostMapping("/confirm") + @Log("移库单强制确认") + @ApiOperation("移库单强制确认") + public ResponseEntity confirm(@RequestBody JSONObject whereJson) { + handMoveStorService.confirm(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @GetMapping("/getInvTypes") + @Log("查询单据字段") + @ApiOperation("查询单据字段") + public ResponseEntity getInvTypes(){ + return new ResponseEntity<>(handMoveStorService.getInvTypes(), HttpStatus.OK); + } + @PostMapping("/handdown") + @Log("移库单手动下发") + @ApiOperation("移库单手动下发") + public ResponseEntity handdown(@RequestBody JSONObject whereJson) { + handMoveStorService.handdown(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/CheckService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/CheckService.java new file mode 100644 index 000000000..8e39d4e73 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/CheckService.java @@ -0,0 +1,94 @@ +package org.nl.wms.st.instor.service; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.springframework.data.domain.Pageable; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Map; + +public interface CheckService { + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map pageQuery(Map whereJson, Pageable page); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + /** + * 新增出库单 + * @param whereJson / + */ + void insertDtl (Map whereJson); + /** + * 查询出库单明细 + * @param whereJson / + * @return + */ + JSONArray getOutBillDtl(Map whereJson); + + JSONArray getOutBillDtl2(Map whereJson); + /** + * 查询出库单明细 + * @param whereJson / + * @return + */ + JSONArray getOutBillDis(Map whereJson); + /** + * 修改出库单 + * @param whereJson / + */ + void update(Map whereJson); + /** + * 查询可分配库存 + * @param whereJson / + * @return + */ + Map getStructIvt(Map whereJson, Pageable page); + /** + * 出库单强制确认 + * @param whereJson / + */ + void confirm(JSONObject whereJson); + /** + * 查询单据字段 + * @return + */ + JSONArray getInvTypes(); + /** + * 移库单手动下发 + * @param whereJson / + */ + void handdown(JSONObject whereJson); + /** + * 盘点保存 + * @param whereJson / + */ + void saveCheck(JSONObject whereJson); + /** + * 财务为准 + * @param whereJson / + */ + void process0(JSONObject whereJson); + /** + * 财务为准 + * @param whereJson / + */ + void process1(JSONObject whereJson); + + /** + * 导出 + * @param rows + * @param response + * @throws IOException + */ + void download(JSONArray rows, HttpServletResponse response) throws IOException; +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/HandMoveStorService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/HandMoveStorService.java new file mode 100644 index 000000000..99c0619b9 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/HandMoveStorService.java @@ -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 HandMoveStorService { + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map 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 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); +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/CheckServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/CheckServiceImpl.java new file mode 100644 index 000000000..23ade1124 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/CheckServiceImpl.java @@ -0,0 +1,676 @@ +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.exception.BadRequestException; +import org.nl.modules.security.service.dto.JwtUserDto; +import org.nl.modules.system.util.CodeUtil; +import org.nl.utils.FileUtil; +import org.nl.utils.SecurityUtils; +import org.nl.wms.common.util.DataAuthUtil; +import org.nl.wms.st.core.service.StorPublicService; +import org.nl.wms.st.instor.service.CheckService; +import org.nl.wms.st.instor.task.HandMoveStorAcsTask; +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 javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.*; + +/** + * PC端出入库新增 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class CheckServiceImpl implements CheckService { + @Autowired + private StorPublicService storPublicService; + @Autowired + private MoreOrLessService moreOrLessService; + + @Override + public Map pageQuery(Map whereJson, Pageable page) { + HashMap map = new HashMap<>(whereJson); + map.put("flag", "1"); + if (StrUtil.isNotEmpty(map.get("check_code"))) { + map.put("check_code", "%" + map.get("check_code") + "%"); + } + String deptIds = DataAuthUtil.getDeptStr(); + map.put("deptIds", deptIds); + if (StrUtil.isNotEmpty(map.get("buss_type"))) { + map.put("buss_type", whereJson.get("buss_type") + "%"); + } + JSONObject jo = WQL.getWO("QST_IVT_CHECK").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "check_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 check_id + */ + void deleteById(String check_id) { + //明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_CheckDtl"); + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst"); + + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + HashMap 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("check_id='" + check_id + "'").uniqueResult(0); + JSONArray ja = wo_dtl.query("check_id='" + check_id + "'").getResultJSONArray(0); + for (int i = 0; i < ja.size(); i++) { + JSONObject jo = ja.getJSONObject(i); + //解锁起点点位、仓位 + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "00"); + from_start.put("struct_id", jo.getString("struct_id")); + storPublicService.updateStructAndPoint(from_start); + + //删除明细 + wo_dtl.delete("checkdtl_id='" + jo.getString("checkdtl_id") + "'"); + } + //更新主表 + wo_mst.update(map, "check_id='" + check_id + "'"); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void insertDtl(Map map) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst"); + + ArrayList rows = (ArrayList) map.get("tableData"); + map.remove("tableData"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + String check_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + String check_code = CodeUtil.getNewCode("PD_CODE"); + map.put("check_id", check_id); + map.put("check_code", check_code); + map.put("buss_type", ""); + map.put("create_mode", "01"); + map.put("input_optid", currentUserId + ""); + map.put("input_optname", nickName); + map.put("input_time", now); + map.put("update_optid", currentUserId + ""); + map.put("update_optname", nickName); + map.put("update_time", now); + map.put("is_delete", "0"); + map.put("is_upload", "0"); + JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser(); + Long deptId = currentUser.getDeptId(); + map.put("sysdeptid", deptId); + map.put("syscompanyid", deptId); + JSONObject jo_mst = JSONObject.parseObject(JSON.toJSONString(map)); + //调用明细处理方法 + this.insertDtlByRows(jo_mst, rows); + wo_mst.insert(map); + } + + /** + * 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细 + * + * @param rows + */ + @Transactional(rollbackFor = Exception.class) + void insertDtlByRows(JSONObject jo_mst, ArrayList rows) { + //明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_CheckDtl"); + //定义需要需要插入的库存集合 + HashSet set = new HashSet<>(); + for (int i = 0; i < rows.size(); i++) { + HashMap row = rows.get(i); + set.add(row.get("struct_id")); + + String checkdtl_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + row.put("checkdtl_id", checkdtl_id); + row.put("check_code", jo_mst.getString("check_code")); + row.put("check_id", jo_mst.getString("check_id")); + row.put("seq_no", (i + 1) + ""); + row.put("is_down", "0"); + wo_dtl.insert(row); + } + + //锁定起点点位、仓位 + Iterator it = set.iterator(); + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "02"); + for (; it.hasNext(); ) { + String struct_id = it.next(); + from_start.put("struct_id", struct_id); + from_start.put("inv_type", jo_mst.getString("check_type")); + from_start.put("inv_id", jo_mst.getString("check_id")); + from_start.put("inv_code", jo_mst.getString("check_code")); + storPublicService.updateStructAndPoint(from_start); + } + } + + @Override + public JSONArray getOutBillDtl(Map whereJson) { + whereJson.put("flag", "2"); + JSONArray jo = WQL.getWO("QST_IVT_CHECK") + .addParamMap((HashMap) whereJson) + .process() + .getResultJSONArray(0); + return jo; + } + + @Override + public JSONArray getOutBillDtl2(Map whereJson) { + whereJson.put("flag", "8"); + JSONArray jo = WQL.getWO("QST_IVT_CHECK") + .addParamMap((HashMap) whereJson) + .process() + .getResultJSONArray(0); + return jo; + } + + @Override + public JSONArray getOutBillDis(Map whereJson) { + whereJson.put("flag", "4"); + JSONArray jo = WQL.getWO("QST_IVT_CHECK") + .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_CheckMst"); + + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + String check_id = (String) whereJson.get("check_id"); + //查询主表 + JSONObject jo_mst = wo_mst.query("check_id='" + check_id + "'").uniqueResult(0); + //调用删除明细,还原库存方法 + this.deleteById(check_id + ""); + //获取明细 + ArrayList rows = (ArrayList) whereJson.get("tableData"); + //调用明细处理方法 + this.insertDtlByRows(jo_mst, rows); + jo_mst.put("remark", whereJson.get("remark")); + jo_mst.put("dtl_num", whereJson.get("dtl_num")); + jo_mst.put("check_type", whereJson.get("check_type")); + jo_mst.put("update_optid", currentUserId + ""); + jo_mst.put("update_optname", nickName); + jo_mst.put("update_time", now); + //更新主表 + wo_mst.update(jo_mst); + } + + @Override + public Map getStructIvt(Map whereJson, Pageable page) { + HashMap map = new HashMap(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") + "%"); + } + JSONObject jo = WQL.getWO("QST_IVT_CHECK") + .addParam("flag", "3") + .addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "struct.struct_id,struct.storagevehicle_code"); + return jo; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void confirm(JSONObject whereJson) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst"); + //明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_CheckDtl"); + + JSONObject form = whereJson.getJSONObject("row"); + JSONArray rows = whereJson.getJSONArray("rows"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + + JSONObject jo_mst = wo_mst.query("status in ('10','30') and check_id='" + form.getString("check_id") + "'").uniqueResult(0); + if (jo_mst == null) { + throw new BadRequestException("盘点单状态异常!"); + } + wo_dtl.delete("status in ('01','04') and check_id='" + form.getString("check_id") + "'"); + //定义需要需要更新的的点位集合 + HashSet set = new HashSet<>(); + for (int i = 0; i < rows.size(); i++) { + JSONObject jo = rows.getJSONObject(i); + String status = jo.getString("status"); + double base_qty = jo.getDoubleValue("base_qty"); + jo.put("seq_no", "" + (i + 1)); + set.add(jo.getString("struct_id")); + //已盘点过的明细不再处理 + if ("05,06,07,99".contains(status)) { + wo_dtl.update(jo); + continue; + } + jo.put("status", "05"); + jo.put("check_optid", currentUserId); + jo.put("check_optname", nickName); + jo.put("check_time", now); + double fac_qty = jo.getDoubleValue("fac_qty"); + //判断盈亏 + if (fac_qty > base_qty) { + jo.put("check_result", "2"); + } else if (fac_qty < base_qty) { + jo.put("check_result", "1"); + } else { + jo.put("status", "99"); + jo.put("check_result", "0"); + } + if (StrUtil.isEmpty(jo.getString("checkdtl_id"))) { + String checkdtl_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + jo.put("checkdtl_id", checkdtl_id); + } + wo_dtl.insert(jo); + } + jo_mst.put("dtl_num", rows.size()); + jo_mst.put("status", "30"); + jo_mst.put("is_nok", "0"); + JSONArray ja_nok = wo_dtl.query("check_result <>'0' and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0); + if (ja_nok.size() != 0) { + jo_mst.put("is_nok", "1"); + } + JSONArray ja = wo_dtl.query("status in ('99','07') and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0); + //说明全部确认 + if (ja.size() == jo_mst.getInteger("dtl_num")) { + HashMap mapdtl = new HashMap<>(); + mapdtl.put("status", "99"); + wo_dtl.update(mapdtl, "check_id='" + form.getString("check_id") + "'"); + + jo_mst.put("status", "99"); + jo_mst.put("confirm_optid", currentUserId); + jo_mst.put("confirm_optname", nickName); + jo_mst.put("confirm_time", now); + //锁定起点点位、仓位 + Iterator it = set.iterator(); + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "00"); + for (; it.hasNext(); ) { + String struct_id = it.next(); + from_start.put("struct_id", struct_id); + storPublicService.updateStructAndPoint(from_start); + } + } + wo_mst.update(jo_mst); + } + + @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.getNickName(); + 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"); + String taskdtl_id = whereJson.getString("taskdtl_id"); + JSONObject result = handMoveStorAcsTask.notifyAcs(taskdtl_id); + if (ObjectUtil.isNotEmpty(result)) { + String status = result.getString("status"); + if ("200".equals(status)) { + HashMap map = new HashMap<>(); + //更新分配表 + map.put("is_issued", "1"); + wo_dtl.update(map, "is_issued='0' and 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, "task_status='01' and taskdtl_id='" + taskdtl_id + "'"); + } else { + throw new BadRequestException("任务下发失败,请稍后重试!"); + } + } else { + throw new BadRequestException("任务下发失败,请稍后重试!"); + } + } + HashMap map = new HashMap<>(); + map.put("bill_status", "20"); + wo_mst.update(map, "moveinv_id='" + moveinv_id + "'"); + } + + @Override + public void saveCheck(JSONObject whereJson) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst"); + //明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_CheckDtl"); + + JSONObject form = whereJson.getJSONObject("row"); + JSONArray rows = whereJson.getJSONArray("rows"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + + JSONObject jo_mst = wo_mst.query("status in ('10','30') and check_id='" + form.getString("check_id") + "'").uniqueResult(0); + if (jo_mst == null) { + throw new BadRequestException("盘点单状态异常!"); + } + wo_dtl.delete("status in ('01','04') and check_id='" + form.getString("check_id") + "'"); + for (int i = 0; i < rows.size(); i++) { + JSONObject jo = rows.getJSONObject(i); + String status = jo.getString("status"); + double base_qty = jo.getDoubleValue("base_qty"); + jo.put("seq_no", "" + (i + 1)); + //已盘点过的明细不再处理 + if ("05,06,07,99".contains(status)) { + wo_dtl.update(jo); + continue; + } + jo.put("status", "04"); + jo.put("check_optid", currentUserId); + jo.put("check_optname", nickName); + jo.put("check_time", now); + double fac_qty = jo.getDoubleValue("fac_qty"); + //判断盈亏 + if (fac_qty > base_qty) { + jo.put("check_result", "2"); + } else if (fac_qty < base_qty) { + jo.put("check_result", "1"); + } else { + jo.put("check_result", "0"); + } + if (StrUtil.isEmpty(jo.getString("checkdtl_id"))) { + String checkdtl_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + jo.put("checkdtl_id", checkdtl_id); + } + wo_dtl.insert(jo); + } + jo_mst.put("dtl_num", rows.size()); + jo_mst.put("status", "30"); + jo_mst.put("is_nok", "0"); + JSONArray ja_nok = wo_dtl.query("check_result <>'0' and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0); + if (ja_nok.size() != 0) { + jo_mst.put("is_nok", "1"); + } + wo_mst.update(jo_mst); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void process0(JSONObject whereJson) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst"); + //明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_CheckDtl"); + + JSONObject form = whereJson.getJSONObject("form"); + JSONObject row = whereJson.getJSONObject("row"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + + JSONObject jo_mst = wo_mst.query("status <>'99' and check_id='" + form.getString("check_id") + "'").uniqueResult(0); + if (jo_mst == null) { + throw new BadRequestException("盘点单状态异常!"); + } + row.put("status", "07"); + row.put("process_optid", currentUserId); + row.put("process_type", "0"); + row.put("is_process", "1"); + row.put("process_time", now); + wo_dtl.update(row); + JSONArray ja = wo_dtl.query("status in ('99','07') and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0); + //说明全部确认 + if (ja.size() == jo_mst.getInteger("dtl_num")) { + HashMap mapdtl = new HashMap<>(); + mapdtl.put("status", "99"); + wo_dtl.update(mapdtl, "check_id='" + form.getString("check_id") + "'"); + + jo_mst.put("status", "99"); + jo_mst.put("confirm_optid", currentUserId); + jo_mst.put("confirm_optname", nickName); + jo_mst.put("confirm_time", now); + for (int i = 0; i < ja.size(); i++) { + JSONObject jo = ja.getJSONObject(i); + //锁定起点点位、仓位 + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "00"); + from_start.put("struct_id", jo.getString("struct_id")); + storPublicService.updateStructAndPoint(from_start); + + } + } + wo_mst.update(jo_mst); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void process1(JSONObject whereJson) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst"); + //明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_CheckDtl"); + //明细表 + WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_CheckDtlDis"); + + JSONObject form = whereJson.getJSONObject("row"); + JSONArray rows = whereJson.getJSONArray("rows"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + + JSONObject jo_mst = wo_mst.query("status <>'99' and check_id='" + form.getString("check_id") + "'").uniqueResult(0); + if (jo_mst == null) { + throw new BadRequestException("盘点单状态异常!"); + } + HashMap map = new HashMap<>(); + map.put("status", "07"); + map.put("process_optid", currentUserId + ""); + map.put("process_type", "1"); + map.put("is_process", "1"); + map.put("process_time", now); + wo_dtl.update(map, "status not in('07','99') and storagevehicle_code='" + form.getString("storagevehicle_code") + "' and check_id='" + form.getString("check_id") + "'"); + + for (int i = 0; i < rows.size(); i++) { + JSONObject jo = rows.getJSONObject(i); + String checkdtldis_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + jo.put("checkdtldis_id", checkdtldis_id); + jo.put("check_id", jo_mst.getString("check_id")); + jo.put("check_code", jo_mst.getString("check_code")); + jo.put("sect_id", form.getString("sect_id")); + jo.put("struct_id", form.getString("struct_id")); + jo.put("struct_name", form.getString("struct_name")); + jo.put("sect_name", form.getString("sect_name")); + wo_dis.insert(jo); + + } + //判断是否要生成损单 + JSONArray ja_sun = WQL.getWO("QST_IVT_CHECK") + .addParam("storagevehicle_code", form.getString("storagevehicle_code")) + .addParam("check_id", form.getString("check_id")) + .addParam("flag", "6") + .process() + .getResultJSONArray(0); + if (ja_sun.size() > 0) { + JSONObject mapMst = new JSONObject(); + mapMst.put("mol_inv_type", "42"); + mapMst.put("create_mode", "02"); + mapMst.put("mol_type", "0"); + mapMst.put("stor_id", ja_sun.getJSONObject(0).getString("stor_id")); + mapMst.put("sect_id", ja_sun.getJSONObject(0).getString("sect_id")); + mapMst.put("sect_name", ja_sun.getJSONObject(0).getString("sect_name")); + mapMst.put("struct_id", ja_sun.getJSONObject(0).getString("struct_id")); + mapMst.put("struct_name", ja_sun.getJSONObject(0).getString("struct_name")); + //List rows_sun = ja_sun.toJavaList(HashMap.class); + mapMst.put("tableData", ja_sun); + moreOrLessService.insertDtl(mapMst); + } + + //判断是否要生成溢单 + JSONArray ja_yi = WQL.getWO("QST_IVT_CHECK") + .addParam("storagevehicle_code", form.getString("storagevehicle_code")) + .addParam("check_id", form.getString("check_id")) + .addParam("flag", "5") + .process() + .getResultJSONArray(0); + if (ja_yi.size() > 0) { + JSONObject mapMst = new JSONObject(); + mapMst.put("mol_inv_type", "42"); + mapMst.put("create_mode", "02"); + mapMst.put("mol_type", "1"); + mapMst.put("stor_id", ja_yi.getJSONObject(0).getString("stor_id")); + mapMst.put("sect_id", ja_yi.getJSONObject(0).getString("sect_id")); + mapMst.put("sect_name", ja_yi.getJSONObject(0).getString("sect_name")); + mapMst.put("struct_id", ja_yi.getJSONObject(0).getString("struct_id")); + mapMst.put("struct_name", ja_yi.getJSONObject(0).getString("struct_name")); + //List rows_yi = ja_yi.toJavaList(HashMap.class); + mapMst.put("tableData", ja_yi); + moreOrLessService.insertDtl(mapMst); + } + + JSONArray ja = wo_dtl.query("status in ('99','07') and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0); + //说明全部确认 + if (ja.size() == jo_mst.getInteger("dtl_num")) { + HashMap mapdtl = new HashMap<>(); + mapdtl.put("status", "99"); + wo_dtl.update(mapdtl, "check_id='" + form.getString("check_id") + "'"); + + jo_mst.put("status", "99"); + jo_mst.put("confirm_optid", currentUserId); + jo_mst.put("confirm_optname", nickName); + jo_mst.put("confirm_time", now); + for (int i = 0; i < ja.size(); i++) { + JSONObject jo = ja.getJSONObject(i); + //锁定起点点位、仓位 + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "00"); + from_start.put("struct_id", jo.getString("struct_id")); + storPublicService.updateStructAndPoint(from_start); + } + //确认损益单 + JSONArray ja_sunyi = WQL.getWO("QST_IVT_CHECK") + .addParam("check_code", form.getString("check_code")) + .addParam("flag", "7") + .process() + .getResultJSONArray(0); + for (int i = 0; i < ja_sunyi.size(); i++) { + JSONObject jo = ja_sunyi.getJSONObject(i); + moreOrLessService.confirm(jo); + } + } + wo_mst.update(jo_mst); + } + + @Override + public JSONArray getInvTypes() { + //查询单据字段类型 + JSONArray ja = WQL.getWO("ST_PUB_QUERY_01") + .addParam("flag", "4") + .process() + .getResultJSONArray(0); + return ja; + } + + @Override + public void download(JSONArray rows, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (int i = 0; i < rows.size(); i++) { + JSONObject jo = rows.getJSONObject(i); + Map map = new LinkedHashMap<>(); + map.put("盘点单号", jo.getString("check_code")); + map.put("明细序号", jo.getString("seq_no")); + map.put("库区编码", jo.getString("sect_code")); + map.put("库区名称", jo.getString("sect_name")); + map.put("货位编码", jo.getString("struct_code")); + map.put("货位名称", jo.getString("struct_name")); + map.put("载具号", jo.getString("storagevehicle_code")); + map.put("物料编码", jo.getString("material_code")); + map.put("物料名称", jo.getString("material_name")); + map.put("桶数", jo.getString("base_qty")); + map.put("盘点桶数", jo.getString("fac_qty")); + map.put("单位", jo.getString("qty_unit_name")); + String check_result = jo.getString("check_result"); + if (check_result.equals("0")) { + map.put("盘点结果", "正常"); + } else if (check_result.equals("1")) { + map.put("盘点结果", "盘亏"); + } else if (check_result.equals("2")) { + map.put("盘点结果", "盘盈"); + } + String status = jo.getString("status"); + if (status.equals("01")) { + map.put("状态", "生成"); + } else if (status.equals("04")) { + map.put("状态", "盘点中"); + } else if (status.equals("05")) { + map.put("状态", "已盘点"); + } else if (status.equals("06")) { + map.put("状态", "异常处理中"); + } else if (status.equals("07")) { + map.put("状态", "异常处理完成"); + } else if (status.equals("99")) { + map.put("状态", "确认完成"); + } + map.put("异常处理人", jo.getString("process_optname")); + map.put("异常处理时间", jo.getString("process_time")); + String process_type = jo.getString("process_type"); + if (process_type.equals("0")) { + map.put("异常处理方式", "账务为准"); + } else if (process_type.equals("1")) { + map.put("异常处理方式", "实物为准"); + } + list.add(map); + } + FileUtil.downloadExcel(list, response); + } + + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java new file mode 100644 index 000000000..149f86a59 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/HandMoveStorServiceImpl.java @@ -0,0 +1,1008 @@ +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.sch.tasks.OutTask; +import org.nl.wms.st.inbill.service.StorPublicService; +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 HandMoveStorServiceImpl implements HandMoveStorService { + private final StorPublicService storPublicService; + + @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("buss_type"))) { + map.put("buss_type", whereJson.get("buss_type") + "%"); + } + JSONObject jo = WQL.getWO("QST_IVT_HANDMOVESTOR").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 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 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", "00"); + 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 rows = (ArrayList) map.get("tableData"); + map.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"); + map.put("moveinv_id", moveinv_id); + map.put("bill_code", bill_code); + map.put("buss_type", ""); + map.put("create_mode", "01"); + map.put("input_optid", currentUserId + ""); + map.put("input_optname", nickName); + map.put("input_time", now); + map.put("update_optid", currentUserId + ""); + map.put("update_optname", nickName); + map.put("update_time", now); + map.put("is_delete", "0"); + map.put("is_upload", "0"); + Long deptId = SecurityUtils.getDeptId(); + map.put("sysdeptid", deptId); + map.put("syscompanyid", deptId); + JSONObject jo_mst = JSONObject.parseObject(JSON.toJSONString(map)); + //调用明细处理方法 + JSONObject ret = this.insertDtlByRows(jo_mst, rows); + map.put("detail_count", ret.getString("detail_count")); + map.put("total_qty", ret.getString("total_qty")); + wo_mst.insert(map); + } + + /** + * 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细 + * + * @param rows + */ + @Transactional(rollbackFor = Exception.class) + JSONObject insertDtlByRows(JSONObject jo_mst, ArrayList 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(); + + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + //定义需要需要插入的库存集合 + HashMap Struct_map = new HashMap(); + StringBuffer ids = new StringBuffer(); + for (int i = 0; i < rows.size(); i++) { + HashMap row = rows.get(i); + JSONObject jo_row = (JSONObject) JSONObject.toJSON(row); + String storagevehicle_code = row.get("storagevehicle_code"); + if (i == 0){ + ids.append("'"); + } + if (!Struct_map.containsKey(storagevehicle_code)) { + Struct_map.put(storagevehicle_code, jo_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 = 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 taskdtl_type='07' and task_status='01' and start_point_code='" + jo.getString("start_point_code") + "'").uniqueResult(0); + if (task != null) { + 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 + @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(); + + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + //定义需要需要插入的库存集合 + HashMap Struct_map = new HashMap(); + 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 taskdtl_type='07' and task_status='01' and start_point_code='" + jo.getString("start_point_code") + "'").uniqueResult(0); + if (task != null) { + 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 rows = (ArrayList) 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 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", "00"); + 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", "00"); + 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 getStructIvt(Map whereJson, Pageable page) { + HashMap map = new HashMap(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_MoveInvDtl"); + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_MoveInv"); + //任务表 + WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); + + String moveinv_id = form.getString("moveinv_id"); + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + + String now = DateUtil.now(); + //查询主表信息 + JSONObject jo_mst = wo_mst.query("moveinv_id = '" + moveinv_id + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jo_mst)) { + throw new BadRequestException("未查到相关移库单"); + } + //判断是否存在未确认状态的明细记录 + JSONObject task = wo_dtl.query("work_status ='02' and moveinv_id = '" + moveinv_id + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(task)) { + throw new BadRequestException("存在已下发未完成的移库任务,不允许强制确认!"); + } + 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 task_map = new HashMap<>(); + task_map.put("task_status", "99"); + task_map.put("update_optid", currentUserId + ""); + task_map.put("update_optname", nickName); + task_map.put("update_time", now); + wo_Task.update(task_map, "task_id='" + jo.getString("task_id") + "'"); + //解锁起点点位、仓位,清除载具 + JSONObject from_start = new JSONObject(); + from_start.put("lock_type", "00"); + from_start.put("storagevehicle_code", jo.getString("storagevehicle_code")); + from_start.put("is_free", "1"); + from_start.put("struct_id", jo.getString("turnout_struct_id")); + storPublicService.updateStructAndPoint(from_start); + //解锁终点点位、仓位,添加载具 + JSONObject from_end = new JSONObject(); + from_end.put("lock_type", "00"); + from_end.put("struct_id", jo.getString("turnin_struct_id")); + from_end.put("storagevehicle_code", jo.getString("storagevehicle_code")); + storPublicService.updateStructAndPoint(from_end); + + //更新移出库存 + 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, "21"); + //更新移入库存 + 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, "33"); + //更新明细 + jo.put("work_status", "99"); + wo_dtl.update(jo); + } + HashMap 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, "moveinv_id='" + moveinv_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); + if (ObjectUtil.isNotEmpty(result)) { + String status = result.getString("status"); + if ("200".equals(status)) { + HashMap 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 taskdtl_id = whereJson.getString("taskdtl_id"); + + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + + JSONObject task = wo_Task.query("task_status<>'99' and taskdtl_id='" + taskdtl_id + "'").uniqueResult(0); + if (task == null) { + throw new BadRequestException("查询不到操作的任务记录!"); + } + String taskdtl_type = task.getString("taskdtl_type"); + String task_id = task.getString("task_id"); + HashMap 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, "taskdtl_id='" + taskdtl_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 map = new HashMap(); + 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 taskdtl_id = jo.getString("taskdtl_id"); + JSONObject result = handMoveStorAcsTask.notifyAcs(taskdtl_id); + JSONObject task = wo_Task.query("taskdtl_id='" + taskdtl_id + "'").uniqueResult(0); + if (ObjectUtil.isNotEmpty(result)) { + String status = result.getString("status"); + if ("200".equals(status)) { + HashMap 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 taskdtl_id='" + taskdtl_id + "'"); + } else { + throw new BadRequestException("任务下发失败,请稍后重试!"); + } + } else { + throw new BadRequestException("任务下发失败,请稍后重试!"); + } + } + HashMap 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); + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/task/HandMoveStorAcsTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/task/HandMoveStorAcsTask.java new file mode 100644 index 000000000..6c4b7573b --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/task/HandMoveStorAcsTask.java @@ -0,0 +1,112 @@ +package org.nl.wms.st.instor.task; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import org.nl.exception.BadRequestException; +import org.nl.utils.SecurityUtils; +import org.nl.utils.SpringContextHolder; +import org.nl.wms.sch.manage.AbstractAcsTask; +import org.nl.wms.st.instor.service.impl.HandMoveStorServiceImpl; +import org.nl.wql.core.bean.WQLObject; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; + +public class HandMoveStorAcsTask extends AbstractAcsTask { + /** + * + * @param taskObj 代表一条任务对象 + * @param status 代表wcs任务完成状态: //1:执行中,2:完成 ,3:acs取消 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updateTaskStatus(JSONObject taskObj, String status) { + //任务表 + WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); + //出库分配表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_MoveInvDtl"); + HashMap map = new HashMap<>(); + + Long currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getNickName(); + String now = DateUtil.now(); + String taskdtl_id = taskObj.getString("taskdtl_id"); + if (StrUtil.isEmpty(taskdtl_id)) { + throw new BadRequestException("任务id不能为空!"); + } + JSONObject task = wo_Task.query("taskdtl_id='"+taskdtl_id+"'").uniqueResult(0); + if(task==null){ + throw new BadRequestException("查询不到操作的任务记录!"); + } + String task_id = task.getString("task_id"); + if("1".equals(status)){ + map.put("work_status","02"); + wo_dtl.update(map,"task_id='"+task_id+"'"); + map.put("task_status","03"); + map.put("update_optid",currentUserId+""); + map.put("update_optname",nickName); + map.put("update_time",now); + wo_Task.update(map,"taskdtl_id='"+taskdtl_id+"'"); + }else if("2".equals(status)){ + HandMoveStorServiceImpl handMoveStorServiceImpl = SpringContextHolder.getBean(HandMoveStorServiceImpl.class); + handMoveStorServiceImpl.finishTask(task); + }else if("3".equals(status)){ + + }else{ + throw new BadRequestException("任务状态更新异常!"); + } + } + + /** + * + * @param form 创建任务需要的参数 + * @return + */ + @Override + public String createTask(JSONObject form) { + return null; + } + + /** + * + * @param taskdtl_id + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void forceFinish(String taskdtl_id) { + //出库明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("st_ivt_moveinvdtl"); + //任务表 + WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); + JSONObject task = wo_Task.query("task_status<>'99' and taskdtl_id='"+taskdtl_id+"'").uniqueResult(0); + if(task==null){ + throw new BadRequestException("查询不到操作的任务记录!"); + } + + String task_id = task.getString("task_id"); + JSONObject dtl = wo_dtl.query("task_id='"+task_id+"'").uniqueResult(0); + + HandMoveStorServiceImpl handMoveStorService = SpringContextHolder.getBean(HandMoveStorServiceImpl.class); + task.put("moveinv_id",dtl.getString("moveinv_id")); + handMoveStorService.finishTask(task); + } + + /** + * + * @param taskdtl_id + */ + @Override + public void pullBack(String taskdtl_id) { + + } + + /** + * + * @param taskdtl_id + */ + @Override + public void cancel(String taskdtl_id) { + + } +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_CHECK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_CHECK.wql new file mode 100644 index 000000000..d94d9e04e --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_CHECK.wql @@ -0,0 +1,383 @@ +[交易说明] + 交易名: 基础点位分页查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.status TYPEAS s_string + 输入.check_code TYPEAS s_string + 输入.create_mode TYPEAS s_string + 输入.check_type TYPEAS s_string + 输入.stor_id TYPEAS s_string + 输入.check_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 + 输入.storagevehicle_code TYPEAS s_string + 输入.deptIds TYPEAS f_string +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + PAGEQUERY + SELECT + checkmst.check_id AS id, + checkmst.* + FROM + ST_IVT_CheckMst checkmst + WHERE + 1 = 1 + AND checkmst.is_delete = '0' + OPTION 输入.check_code <> "" + checkmst.check_code like 输入.check_code + ENDOPTION + OPTION 输入.buss_type <> "" + checkmst.buss_type like 输入.buss_type + ENDOPTION + OPTION 输入.check_type <> "" + checkmst.check_type = 输入.check_type + ENDOPTION + OPTION 输入.stor_id <> "" + checkmst.stor_id = 输入.stor_id + ENDOPTION + OPTION 输入.deptIds <> "" + checkmst.sysdeptid in 输入.deptIds + ENDOPTION + OPTION 输入.create_mode <> "" + checkmst.create_mode = 输入.create_mode + ENDOPTION + OPTION 输入.status <> "" + checkmst.status = 输入.status + ENDOPTION + OPTION 输入.begin_time <> "" + checkmst.input_time >= 输入.begin_time + ENDOPTION + OPTION 输入.end_time <> "" + checkmst.input_time <= 输入.end_time + ENDOPTION + ENDSELECT + ENDPAGEQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT + CheckDtl.*, + struct.struct_code, + struct.sect_code, + mb.material_code, + mb.material_name, + user1.nick_name AS process_optname + FROM + ST_IVT_CheckDtl CheckDtl + LEFT JOIN md_me_materialbase mb ON mb.material_id = CheckDtl.material_id + LEFT JOIN st_ivt_structattr struct ON struct.struct_id = CheckDtl.struct_id + LEFT JOIN sys_user user1 ON user1.user_id = CheckDtl.process_optid + WHERE + 1 = 1 + OPTION 输入.check_id <> "" + CheckDtl.check_id = 输入.check_id + ENDOPTION + OPTION 输入.checkdtl_id <> "" + CheckDtl.checkdtl_id = 输入.checkdtl_id + ENDOPTION + OPTION 输入.status <> "" + CheckDtl.status <= 输入.status + ENDOPTION + order by CheckDtl.seq_no + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + PAGEQUERY + SELECT + bucketcopy.material_id, + bucketcopy.base_qty, + bucketcopy.storage_qty, + '42' AS qty_unit_id, + '桶' AS qty_unit_name, + mb.material_code, + mb.material_name, + struct.struct_id, + struct.struct_code, + struct.struct_name, + struct.sect_id, + struct.sect_code, + struct.sect_name, + struct.storagevehicle_id, + struct.storagevehicle_code + FROM + st_ivt_structattr struct + INNER JOIN ( + SELECT + bucket.storagevehicle_code, + bucket.material_id, + sum(bucket.storage_qty) AS storage_qty, + COUNT(bucket.bucketunique) AS base_qty + FROM + MD_PB_BucketRecord bucket + WHERE + 1 = 1 + AND bucket.storage_qty > 0 + GROUP BY + bucket.storagevehicle_code, + bucket.material_id + ) bucketcopy ON bucketcopy.storagevehicle_code = struct.storagevehicle_code + LEFT JOIN md_me_materialbase mb ON mb.material_id = bucketcopy.material_id + WHERE + 1 = 1 + AND struct.lock_type = '00' + AND struct.storagevehicle_id > 0 + OPTION 输入.material_id <> "" + bucketcopy.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 <> "" + struct.stor_id = 输入.stor_id + ENDOPTION + OPTION 输入.sect_id <> "" + struct.sect_id = 输入.sect_id + ENDOPTION + ENDSELECT + ENDPAGEQUERY + ENDIF + + IF 输入.flag = "4" + QUERY + SELECT + bucket.bucket_record_id, + bucket.bucketunique, + bucket.material_id, + bucket.ivt_level, + bucket.is_active, + bucket.quality_scode, + bucket.qty_unit_id, + bucket.qty_unit_name, + bucket.storage_qty AS ivt_qty, + bucket.storage_qty AS ivt_qty_ck, + bucket.pcsn, + bucket.storagevehicle_code, + bucket.storagevehicle_id, + StorageVehicleInfo.storagevehicle_type, + mb.material_code, + mb.material_name + FROM + MD_PB_BucketRecord bucket + INNER JOIN MD_PB_StorageVehicleInfo StorageVehicleInfo ON StorageVehicleInfo.storagevehicle_id = bucket.storagevehicle_id + LEFT JOIN md_me_materialbase mb ON mb.material_id = bucket.material_id + WHERE + 1 = 1 + AND bucket.STATUS = '03' + OPTION 输入.storagevehicle_code <> "" + bucket.storagevehicle_code = 输入.storagevehicle_code + ENDOPTION + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "5" + QUERY + SELECT + checkdis.sect_id, + checkdis.sect_name, + checkdis.struct_id, + checkdis.struct_name, + checkdis.storagevehicle_id, + checkdis.storagevehicle_code, + checkdis.storagevehicle_type, + checkdis.bucketunique, + checkdis.material_id, + checkdis.pcsn, + checkdis.quality_scode, + checkdis.ivt_level, + checkdis.is_active, + checkdis.qty_unit_id, + checkdis.qty_unit_name, + checkdis.checkdtldis_id AS source_billdtl_id, + CheckMst.check_type AS source_bill_type, + checkdis.check_code AS source_bill_code, + 'ST_IVT_CheckMst' AS source_bill_table, + checkdis.ivt_qty, + CheckMst.stor_id, + checkdis.ivt_qty_ck - checkdis.ivt_qty AS mol_qty + FROM + ST_IVT_CheckDtlDis checkdis + inner join ST_IVT_CheckMst CheckMst on CheckMst.check_id=checkdis.check_id + where 1=1 and checkdis.ivt_qty_ck>checkdis.ivt_qty + OPTION 输入.storagevehicle_code <> "" + checkdis.storagevehicle_code = 输入.storagevehicle_code + ENDOPTION + OPTION 输入.check_id <> "" + checkdis.check_id = 输入.check_id + ENDOPTION + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "6" + QUERY + SELECT + checkdis.sect_id, + checkdis.sect_name, + checkdis.struct_id, + checkdis.struct_name, + checkdis.storagevehicle_id, + checkdis.storagevehicle_code, + checkdis.storagevehicle_type, + checkdis.bucketunique, + checkdis.material_id, + checkdis.pcsn, + checkdis.quality_scode, + checkdis.ivt_level, + checkdis.is_active, + checkdis.qty_unit_id, + checkdis.qty_unit_name, + checkdis.checkdtldis_id AS source_billdtl_id, + CheckMst.check_type AS source_bill_type, + checkdis.check_code AS source_bill_code, + 'ST_IVT_CheckMst' AS source_bill_table, + checkdis.ivt_qty, + CheckMst.stor_id, + checkdis.ivt_qty - checkdis.ivt_qty_ck AS mol_qty + FROM + ST_IVT_CheckDtlDis checkdis + inner join ST_IVT_CheckMst CheckMst on CheckMst.check_id=checkdis.check_id + where 1=1 and checkdis.ivt_qty_ck "" + checkdis.storagevehicle_code = 输入.storagevehicle_code + ENDOPTION + OPTION 输入.check_id <> "" + checkdis.check_id = 输入.check_id + ENDOPTION + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "7" + QUERY + SELECT + MoreOrLessDtl.struct_id, + MoreOrLessDtl.mol_id, + struct.struct_code + FROM + ST_IVT_MoreOrLessDtl MoreOrLessDtl + INNER JOIN ST_IVT_StructAttr struct ON struct.struct_id = MoreOrLessDtl.struct_id + INNER JOIN ST_IVT_MoreOrLessMst MoreOrLessMst ON MoreOrLessMst.mol_id = MoreOrLessDtl.mol_id + WHERE + 1 = 1 + AND MoreOrLessMst.`status` <> '99' + AND MoreOrLessMst.is_delete = '0' + OPTION 输入.check_code <> "" + MoreOrLessDtl.source_bill_code = 输入.check_code + ENDOPTION + GROUP BY mol_id,struct_id + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "8" + QUERY + SELECT + CheckDtl.checkdtl_id, + CheckDtl.check_id, + CheckDtl.check_code, + CheckDtl.seq_no, + CheckDtl.sect_id, + CheckDtl.sect_name, + CheckDtl.struct_id, + CheckDtl.struct_name, + CheckDtl.checkpoint_id, + CheckDtl.storagevehicle_id, + CheckDtl.storagevehicle_code, + CheckDtl.material_id, + CheckDtl.base_qty, + CheckDtl.qty_unit_id, + CheckDtl.qty_unit_name, + CheckDtl.STATUS, + CheckDtl.is_down, + ( CASE WHEN CheckDtl.fac_qty IS NULL OR CheckDtl.fac_qty = '' THEN CheckDtl.base_qty ELSE CheckDtl.fac_qty END ) AS fac_qty, + CheckDtl.check_result, + CheckDtl.check_optid, + CheckDtl.check_optname, + CheckDtl.check_time, + CheckDtl.is_process, + CheckDtl.process_type, + CheckDtl.process_optid, + CheckDtl.process_time, + struct.struct_code, + struct.sect_code, + mb.material_code, + mb.material_name, + user1.nick_name AS process_optname + FROM + ST_IVT_CheckDtl CheckDtl + LEFT JOIN md_me_materialbase mb ON mb.material_id = CheckDtl.material_id + LEFT JOIN st_ivt_structattr struct ON struct.struct_id = CheckDtl.struct_id + LEFT JOIN sys_user user1 ON user1.user_id = CheckDtl.process_optid + WHERE + 1 = 1 + OPTION 输入.check_id <> "" + CheckDtl.check_id = 输入.check_id + ENDOPTION + OPTION 输入.checkdtl_id <> "" + CheckDtl.checkdtl_id = 输入.checkdtl_id + ENDOPTION + OPTION 输入.status <> "" + CheckDtl.status <= 输入.status + ENDOPTION + order by CheckDtl.seq_no + ENDSELECT + ENDQUERY + ENDIF diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_HANDMOVESTOR.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_HANDMOVESTOR.wql new file mode 100644 index 000000000..4eb59875b --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_HANDMOVESTOR.wql @@ -0,0 +1,275 @@ +[交易说明] + 交易名: 基础点位分页查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为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 + move.moveinv_id AS id, + move.* + FROM + ST_IVT_MoveInv move + WHERE + 1 = 1 + AND move.is_delete = '0' + AND move.moveinv_id IN ( + SELECT DISTINCT + (movedtl.moveinv_id) + FROM + st_ivt_moveinvdtl movedtl + LEFT JOIN md_me_materialbase mb ON mb.material_id = movedtl.material_id + WHERE + 1 = 1 + OPTION 输入.material_code <> "" + (mb.material_code LIKE 输入.material_code OR mb.material_name LIKE 输入.material_code) + ENDOPTION + ) + OPTION 输入.bill_code <> "" + move.bill_code like 输入.bill_code + ENDOPTION + OPTION 输入.buss_type <> "" + move.buss_type like 输入.buss_type + ENDOPTION + OPTION 输入.bill_type <> "" + move.bill_type = 输入.bill_type + ENDOPTION + OPTION 输入.stor_id <> "" + move.stor_id = 输入.stor_id + ENDOPTION + OPTION 输入.deptIds <> "" + move.sysdeptid in 输入.deptIds + ENDOPTION + OPTION 输入.create_mode <> "" + move.create_mode = 输入.create_mode + ENDOPTION + OPTION 输入.bill_status <> "" + move.bill_status = 输入.bill_status + ENDOPTION + OPTION 输入.begin_time <> "" + move.input_time >= 输入.begin_time + ENDOPTION + OPTION 输入.end_time <> "" + move.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.ivt_level, + ivt2.is_active, + ivt2.qty_unit_id, + ivt2.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 + 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 + WHERE + 1 = 1 + AND struct.lock_type = '00' + AND struct.storagevehicle_id > 0 + 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.ivt_level, + ivt2.is_active, + ivt2.qty_unit_id, + ivt2.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 + WHERE + 1 = 1 + AND struct.lock_type = '00' + AND struct.storagevehicle_id > 0 + 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(taskdtl_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 + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDialog.vue new file mode 100644 index 000000000..343e392d2 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDialog.vue @@ -0,0 +1,293 @@ + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue new file mode 100644 index 000000000..ebba94596 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue @@ -0,0 +1,172 @@ + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/CheckDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/CheckDialog.vue new file mode 100644 index 000000000..28f1bc4ca --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/CheckDialog.vue @@ -0,0 +1,406 @@ + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/ProcessDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/ProcessDialog.vue new file mode 100644 index 000000000..55b7c5c3d --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/ProcessDialog.vue @@ -0,0 +1,251 @@ + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/ReCheckDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/ReCheckDialog.vue new file mode 100644 index 000000000..1aa94b7b7 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/ReCheckDialog.vue @@ -0,0 +1,352 @@ + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/index.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/index.vue new file mode 100644 index 000000000..8b5f96107 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/index.vue @@ -0,0 +1,352 @@ + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/AddDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/AddDialog.vue new file mode 100644 index 000000000..2334f445a --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/AddDialog.vue @@ -0,0 +1,417 @@ + + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/AddDtl.vue new file mode 100644 index 000000000..ff5a163d9 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/AddDtl.vue @@ -0,0 +1,196 @@ + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/index.vue b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/index.vue new file mode 100644 index 000000000..9a3ffef5a --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/handmovestor/index.vue @@ -0,0 +1,324 @@ + + + +