This commit is contained in:
2022-11-09 10:53:35 +08:00
15 changed files with 213 additions and 321 deletions

View File

@@ -1,51 +0,0 @@
package org.nl.modules.security.satoken;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.mnt.websocket.MsgType;
import org.nl.modules.mnt.websocket.SocketMsg;
import org.nl.modules.mnt.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author: lyd
* @description:
* @Date: 2022/10/8
*/
@Slf4j
@Component
public class TokenKeyExpirationListener extends KeyExpirationEventMessageListener {
@Autowired
private StringRedisTemplate redisTemplate;
public TokenKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
@Override
public void onMessage(Message message, byte[] pattern) {
// 监听过期的key
String expireKey = new String(message.getBody(), StandardCharsets.UTF_8);
//获取key原本的value 获取不到 是null
String expireKeyValue = redisTemplate.opsForValue().get("my-satoken");
//我是根据tokenvalues作为主键ID的
String[] split = expireKey.split(":");
String s = split[split.length - 1];
try {
WebSocketServer.sendInfo(new SocketMsg("token会话过期", MsgType.INFO), "exp-token");
} catch (IOException e) {
log.error(e.getMessage(), e);
}
log.info("expireKey---"+expireKey);
log.info("expireKeyValue---"+expireKeyValue);
}
}

View File

