java110 2 роки тому
батько
коміт
1b293634db

+ 12 - 0
java110-bean/src/main/java/com/java110/dto/purchase/AllocationStorehouseDto.java

@@ -1,9 +1,11 @@
 package com.java110.dto.purchase;
 
 import com.java110.dto.PageDto;
+import com.java110.dto.resource.ResourceStoreTimesDto;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @ClassName FloorDto
@@ -67,6 +69,8 @@ public class AllocationStorehouseDto extends PageDto implements Serializable {
     private String isFixedName;
     private String timesId;
 
+    private List<ResourceStoreTimesDto> times;
+
     public String getAsId() {
         return asId;
     }
@@ -412,4 +416,12 @@ public class AllocationStorehouseDto extends PageDto implements Serializable {
     public void setTimesId(String timesId) {
         this.timesId = timesId;
     }
+
+    public List<ResourceStoreTimesDto> getTimes() {
+        return times;
+    }
+
+    public void setTimes(List<ResourceStoreTimesDto> times) {
+        this.times = times;
+    }
 }

+ 8 - 6
java110-db/src/main/resources/mapper/store/AllocationStorehouseV1ServiceDaoImplMapper.xml

@@ -85,18 +85,14 @@
         <if test="remark !=null and remark != ''">
             , t.remark= #{remark}
         </if>
-        <if test="storeId !=null and storeId != ''">
-            , t.store_id= #{storeId}
-        </if>
+
         <if test="resId !=null and resId != ''">
             , t.res_id= #{resId}
         </if>
         <if test="shIdz !=null and shIdz != ''">
             , t.sh_id_z= #{shIdz}
         </if>
-        <if test="applyId !=null and applyId != ''">
-            , t.apply_id= #{applyId}
-        </if>
+
         <if test="resName !=null and resName != ''">
             , t.res_name= #{resName}
         </if>
@@ -122,6 +118,12 @@
         <if test="timesId !=null and timesId != ''">
             and t.times_id= #{timesId}
         </if>
+        <if test="applyId !=null and applyId != ''">
+            and t.apply_id= #{applyId}
+        </if>
+        <if test="storeId !=null and storeId != ''">
+            and t.store_id= #{storeId}
+        </if>
 
     </update>
 

+ 101 - 34
service-common/src/main/java/com/java110/common/cmd/auditUser/ListItemOutAuditHistoryOrdersCmd.java

@@ -5,12 +5,19 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.oaWorkflow.OaWorkflowDto;
+import com.java110.dto.oaWorkflow.WorkflowDto;
 import com.java110.dto.purchase.PurchaseApplyDto;
 import com.java110.dto.audit.AuditUser;
 import com.java110.intf.common.IGoodCollectionUserInnerServiceSMO;
+import com.java110.intf.common.IOaWorkflowActivitiInnerServiceSMO;
+import com.java110.intf.common.IResourceEntryStoreInnerServiceSMO;
+import com.java110.intf.oa.IOaWorkflowInnerServiceSMO;
+import com.java110.intf.store.IPurchaseApplyInnerServiceSMO;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.ResultVo;
 import com.java110.vo.api.resourceOrder.ApiResourceOrderDataVo;
 import com.java110.vo.api.resourceOrder.ApiResourceOrderVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +33,22 @@ public class ListItemOutAuditHistoryOrdersCmd extends Cmd {
     @Autowired
     private IGoodCollectionUserInnerServiceSMO goodCollectionUserInnerServiceSMOImpl;
 
+    @Autowired
+    private IResourceEntryStoreInnerServiceSMO resourceEntryStoreInnerServiceSMOImpl;
+
+    @Autowired
+    private IOaWorkflowActivitiInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl;
+
+    @Autowired
+    private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl;
+
+    @Autowired
+    private IPurchaseApplyInnerServiceSMO purchaseApplyInnerServiceSMOImpl;
+
+    @Autowired
+    private IOaWorkflowActivitiInnerServiceSMO oaWorkflowActivitiInnerServiceSMOImpl;
+
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         Assert.hasKeyAndValue(reqJson, "storeId", "必填,请填写商户ID");
@@ -38,51 +61,95 @@ public class ListItemOutAuditHistoryOrdersCmd extends Cmd {
 
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+        String userId = context.getReqHeaders().get("user-id");
+        String storeId = context.getReqHeaders().get("store-id");
+
+        OaWorkflowDto oaWorkflowDto = new OaWorkflowDto();
+        oaWorkflowDto.setState(OaWorkflowDto.STATE_COMPLAINT);
+        oaWorkflowDto.setFlowType(OaWorkflowDto.FLOW_TYPE_RESOURCE_OUT);
+        List<OaWorkflowDto> oaWorkflowDtos = oaWorkflowInnerServiceSMOImpl.queryOaWorkflows(oaWorkflowDto);
+
+        if (oaWorkflowDtos == null || oaWorkflowDtos.size() < 1) {
+            return;
+        }
+        List<String> flowIds = new ArrayList<>();
+        for (OaWorkflowDto tmpOaWorkflowDto : oaWorkflowDtos) {
+            flowIds.add(WorkflowDto.DEFAULT_PROCESS + tmpOaWorkflowDto.getFlowId());
+        }
+
         AuditUser auditUser = new AuditUser();
-        auditUser.setUserId(reqJson.getString("userId"));
+        auditUser.setProcessDefinitionKeys(flowIds);
+        auditUser.setUserId(userId);
+        auditUser.setStoreId(storeId);
         auditUser.setPage(reqJson.getInteger("page"));
         auditUser.setRow(reqJson.getInteger("row"));
-        auditUser.setStoreId(reqJson.getString("storeId"));
-        auditUser.setCommunityId(reqJson.getString("communityId"));
 
-        long count = goodCollectionUserInnerServiceSMOImpl.getUserHistoryTaskCount(auditUser);
-        //领用已办(默认只查询和当前登录用户相关并且是参与流程审批或者自己提交已经结束的审批数据)
-        List<ApiResourceOrderDataVo> auditOrders = null;
+        long count = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserHistoryTaskCount(auditUser);
 
-        if (count > 0) {
-            List<PurchaseApplyDto> purchaseApplyDtos = goodCollectionUserInnerServiceSMOImpl.getUserHistoryTasks(auditUser);
-            auditOrders = BeanConvertUtil.covertBeanList(purchaseApplyDtos, ApiResourceOrderDataVo.class);
-            for (ApiResourceOrderDataVo apiResourceOrderDataVo : auditOrders) {
-                switch (apiResourceOrderDataVo.getState()) {
-                    case "1000":
-                        apiResourceOrderDataVo.setStateName("待审核");
-                        break;
-                    case "1001":
-                        apiResourceOrderDataVo.setStateName("审核中");
-                        break;
-                    case "1002":
-                        apiResourceOrderDataVo.setStateName("已审核");
-                        break;
-                }
-                if (apiResourceOrderDataVo.getResOrderType().equals("10000")) {
-                    apiResourceOrderDataVo.setResOrderTypeName("采购申请");
-                } else {
-                    apiResourceOrderDataVo.setResOrderTypeName("出库申请");
-                }
+        List<JSONObject> datas = null;
 
-            }
+        if (count > 0) {
+            datas = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserHistoryTasks(auditUser);
+            //刷新 表单数据
+            refreshFormData(datas, reqJson, storeId);
         } else {
-            auditOrders = new ArrayList<>();
+            datas = new ArrayList<>();
         }
 
-        ApiResourceOrderVo apiResourceOrderVo = new ApiResourceOrderVo();
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, datas);
 
-        apiResourceOrderVo.setTotal((int) count);
-        apiResourceOrderVo.setRecords((int) Math.ceil((double) count / (double) reqJson.getInteger("row")));
-        apiResourceOrderVo.setResourceOrders(auditOrders);
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        context.setResponseEntity(responseEntity);
+    }
 
-        ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiResourceOrderVo), HttpStatus.OK);
+    private void refreshFormData(List<JSONObject> datas, JSONObject paramIn, String storeId) {
 
-        context.setResponseEntity(responseEntity);
+        List<String> ids = new ArrayList<>();
+        for (JSONObject data : datas) {
+            ids.add(data.getString("id"));
+        }
+        if (ids.size() < 1) {
+            return;
+        }
+
+        //todo 查询 领用
+        PurchaseApplyDto purchaseApplyDto = new PurchaseApplyDto();
+        purchaseApplyDto.setStoreId(storeId);
+        purchaseApplyDto.setApplyOrderIds(ids.toArray(new String[ids.size()]));
+        List<PurchaseApplyDto> tmpPurchaseApplyDtos = purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyAndDetails(purchaseApplyDto);
+
+        if (tmpPurchaseApplyDtos == null || tmpPurchaseApplyDtos.size() < 1) {
+            return;
+        }
+
+        for (PurchaseApplyDto tmpPurchaseApplyDto : tmpPurchaseApplyDtos) {
+            switch (tmpPurchaseApplyDto.getState()) {
+                case "1000":
+                    tmpPurchaseApplyDto.setStateName("待审核");
+                    break;
+                case "1001":
+                    tmpPurchaseApplyDto.setStateName("审核中");
+                    break;
+                case "1002":
+                    tmpPurchaseApplyDto.setStateName("已审核");
+                    break;
+            }
+            if (tmpPurchaseApplyDto.getResOrderType().equals("10000")) {
+                tmpPurchaseApplyDto.setResOrderTypeName("采购申请");
+            } else {
+                tmpPurchaseApplyDto.setResOrderTypeName("出库申请");
+            }
+
+
+        }
+        JSONObject curTaskNode = null;
+        for (JSONObject data : datas) {
+
+            for (PurchaseApplyDto form : tmpPurchaseApplyDtos) {
+                if (data.getString("id").equals(form.getApplyOrderId())) {
+                    data.putAll(BeanConvertUtil.beanCovertJson(form));
+                }
+            }
+        }
     }
 }

