Browse Source

采购修改cmd方式 完成

java110 3 years ago
parent
commit
09305c259c
15 changed files with 828 additions and 407 deletions
  1. 9 0
      java110-bean/src/main/java/com/java110/po/allocationUserStorehouse/AllocationUserStorehousePo.java
  2. 160 0
      java110-db/src/main/resources/mapper/store/AllocationUserStorehouseV1ServiceDaoImplMapper.xml
  3. 68 0
      java110-interface/src/main/java/com/java110/intf/store/IAllocationUserStorehouseV1InnerServiceSMO.java
  4. 0 49
      service-api/src/main/java/com/java110/api/listener/resourceStore/DeleteUserStorehouseListener.java
  5. 0 50
      service-api/src/main/java/com/java110/api/listener/resourceStore/SaveAllocationStorehouseApplyListener.java
  6. 0 56
      service-api/src/main/java/com/java110/api/listener/resourceStore/SaveAllocationUserStorehouseListener.java
  7. 0 50
      service-api/src/main/java/com/java110/api/listener/resourceStore/SaveUserStorehouseListener.java
  8. 0 51
      service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateAllocationStorehouseApplyListener.java
  9. 0 51
      service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateAllocationStorehouseListener.java
  10. 0 50
      service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateAllocationUserStorehouseListener.java
  11. 0 50
      service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateUserStorehouseListener.java
  12. 313 0
      service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationUserStorehouseCmd.java
  13. 77 0
      service-store/src/main/java/com/java110/store/dao/IAllocationUserStorehouseV1ServiceDao.java
  14. 112 0
      service-store/src/main/java/com/java110/store/dao/impl/AllocationUserStorehouseV1ServiceDaoImpl.java
  15. 89 0
      service-store/src/main/java/com/java110/store/smo/impl/AllocationUserStorehouseV1InnerServiceSMOImpl.java

+ 9 - 0
java110-bean/src/main/java/com/java110/po/allocationUserStorehouse/AllocationUserStorehousePo.java

