Parcourir la source

优化采购流程

java110 il y a 2 ans
Parent
commit
eff52cafb9

+ 10 - 0
java110-bean/src/main/java/com/java110/vo/api/purchaseApply/ApiPurchaseApplyDataVo.java

@@ -32,6 +32,8 @@ public class ApiPurchaseApplyDataVo implements Serializable {
     private String isFixed;
     private String isFixedName;
 
+    private String shId;
+
 
     public String getApplyOrderId() {
         return applyOrderId;
@@ -216,4 +218,12 @@ public class ApiPurchaseApplyDataVo implements Serializable {
     public void setIsFixedName(String isFixedName) {
         this.isFixedName = isFixedName;
     }
+
+    public String getShId() {
+        return shId;
+    }
+
+    public void setShId(String shId) {
+        this.shId = shId;
+    }
 }

+ 12 - 0
java110-bean/src/main/java/com/java110/vo/api/purchaseApply/PurchaseApplyDetailVo.java

@@ -1,5 +1,7 @@
 package com.java110.vo.api.purchaseApply;
 
+import com.java110.dto.resource.ResourceStoreTimesDto;
+
 import java.util.List;
 
 //采购明细表
@@ -37,6 +39,8 @@ public class PurchaseApplyDetailVo {
     private String consultPrice;
     private String timesId;
 
+    private List<ResourceStoreTimesDto> times;
+
     public String getApplyOrderId() {
         return applyOrderId;
     }
@@ -292,6 +296,14 @@ public class PurchaseApplyDetailVo {
     public void setTimesId(String timesId) {
         this.timesId = timesId;
     }
+
+    public List<ResourceStoreTimesDto> getTimes() {
+        return times;
+    }
+
+    public void setTimes(List<ResourceStoreTimesDto> times) {
+        this.times = times;
+    }
 }
 
 

+ 5 - 4
java110-db/src/main/resources/mapper/store/PurchaseApplyDetailV1ServiceDaoImplMapper.xml

@@ -10,7 +10,7 @@
         insert into purchase_apply_detail(
         original_stock,quantity,operate,price,purchase_remark,purchase_quantity,rs_id,apply_order_id,remark,id,res_id
         ) values (
-        #{originalStock},#{quantity},#{operate},#{price},#{purchaseRemark},#{purchaseQuantity},#{rsId},#{applyOrderId},#{remark},#{id},#{resId}
+        #{originalStock},#{quantity},'ADD',#{price},#{purchaseRemark},#{purchaseQuantity},#{rsId},#{applyOrderId},#{remark},#{id},#{resId}
         )
     </insert>
 
@@ -88,9 +88,7 @@
         <if test="rsId !=null and rsId != ''">
             , t.rs_id= #{rsId}
         </if>
-        <if test="applyOrderId !=null and applyOrderId != ''">
-            , t.apply_order_id= #{applyOrderId}
-        </if>
+
         <if test="remark !=null and remark != ''">
             , t.remark= #{remark}
         </if>
@@ -101,6 +99,9 @@
         <if test="id !=null and id != ''">
             and t.id= #{id}
         </if>
+        <if test="applyOrderId !=null and applyOrderId != ''">
+            and t.apply_order_id= #{applyOrderId}
+        </if>
 
     </update>
 

+ 1 - 0
java110-db/src/main/resources/mapper/user/UserServiceDaoImplMapper.xml

@@ -582,6 +582,7 @@
             and uosr.status_cd =0
             GROUP BY u.user_id,u.name,u.email,u.address,u.location_cd,
             u.age,u.sex,u.tel,u.level_cd ,u.b_id,su.rel_cd ,td.name
+            ,uo.org_id,uo.org_name,uosr.store_id,uosr.rel_id
         </if>
         order by u.create_time desc
         <if test="page != -1 and page != null ">

+ 1 - 1
service-store/src/main/java/com/java110/store/cmd/purchase/PurchaseApplyCmd.java

@@ -82,7 +82,7 @@ public class PurchaseApplyCmd extends Cmd {
         Assert.hasKeyAndValue(reqJson, "endUserName", "必填,请填写采购联系人");
         Assert.hasKeyAndValue(reqJson, "endUserTel", "必填,请填写采购联系电话");
         Assert.hasKeyAndValue(reqJson, "communityId", "必填,请填写小区信息");
-        Assert.hasKeyAndValue(reqJson, "shId", "必填,请填写商户ID");
+        Assert.hasKeyAndValue(reqJson, "shId", "必填,请填写仓库");
         Assert.hasKey(reqJson, "resourceStores", "必填,请填写申请采购的物资");
 
         JSONArray resourceStores = reqJson.getJSONArray("resourceStores");

+ 21 - 1
service-store/src/main/java/com/java110/store/cmd/purchase/ResourceEnterCmd.java

@@ -3,6 +3,7 @@ package com.java110.store.cmd.purchase;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.core.annotation.Java110Cmd;
+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;
@@ -10,6 +11,7 @@ import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.doc.annotation.*;
 import com.java110.dto.purchase.PurchaseApplyDto;
 import com.java110.dto.resource.ResourceStoreDto;
+import com.java110.intf.common.IOaWorkflowActivitiInnerServiceSMO;
 import com.java110.intf.store.IPurchaseApplyDetailInnerServiceSMO;
 import com.java110.intf.store.IPurchaseApplyInnerServiceSMO;
 import com.java110.intf.store.IResourceStoreInnerServiceSMO;
@@ -84,6 +86,9 @@ public class ResourceEnterCmd extends Cmd{
     @Autowired
     private IResourceStoreTimesV1InnerServiceSMO resourceStoreTimesV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IOaWorkflowActivitiInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         Assert.hasKeyAndValue(reqJson, "applyOrderId", "订单ID为空");
@@ -172,9 +177,24 @@ public class ResourceEnterCmd extends Cmd{
         String applyOrderId = purchaseApplyPo.getApplyOrderId();
         PurchaseApplyPo purchaseApply = new PurchaseApplyPo();
         purchaseApply.setApplyOrderId(applyOrderId);
-        purchaseApply.setState(PurchaseApplyDto.STATE_AUDITED);
+
+        reqJson.put("auditCode","1100");
+        reqJson.put("auditMessage","入库成功");
+        reqJson.put("storeId", CmdContextUtils.getStoreId(context));
+        reqJson.put("nextUserId", reqJson.getString("staffId"));
+        boolean isLastTask = oaWorkflowUserInnerServiceSMOImpl.completeTask(reqJson);
+
+        if (isLastTask) {
+            purchaseApply.setState(PurchaseApplyDto.STATE_END);
+        } else {
+            purchaseApply.setState(PurchaseApplyDto.STATE_DEALING);
+        }
         purchaseApply.setStatusCd("0");
         purchaseApplyInnerServiceSMOImpl.updatePurchaseApply(purchaseApply);
+
+        //todo 如果包含taskId 流程提交下去
+
+
         context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_OK, "采购申请成功"));
     }
 }

+ 1 - 2
service-store/src/main/java/com/java110/store/cmd/purchaseApply/AuditApplyOrderCmd.java

@@ -5,13 +5,11 @@ 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.purchaseApply.PurchaseApplyDto;
 import com.java110.dto.purchase.PurchaseApplyDto;
 import com.java110.intf.common.IOaWorkflowActivitiInnerServiceSMO;
 import com.java110.intf.common.IPurchaseApplyUserInnerServiceSMO;
 import com.java110.intf.store.IPurchaseApplyInnerServiceSMO;
 import com.java110.intf.store.IPurchaseApplyV1InnerServiceSMO;
-import com.java110.po.purchaseApply.PurchaseApplyPo;
 import com.java110.po.purchase.PurchaseApplyPo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
@@ -86,6 +84,7 @@ public class AuditApplyOrderCmd extends Cmd {
         } else if ("1200".equals(reqJson.getString("auditCode"))
                 || "1400".equals(reqJson.getString("auditCode"))
         ) { //退回操作
+            reqJson.put("startUserId",purchaseApplyDtos.get(0).getCreateUserId());
             oaWorkflowUserInnerServiceSMOImpl.goBackTask(reqJson);
             //reqJson.put("state", "1003"); //工单退单
             purchaseApplyPo.setState(PurchaseApplyDto.STATE_NOT_PASS);

+ 62 - 42
service-store/src/main/java/com/java110/store/cmd/purchaseApply/ListPurchaseApplysCmd.java

@@ -116,48 +116,8 @@ public class ListPurchaseApplysCmd extends Cmd {
             List<PurchaseApplyDto> purchaseApplyDtos = purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyAndDetails(purchaseApplyDto);
             purchaseApplyDtos = freshCurrentUser(purchaseApplyDtos);
             purchaseApplys = BeanConvertUtil.covertBeanList(purchaseApplyDtos, ApiPurchaseApplyDataVo.class);
-            for (ApiPurchaseApplyDataVo apiPurchaseApplyDataVo : purchaseApplys) {
-                List<PurchaseApplyDetailVo> applyDetailList = apiPurchaseApplyDataVo.getPurchaseApplyDetailVo();
-                if (applyDetailList.size() > 0) {
-                    StringBuffer resNames = new StringBuffer();
-                    BigDecimal totalPrice = new BigDecimal(0);
-                    BigDecimal purchaseTotalPrice = new BigDecimal(0);
-                    Integer cursor = 0;
-                    for (PurchaseApplyDetailVo purchaseApplyDetailVo : applyDetailList) {
-                        ResourceStoreDto resourceStoreDto = new ResourceStoreDto();
-                        resourceStoreDto.setResId(purchaseApplyDetailVo.getResId());
-                        List<ResourceStoreDto> resourceStoreDtos = resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto);
-                        Assert.listOnlyOne(resourceStoreDtos, "查询物品信息错误!");
-                        //是否是固定物品
-                        apiPurchaseApplyDataVo.setIsFixed(resourceStoreDtos.get(0).getIsFixed());
-                        apiPurchaseApplyDataVo.setIsFixedName(resourceStoreDtos.get(0).getIsFixedName());
-                        purchaseApplyDetailVo.setIsFixed(resourceStoreDtos.get(0).getIsFixed());
-                        purchaseApplyDetailVo.setIsFixedName(resourceStoreDtos.get(0).getIsFixedName());
-                        //获取仓库名称
-                        String shName = resourceStoreDtos.get(0).getShName();
-                        String shId = resourceStoreDtos.get(0).getShId();
-                        purchaseApplyDetailVo.setShName(shName);
-                        purchaseApplyDetailVo.setShId(shId);
-                        cursor++;
-                        if (applyDetailList.size() > 1) {
-                            resNames.append(cursor + ":" + purchaseApplyDetailVo.getResName() + "      ");
-                        } else {
-                            resNames.append(purchaseApplyDetailVo.getResName());
-                        }
-                        BigDecimal price = new BigDecimal(purchaseApplyDetailVo.getPrice());
-                        BigDecimal quantity = new BigDecimal(purchaseApplyDetailVo.getQuantity());
-                        totalPrice = totalPrice.add(price.multiply(quantity));
-                        if (!StringUtil.isEmpty(purchaseApplyDetailVo.getPurchasePrice()) && !StringUtil.isEmpty(purchaseApplyDetailVo.getPurchaseQuantity())) {
-                            BigDecimal purchasePrice = new BigDecimal(purchaseApplyDetailVo.getPurchasePrice());
-                            BigDecimal purchaseQuantity = new BigDecimal(purchaseApplyDetailVo.getPurchaseQuantity());
-                            purchaseTotalPrice = purchaseTotalPrice.add(purchasePrice.multiply(purchaseQuantity));
-                        }
-                    }
-                    apiPurchaseApplyDataVo.setResourceNames(resNames.toString());
-                    apiPurchaseApplyDataVo.setTotalPrice(totalPrice.toString());
-                    apiPurchaseApplyDataVo.setPurchaseTotalPrice(purchaseTotalPrice.toString());
-                }
-            }
+            //todo 查询结果刷新
+            refreshApplys(purchaseApplys);
         } else {
             purchaseApplys = new ArrayList<>();
         }
@@ -169,6 +129,66 @@ public class ListPurchaseApplysCmd extends Cmd {
         context.setResponseEntity(responseEntity);
     }
 
+    /**
+     * 查询结果 洗礼
+     *
+     * @param purchaseApplys
+     */
+    private void refreshApplys(List<ApiPurchaseApplyDataVo> purchaseApplys) {
+        for (ApiPurchaseApplyDataVo apiPurchaseApplyDataVo : purchaseApplys) {
+            List<PurchaseApplyDetailVo> applyDetailList = apiPurchaseApplyDataVo.getPurchaseApplyDetailVo();
+            //todo 如果没有物品直接 跳过
+            if (applyDetailList == null || applyDetailList.size() < 1) {
+                continue;
+            }
+            StringBuffer resNames = new StringBuffer();
+            BigDecimal totalPrice = new BigDecimal(0);
+            BigDecimal purchaseTotalPrice = new BigDecimal(0);
+            Integer cursor = 0;
+            for (PurchaseApplyDetailVo purchaseApplyDetailVo : applyDetailList) {
+                ResourceStoreDto resourceStoreDto = new ResourceStoreDto();
+                resourceStoreDto.setResId(purchaseApplyDetailVo.getResId());
+                List<ResourceStoreDto> resourceStoreDtos = resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto);
+
+                if (resourceStoreDtos == null || resourceStoreDtos.size() < 1) {
+                    continue;
+                }
+
+                purchaseApplyDetailVo.setTimes(resourceStoreDtos.get(0).getTimes());
+
+                //todo 是否是固定物品
+                apiPurchaseApplyDataVo.setIsFixed(resourceStoreDtos.get(0).getIsFixed());
+                apiPurchaseApplyDataVo.setIsFixedName(resourceStoreDtos.get(0).getIsFixedName());
+                purchaseApplyDetailVo.setIsFixed(resourceStoreDtos.get(0).getIsFixed());
+                purchaseApplyDetailVo.setIsFixedName(resourceStoreDtos.get(0).getIsFixedName());
+                //todo 获取仓库名称
+                String shName = resourceStoreDtos.get(0).getShName();
+                String shId = resourceStoreDtos.get(0).getShId();
+                purchaseApplyDetailVo.setShName(shName);
+                purchaseApplyDetailVo.setShId(shId);
+                apiPurchaseApplyDataVo.setShId(shId);
+                cursor++;
+                if (applyDetailList.size() > 1) {
+                    resNames.append(cursor + ":" + purchaseApplyDetailVo.getResName() + "      ");
+                } else {
+                    resNames.append(purchaseApplyDetailVo.getResName());
+                }
+                BigDecimal price = new BigDecimal(purchaseApplyDetailVo.getPrice());
+                BigDecimal quantity = new BigDecimal(purchaseApplyDetailVo.getQuantity());
+                totalPrice = totalPrice.add(price.multiply(quantity));
+                if (!StringUtil.isEmpty(purchaseApplyDetailVo.getPurchasePrice()) && !StringUtil.isEmpty(purchaseApplyDetailVo.getPurchaseQuantity())) {
+                    BigDecimal purchasePrice = new BigDecimal(purchaseApplyDetailVo.getPurchasePrice());
+                    BigDecimal purchaseQuantity = new BigDecimal(purchaseApplyDetailVo.getPurchaseQuantity());
+                    purchaseTotalPrice = purchaseTotalPrice.add(purchasePrice.multiply(purchaseQuantity));
+                }
+            }
+            apiPurchaseApplyDataVo.setResourceNames(resNames.toString());
+            apiPurchaseApplyDataVo.setTotalPrice(totalPrice.toString());
+            apiPurchaseApplyDataVo.setPurchaseTotalPrice(purchaseTotalPrice.toString());
+        }
+
+    }
+
     private List<PurchaseApplyDto> freshCurrentUser(List<PurchaseApplyDto> purchaseApplyDtos) {
         List<PurchaseApplyDto> tmpPurchaseApplyDtos = new ArrayList<>();
         for (PurchaseApplyDto purchaseApplyDto : purchaseApplyDtos) {

+ 51 - 2
service-store/src/main/java/com/java110/store/cmd/purchaseApply/UpdatePurchaseApplyCmd.java

@@ -15,22 +15,30 @@
  */
 package com.java110.store.cmd.purchaseApply;
 
+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.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.store.IPurchaseApplyDetailV1InnerServiceSMO;
 import com.java110.intf.store.IPurchaseApplyV1InnerServiceSMO;
+import com.java110.po.purchase.PurchaseApplyDetailPo;
 import com.java110.po.purchase.PurchaseApplyPo;
 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.ArrayList;
+import java.util.List;
+
 
 /**
  * 类表述:更新
@@ -51,17 +59,30 @@ public class UpdatePurchaseApplyCmd extends Cmd {
     @Autowired
     private IPurchaseApplyV1InnerServiceSMO purchaseApplyV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IPurchaseApplyDetailV1InnerServiceSMO purchaseApplyDetailV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "applyOrderId", "订单号不能为空");
-        Assert.hasKeyAndValue(reqJson, "state", "必填,请填订单状态");
+        Assert.hasKeyAndValue(reqJson, "description", "必填,请填写采购申请说明");
+        Assert.hasKeyAndValue(reqJson, "endUserName", "必填,请填写采购联系人");
+        Assert.hasKeyAndValue(reqJson, "endUserTel", "必填,请填写采购联系电话");
+        Assert.hasKeyAndValue(reqJson, "communityId", "必填,请填写小区信息");
+        Assert.hasKey(reqJson, "resourceStores", "必填,请填写申请采购的物资");
 
+        JSONArray resourceStores = reqJson.getJSONArray("resourceStores");
+
+        if (resourceStores == null || resourceStores.size() < 1) {
+            throw new CmdException("未包含采购物品");
+        }
     }
 
     @Override
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
-
+        JSONArray resourceStores = reqJson.getJSONArray("resourceStores");
+        reqJson.remove("resourceStores");
         PurchaseApplyPo purchaseApplyPo = BeanConvertUtil.covertBean(reqJson, PurchaseApplyPo.class);
         int flag = purchaseApplyV1InnerServiceSMOImpl.updatePurchaseApply(purchaseApplyPo);
 
@@ -69,6 +90,34 @@ public class UpdatePurchaseApplyCmd extends Cmd {
             throw new CmdException("更新数据失败");
         }
 
+        //todo 删除
+        PurchaseApplyDetailPo purchaseApplyDetailPo = new PurchaseApplyDetailPo();
+        purchaseApplyDetailPo.setApplyOrderId(purchaseApplyPo.getApplyOrderId());
+        purchaseApplyDetailV1InnerServiceSMOImpl.deletePurchaseApplyDetail(purchaseApplyDetailPo);
+
+
+        for (int resourceStoreIndex = 0; resourceStoreIndex < resourceStores.size(); resourceStoreIndex++) {
+            JSONObject resourceStore = resourceStores.getJSONObject(resourceStoreIndex);
+            resourceStore.put("originalStock", resourceStore.getString("stock"));
+            JSONArray timeList = resourceStore.getJSONArray("times");
+            purchaseApplyDetailPo = BeanConvertUtil.covertBean(resourceStore, PurchaseApplyDetailPo.class);
+            purchaseApplyDetailPo.setPurchaseQuantity(resourceStore.getString("quantity"));
+            purchaseApplyDetailPo.setId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_applyOrderId));
+            purchaseApplyDetailPo.setApplyOrderId(purchaseApplyPo.getApplyOrderId());
+            //获取采购参考价格
+            String consultPrice = null;
+            if (resourceStore.containsKey("timesId") && !StringUtil.isEmpty(resourceStore.getString("timesId"))) {
+                for (int timesIndex = 0; timesIndex < timeList.size(); timesIndex++) {
+                    JSONObject times = timeList.getJSONObject(timesIndex);
+                    if (times.getString("timesId").equals(resourceStore.getString("timesId"))) {
+                        consultPrice = times.getString("price");
+                    }
+                }
+            }
+            purchaseApplyDetailPo.setConsultPrice(consultPrice);
+            purchaseApplyDetailV1InnerServiceSMOImpl.savePurchaseApplyDetail(purchaseApplyDetailPo);
+        }
+
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 }