+ 100 - 11
service-store/src/main/java/com/java110/store/cmd/resourceStore/ListAllocationStoreHisAuditOrdersCmd.java

@@ -5,13 +5,21 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.dto.oaWorkflow.OaWorkflowDto;
+import com.java110.dto.oaWorkflow.WorkflowDto;
 import com.java110.dto.purchase.AllocationStorehouseApplyDto;
 import com.java110.dto.audit.AuditUser;
 import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
+import com.java110.intf.common.IOaWorkflowActivitiInnerServiceSMO;
+import com.java110.intf.common.IWorkflowStepStaffInnerServiceSMO;
+import com.java110.intf.oa.IOaWorkflowInnerServiceSMO;
+import com.java110.intf.store.IAllocationStorehouseApplyInnerServiceSMO;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 
 import java.text.ParseException;
@@ -24,6 +32,21 @@ public class ListAllocationStoreHisAuditOrdersCmd extends Cmd {
     @Autowired
     private IAllocationStorehouseUserInnerServiceSMO allocationStorehouseUserInnerServiceSMOImpl;
 
+
+    @Autowired
+    private IWorkflowStepStaffInnerServiceSMO workflowStepStaffInnerServiceSMOImpl;
+
+    @Autowired
+    private IOaWorkflowActivitiInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl;
+
+    @Autowired
+    private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl;
+
+    @Autowired
+    private IOaWorkflowActivitiInnerServiceSMO oaWorkflowActivitiInnerServiceSMOImpl;
+
+    @Autowired
+    private IAllocationStorehouseApplyInnerServiceSMO allocationStorehouseApplyInnerServiceSMOImpl;
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         Assert.hasKeyAndValue(reqJson, "storeId", "必填,请填写商户ID");
@@ -36,26 +59,92 @@ public class ListAllocationStoreHisAuditOrdersCmd extends Cmd {
 
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+
+        String userId = context.getReqHeaders().get("user-id");
+        String storeId = context.getReqHeaders().get("store-id");
+
+        OaWorkflowDto oaWorkflowDto = new OaWorkflowDto();
+        oaWorkflowDto.setState(OaWorkflowDto.STATE_COMPLAINT);
+        oaWorkflowDto.setFlowType(OaWorkflowDto.FLOW_TYPE_ALLOCATION);
+        List<OaWorkflowDto> oaWorkflowDtos = oaWorkflowInnerServiceSMOImpl.queryOaWorkflows(oaWorkflowDto);
+
+        if (oaWorkflowDtos == null || oaWorkflowDtos.size() < 1) {
+            return;
+        }
+        List<String> flowIds = new ArrayList<>();
+        for (OaWorkflowDto tmpOaWorkflowDto : oaWorkflowDtos) {
+            flowIds.add(WorkflowDto.DEFAULT_PROCESS + tmpOaWorkflowDto.getFlowId());
+        }
+
         AuditUser auditUser = new AuditUser();
-        auditUser.setUserId(reqJson.getString("userId"));
+        auditUser.setProcessDefinitionKeys(flowIds);
+        auditUser.setUserId(userId);
+        auditUser.setStoreId(storeId);
         auditUser.setPage(reqJson.getInteger("page"));
         auditUser.setRow(reqJson.getInteger("row"));
-        auditUser.setStoreId(reqJson.getString("storeId"));
-        //调拨已办((默认只查询和当前登录用户相关并且是参与流程审批或者自己提交已经结束的审批数据))
-        long count = allocationStorehouseUserInnerServiceSMOImpl.getUserHistoryTaskCount(auditUser);
 
-        List<AllocationStorehouseApplyDto> purchaseApplyDtos = null;
+        long count = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserHistoryTaskCount(auditUser);
+
+        List<JSONObject> datas = null;
 
         if (count > 0) {
-            purchaseApplyDtos = allocationStorehouseUserInnerServiceSMOImpl.getUserHistoryTasks(auditUser);
+            datas = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserHistoryTasks(auditUser);
+            //刷新 表单数据
+            refreshFormData(datas, reqJson, storeId);
         } else {
-            purchaseApplyDtos = new ArrayList<>();
+            datas = new ArrayList<>();
         }
 
-        ResponseEntity responseEntity
-                = ResultVo.createResponseEntity((int) Math.ceil((double) count / (double) reqJson.getInteger("row")),
-                (int) count,
-                purchaseApplyDtos);
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, datas);
+
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
         context.setResponseEntity(responseEntity);
+
+    }
+
+    private void refreshFormData(List<JSONObject> datas, JSONObject paramIn, String storeId) {
+
+        List<String> ids = new ArrayList<>();
+        for (JSONObject data : datas) {
+            ids.add(data.getString("id"));
+        }
+        if (ids.size() < 1) {
+            return;
+        }
+
+        //查询 投诉信息
+        AllocationStorehouseApplyDto allocationStorehouseApplyDto = new AllocationStorehouseApplyDto();
+        allocationStorehouseApplyDto.setStoreId(storeId);
+        allocationStorehouseApplyDto.setApplyIds(ids.toArray(new String[ids.size()]));
+        List<AllocationStorehouseApplyDto> tmpAllocationStorehouseApplyDtos
+                = allocationStorehouseApplyInnerServiceSMOImpl.queryAllocationStorehouseApplys(allocationStorehouseApplyDto);
+
+
+        if (tmpAllocationStorehouseApplyDtos == null || tmpAllocationStorehouseApplyDtos.size() < 1) {
+            return;
+        }
+
+        for (AllocationStorehouseApplyDto tmpAllocationStorehouseApplyDto : tmpAllocationStorehouseApplyDtos) {
+            switch (tmpAllocationStorehouseApplyDto.getState()) {
+                case "1000":
+                    tmpAllocationStorehouseApplyDto.setStateName("待审核");
+                    break;
+                case "1001":
+                    tmpAllocationStorehouseApplyDto.setStateName("审核中");
+                    break;
+                case "1002":
+                    tmpAllocationStorehouseApplyDto.setStateName("已审核");
+                    break;
+            }
+        }
+        JSONObject curTaskNode = null;
+        for (JSONObject data : datas) {
+
+            for (AllocationStorehouseApplyDto form : tmpAllocationStorehouseApplyDtos) {
+                if (data.getString("id").equals(form.getApplyId())) {
+                    data.putAll(BeanConvertUtil.beanCovertJson(form));
+                }
+            }
+        }
     }
 }