@@ -17,6 +17,7 @@ public class AllocationUserStorehousePo implements Serializable {
     private String createTime;
     private String giveQuantity;
     private String resCode;
+    private String statusCd = "0";
 
     public String getAcceptUserId() {
         return acceptUserId;
@@ -121,4 +122,12 @@ public class AllocationUserStorehousePo implements Serializable {
     public void setResCode(String resCode) {
         this.resCode = resCode;
     }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
 }

+ 160 - 0
java110-db/src/main/resources/mapper/store/AllocationUserStorehouseV1ServiceDaoImplMapper.xml

@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl">
+
+
+
+
+
+    <!-- 保存用户仓库信息 add by wuxw 2018-07-03 -->
+    <insert id="saveAllocationUserStorehouseInfo" parameterType="Map">
+        insert into allocation_user_storehouse(
+res_name,start_user_id,accept_user_id,accept_user_name,start_user_name,aus_id,remark,store_id,stock,res_id,give_quantity
+) values (
+#{resName},#{startUserId},#{acceptUserId},#{acceptUserName},#{startUserName},#{ausId},#{remark},#{storeId},#{stock},#{resId},#{giveQuantity}
+)
+    </insert>
+
+
+
+    <!-- 查询用户仓库信息 add by wuxw 2018-07-03 -->
+    <select id="getAllocationUserStorehouseInfo" parameterType="Map" resultType="Map">
+        select  t.res_name,t.res_name resName,t.start_user_id,t.start_user_id startUserId,t.accept_user_id,t.accept_user_id acceptUserId,t.accept_user_name,t.accept_user_name acceptUserName,t.start_user_name,t.start_user_name startUserName,t.aus_id,t.aus_id ausId,t.status_cd,t.status_cd statusCd,t.remark,t.store_id,t.store_id storeId,t.stock,t.res_id,t.res_id resId,t.give_quantity,t.give_quantity giveQuantity 
+from allocation_user_storehouse t 
+where 1 =1 
+<if test="resName !=null and resName != ''">
+   and t.res_name= #{resName}
+</if> 
+<if test="startUserId !=null and startUserId != ''">
+   and t.start_user_id= #{startUserId}
+</if> 
+<if test="acceptUserId !=null and acceptUserId != ''">
+   and t.accept_user_id= #{acceptUserId}
+</if> 
+<if test="acceptUserName !=null and acceptUserName != ''">
+   and t.accept_user_name= #{acceptUserName}
+</if> 
+<if test="startUserName !=null and startUserName != ''">
+   and t.start_user_name= #{startUserName}
+</if> 
+<if test="ausId !=null and ausId != ''">
+   and t.aus_id= #{ausId}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="remark !=null and remark != ''">
+   and t.remark= #{remark}
+</if> 
+<if test="storeId !=null and storeId != ''">
+   and t.store_id= #{storeId}
+</if> 
+<if test="stock !=null and stock != ''">
+   and t.stock= #{stock}
+</if> 
+<if test="resId !=null and resId != ''">
+   and t.res_id= #{resId}
+</if> 
+<if test="giveQuantity !=null and giveQuantity != ''">
+   and t.give_quantity= #{giveQuantity}
+</if> 
+order by t.create_time desc
+<if test="page != -1 and page != null ">
+   limit #{page}, #{row}
+</if> 
+
+    </select>
+
+
+
+
+    <!-- 修改用户仓库信息 add by wuxw 2018-07-03 -->
+    <update id="updateAllocationUserStorehouseInfo" parameterType="Map">
+        update  allocation_user_storehouse t set t.status_cd = #{statusCd}
+<if test="newBId != null and newBId != ''">
+,t.b_id = #{newBId}
+</if> 
+<if test="resName !=null and resName != ''">
+, t.res_name= #{resName}
+</if> 
+<if test="startUserId !=null and startUserId != ''">
+, t.start_user_id= #{startUserId}
+</if> 
+<if test="acceptUserId !=null and acceptUserId != ''">
+, t.accept_user_id= #{acceptUserId}
+</if> 
+<if test="acceptUserName !=null and acceptUserName != ''">
+, t.accept_user_name= #{acceptUserName}
+</if> 
+<if test="startUserName !=null and startUserName != ''">
+, t.start_user_name= #{startUserName}
+</if> 
+<if test="remark !=null and remark != ''">
+, t.remark= #{remark}
+</if> 
+<if test="storeId !=null and storeId != ''">
+, t.store_id= #{storeId}
+</if> 
+<if test="stock !=null and stock != ''">
+, t.stock= #{stock}
+</if> 
+<if test="resId !=null and resId != ''">
+, t.res_id= #{resId}
+</if> 
+<if test="giveQuantity !=null and giveQuantity != ''">
+, t.give_quantity= #{giveQuantity}
+</if> 
+ where 1=1 <if test="ausId !=null and ausId != ''">
+and t.aus_id= #{ausId}
+</if> 
+
+    </update>
+
+    <!-- 查询用户仓库数量 add by wuxw 2018-07-03 -->
+     <select id="queryAllocationUserStorehousesCount" parameterType="Map" resultType="Map">
+        select  count(1) count 
+from allocation_user_storehouse t 
+where 1 =1 
+<if test="resName !=null and resName != ''">
+   and t.res_name= #{resName}
+</if> 
+<if test="startUserId !=null and startUserId != ''">
+   and t.start_user_id= #{startUserId}
+</if> 
+<if test="acceptUserId !=null and acceptUserId != ''">
+   and t.accept_user_id= #{acceptUserId}
+</if> 
+<if test="acceptUserName !=null and acceptUserName != ''">
+   and t.accept_user_name= #{acceptUserName}
+</if> 
+<if test="startUserName !=null and startUserName != ''">
+   and t.start_user_name= #{startUserName}
+</if> 
+<if test="ausId !=null and ausId != ''">
+   and t.aus_id= #{ausId}
+</if> 
+<if test="statusCd !=null and statusCd != ''">
+   and t.status_cd= #{statusCd}
+</if> 
+<if test="remark !=null and remark != ''">
+   and t.remark= #{remark}
+</if> 
+<if test="storeId !=null and storeId != ''">
+   and t.store_id= #{storeId}
+</if> 
+<if test="stock !=null and stock != ''">
+   and t.stock= #{stock}
+</if> 
+<if test="resId !=null and resId != ''">
+   and t.res_id= #{resId}
+</if> 
+<if test="giveQuantity !=null and giveQuantity != ''">
+   and t.give_quantity= #{giveQuantity}
+</if> 
+
+
+     </select>
+
+</mapper>

+ 68 - 0
java110-interface/src/main/java/com/java110/intf/store/IAllocationUserStorehouseV1InnerServiceSMO.java

@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.intf.store;
+
+import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.allocationUserStorehouse.AllocationUserStorehouseDto;
+import com.java110.po.allocationUserStorehouse.AllocationUserStorehousePo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
+/**
+ * 类表述: 服务之前调用的接口类,不对外提供接口能力 只用于接口建调用
+ * add by 吴学文 at 2022-08-08 16:22:31 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@FeignClient(name = "store-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/allocationUserStorehouseV1Api")
+public interface IAllocationUserStorehouseV1InnerServiceSMO {
+
+
+    @RequestMapping(value = "/saveAllocationUserStorehouse", method = RequestMethod.POST)
+    public int saveAllocationUserStorehouse(@RequestBody AllocationUserStorehousePo allocationUserAllocationUserStorehousehousePo);
+
+    @RequestMapping(value = "/updateAllocationUserStorehouse", method = RequestMethod.POST)
+    public int updateAllocationUserStorehouse(@RequestBody  AllocationUserStorehousePo allocationUserAllocationUserStorehousehousePo);
+
+    @RequestMapping(value = "/deleteAllocationUserStorehouse", method = RequestMethod.POST)
+    public int deleteAllocationUserStorehouse(@RequestBody  AllocationUserStorehousePo allocationUserAllocationUserStorehousehousePo);
+
+    /**
+     * <p>查询小区楼信息</p>
+     *
+     *
+     * @param allocationUserAllocationUserStorehousehouseDto 数据对象分享
+     * @return AllocationUserStorehouseDto 对象数据
+     */
+    @RequestMapping(value = "/queryAllocationUserStorehouses", method = RequestMethod.POST)
+    List<AllocationUserStorehouseDto> queryAllocationUserStorehouses(@RequestBody AllocationUserStorehouseDto allocationUserAllocationUserStorehousehouseDto);
+
+    /**
+     * 查询<p>小区楼</p>总记录数
+     *
+     * @param allocationUserAllocationUserStorehousehouseDto 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/queryAllocationUserStorehousesCount", method = RequestMethod.POST)
+    int queryAllocationUserStorehousesCount(@RequestBody AllocationUserStorehouseDto allocationUserAllocationUserStorehousehouseDto);
+}

+ 0 - 49
service-api/src/main/java/com/java110/api/listener/resourceStore/DeleteUserStorehouseListener.java

@@ -1,49 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.userStorehouse.IUserStorehouseBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeUserStorehouseConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-
-/**
- * 保存小区侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("deleteUserStorehouseListener")
-public class DeleteUserStorehouseListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IUserStorehouseBMO userStorehouseBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-
-        Assert.hasKeyAndValue(reqJson, "usId", "usId不能为空");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        userStorehouseBMOImpl.deleteUserStorehouse(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeUserStorehouseConstant.DELETE_USERSTOREHOUSE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-}

+ 0 - 50
service-api/src/main/java/com/java110/api/listener/resourceStore/SaveAllocationStorehouseApplyListener.java

@@ -1,50 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.allocationStorehouseApply.IAllocationStorehouseApplyBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeAllocationStorehouseApplyConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存商户侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("saveAllocationStorehouseApplyListener")
-public class SaveAllocationStorehouseApplyListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IAllocationStorehouseApplyBMO allocationStorehouseApplyBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-
-        Assert.hasKeyAndValue(reqJson, "startUserId", "请求报文中未包含startUserId");
-        Assert.hasKeyAndValue(reqJson, "startUserName", "请求报文中未包含startUserName");
-        Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含remark");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        allocationStorehouseApplyBMOImpl.addAllocationStorehouseApply(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeAllocationStorehouseApplyConstant.ADD_ALLOCATIONSTOREHOUSEAPPLY;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-}

+ 0 - 56
service-api/src/main/java/com/java110/api/listener/resourceStore/SaveAllocationUserStorehouseListener.java

@@ -1,56 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.allocationUserStorehouse.IAllocationUserStorehouseBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeAllocationUserStorehouseConstant;
-import com.java110.utils.util.Assert;
-import com.java110.core.context.DataFlowContext;
-import com.java110.utils.util.StringUtil;
-import com.java110.vo.ResultVo;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-import com.java110.core.annotation.Java110Listener;
-import org.springframework.http.ResponseEntity;
-
-/**
- * 保存商户侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("saveAllocationUserStorehouseListener")
-public class SaveAllocationUserStorehouseListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IAllocationUserStorehouseBMO allocationUserStorehouseBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-        //Assert.hasKeyAndValue(reqJson, "acceptUserId", "请求报文中未包含acceptUserId");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        String userId = reqJson.getString("userId");
-        String acceptUserId = reqJson.getString("acceptUserId");
-        if(!StringUtil.isEmpty(userId) && !StringUtil.isEmpty(acceptUserId) && acceptUserId.equals(userId)){
-            ResponseEntity<String> responseEntity = ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "物品接受人不能是本人,所以无法进行转赠操作!");
-            context.setResponseEntity(responseEntity);
-            return;
-        }
-        allocationUserStorehouseBMOImpl.addAllocationUserStorehouse(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeAllocationUserStorehouseConstant.ADD_ALLOCATIONUSERSTOREHOUSE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-}

+ 0 - 50
service-api/src/main/java/com/java110/api/listener/resourceStore/SaveUserStorehouseListener.java

@@ -1,50 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.userStorehouse.IUserStorehouseBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeUserStorehouseConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存商户侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("saveUserStorehouseListener")
-public class SaveUserStorehouseListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IUserStorehouseBMO userStorehouseBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
-
-        Assert.hasKeyAndValue(reqJson, "resId", "请求报文中未包含resId");
-        Assert.hasKeyAndValue(reqJson, "stock", "请求报文中未包含stock");
-        Assert.hasKeyAndValue(reqJson, "userId", "请求报文中未包含userId");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-        userStorehouseBMOImpl.addUserStorehouse(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeUserStorehouseConstant.ADD_USERSTOREHOUSE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-
-}

+ 0 - 51
service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateAllocationStorehouseApplyListener.java

@@ -1,51 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.allocationStorehouseApply.IAllocationStorehouseApplyBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeAllocationStorehouseApplyConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存调拨申请侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("updateAllocationStorehouseApplyListener")
-public class UpdateAllocationStorehouseApplyListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IAllocationStorehouseApplyBMO allocationStorehouseApplyBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "applyId", "applyId不能为空");
-        Assert.hasKeyAndValue(reqJson, "startUserId", "请求报文中未包含startUserId");
-        Assert.hasKeyAndValue(reqJson, "startUserName", "请求报文中未包含startUserName");
-        Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含remark");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        allocationStorehouseApplyBMOImpl.updateAllocationStorehouseApply(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeAllocationStorehouseApplyConstant.UPDATE_ALLOCATIONSTOREHOUSEAPPLY;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-}

+ 0 - 51
service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateAllocationStorehouseListener.java

@@ -1,51 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.allocationStorehouse.IAllocationStorehouseBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeAllocationStorehouseConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存仓库调拨侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("updateAllocationStorehouseListener")
-public class UpdateAllocationStorehouseListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IAllocationStorehouseBMO allocationStorehouseBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "asId", "asId不能为空");
-        Assert.hasKeyAndValue(reqJson, "shIda", "请求报文中未包含shIda");
-        Assert.hasKeyAndValue(reqJson, "shIdz", "请求报文中未包含shIdz");
-        Assert.hasKeyAndValue(reqJson, "resId", "请求报文中未包含resId");
-        Assert.hasKeyAndValue(reqJson, "stock", "请求报文中未包含stock");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        allocationStorehouseBMOImpl.updateAllocationStorehouse(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeAllocationStorehouseConstant.UPDATE_ALLOCATIONSTOREHOUSE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-}

+ 0 - 50
service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateAllocationUserStorehouseListener.java

@@ -1,50 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.allocationUserStorehouse.IAllocationUserStorehouseBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeAllocationUserStorehouseConstant;
-import com.java110.utils.util.Assert;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存物品供应商侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("updateAllocationUserStorehouseListener")
-public class UpdateAllocationUserStorehouseListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IAllocationUserStorehouseBMO allocationUserStorehouseBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "ausId", "ausId不能为空");
-        Assert.hasKeyAndValue(reqJson, "resId", "请求报文中未包含resId");
-        Assert.hasKeyAndValue(reqJson, "stock", "请求报文中未包含stock");
-        Assert.hasKeyAndValue(reqJson, "acceptUserId", "请求报文中未包含acceptUserId");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        allocationUserStorehouseBMOImpl.updateAllocationUserStorehouse(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeAllocationUserStorehouseConstant.UPDATE_ALLOCATIONUSERSTOREHOUSE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-}

+ 0 - 50
service-api/src/main/java/com/java110/api/listener/resourceStore/UpdateUserStorehouseListener.java

@@ -1,50 +0,0 @@
-package com.java110.api.listener.resourceStore;
-
-import com.alibaba.fastjson.JSONObject;
-import com.java110.api.bmo.userStorehouse.IUserStorehouseBMO;
-import com.java110.api.listener.AbstractServiceApiPlusListener;
-import com.java110.core.annotation.Java110Listener;
-import com.java110.core.context.DataFlowContext;
-import com.java110.core.event.service.api.ServiceDataFlowEvent;
-import com.java110.utils.constant.ServiceCodeUserStorehouseConstant;
-import com.java110.utils.util.Assert;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpMethod;
-
-/**
- * 保存个人物品侦听
- * add by wuxw 2019-06-30
- */
-@Java110Listener("updateUserStorehouseListener")
-public class UpdateUserStorehouseListener extends AbstractServiceApiPlusListener {
-
-    @Autowired
-    private IUserStorehouseBMO userStorehouseBMOImpl;
-
-    @Override
-    protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
-
-        Assert.hasKeyAndValue(reqJson, "usId", "usId不能为空");
-        Assert.hasKeyAndValue(reqJson, "resId", "请求报文中未包含resId");
-        Assert.hasKeyAndValue(reqJson, "stock", "请求报文中未包含stock");
-        Assert.hasKeyAndValue(reqJson, "userId", "请求报文中未包含userId");
-        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
-
-    }
-
-    @Override
-    protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context, JSONObject reqJson) {
-
-        userStorehouseBMOImpl.updateUserStorehouse(reqJson, context);
-    }
-
-    @Override
-    public String getServiceCode() {
-        return ServiceCodeUserStorehouseConstant.UPDATE_USERSTOREHOUSE;
-    }
-
-    @Override
-    public HttpMethod getHttpMethod() {
-        return HttpMethod.POST;
-    }
-}

