From a6c962f1c6e14984f2bbc2f3e43fa85947d3cb0a Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: 星期六, 25 三月 2023 00:26:41 +0800
Subject: [PATCH] 支持厂拍门禁
---
service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java | 87 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java b/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java
index 382ad37..3d5637f 100644
--- a/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java
+++ b/service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java
@@ -5,12 +5,13 @@
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.annotation.Java110Transactional;
import com.java110.core.context.ICmdDataFlowContext;
-import com.java110.core.event.cmd.AbstractServiceCmdListener;
+import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
import com.java110.core.factory.GenerateCodeFactory;
import com.java110.dto.allocationStorehouse.AllocationStorehouseDto;
import com.java110.dto.allocationStorehouseApply.AllocationStorehouseApplyDto;
import com.java110.dto.resourceStore.ResourceStoreDto;
+import com.java110.dto.resourceStoreTimes.ResourceStoreTimesDto;
import com.java110.dto.user.UserDto;
import com.java110.dto.userStorehouse.UserStorehouseDto;
import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
@@ -18,7 +19,9 @@
import com.java110.intf.user.IUserV1InnerServiceSMO;
import com.java110.po.allocationStorehouse.AllocationStorehousePo;
import com.java110.po.allocationStorehouseApply.AllocationStorehouseApplyPo;
+import com.java110.po.purchase.PurchaseApplyDetailPo;
import com.java110.po.purchase.ResourceStorePo;
+import com.java110.po.resourceStoreTimes.ResourceStoreTimesPo;
import com.java110.po.userStorehouse.UserStorehousePo;
import com.java110.utils.exception.CmdException;
import com.java110.utils.lock.DistributedLock;
@@ -38,7 +41,7 @@
*
*/
@Java110Cmd(serviceCode = "resourceStore.saveAllocationStorehouse")
-public class SaveAllocationStorehouseCmd extends AbstractServiceCmdListener {
+public class SaveAllocationStorehouseCmd extends Cmd {
@Autowired
private IResourceStoreInnerServiceSMO resourceStoreInnerServiceSMOImpl;
@@ -63,6 +66,9 @@
@Autowired
private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IResourceStoreTimesV1InnerServiceSMO resourceStoreTimesV1InnerServiceSMOImpl;
@Override
public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
@@ -134,6 +140,13 @@
}
}
+ /**
+ * 璋冩嫧鐢宠-璋冩嫧鐢宠鍙戣捣
+ * @param event 浜嬩欢瀵硅薄
+ * @param cmdDataFlowContext
+ * @param reqJson 璇锋眰鎶ユ枃
+ * @throws CmdException
+ */
@Override
@Java110Transactional
public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
@@ -289,6 +302,21 @@
if (flag < 1) {
throw new CmdException("淇濆瓨淇敼鐗╁搧澶辫触");
}
+ // 淇濆瓨鑷� 鐗╁搧 times琛�
+ //鏌ヨ璋冩嫧鎵规浠锋牸
+ ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
+ resourceStoreTimesDto.setTimesId(resObj.getString("timesId"));
+ List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
+
+ ResourceStoreTimesPo resourceStoreTimesPo = new ResourceStoreTimesPo();
+ resourceStoreTimesPo.setApplyOrderId(GenerateCodeFactory.getGeneratorId("10"));
+ resourceStoreTimesPo.setPrice(resourceStoreTimesDtos.get(0).getPrice());
+ resourceStoreTimesPo.setStock(resObj.getString("curStock"));
+ resourceStoreTimesPo.setResCode(resObj.getString("resCode"));
+ resourceStoreTimesPo.setStoreId(reqJson.getString("storeId"));
+ resourceStoreTimesPo.setTimesId(GenerateCodeFactory.getGeneratorId("10"));
+ resourceStoreTimesPo.setShId(resObj.getString("shzId"));
+ resourceStoreTimesV1InnerServiceSMOImpl.saveOrUpdateResourceStoreTimes(resourceStoreTimesPo);
}
} else { //濡傛灉鐩爣浠撳簱涓嬫病鏈夎繖涓墿鍝佷俊鎭紝灏辨彃鍏ヤ竴鏉$墿鍝佷俊鎭�
ResourceStoreDto resourceStore = new ResourceStoreDto();
@@ -339,6 +367,26 @@
if (flag < 1) {
throw new CmdException("淇濆瓨淇敼鐗╁搧澶辫触");
}
+
+
+ // 淇濆瓨鑷� 鐗╁搧 times琛�
+ //鏌ヨ璋冩嫧鎵规浠锋牸
+ ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
+ resourceStoreTimesDto.setTimesId(resObj.getString("timesId"));
+ List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
+
+ ResourceStoreTimesPo resourceStoreTimesPo = new ResourceStoreTimesPo();
+ resourceStoreTimesPo.setApplyOrderId(GenerateCodeFactory.getGeneratorId("10"));
+ resourceStoreTimesPo.setPrice(resourceStoreTimesDtos.get(0).getPrice());
+ resourceStoreTimesPo.setStock(resObj.getString("curStock"));
+ resourceStoreTimesPo.setResCode(resourceStoreList.get(0).getResCode());
+ resourceStoreTimesPo.setStoreId(reqJson.getString("storeId"));
+ resourceStoreTimesPo.setTimesId(GenerateCodeFactory.getGeneratorId("10"));
+ resourceStoreTimesPo.setShId(resObj.getString("shzId"));
+ resourceStoreTimesV1InnerServiceSMOImpl.saveOrUpdateResourceStoreTimes(resourceStoreTimesPo);
+
+
+
}
}
@@ -385,6 +433,9 @@
BigDecimal oldCurStore = new BigDecimal(allocationStorehouseApplyPo.getApplyCount());
oldCurStore = oldCurStore.add(new BigDecimal(resObj.getString("curStock")));
allocationStorehouseApplyPo.setApplyCount(oldCurStore.toString());
+ //鍔犲叆 浠庡簱瀛樹腑鎵e噺
+ subResourceStoreTimesStock(resObj);
+
} finally {
DistributedLock.releaseDistributedLock(requestId, key);
}
@@ -411,6 +462,7 @@
allocationStorehousePo.setRemark(reqJson.getString("remark"));
allocationStorehousePo.setStartUserId(reqJson.getString("userId"));
allocationStorehousePo.setStartUserName(reqJson.getString("userName"));
+ allocationStorehousePo.setTimesId(resObj.getString("timesId"));
int flag = allocationStorehouseV1InnerServiceSMOImpl.saveAllocationStorehouse(allocationStorehousePo);
if (flag < 1) {
@@ -445,4 +497,35 @@
return allocationStorehouseApplyPo;
}
+
+ /**
+ * 浠巘imes涓墸鍑�
+ *
+ * @param resObj
+ */
+ private void subResourceStoreTimesStock(JSONObject resObj) {
+ String applyQuantity = resObj.getString("curStock");
+ ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
+ resourceStoreTimesDto.setResCode(resObj.getString("resCode"));
+ resourceStoreTimesDto.setTimesId(resObj.getString("timesId"));
+ List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
+
+ if (resourceStoreTimesDtos == null || resourceStoreTimesDtos.size() < 1) {
+ return;
+ }
+ int stock = 0;
+ int quantity = Integer.parseInt(applyQuantity);
+ ResourceStoreTimesPo resourceStoreTimesPo = null;
+
+ stock = Integer.parseInt(resourceStoreTimesDtos.get(0).getStock());
+ if (stock < quantity) {
+ throw new CmdException(resourceStoreTimesDtos.get(0).getResCode() + "浠锋牸涓猴細" + resourceStoreTimesDtos.get(0).getPrice() + "鐨勫簱瀛�" + resourceStoreTimesDtos.get(0).getStock() + ",搴撳瓨涓嶈冻");
+ }
+
+ stock = stock - quantity;
+ resourceStoreTimesPo = new ResourceStoreTimesPo();
+ resourceStoreTimesPo.setTimesId(resourceStoreTimesDtos.get(0).getTimesId());
+ resourceStoreTimesPo.setStock(stock + "");
+ resourceStoreTimesV1InnerServiceSMOImpl.updateResourceStoreTimes(resourceStoreTimesPo);
+ }
}
--
Gitblit v1.8.0