+ 4 - 1
service-store/src/main/java/com/java110/store/cmd/resourceStore/ListAllocationStorehouseApplysCmd.java

@@ -21,6 +21,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * 查询调拨记录
+ */
 @Java110Cmd(serviceCode = "resourceStore.listAllocationStorehouseApplys")
 public class ListAllocationStorehouseApplysCmd extends Cmd {
 
@@ -45,7 +48,7 @@ public class ListAllocationStorehouseApplysCmd extends Cmd {
         basePrivilegeDto.setResource("/viewlistAllocationStorehouses");
         basePrivilegeDto.setUserId(userId);
         List<Map> privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
-        if (privileges.size()==0) {
+        if (privileges.size() == 0) {
             allocationStorehouseApplyDto.setStartUserId(userId);
         }
         int count = allocationStorehouseApplyInnerServiceSMOImpl.queryAllocationStorehouseApplysCount(allocationStorehouseApplyDto);

+ 6 - 0
service-store/src/main/java/com/java110/store/cmd/resourceStore/SaveAllocationStorehouseCmd.java

@@ -213,6 +213,8 @@ public class SaveAllocationStorehouseCmd extends Cmd {
 
         //封装调拨对象
         AllocationStorehouseApplyPo allocationStorehouseApplyPo = covertAllocationStorehouseApply(reqJson);
+        //todo 默认写0 后面 相加
+        allocationStorehouseApplyPo.setApplyCount("0");
         JSONArray resourceStores = reqJson.getJSONArray("resourceStores");
         JSONObject resObj = null;
         for (int resIndex = 0; resIndex < resourceStores.size(); resIndex++) {
@@ -604,6 +606,10 @@ public class SaveAllocationStorehouseCmd extends Cmd {
         if (flag < 1) {
             throw new CmdException("保存调拨物品失败");
         }
+
+        int applyCount = Integer.parseInt(allocationStorehouseApplyPo.getApplyCount());
+        applyCount += resObj.getIntValue("curStock");
+        allocationStorehouseApplyPo.setApplyCount(applyCount + "");
     }
 
     /**

+ 201 - 0
service-store/src/main/java/com/java110/store/cmd/resourceStore/UpdateAllocationStorehouseCmd.java

@@ -0,0 +1,201 @@
+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.annotation.Java110Transactional;
+import com.java110.core.context.CmdContextUtils;
+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.oaWorkflow.OaWorkflowDto;
+import com.java110.dto.purchase.AllocationStorehouseApplyDto;
+import com.java110.dto.purchase.AllocationStorehouseDto;
+import com.java110.dto.resource.ResourceStoreDto;
+import com.java110.dto.resource.ResourceStoreTimesDto;
+import com.java110.dto.store.StorehouseDto;
+import com.java110.dto.user.UserDto;
+import com.java110.dto.user.UserStorehouseDto;
+import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO;
+import com.java110.intf.common.IOaWorkflowActivitiInnerServiceSMO;
+import com.java110.intf.oa.IOaWorkflowInnerServiceSMO;
+import com.java110.intf.store.*;
+import com.java110.intf.user.IUserV1InnerServiceSMO;
+import com.java110.po.purchase.AllocationStorehouseApplyPo;
+import com.java110.po.purchase.AllocationStorehousePo;
+import com.java110.po.purchase.ResourceStorePo;
+import com.java110.po.resource.ResourceStoreTimesPo;
+import com.java110.po.user.UserStorehousePo;
+import com.java110.store.bmo.allocation.IAllocationBMO;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.lock.DistributedLock;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 修改调拨申请
+ */
+@Java110Cmd(serviceCode = "resourceStore.updateAllocationStorehouse")
+public class UpdateAllocationStorehouseCmd extends Cmd {
+
+    @Autowired
+    private IResourceStoreInnerServiceSMO resourceStoreInnerServiceSMOImpl;
+
+    @Autowired
+    private IAllocationStorehouseUserInnerServiceSMO allocationStorehouseUserInnerServiceSMOImpl;
+
+    @Autowired
+    private IAllocationStorehouseApplyV1InnerServiceSMO allocationStorehouseApplyV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IAllocationStorehouseV1InnerServiceSMO allocationStorehouseV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IResourceStoreV1InnerServiceSMO resourceStoreV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IUserStorehouseV1InnerServiceSMO userStorehouseV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
+
+
+    @Autowired
+    private IStorehouseV1InnerServiceSMO storehouseV1InnerServiceSMOImpl;
+
+
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+        Assert.hasKeyAndValue(reqJson, "remark", "请求报文中未包含申请信息");
+        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含storeId");
+        if (!reqJson.containsKey("resourceStores")) {
+            throw new IllegalArgumentException("请求报文中未包含物品信息");
+        }
+        JSONArray resourceStores = reqJson.getJSONArray("resourceStores");
+        if (resourceStores == null || resourceStores.size() < 1) {
+            throw new IllegalArgumentException("请求报文中未包含物品信息");
+        }
+        //todo 校验 物品是否存在
+        for (int resIndex = 0; resIndex < resourceStores.size(); resIndex++) {
+            //主要用来校验库存够不够
+            ResourceStoreDto resourceStoreDto = new ResourceStoreDto();
+            resourceStoreDto.setStoreId(reqJson.getString("storeId"));
+            resourceStoreDto.setResId(resourceStores.getJSONObject(resIndex).getString("resId"));
+            resourceStoreDto.setShId(resourceStores.getJSONObject(resIndex).getString("shId"));
+            List<ResourceStoreDto> resourceStoreDtos = resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto);
+            Assert.listOnlyOne(resourceStoreDtos, "未包含 物品信息");
+            double stockA = Double.parseDouble(resourceStoreDtos.get(0).getStock());
+            double stockB = Double.parseDouble(resourceStores.getJSONObject(resIndex).getString("curStock"));
+            if (stockA < stockB) {
+                throw new IllegalArgumentException("库存不足");
+            }
+            resourceStores.getJSONObject(resIndex).put("resName", resourceStoreDtos.get(0).getResName());
+            resourceStores.getJSONObject(resIndex).put("stockA", stockA);
+        }
+    }
+
+
+    /**
+     * 调拨申请-调拨申请发起
+     *
+     * @param event              事件对象
+     * @param cmdDataFlowContext
+     * @param reqJson            请求报文
+     * @throws CmdException
+     */
+    @Override
+    @Java110Transactional
+    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+        int flag = 0;
+
+        // 查询用户名称
+        UserDto userDto = new UserDto();
+        userDto.setUserId(reqJson.getString("userId"));
+        List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
+
+        Assert.listOnlyOne(userDtos, "用户不存在");
+        reqJson.put("userName", userDtos.get(0).getName());
+
+        //封装调拨对象
+        AllocationStorehouseApplyPo allocationStorehouseApplyPo = covertAllocationStorehouseApply(reqJson);
+        //todo 默认写0 后面 相加
+        allocationStorehouseApplyPo.setApplyCount("0");
+
+        //todo 删除 老的 调拨物品
+        AllocationStorehousePo allocationStorehousePo = new AllocationStorehousePo();
+        allocationStorehousePo.setApplyId(allocationStorehouseApplyPo.getApplyId());
+        allocationStorehouseV1InnerServiceSMOImpl.deleteAllocationStorehouse(allocationStorehousePo);
+        JSONArray resourceStores = reqJson.getJSONArray("resourceStores");
+        JSONObject resObj = null;
+        for (int resIndex = 0; resIndex < resourceStores.size(); resIndex++) {
+            //处理 物品信息
+            resObj = resourceStores.getJSONObject(resIndex);
+            //todo 记录明细
+            saveAllocationStorehouse(reqJson, allocationStorehouseApplyPo, resObj);
+
+        }
+        flag = allocationStorehouseApplyV1InnerServiceSMOImpl.updateAllocationStorehouseApply(allocationStorehouseApplyPo);
+        if (flag < 1) {
+            throw new CmdException("保存修改物品失败");
+        }
+
+
+        cmdDataFlowContext.setResponseEntity(ResultVo.success());
+    }
+    private void saveAllocationStorehouse(JSONObject reqJson, AllocationStorehouseApplyPo allocationStorehouseApplyPo, JSONObject resObj) {
+        AllocationStorehousePo allocationStorehousePo = new AllocationStorehousePo();
+        allocationStorehousePo.setAsId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_allocationStorehouseId));
+        allocationStorehousePo.setApplyId(allocationStorehouseApplyPo.getApplyId());
+        allocationStorehousePo.setResId(resObj.getString("resId"));
+        allocationStorehousePo.setResName(resObj.getString("resName"));
+
+        allocationStorehousePo.setShIda(resObj.getString("shId"));
+        allocationStorehouseApplyPo.setShId(resObj.getString("shId"));
+
+        allocationStorehousePo.setShIdz(resObj.getString("shzId"));
+        allocationStorehousePo.setStoreId(reqJson.getString("storeId"));
+        //调拨(返还)数量
+        allocationStorehousePo.setStock(resObj.getString("curStock"));
+        //原有库存
+        allocationStorehousePo.setOriginalStock(resObj.getString("stock"));
+        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) {
+            throw new CmdException("保存调拨物品失败");
+        }
+
+        int applyCount = Integer.parseInt(allocationStorehouseApplyPo.getApplyCount());
+        applyCount += resObj.getIntValue("curStock");
+        allocationStorehouseApplyPo.setApplyCount(applyCount + "");
+    }
+
+    /**
+     * 封装对象
+     *
+     * @param reqJson
+     * @return
+     */
+    private AllocationStorehouseApplyPo covertAllocationStorehouseApply(JSONObject reqJson) {
+
+        AllocationStorehouseApplyPo allocationStorehouseApplyPo = new AllocationStorehouseApplyPo();
+        allocationStorehouseApplyPo.setApplyId(reqJson.getString("applyId"));
+        allocationStorehouseApplyPo.setRemark(reqJson.getString("remark"));
+        allocationStorehouseApplyPo.setStoreId(reqJson.getString("storeId"));
+        allocationStorehouseApplyPo.setCommunityId(reqJson.getString("communityId"));
+        return allocationStorehouseApplyPo;
+    }
+}