+ 313 - 0
service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationUserStorehouseCmd.java

@@ -0,0 +1,313 @@
+package com.java110.store.cmd.resourceStore;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.context.DataFlowContext;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.resourceStore.ResourceStoreDto;
+import com.java110.dto.userStorehouse.UserStorehouseDto;
+import com.java110.intf.store.*;
+import com.java110.po.allocationUserStorehouse.AllocationUserStorehousePo;
+import com.java110.po.resourceStoreUseRecord.ResourceStoreUseRecordPo;
+import com.java110.po.userStorehouse.UserStorehousePo;
+import com.java110.utils.constant.BusinessTypeConstant;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+
+@Java110Cmd(serviceCode = "resourceStore.saveAllocationUserStorehouse")
+public class SaveAllocationUserStorehouseCmd extends Cmd {
+
+    @Autowired
+    private IUserStorehouseInnerServiceSMO userStorehouseInnerServiceSMOImpl;
+
+    @Autowired
+    private IUserStorehouseV1InnerServiceSMO userStorehouseV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IResourceStoreInnerServiceSMO resourceStoreInnerServiceSMOImpl;
+
+    @Autowired
+    private IResourceStoreUseRecordV1InnerServiceSMO resourceStoreUseRecordV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IAllocationUserStorehouseV1InnerServiceSMO allocationUserStorehouseV1InnerServiceSMOImpl;
+
+
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
+        //Assert.hasKeyAndValue(reqJson, "acceptUserId", "请求报文中未包含acceptUserId");
+        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+        String userId = reqJson.getString("userId");
+        String acceptUserId = reqJson.getString("acceptUserId");
+        if(!StringUtil.isEmpty(userId) && !StringUtil.isEmpty(acceptUserId) && acceptUserId.equals(userId)){
+            ResponseEntity<String> responseEntity = ResultVo.createResponseEntity(ResultVo.CODE_ERROR, "物品接受人不能是本人,所以无法进行转赠操作!");
+            context.setResponseEntity(responseEntity);
+            return;
+        }
+
+        addAllocationUserStorehouse(reqJson,context);
+    }
+
+    public void addAllocationUserStorehouse(JSONObject paramInJson, ICmdDataFlowContext dataFlowContext) {
+        String resourceStores = paramInJson.getString("resourceStores");
+        JSONArray json = JSONArray.parseArray(resourceStores);
+        int flag1 = 0;
+        if (json.size() > 0) {
+            Object[] objects = json.toArray();
+            String flag = paramInJson.getString("flag");
+            if (!StringUtil.isEmpty(flag) && flag.equals("1")) { //损耗
+                for (int i = 0; i < objects.length; i++) {
+                    Object object = objects[i];
+                    JSONObject paramIn = JSONObject.parseObject(String.valueOf(object));
+                    ResourceStoreUseRecordPo resourceStoreUseRecordPo = new ResourceStoreUseRecordPo();
+                    resourceStoreUseRecordPo.setRsurId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_rsurId));
+                    resourceStoreUseRecordPo.setRepairId("-1"); //报修记录
+                    resourceStoreUseRecordPo.setResId(paramIn.getString("resId")); //物品资源id
+                    resourceStoreUseRecordPo.setCommunityId(paramInJson.getString("communityId")); //小区id
+                    resourceStoreUseRecordPo.setStoreId(paramInJson.getString("storeId")); //商户id
+                    resourceStoreUseRecordPo.setQuantity(paramIn.getString("giveQuantity")); //损耗数量
+                    //根据物品资源id查询物品资源信息
+                    ResourceStoreDto resourceStoreDto = new ResourceStoreDto();
+                    resourceStoreDto.setResId(paramIn.getString("resId"));
+                    List<ResourceStoreDto> resourceStoreDtos = resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto);
+                    Assert.listOnlyOne(resourceStoreDtos, "查询房屋信息错误!");
+                    resourceStoreUseRecordPo.setUnitPrice(resourceStoreDtos.get(0).getPrice()); //物品资源单价
+                    resourceStoreUseRecordPo.setCreateUserId(paramInJson.getString("userId")); //创建人id
+                    resourceStoreUseRecordPo.setCreateUserName(paramInJson.getString("userName")); //创建人名称
+                    resourceStoreUseRecordPo.setRemark(paramIn.getString("purchaseRemark")); //备注
+                    resourceStoreUseRecordPo.setResourceStoreName(paramIn.getString("resName")); //物品名称
+                    resourceStoreUseRecordPo.setState(paramIn.getString("state")); //1001 报废回收   2002 工单损耗   3003 公用损耗
+                    flag1 = resourceStoreUseRecordV1InnerServiceSMOImpl.saveResourceStoreUseRecord(resourceStoreUseRecordPo);
+                    if(flag1 <1){
+                        throw new CmdException("保存失败");
+                    }
+                    //个人物品处理
+                    UserStorehouseDto userStorehouseDto = new UserStorehouseDto();
+                    userStorehouseDto.setUserId(paramInJson.getString("userId"));
+                    userStorehouseDto.setResId(paramIn.getString("resId"));
+                    //查询个人物品信息
+                    List<UserStorehouseDto> userStorehouseDtos = userStorehouseInnerServiceSMOImpl.queryUserStorehouses(userStorehouseDto);
+                    Assert.listOnlyOne(userStorehouseDtos, "查询个人物品信息错误!");
+                    //获取个人物品信息id
+                    String usId = userStorehouseDtos.get(0).getUsId();
+                    //获取物品单位
+                    if (StringUtil.isEmpty(userStorehouseDtos.get(0).getUnitCode())) {
+                        throw new IllegalArgumentException("物品单位不能为空");
+                    }
+                    String unitCode = userStorehouseDtos.get(0).getUnitCode(); //物品单位
+                    //获取物品最小计量单位
+                    if (StringUtil.isEmpty(userStorehouseDtos.get(0).getMiniUnitCode())) {
+                        throw new IllegalArgumentException("物品最小计量单位不能为空");
+                    }
+                    String miniUnitCode = userStorehouseDtos.get(0).getMiniUnitCode(); //物品最小计量单位
+                    UserStorehousePo userStorehousePo = new UserStorehousePo();
+                    userStorehousePo.setUsId(usId); //个人物品id
+                    //获取最小单位计量总数
+                    String miniStock = userStorehouseDtos.get(0).getMiniStock();
+                    //获取最小计量单位数量
+                    String miniUnitStock = paramIn.getString("miniUnitStock");
+                    //获取报废数量
+                    String giveQuantity = paramIn.getString("giveQuantity");
+                    //除去报废个人物品剩余的最小单位计量总数
+                    BigDecimal num1 = new BigDecimal(miniStock);
+                    BigDecimal num2 = new BigDecimal(giveQuantity);
+                    BigDecimal quantity = num1.subtract(num2);
+                    if (quantity.doubleValue() == 0.0) { //如果减去报废后剩余0个,那么最小计量单位总数和物品数量都变为0
+                        userStorehousePo.setMiniStock("0");
+                        userStorehousePo.setStock("0");
+                    } else {
+                        userStorehousePo.setMiniStock(String.valueOf(quantity)); //减去报废后剩余的最小计量单位总数
+                        BigDecimal reduceNum = num1.subtract(num2);
+                        if (unitCode.equals(miniUnitCode)) { //如果物品单位与最小计量单位相同,就不向上取整
+                            userStorehousePo.setStock(String.valueOf(reduceNum));
+                        } else { //如果物品最小计量单位与物品单位不同,就向上取整
+                            //用转赠后最小计量总数除以最小计量单位数量,并向上取整,获取转赠后的库存数
+                            BigDecimal num3 = new BigDecimal(miniUnitStock);
+                            BigDecimal unitStock = reduceNum.divide(num3, 2, BigDecimal.ROUND_HALF_UP);
+                            Integer stockNumber = (int) Math.ceil(unitStock.doubleValue());
+                            userStorehousePo.setStock(String.valueOf(stockNumber)); //减去报废后剩余的个人物品数量
+                        }
+                    }
+                    flag1 = userStorehouseV1InnerServiceSMOImpl.updateUserStorehouse(userStorehousePo);
+                    if(flag1 <1){
+                        throw new CmdException("保存失败");
+                    }
+                }
+            } else { //退还
+                for (int i = 0; i < objects.length; i++) {
+                    Object object = objects[i];
+                    JSONObject paramIn = JSONObject.parseObject(String.valueOf(object));
+                    String stock = paramIn.getString("stock");
+                    //获取最小计量总数
+                    String miniStock = paramIn.getString("miniStock");
+                    //获取最小计量单位数量
+                    String miniUnitStock = paramIn.getString("miniUnitStock");
+                    //获取转赠数量
+                    String giveQuantity = paramIn.getString("giveQuantity");
+                    //获取物品id
+                    String resId = paramIn.getString("resId");
+                    //获取物品id
+                    String resCode = paramIn.getString("resCode");
+                    //获取物品名称
+                    String resName = paramIn.getString("resName");
+                    //获取当前用户id
+                    String userId = paramInJson.getString("userId");
+                    //获取接受转赠用户id
+                    String acceptUserId = paramInJson.getString("acceptUserId");
+                    //获取接受转赠用户名称
+                    String acceptUserName = paramInJson.getString("acceptUserName");
+                    //获取商户id
+                    String storeId = paramInJson.getString("storeId");
+                    JSONObject allocationUserStorehouseJson = new JSONObject();
+                    allocationUserStorehouseJson.put("ausId", "-1");
+                    allocationUserStorehouseJson.put("resId", resId);
+                    allocationUserStorehouseJson.put("resCode", resCode);
+                    allocationUserStorehouseJson.put("resName", resName);
+                    allocationUserStorehouseJson.put("storeId", storeId);
+                    allocationUserStorehouseJson.put("stock", stock);
+                    allocationUserStorehouseJson.put("giveQuantity", giveQuantity);
+                    allocationUserStorehouseJson.put("startUserId", userId);
+                    allocationUserStorehouseJson.put("startUserName", paramInJson.getString("userName"));
+                    allocationUserStorehouseJson.put("acceptUserId", acceptUserId);
+                    allocationUserStorehouseJson.put("acceptUserName", acceptUserName);
+                    allocationUserStorehouseJson.put("createTime", new Date());
+                    allocationUserStorehouseJson.put("remark", paramInJson.getString("description"));
+                    AllocationUserStorehousePo allocationUserStorehousePo = BeanConvertUtil.covertBean(allocationUserStorehouseJson, AllocationUserStorehousePo.class);
+                    flag1 = allocationUserStorehouseV1InnerServiceSMOImpl.saveAllocationUserStorehouse(allocationUserStorehousePo);
+                    if(flag1 <1){
+                        throw new CmdException("保存失败");
+                    }
+                    UserStorehouseDto userStorehouseDto = new UserStorehouseDto();
+                    userStorehouseDto.setUserId(userId);
+                    userStorehouseDto.setResId(resId);
+                    List<UserStorehouseDto> userStorehouseDtos = userStorehouseInnerServiceSMOImpl.queryUserStorehouses(userStorehouseDto);
+                    Assert.listOnlyOne(userStorehouseDtos, "查询个人物品信息错误!");
+                    //获取个人物品信息id
+                    String usId = userStorehouseDtos.get(0).getUsId();
+                    //获取物品单位
+                    if (StringUtil.isEmpty(userStorehouseDtos.get(0).getUnitCode())) {
+                        throw new IllegalArgumentException("物品单位不能为空");
+                    }
+                    String unitCode = userStorehouseDtos.get(0).getUnitCode();
+                    //获取物品最小计量单位
+                    if (StringUtil.isEmpty(userStorehouseDtos.get(0).getMiniUnitCode())) {
+                        throw new IllegalArgumentException("物品最小计量单位不能为空");
+                    }
+                    String miniUnitCode = userStorehouseDtos.get(0).getMiniUnitCode();
+                    UserStorehousePo userStorehousePo = new UserStorehousePo();
+                    userStorehousePo.setUsId(usId);
+                    //转赠后个人物品最小计量总数
+                    BigDecimal num1 = new BigDecimal(miniStock);
+                    BigDecimal num2 = new BigDecimal(giveQuantity);
+                    BigDecimal quantity = num1.subtract(num2);
+                    if (quantity.doubleValue() == 0.0) {
+                        userStorehousePo.setMiniStock("0");
+                        userStorehousePo.setStock("0");
+                    } else {
+                        userStorehousePo.setMiniStock(String.valueOf(quantity));
+                        BigDecimal reduceNum = num1.subtract(num2);
+                        if (unitCode.equals(miniUnitCode)) { //如果物品单位与最小计量单位相同,就不向上取整
+                            userStorehousePo.setStock(String.valueOf(reduceNum));
+                        } else { //如果物品最小计量单位与物品单位不同,就向上取整
+                            //用转赠后最小计量总数除以最小计量单位数量,并向上取整,获取转赠后的库存数
+                            BigDecimal num3 = new BigDecimal(miniUnitStock);
+                            BigDecimal unitStock = reduceNum.divide(num3, 2, BigDecimal.ROUND_HALF_UP);
+                            Integer stockNumber = (int) Math.ceil(unitStock.doubleValue());
+                            userStorehousePo.setStock(String.valueOf(stockNumber));
+                        }
+                    }
+                    //更新当前用户库存数
+                    flag1 = userStorehouseV1InnerServiceSMOImpl.updateUserStorehouse(userStorehousePo);
+                    if(flag1 <1){
+                        throw new CmdException("保存失败");
+                    }
+                    UserStorehouseDto userStorehouse = new UserStorehouseDto();
+                    userStorehouse.setUserId(acceptUserId);
+                    userStorehouse.setResCode(resCode);
+                    //查询接受转赠人的个人物品信息
+                    List<UserStorehouseDto> userStorehouses = userStorehouseInnerServiceSMOImpl.queryUserStorehouses(userStorehouse);
+                    if (userStorehouses != null && userStorehouses.size() == 1) {
+                        UserStorehousePo userStorePo = new UserStorehousePo();
+                        //计算接受用户的最小计量总数
+                        BigDecimal num4 = new BigDecimal(userStorehouses.get(0).getMiniStock());
+                        BigDecimal num5 = new BigDecimal(giveQuantity);
+                        BigDecimal addNum = num4.add(num5);
+                        BigDecimal acceptMiniStock = num4.add(num5);
+                        userStorePo.setMiniStock(String.valueOf(acceptMiniStock));
+                        //获取物品单位
+                        if (StringUtil.isEmpty(userStorehouses.get(0).getUnitCode())) {
+                            throw new IllegalArgumentException("物品单位不能为空");
+                        }
+                        String unitCode1 = userStorehouses.get(0).getUnitCode();
+                        //获取物品最小计量单位
+                        if (StringUtil.isEmpty(userStorehouses.get(0).getMiniUnitCode())) {
+                            throw new IllegalArgumentException("物品最小计量单位不能为空");
+                        }
+                        String miniUnitCode1 = userStorehouses.get(0).getMiniUnitCode();
+                        //计算接受用户的库存数量
+                        BigDecimal num6 = new BigDecimal(miniUnitStock);
+                        BigDecimal unitStock = addNum.divide(num6, 2, BigDecimal.ROUND_HALF_UP);
+                        if (unitCode1.equals(miniUnitCode1)) { //如果物品单位与物品最小计量单位相同,就不向上取整
+                            //如果物品单位与最小计量单位相同,物品库存就等于最小计量总数
+                            userStorePo.setStock(String.valueOf(acceptMiniStock));
+                        } else { //如果物品单位与物品最小计量单位不同,就向上取整
+                            Integer stockNumber = (int) Math.ceil(unitStock.doubleValue());
+                            userStorePo.setStock(String.valueOf(stockNumber));
+                        }
+                        userStorePo.setUsId(userStorehouses.get(0).getUsId());
+                        //更新当前用户的库存数量
+                        flag1 = userStorehouseV1InnerServiceSMOImpl.updateUserStorehouse(userStorePo);
+                        if(flag1 <1){
+                            throw new CmdException("保存失败");
+                        }
+                    } else if (userStorehouses != null && userStorehouses.size() > 1) {
+                        throw new IllegalArgumentException("查询个人物品信息错误!");
+                    } else {
+                        //计算转赠后库存数量
+                        BigDecimal num7 = new BigDecimal(giveQuantity);
+                        BigDecimal num8 = new BigDecimal(miniUnitStock);
+                        BigDecimal unitStock = num7.divide(num8, 2, BigDecimal.ROUND_HALF_UP);
+                        UserStorehousePo userStorePo = new UserStorehousePo();
+                        userStorePo.setUsId("-1");
+                        userStorePo.setResId(resId);
+                        userStorePo.setResName(resName);
+                        userStorePo.setStoreId(storeId);
+                        userStorePo.setResCode(resCode);
+                        if (unitCode.equals(miniUnitCode)) { //如果物品单位与物品最小计量单位相同,就不向上取整
+                            userStorePo.setStock(String.valueOf(num7));
+                        } else { //如果物品单位与物品最小计量单位不同,就向上取整
+                            Integer stockNumber = (int) Math.ceil(unitStock.doubleValue());
+                            userStorePo.setStock(String.valueOf(stockNumber));
+                        }
+                        userStorePo.setMiniStock(giveQuantity);
+                        userStorePo.setUserId(acceptUserId);
+                        //保存接受转赠用户个人物品信息
+                        flag1 = userStorehouseV1InnerServiceSMOImpl.updateUserStorehouse(userStorePo);
+                        if(flag1 <1){
+                            throw new CmdException("保存失败");
+                        }                    }
+                }
+            }
+        }
+    }
+}

