From 0e4aa52a6de100ab96408178927cfb22f7328e34 Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期六, 15 七月 2023 22:20:19 +0800
Subject: [PATCH] 提交武汉黄陂军粮配置信息
---
igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java | 228 +++++++++++++++++++++++---------------------------------
1 files changed, 94 insertions(+), 134 deletions(-)
diff --git a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
index 460f565..58e3093 100644
--- a/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
+++ b/igds-inout/src/main/java/com/ld/igds/inout/service/impl/InoutServiceImpl.java
@@ -1,29 +1,22 @@
package com.ld.igds.inout.service.impl;
import com.bstek.dorado.data.entity.EntityUtils;
-import com.ld.igds.check.dto.CheckItemData;
-import com.ld.igds.common.CoreCommonService;
-import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
-import com.ld.igds.constant.FoodType;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.data.CommonData;
import com.ld.igds.data.Page;
import com.ld.igds.inout.InoutConstant;
-import com.ld.igds.inout.dto.InoutData;
-import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.dto.InoutCheckData;
import com.ld.igds.inout.dto.InoutCheckParam;
+import com.ld.igds.inout.dto.InoutData;
+import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.mapper.InoutCheckMapper;
import com.ld.igds.inout.mapper.InoutRecordMapper;
import com.ld.igds.inout.service.InoutService;
-import com.ld.igds.io.constant.OrderRespEnum;
-import com.ld.igds.models.Depot;
+import com.ld.igds.models.InoutPrice;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
import com.ld.igds.util.RedisUtil;
-import com.ld.igds.websocket.WebSocketPacket;
-import com.ld.igds.websocket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@@ -32,9 +25,6 @@
import javax.annotation.Resource;
import java.util.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.FutureTask;
@Slf4j
@Component
@@ -46,8 +36,6 @@
private InoutCheckMapper inoutCheckMapper;
@Resource
private RedisUtil redisUtil;
- @Resource
- private CoreCommonService commonService;
@Override
public InoutData inoutProgressQuery(InoutParam param) throws Exception {
@@ -60,8 +48,6 @@
if (null != result) {
return result;
}
-
-
List<InoutData> list = inoutMapper.inoutProgressQuery(param);
if (null == list || list.size() == 0)
return null;
@@ -103,22 +89,24 @@
inoutMapper.deleteData(param);
- delInoutFromCache(param.getDeptId(), param.getType(), param.getId());
+ delFromCache(param.getDeptId(), param.getType(), param.getId());
return null;
}
@Override
- public String inoutStop(InoutParam param) {
+ public String inoutStop(InoutParam param) throws Exception {
if (StringUtils.isEmpty(param.getCompanyId())) {
- param.setCompanyId(ContextUtil.getCompanyId());
+ param.setCompanyId(ContextUtil.getDefaultCompanyId());
}
- // 缂撳瓨涓垹闄�
- delInoutFromCache(param.getDeptId(), param.getType(), param.getId());
param.setProgress(InoutConstant.PROGRESS_RECORD);
- param.setRecordStatus(InoutConstant.RECORD_STATUS_ERROR);
+ param.setRecordStatus(InoutConstant.RECORD_STATUS_DEL);
+
+
+ // 缂撳瓨涓垹闄�
+ delFromCache(param.getDeptId(), param.getType(), param.getId());
inoutMapper.inoutStop(param);
@@ -156,9 +144,18 @@
data.setUserName("");
}
- inoutMapper.insertData(data);
+ InoutData newData;
+ if (EntityUtils.isEntity(data)) {
+ newData = new InoutData();
+ BeanUtils.copyProperties(data, newData, new String[]{"checkItems", "files"});
+ } else {
+ newData = data;
+ }
- updateInoutCache(data);
+ inoutMapper.insertData(newData);
+
+
+ updateInoutCache(newData);
} catch (Exception e) {
log.error("------------鍑哄叆搴撴墽琛屼繚瀛樺嚭閿�---{}", e);
@@ -171,6 +168,8 @@
@Override
public String updateData(InoutData data) throws Exception {
+
+ data.setUpdateTime(new Date());
if (StringUtils.isEmpty(data.getCompanyId())) {
data.setCompanyId(ContextUtil.getCompanyId());
}
@@ -183,6 +182,29 @@
}
inoutMapper.updateData(newData);
+
+ //鏇存柊缂撳瓨
+ updateInoutCache(newData);
+
+ return null;
+ }
+
+ @Override
+ public String updateDataByHandle(InoutData data) {
+ data.setUpdateTime(new Date());
+
+ if (StringUtils.isEmpty(data.getCompanyId())) {
+ data.setCompanyId(ContextUtil.getCompanyId());
+ }
+ InoutData newData;
+ if (EntityUtils.isEntity(data)) {
+ newData = new InoutData();
+ BeanUtils.copyProperties(data, newData, new String[]{"checkItems", "files"});
+ } else {
+ newData = data;
+ }
+
+ inoutMapper.updateDataByHandle(newData);
//鏇存柊缂撳瓨
updateInoutCache(newData);
@@ -215,6 +237,10 @@
// 璁剧疆韬唤璇佸彿鐨勬ā绯婃煡璇㈡潯浠�
if (null != param.getUserId()) {
param.setUserId("%" + param.getUserId() + "%");
+ }
+
+ if (null != param.getRecordStatus() && InoutConstant.RECORD_STATUS_NORMAL.equals(param.getRecordStatus())) {
+ param.setRecordStatus(null);
}
List<InoutData> records = inoutMapper.pageRecordData(page, param);
@@ -259,12 +285,15 @@
@Override
public String toComplete(InoutParam param) throws Exception {
+ param.setUpdateTime(new Date());
+
if (null == param.getCompanyId()) {
- param.setCompanyId(ContextUtil.getCompanyId());
+ param.setCompanyId(ContextUtil.getDefaultCompanyId());
}
// 娓呴櫎缂撳瓨
- this.delInoutFromCache(param.getDeptId(), param.getType(), param.getId());
+// this.delFromCache(param.getDeptId(), param.getType(), param.getId());
+
inoutMapper.toComplete(param);
@@ -274,7 +303,7 @@
@Override
public String quickComplete(InoutData data) throws Exception {
if (null == data.getCompanyId()) {
- data.setCompanyId(ContextUtil.getCompanyId());
+ data.setCompanyId(ContextUtil.getDefaultCompanyId());
}
if (null == data.getCompleteTime()) {
data.setCompleteTime(new Date());
@@ -285,7 +314,6 @@
if (null == data.getEmptyWeightTime()) {
data.setEmptyWeightTime(new Date());
}
-
//璋冩暣鏃堕棿宸�
if (InoutConstant.TYPE_IN.equals(data.getType())) {
@@ -314,15 +342,10 @@
// 璁剧疆娴佺▼缁撴潫
data.setProgress(InoutConstant.PROGRESS_RECORD);
-
- if (null == data.getFoodType()) {
- // 鏍规嵁浠撳簱淇℃伅鑾峰彇缂撳瓨
- Depot depot = commonService.getCacheDepot(data.getCompanyId(), data.getDepotId());
- data.setFoodType(depot.getFoodType());
- }
-
+ //鎵ц鏇存柊
inoutMapper.updateData(data);
+ //鏇存柊缂撳瓨
updateInoutCache(data);
return null;
@@ -336,19 +359,17 @@
if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
- delInoutFromCache(data.getDeptId(), data.getType(), data.getId());
+ delFromCache(data.getDeptId(), data.getType(), data.getId());
setCompleteInoutCache(data.getDeptId(), data);
} else {
setInoutCache(data.getDeptId(), data);
}
- //鎺ㄩ�佸ぇ灞�
- notifyToScreen(data.getCompanyId(), data.getDeptId(), data.getProgress());
}
- public void delInoutFromCache(String deptId, String type, String id) {
+ public void delFromCache(String deptId, String type, String id) {
if (StringUtils.isEmpty(deptId)) {
return;
}
@@ -425,22 +446,6 @@
}
@Override
- public void notifyWeb(InoutData result) {
- // 濡傛灉褰撳墠涓烘弧杞︾О閲嶆墽琛屾帹閫�
- if (result.getType().equals(InoutConstant.TYPE_IN) && result.getProgress().equals(InoutConstant.PROGRESS_WEIGHT_FULL)) {
- WebSocketPacket packet = new WebSocketPacket();
- packet.setBizType(BizType.SCREEN_CHECK.getCode());
- packet.setCompanyId(result.getCompanyId());
- packet.setOrderResp(OrderRespEnum.MSG_SUCCESS.getCode());
- packet.setData(result);
- packet.setBizTag(InoutConstant.PROGRESS_WEIGHT_FULL);
- log.debug("----鍚戝寲楠屽ぇ灞忔帹閫佹弧杞︾О閲嶄俊鎭� ----{}", result.getPlateNum());
- WebSocketServer.sendByBizTag(packet);
- }
-
- }
-
- @Override
public Page<InoutData> pageUnCompleteData(InoutParam param) {
if (StringUtils.isEmpty(param.getCompanyId())) {
@@ -473,10 +478,7 @@
}
@Override
- public InoutData getLastRecord(String companyId, String depotId) {
- InoutParam param = new InoutParam();
- param.setCompanyId(companyId);
- param.setDepotId(depotId);
+ public InoutData getLastRecord(InoutParam param) {
return inoutMapper.getLastRecord(param);
}
@@ -484,7 +486,7 @@
public String addInoutDataByLossOver(InoutData data) {
// 鑾峰彇涓婁竴杞︾殑娴佹按鏁版嵁
- InoutData inoutData = this.getLastRecord(data.getCompanyId(), data.getDepotId());
+ // InoutData inoutData = this.getLastRecord(data.getCompanyId(), data.getDepotId());
// // 璁剧疆娴佹按鐨勫簱瀛�
// if (InoutConstant.TYPE_IN.equals(inoutData.getType())) {
@@ -504,22 +506,6 @@
@Override
public void delInoutDataByLossOver(InoutParam param) {
inoutMapper.deleteData(param);
- }
-
- @Override
- public void setCheckCache(InoutData data) {
-
- String cacheKey = RedisConst.buildKey(data.getCompanyId(), data.getCheckId());
-
- //鍖栭獙缁撴灉瀛樺叆缂撳瓨3澶�
- redisUtil.set(cacheKey, data.getCheckItems(), 60 * 60 * 24 * 3);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List<CheckItemData> getCheckCache(String companyId, String checkId) {
- String cacheKey = RedisConst.buildKey(companyId, checkId);
- return (List<CheckItemData>) redisUtil.get(cacheKey);
}
/**
@@ -625,54 +611,6 @@
}
/**
- * 鎺ㄩ�佸埌澶у睆锛屽垽鏂彧鏈夊綋澶у睆鍦ㄧ嚎鏃跺�欐墠澶勭悊褰撳墠閫昏緫锛岄伩鍏嶉〉闈㈠崱椤匡紝璋冪敤瀛愪换鍔″畬鎴愭帹閫�
- *
- * @param companyId 缁勭粐缂栧彿
- * @param deptId 鍒嗗簱缂栧彿
- * @param progress 娴佽浆鑺傜偣
- */
- public void notifyToScreen(String companyId, String deptId, String progress) {
-
- // 鎺ㄩ�佸埌澶у睆
- List<InoutData> curList = this.getListInoutCache(deptId);
-
- List<InoutData> completeList = this.getCompleteListInoutCache(deptId);
-
-
- if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN
- .getCode())) {
- WebSocketServer.contextOnLineMap.put(BizType.SCREEN.getCode(),
- false);
- }
- if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN_INOUT
- .getCode())) {
- WebSocketServer.contextOnLineMap.put(
- BizType.SCREEN_INOUT.getCode(), false);
- }
- if (null == WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK
- .getCode())) {
- WebSocketServer.contextOnLineMap.put(
- BizType.SCREEN_CHECK.getCode(), false);
- }
-
- if (WebSocketServer.contextOnLineMap.get(BizType.SCREEN.getCode())
- || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_INOUT
- .getCode())
- || WebSocketServer.contextOnLineMap.get(BizType.SCREEN_CHECK
- .getCode())) {
-
-
-
- // 鍒涘缓涓�涓瓙浠诲姟杩涜鎺ㄩ�佷俊鎭�
- FutureTask<String> futureTask = new FutureTask<>(new NotifyScreenTask(curList, completeList, deptId));
-
- ExecutorService executorService = Executors.newCachedThreadPool();
- executorService.submit(futureTask);
- executorService.shutdown();
- }
- }
-
- /**
* 鍒涘缓鍑哄叆搴搆ey
*
* @param deptId
@@ -722,7 +660,8 @@
data.setCompanyId(ContextUtil.subDeptId(null));
}
- int num = inoutCheckMapper.updateSampleData(data);
+ inoutCheckMapper.updateSampleData(data);
+
return null;
}
@@ -752,16 +691,37 @@
}
@Override
- public String updateCheckData(InoutCheckData data) {
- if (StringUtils.isEmpty(data.getCompanyId())) {
- data.setCompanyId(ContextUtil.getCompanyId());
- }
- if (StringUtils.isEmpty(data.getDeptId())) {
- data.setCompanyId(ContextUtil.subDeptId(null));
- }
+ public String updateCheckData(InoutData data) {
+ data.setUpdateTime(new Date());
- int num = inoutCheckMapper.updateCheckData(data);
+ inoutCheckMapper.updateCheckData(data);
+
+ //鏇存柊缂撳瓨
+ updateInoutCache(data);
+
return null;
}
+ @Override
+ public List<InoutPrice> getPrice(InoutCheckParam param) {
+ if (null == param.getStart()) {
+ param.setStart(new Date());
+ }
+ if (null == param.getEnd()) {
+ param.setEnd(new Date());
+ }
+ return inoutCheckMapper.getPrice(param);
+ }
+
+ @Override
+ public InoutCheckData inoutDataByCheckId(InoutCheckParam param) throws Exception {
+ List<InoutCheckData> list = inoutCheckMapper.inoutDataByCheckId(param);
+ if (null == list || list.size() == 0)
+ return null;
+ if (list.size() == 1) {
+ return list.get(0);
+ } else {
+ throw new Exception("褰撳墠鏉′欢涓嬪瓨鍦ㄥ涓弧瓒虫潯浠剁殑鏁版嵁锛岃鏍告煡锛侊紒");
+ }
+ }
}
--
Gitblit v1.9.3