+ 2 - 1
service-store/src/main/java/com/java110/store/smo/impl/AllocationStorehouseApplyInnerServiceSMOImpl.java

@@ -40,7 +40,8 @@ public class AllocationStorehouseApplyInnerServiceSMOImpl extends BaseServiceSMO
             allocationAllocationStorehouseApplyhouseApplyDto.setPage((page - 1) * allocationAllocationStorehouseApplyhouseApplyDto.getRow());
         }
 
-        List<AllocationStorehouseApplyDto> allocationAllocationStorehouseApplyhouseApplys = BeanConvertUtil.covertBeanList(allocationAllocationStorehouseApplyhouseApplyServiceDaoImpl.getAllocationStorehouseApplyInfo(BeanConvertUtil.beanCovertMap(allocationAllocationStorehouseApplyhouseApplyDto)), AllocationStorehouseApplyDto.class);
+        List<AllocationStorehouseApplyDto> allocationAllocationStorehouseApplyhouseApplys = BeanConvertUtil.covertBeanList(
+                allocationAllocationStorehouseApplyhouseApplyServiceDaoImpl.getAllocationStorehouseApplyInfo(BeanConvertUtil.beanCovertMap(allocationAllocationStorehouseApplyhouseApplyDto)), AllocationStorehouseApplyDto.class);
 
         return allocationAllocationStorehouseApplyhouseApplys;
     }