+ 77 - 0
service-store/src/main/java/com/java110/store/dao/IAllocationUserStorehouseV1ServiceDao.java

@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.store.dao;
+
+
+import com.java110.utils.exception.DAOException;
+import com.java110.entity.merchant.BoMerchant;
+import com.java110.entity.merchant.BoMerchantAttr;
+import com.java110.entity.merchant.Merchant;
+import com.java110.entity.merchant.MerchantAttr;
+
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 类表述:
+ * add by 吴学文 at 2022-08-08 16:22:31 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+public interface IAllocationUserStorehouseV1ServiceDao {
+
+
+    /**
+     * 保存 用户仓库信息
+     * @param info
+     * @throws DAOException DAO异常
+     */
+    int saveAllocationUserStorehouseInfo(Map info) throws DAOException;
+
+
+
+
+    /**
+     * 查询用户仓库信息(instance过程)
+     * 根据bId 查询用户仓库信息
+     * @param info bId 信息
+     * @return 用户仓库信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getAllocationUserStorehouseInfo(Map info) throws DAOException;
+
+
+
+    /**
+     * 修改用户仓库信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    int updateAllocationUserStorehouseInfo(Map info) throws DAOException;
+
+
+    /**
+     * 查询用户仓库总数
+     *
+     * @param info 用户仓库信息
+     * @return 用户仓库数量
+     */
+    int queryAllocationUserStorehousesCount(Map info);
+
+}