@@ -25,8 +25,8 @@ public class CheckController {
private final CheckService checkService;
@GetMapping
@Log("查询手工移库")
@ApiOperation("查询手工移库")
@Log("查询盘点")
@ApiOperation("查询盘点")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(checkService.pageQuery(whereJson,page), HttpStatus.OK);
}
@@ -39,8 +39,8 @@ public class CheckController {
}
@GetMapping("/getOutBillDtl2")
@Log("查询移库单")
@ApiOperation("查询移库单")
@Log("查询盘点单明细2")
@ApiOperation("查询盘点单明细2")
public ResponseEntity<Object> getOutBillDtl2(@RequestParam Map whereJson){
return new ResponseEntity<>(checkService.getOutBillDtl2(whereJson), HttpStatus.OK);
}
@@ -60,28 +60,28 @@ public class CheckController {
}
@PutMapping
@Log("修改移库")
@ApiOperation("修改移库")
public ResponseEntity<Object> update(@RequestBody Map whereJson){
@Log("修改盘点")
@ApiOperation("修改盘点")
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson){
checkService.update(whereJson);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@PostMapping()
@Log("新增移库")
@ApiOperation("新增移库")
public ResponseEntity<Object> insertDtl(@RequestBody Map whereJson){
@Log("新增盘点")
@ApiOperation("新增盘点")
public ResponseEntity<Object> insertDtl(@RequestBody JSONObject whereJson){
checkService.insertDtl(whereJson);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@GetMapping("/getStructIvt")
@Log("查询可分配库存")
@ApiOperation("查询可分配库存")
@Log("查询可盘点库存")
@ApiOperation("查询可盘点库存")
public ResponseEntity<Object> getStructIvt(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(checkService.getStructIvt(whereJson,page), HttpStatus.OK);
}
@PostMapping("/confirm")
@Log("移库单强制确认")
@ApiOperation("移库单强制确认")
@Log("盘点确定")
@ApiOperation("盘点确定")
public ResponseEntity<Object> confirm(@RequestBody JSONObject whereJson) {
checkService.confirm(whereJson);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);

View File

@@ -27,7 +27,7 @@ public interface CheckService {
* 新增出库单
* @param whereJson /
*/
void insertDtl (Map whereJson);
void insertDtl (JSONObject whereJson);
/**
* 查询出库单明细
* @param whereJson /
@@ -46,7 +46,7 @@ public interface CheckService {
* 修改出库单
* @param whereJson /
*/
void update(Map whereJson);
void update(JSONObject whereJson);
/**
* 查询可分配库存
* @param whereJson /

View File

@@ -97,36 +97,57 @@ public class CheckServiceImpl implements CheckService {
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDtl(Map map) {
//主表
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst");
public void insertDtl(JSONObject jsonObject) {
ArrayList<HashMap> rows = (ArrayList<HashMap>) map.get("tableData");
map.remove("tableData");
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_CheckMst"); // 盘点单主表
WQLObject dtlTab = WQLObject.getWQLObject("ST_IVT_CheckDtl"); // 盘点单明细表
JSONArray dtlArr = jsonObject.getJSONArray("tableData");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
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");
Long deptId = SecurityUtils.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);
// 插入主表
JSONObject jsonMst = new JSONObject();
jsonMst.put("check_id", IdUtil.getSnowflake(1,1).nextId());
jsonMst.put("check_code", CodeUtil.getNewCode("PD_CODE"));
jsonMst.put("buss_type", jsonObject.getString("check_type"));
jsonMst.put("check_type", jsonObject.getString("check_type"));
jsonMst.put("stor_id", jsonObject.getLongValue("stor_id"));
jsonMst.put("stor_name", jsonObject.getString("stor_name"));
jsonMst.put("dtl_num", dtlArr.size());
jsonMst.put("create_mode", "01");
jsonMst.put("is_nok", "0");
jsonMst.put("input_optid", currentUserId);
jsonMst.put("input_optname", nickName);
jsonMst.put("input_time", DateUtil.now());
jsonMst.put("remark", jsonObject.getString("remark"));
jsonMst.put("status", "1");
jsonMst.put("sysdeptid", deptId);
jsonMst.put("syscompanyid", deptId);
mstTab.insert(jsonMst);
// 插入明细
for (int i = 0; i < dtlArr.size(); i++) {
JSONObject json = dtlArr.getJSONObject(i);
JSONObject jsonDtl = new JSONObject();
jsonDtl.put("checkdtl_id", IdUtil.getSnowflake(1,1).nextId());
jsonDtl.put("check_id", jsonMst.getLongValue("check_id"));
jsonDtl.put("check_code", jsonMst.getString("check_code"));
jsonDtl.put("seq_no", i+1);
jsonDtl.put("sect_id", json.getLongValue("sect_id"));
jsonDtl.put("sect_name", json.getString("sect_name"));
jsonDtl.put("struct_id", json.getLongValue("struct_id"));
jsonDtl.put("struct_name", json.getString("struct_name"));
jsonDtl.put("storagevehicle_code", json.getString("storagevehicle_code"));
jsonDtl.put("material_id", json.getLongValue("material_id"));
jsonDtl.put("base_qty", json.getDoubleValue("base_qty"));
jsonDtl.put("qty_unit_id", json.getLongValue("measure_unit_id"));
jsonDtl.put("qty_unit_name", json.getString("qty_unit_name"));
jsonDtl.put("status", "1");
jsonDtl.put("fac_qty", json.getDoubleValue("fac_qty"));
dtlTab.insert(jsonDtl);
}
}
/**
@@ -152,19 +173,6 @@ public class CheckServiceImpl implements CheckService {
row.put("is_down", "0");
wo_dtl.insert(row);
}
//锁定起点点位、仓位
Iterator<String> 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
@@ -199,30 +207,46 @@ public class CheckServiceImpl implements CheckService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(Map whereJson) {
//主表
WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_CheckMst");
public void update(JSONObject jsonObject) {
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_CheckMst"); // 盘点单主表
WQLObject dtlTab = WQLObject.getWQLObject("ST_IVT_CheckDtl"); // 盘点单明细表
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
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<HashMap> rows = (ArrayList<HashMap>) 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);
JSONArray dtlArr = jsonObject.getJSONArray("tableData");
// 插入主表
JSONObject jsonMst = mstTab.query("check_id = '" + jsonObject.getString("check_id") + "'").uniqueResult(0);
jsonMst.put("buss_type", jsonObject.getString("check_type"));
jsonMst.put("check_type", jsonObject.getString("check_type"));
jsonMst.put("stor_id", jsonObject.getLongValue("stor_id"));
jsonMst.put("stor_name", jsonObject.getString("stor_name"));
jsonMst.put("dtl_num", dtlArr.size());
jsonMst.put("create_mode", "01");
jsonMst.put("remark", jsonObject.getString("remark"));
jsonMst.put("status", "1");
mstTab.update(jsonMst);
// 插入明细
dtlTab.delete("check_id = '"+jsonObject.getString("check_id")+"'");
for (int i = 0; i < dtlArr.size(); i++) {
JSONObject json = dtlArr.getJSONObject(i);
JSONObject jsonDtl = new JSONObject();
jsonDtl.put("checkdtl_id", IdUtil.getSnowflake(1,1).nextId());
jsonDtl.put("check_id", jsonMst.getLongValue("check_id"));
jsonDtl.put("check_code", jsonMst.getString("check_code"));
jsonDtl.put("seq_no", i+1);
jsonDtl.put("sect_id", json.getLongValue("sect_id"));
jsonDtl.put("sect_name", json.getString("sect_name"));
jsonDtl.put("struct_id", json.getLongValue("struct_id"));
jsonDtl.put("struct_name", json.getString("struct_name"));
jsonDtl.put("storagevehicle_code", json.getString("storagevehicle_code"));
jsonDtl.put("material_id", json.getLongValue("material_id"));
jsonDtl.put("base_qty", json.getDoubleValue("base_qty"));
jsonDtl.put("qty_unit_id", json.getLongValue("measure_unit_id"));
jsonDtl.put("qty_unit_name", json.getString("qty_unit_name"));
jsonDtl.put("status", "1");
jsonDtl.put("fac_qty", json.getDoubleValue("fac_qty"));
dtlTab.insert(jsonDtl);
}
}
@Override
@@ -236,7 +260,7 @@ public class CheckServiceImpl implements CheckService {
}
JSONObject jo = WQL.getWO("QST_IVT_CHECK")
.addParam("flag", "3")
.addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "struct.struct_id,struct.storagevehicle_code");
.addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "struct.struct_code");
return jo;
}
@@ -254,55 +278,51 @@ public class CheckServiceImpl implements CheckService {
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
JSONObject jo_mst = wo_mst.query("status in ('10','30') and check_id='" + form.getString("check_id") + "'").uniqueResult(0);
JSONObject jo_mst = wo_mst.query("status in ('1','3') 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") + "'");
wo_dtl.delete("status in ('1','2') and check_id='" + form.getString("check_id") + "'");
//定义需要需要更新的的点位集合
HashSet<String> 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)) {
if ("3,4,5,99".contains(status)) {
wo_dtl.update(jo);
continue;
}
jo.put("status", "05");
jo.put("status", "3");
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");
jo.put("check_result", "3");
} else if (fac_qty < base_qty) {
jo.put("check_result", "1");
jo.put("check_result", "2");
} 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);
jo.put("check_result", "1");
}
wo_dtl.insert(jo);
}
jo_mst.put("dtl_num", rows.size());
jo_mst.put("status", "30");
jo_mst.put("status", "3");
jo_mst.put("is_nok", "0");
JSONArray ja_nok = wo_dtl.query("check_result <>'0' and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0);
JSONArray ja_nok = wo_dtl.query("check_result <>'1' 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);
JSONArray ja = wo_dtl.query("status in ('99') and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0);
//说明全部确认
if (ja.size() == jo_mst.getInteger("dtl_num")) {
HashMap<String, String> mapdtl = new HashMap<>();
mapdtl.put("status", "99");
wo_dtl.update(mapdtl, "check_id='" + form.getString("check_id") + "'");
@@ -310,15 +330,6 @@ public class CheckServiceImpl implements CheckService {
jo_mst.put("confirm_optid", currentUserId);
jo_mst.put("confirm_optname", nickName);
jo_mst.put("confirm_time", now);
//锁定起点点位、仓位
Iterator<String> 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);
}
@@ -387,48 +398,48 @@ public class CheckServiceImpl implements CheckService {
JSONObject form = whereJson.getJSONObject("row");
JSONArray rows = whereJson.getJSONArray("rows");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
JSONObject jo_mst = wo_mst.query("status in ('10','30') and check_id='" + form.getString("check_id") + "'").uniqueResult(0);
JSONObject jo_mst = wo_mst.query("status in ('1','3') 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") + "'");
wo_dtl.delete("status in ('1','2') 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)) {
if ("3,4,5,99".contains(status)) {
wo_dtl.update(jo);
continue;
}
jo.put("status", "04");
jo.put("status", "2");
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");
jo.put("check_result", "3");
} else if (fac_qty < base_qty) {
jo.put("check_result", "1");
jo.put("check_result", "2");
} 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);
jo.put("check_result", "1");
}
wo_dtl.insert(jo);
}
jo_mst.put("dtl_num", rows.size());
jo_mst.put("status", "30");
jo_mst.put("status", "3");
jo_mst.put("is_nok", "0");
JSONArray ja_nok = wo_dtl.query("check_result <>'0' and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0);
JSONArray ja_nok = wo_dtl.query("check_result <>'1' and check_id='" + form.getString("check_id") + "'").getResultJSONArray(0);
if (ja_nok.size() != 0) {
jo_mst.put("is_nok", "1");
}

View File

@@ -69,35 +69,40 @@
FROM
ST_IVT_CheckMst checkmst
WHERE
1 = 1
AND checkmst.is_delete = '0'
checkmst.is_delete = '0'
OPTION 输入.check_code <> ""
checkmst.check_code like 输入.check_code
ENDOPTION
OPTION 输入.buss_type <> ""
checkmst.buss_type like 输入.buss_type
checkmst.buss_type = 输入.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
@@ -135,61 +140,47 @@
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
struct.sect_id,
struct.sect_code,
struct.sect_name,
struct.struct_id,
struct.struct_code,
struct.struct_name,
struct.storagevehicle_code,
mb.material_id,
mb.material_name,
mb.material_code,
'1' AS base_qty,
'0' AS fac_qty,
'箱' AS qty_unit_name,
'1585604690706567168' AS measure_unit_id
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
st_ivt_structivt ivt
LEFT JOIN st_ivt_structattr struct ON ivt.struct_id = struct.struct_id
LEFT JOIN md_me_materialbase mb ON mb.material_id = ivt.material_id
WHERE
1 = 1
AND struct.lock_type = '00'
AND struct.storagevehicle_id > 0
OPTION 输入.material_id <> ""
bucketcopy.material_id = 输入.material_id
ENDOPTION
AND struct.lock_type = '1'
AND IFNULL(struct.storagevehicle_code,'') <> ''
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
group by ivt.struct_id
ENDSELECT
ENDPAGEQUERY
ENDIF
@@ -347,7 +338,7 @@
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.fac_qty,
CheckDtl.check_result,
CheckDtl.check_optid,
CheckDtl.check_optname,