+ 25 - 2
service-store/src/main/java/com/java110/store/smo/impl/AllocationStorehouseInnerServiceSMOImpl.java

@@ -3,9 +3,13 @@ package com.java110.store.smo.impl;
 
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.dto.PageDto;
+import com.java110.dto.file.FileRelDto;
 import com.java110.dto.purchase.AllocationStorehouseDto;
+import com.java110.dto.resource.ResourceStoreDto;
+import com.java110.dto.resource.ResourceStoreTimesDto;
 import com.java110.dto.user.UserDto;
 import com.java110.intf.store.IAllocationStorehouseInnerServiceSMO;
+import com.java110.intf.store.IResourceStoreTimesV1InnerServiceSMO;
 import com.java110.store.dao.IAllocationStorehouseServiceDao;
 import com.java110.utils.util.BeanConvertUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +33,9 @@ public class AllocationStorehouseInnerServiceSMOImpl extends BaseServiceSMO impl
     @Autowired
     private IAllocationStorehouseServiceDao allocationAllocationStorehousehouseServiceDaoImpl;
 
+    @Autowired
+    private IResourceStoreTimesV1InnerServiceSMO resourceStoreTimesV1InnerServiceSMOImpl;
+
 
     @Override
     public List<AllocationStorehouseDto> queryAllocationStorehouses(@RequestBody AllocationStorehouseDto allocationAllocationStorehousehouseDto) {
@@ -41,10 +48,26 @@ public class AllocationStorehouseInnerServiceSMOImpl extends BaseServiceSMO impl
             allocationAllocationStorehousehouseDto.setPage((page - 1) * allocationAllocationStorehousehouseDto.getRow());
         }
 