+ 112 - 0
service-store/src/main/java/com/java110/store/dao/impl/AllocationUserStorehouseV1ServiceDaoImpl.java

@@ -0,0 +1,112 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.store.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.util.DateUtil;
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.store.dao.IAllocationUserStorehouseV1ServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 类表述:
+ * add by 吴学文 at 2022-08-08 16:22:31 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@Service("allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl")
+public class AllocationUserStorehouseV1ServiceDaoImpl extends BaseServiceDao implements IAllocationUserStorehouseV1ServiceDao {
+
+    private static Logger logger = LoggerFactory.getLogger(AllocationUserStorehouseV1ServiceDaoImpl.class);
+
+
+
+
+
+    /**
+     * 保存用户仓库信息 到 instance
+     * @param info   bId 信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public int saveAllocationUserStorehouseInfo(Map info) throws DAOException {
+        logger.debug("保存 saveAllocationUserStorehouseInfo 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.saveAllocationUserStorehouseInfo",info);
+
+        return saveFlag;
+    }
+
+
+    /**
+     * 查询用户仓库信息(instance)
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getAllocationUserStorehouseInfo(Map info) throws DAOException {
+        logger.debug("查询 getAllocationUserStorehouseInfo 入参 info : {}",info);
+
+        List<Map> businessAllocationUserStorehouseInfos = sqlSessionTemplate.selectList("allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.getAllocationUserStorehouseInfo",info);
+
+        return businessAllocationUserStorehouseInfos;
+    }
+
+
+    /**
+     * 修改用户仓库信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public int updateAllocationUserStorehouseInfo(Map info) throws DAOException {
+        logger.debug("修改 updateAllocationUserStorehouseInfo 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.update("allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.updateAllocationUserStorehouseInfo",info);
+
+        return saveFlag;
+    }
+
+     /**
+     * 查询用户仓库数量
+     * @param info 用户仓库信息
+     * @return 用户仓库数量
+     */
+    @Override
+    public int queryAllocationUserStorehousesCount(Map info) {
+        logger.debug("查询 queryAllocationUserStorehousesCount 入参 info : {}",info);
+
+        List<Map> businessAllocationUserStorehouseInfos = sqlSessionTemplate.selectList("allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.queryAllocationUserStorehousesCount", info);
+        if (businessAllocationUserStorehouseInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessAllocationUserStorehouseInfos.get(0).get("count").toString());
+    }
+
+
+}