-        List<AllocationStorehouseDto> allocationAllocationStorehousehouses = BeanConvertUtil.covertBeanList(allocationAllocationStorehousehouseServiceDaoImpl.getAllocationStorehouseInfo(BeanConvertUtil.beanCovertMap(allocationAllocationStorehousehouseDto)), AllocationStorehouseDto.class);
+        List<AllocationStorehouseDto> allocationStorehouseDtos = BeanConvertUtil.covertBeanList(
+                allocationAllocationStorehousehouseServiceDaoImpl.getAllocationStorehouseInfo(BeanConvertUtil.beanCovertMap(allocationAllocationStorehousehouseDto)),
+                AllocationStorehouseDto.class);
+
+        if(allocationStorehouseDtos == null || allocationStorehouseDtos.size() < 1){
+            return allocationStorehouseDtos;
+        }
+
+        //todo 计算times
+        for (AllocationStorehouseDto allocationStorehouseDto : allocationStorehouseDtos) {
+            ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
+            resourceStoreTimesDto.setStoreId(allocationStorehouseDto.getStoreId());
+            resourceStoreTimesDto.setResCode(allocationStorehouseDto.getResCode());
+            resourceStoreTimesDto.setShId(allocationStorehouseDto.getShIda());
+            List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
+            allocationStorehouseDto.setTimes(resourceStoreTimesDtos);
+        }
 
 
-        return allocationAllocationStorehousehouses;
+        return allocationStorehouseDtos;
     }
 
     /**