+ 89 - 0
service-store/src/main/java/com/java110/store/smo/impl/AllocationUserStorehouseV1InnerServiceSMOImpl.java

@@ -0,0 +1,89 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.store.smo.impl;
+
+
+import com.java110.dto.allocationUserStorehouse.AllocationUserStorehouseDto;
+import com.java110.po.allocationUserStorehouse.AllocationUserStorehousePo;
+import com.java110.store.dao.IAllocationUserStorehouseV1ServiceDao;
+import com.java110.intf.store.IAllocationUserStorehouseV1InnerServiceSMO;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.dto.user.UserDto;
+import com.java110.dto.PageDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 类表述: 服务之前调用的接口实现类,不对外提供接口能力 只用于接口建调用
+ * add by 吴学文 at 2022-08-08 16:22:31 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@RestController
+public class AllocationUserStorehouseV1InnerServiceSMOImpl extends BaseServiceSMO implements IAllocationUserStorehouseV1InnerServiceSMO {
+
+    @Autowired
+    private IAllocationUserStorehouseV1ServiceDao allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl;
+
+
+    @Override
+    public int saveAllocationUserStorehouse(@RequestBody AllocationUserStorehousePo allocationUserAllocationUserStorehousehousePo) {
+        int saveFlag = allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.saveAllocationUserStorehouseInfo(BeanConvertUtil.beanCovertMap(allocationUserAllocationUserStorehousehousePo));
+        return saveFlag;
+    }
+
+     @Override
+    public int updateAllocationUserStorehouse(@RequestBody  AllocationUserStorehousePo allocationUserAllocationUserStorehousehousePo) {
+        int saveFlag = allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.updateAllocationUserStorehouseInfo(BeanConvertUtil.beanCovertMap(allocationUserAllocationUserStorehousehousePo));
+        return saveFlag;
+    }
+
+     @Override
+    public int deleteAllocationUserStorehouse(@RequestBody  AllocationUserStorehousePo allocationUserAllocationUserStorehousehousePo) {
+       allocationUserAllocationUserStorehousehousePo.setStatusCd("1");
+       int saveFlag = allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.updateAllocationUserStorehouseInfo(BeanConvertUtil.beanCovertMap(allocationUserAllocationUserStorehousehousePo));
+       return saveFlag;
+    }
+
+    @Override
+    public List<AllocationUserStorehouseDto> queryAllocationUserStorehouses(@RequestBody  AllocationUserStorehouseDto allocationUserAllocationUserStorehousehouseDto) {
+
+        //校验是否传了 分页信息
+
+        int page = allocationUserAllocationUserStorehousehouseDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            allocationUserAllocationUserStorehousehouseDto.setPage((page - 1) * allocationUserAllocationUserStorehousehouseDto.getRow());
+        }
+
+        List<AllocationUserStorehouseDto> allocationUserAllocationUserStorehousehouses = BeanConvertUtil.covertBeanList(allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.getAllocationUserStorehouseInfo(BeanConvertUtil.beanCovertMap(allocationUserAllocationUserStorehousehouseDto)), AllocationUserStorehouseDto.class);
+
+        return allocationUserAllocationUserStorehousehouses;
+    }
+
+
+    @Override
+    public int queryAllocationUserStorehousesCount(@RequestBody AllocationUserStorehouseDto allocationUserAllocationUserStorehousehouseDto) {
+        return allocationUserAllocationUserStorehousehouseV1ServiceDaoImpl.queryAllocationUserStorehousesCount(BeanConvertUtil.beanCovertMap(allocationUserAllocationUserStorehousehouseDto));    }
+
+}