home 2 år sedan
förälder
incheckning
1a775a49da

+ 9 - 0
hx-service-api/storage-api/src/main/java/com/fjhx/entity/stock/StockBackDetails.java

@@ -51,5 +51,14 @@ public class StockBackDetails implements Serializable {
      */
     private String rfid;
 
+    /**
+     * 审批状态(0审批中 1已审批)
+     */
+    private Integer flowStatus;
+
+    /**
+     * 审批数据
+     */
+    private String flowData;
 
 }

+ 10 - 0
hx-service-api/storage-api/src/main/java/com/fjhx/params/stock/StockBackDetailsVo.java

@@ -19,4 +19,14 @@ public class StockBackDetailsVo extends StockBackDetails {
      */
     private Date operationTime;
 
+    /**
+     * 审批结果(1通过 0拒绝)
+     */
+    private Integer flowResult;
+
+    /**
+     * 物料名称
+     */
+    private String materialName;
+
 }

+ 5 - 11
hx-service/ding/pom.xml

@@ -18,17 +18,11 @@
 
     <dependencies>
 
-        <dependency>
-            <groupId>com.aliyun</groupId>
-            <artifactId>dingtalk</artifactId>
-            <version>1.4.69</version>
-        </dependency>
-
-        <dependency>
-            <groupId>com.taobao</groupId>
-            <artifactId>taobao-sdk</artifactId>
-            <version>20201116</version>
-        </dependency>
+        <!--        <dependency>-->
+        <!--            <groupId>com.aliyun</groupId>-->
+        <!--            <artifactId>dingtalk</artifactId>-->
+        <!--            <version>1.4.69</version>-->
+        <!--        </dependency>-->
 
     </dependencies>
 

+ 69 - 71
hx-service/ding/src/main/java/com/fjhx/utils/DingUtil.java

@@ -1,78 +1,76 @@
 package com.fjhx.utils;
 
-import com.dingtalk.api.DefaultDingTalkClient;
-import com.dingtalk.api.DingTalkClient;
-import com.dingtalk.api.request.OapiServiceGetCorpTokenRequest;
-import com.dingtalk.api.request.OapiV2DepartmentGetRequest;
-import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
-import com.dingtalk.api.request.OapiV2UserGetRequest;
-import com.dingtalk.api.response.OapiServiceGetCorpTokenResponse;
-import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
-import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
-import com.dingtalk.api.response.OapiV2UserGetResponse;
-import com.taobao.api.ApiException;
-
-import java.util.List;
+//import com.dingtalk.api.DefaultDingTalkClient;
+//import com.dingtalk.api.DingTalkClient;
+//import com.dingtalk.api.request.OapiServiceGetCorpTokenRequest;
+//import com.dingtalk.api.request.OapiV2DepartmentGetRequest;
+//import com.dingtalk.api.request.OapiV2DepartmentListsubRequest;
+//import com.dingtalk.api.request.OapiV2UserGetRequest;
+//import com.dingtalk.api.response.OapiServiceGetCorpTokenResponse;
+//import com.dingtalk.api.response.OapiV2DepartmentGetResponse;
+//import com.dingtalk.api.response.OapiV2DepartmentListsubResponse;
+//import com.dingtalk.api.response.OapiV2UserGetResponse;
+//import com.taobao.api.ApiException;
 
 public class DingUtil {
 
-    private static final String accessKey = "suitepgu4shlatgllyiqp";
-    private static final String accessSecret = "52-_2aKc3WGd8qVX5FRFmR6MnkeAOi6seUKYxjMWBCeiXZJ0l01_YaDfABIP-hmk";
-
-    public static void main(String[] args) throws ApiException {
-        OapiServiceGetCorpTokenResponse corpToken = getCorpToken("ding53d823e205604918a39a90f97fcb1e09",
-                "R9lsfWBExszmJuiJwF8gd3LQ31YUnUaPRQ0L0W4CsslEsyM1L5GVfLXPJExnhbqRsLntMnFp7KYCha9msIjRCY");
-
-        if (corpToken.getErrcode().equals(0L)) {
-            String accessToken = corpToken.getAccessToken();
-            getDeptList(accessToken, 1L);
-
-        }
-    }
-
-    /**
-     * 获取token
-     */
-    public static OapiServiceGetCorpTokenResponse getCorpToken(String authCorpid, String suiteTicket) throws ApiException {
-
-        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/service/get_corp_token");
-        OapiServiceGetCorpTokenRequest req = new OapiServiceGetCorpTokenRequest();
-        req.setAuthCorpid(authCorpid);
-
-        return client.execute(req, accessKey, accessSecret, suiteTicket);
-    }
-
-    public static void getDeptList(String accessToken, Long deptId) throws ApiException {
-        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
-        OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
-        req.setDeptId(deptId);
-        OapiV2DepartmentListsubResponse rsp = client.execute(req, accessToken);
-
-        List<OapiV2DepartmentListsubResponse.DeptBaseResponse> result = rsp.getResult();
-
-        for (OapiV2DepartmentListsubResponse.DeptBaseResponse deptBaseResponse : result) {
-            getDeptList(accessToken, deptBaseResponse.getDeptId());
-
-            getDeptDetails(accessToken,deptBaseResponse.getDeptId());
-        }
-
-    }
-
-    public static void getDeptDetails(String accessToken, Long deptId) throws ApiException {
-        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
-        OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
-        req.setDeptId(deptId);
-        OapiV2DepartmentGetResponse rsp = client.execute(req, accessToken);
-        System.out.println(rsp.getBody());
-    }
-
-
-    public static void getUser(String accessToken, String userId) throws ApiException {
-        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
-        OapiV2UserGetRequest req = new OapiV2UserGetRequest();
-        req.setUserid(userId);
-        OapiV2UserGetResponse rsp = client.execute(req, accessToken);
-        System.out.println(rsp.getBody());
-    }
+//    private static final String accessKey = "suitepgu4shlatgllyiqp";
+//    private static final String accessSecret = "52-_2aKc3WGd8qVX5FRFmR6MnkeAOi6seUKYxjMWBCeiXZJ0l01_YaDfABIP-hmk";
+//
+//    public static void main(String[] args) throws ApiException {
+//        OapiServiceGetCorpTokenResponse corpToken = getCorpToken("ding53d823e205604918a39a90f97fcb1e09",
+//                "R9lsfWBExszmJuiJwF8gd3LQ31YUnUaPRQ0L0W4CsslEsyM1L5GVfLXPJExnhbqRsLntMnFp7KYCha9msIjRCY");
+//
+//        if (corpToken.getErrcode().equals(0L)) {
+//            String accessToken = corpToken.getAccessToken();
+//            getDeptList(accessToken, 1L);
+//
+//        }
+//    }
+//
+//    /**
+//     * 获取token
+//     */
+//    public static OapiServiceGetCorpTokenResponse getCorpToken(String authCorpid, String suiteTicket) throws ApiException {
+//
+//        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/service/get_corp_token");
+//        OapiServiceGetCorpTokenRequest req = new OapiServiceGetCorpTokenRequest();
+//        req.setAuthCorpid(authCorpid);
+//
+//        return client.execute(req, accessKey, accessSecret, suiteTicket);
+//    }
+//
+//    public static void getDeptList(String accessToken, Long deptId) throws ApiException {
+//        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/listsub");
+//        OapiV2DepartmentListsubRequest req = new OapiV2DepartmentListsubRequest();
+//        req.setDeptId(deptId);
+//        OapiV2DepartmentListsubResponse rsp = client.execute(req, accessToken);
+//
+//        List<OapiV2DepartmentListsubResponse.DeptBaseResponse> result = rsp.getResult();
+//
+//        for (OapiV2DepartmentListsubResponse.DeptBaseResponse deptBaseResponse : result) {
+//            getDeptList(accessToken, deptBaseResponse.getDeptId());
+//
+//            getDeptDetails(accessToken,deptBaseResponse.getDeptId());
+//        }
+//
+//    }
+//
+//    public static void getDeptDetails(String accessToken, Long deptId) throws ApiException {
+//        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
+//        OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
+//        req.setDeptId(deptId);
+//        OapiV2DepartmentGetResponse rsp = client.execute(req, accessToken);
+//        System.out.println(rsp.getBody());
+//    }
+//
+//
+//    public static void getUser(String accessToken, String userId) throws ApiException {
+//        DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/user/get");
+//        OapiV2UserGetRequest req = new OapiV2UserGetRequest();
+//        req.setUserid(userId);
+//        OapiV2UserGetResponse rsp = client.execute(req, accessToken);
+//        System.out.println(rsp.getBody());
+//    }
 
 }

+ 49 - 8
hx-service/storage/src/main/java/com/fjhx/stock/controller/StockBackController.java

@@ -1,10 +1,12 @@
 package com.fjhx.stock.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.entity.stock.StockBack;
 import com.fjhx.entity.stock.StockBackCorrect;
 import com.fjhx.entity.stock.StockBackDetails;
+import com.fjhx.material.service.MaterialService;
 import com.fjhx.params.stock.CheckDetailsVo;
 import com.fjhx.params.stock.StatisticsResult;
 import com.fjhx.params.stock.StockBackDetailsVo;
@@ -12,6 +14,7 @@ import com.fjhx.params.stock.SubmitBackVo;
 import com.fjhx.stock.service.StockBackCorrectService;
 import com.fjhx.stock.service.StockBackDetailsService;
 import com.fjhx.stock.service.StockBackService;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.tool.api.R;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -44,6 +47,9 @@ public class StockBackController {
     @Autowired
     private StockBackCorrectService stockBackCorrectService;
 
+    @Autowired
+    private MaterialService materialService;
+
     /**
      * 获取今日领料
      */
@@ -175,20 +181,55 @@ public class StockBackController {
     }
 
     @PostMapping("/edit")
-    public R edit(@RequestBody StockBackDetailsVo stockBackDetails) {
+    public R edit(@RequestBody StockBackDetailsVo vo) {
+        StockBackDetails stockBackDetails = stockBackDetailsService.getById(vo.getId());
+        if (stockBackDetails.getFlowStatus() == 0) {
+            throw new ServiceException("节点正在审批中,不可重复发起");
+        }
+        stockBackDetails.setFlowStatus(0);
+        stockBackDetails.setFlowData(JSONObject.toJSONString(vo));
         stockBackDetailsService.updateById(stockBackDetails);
+        return R.success();
+    }
+
+    @PostMapping("/getFlowData")
+    public R flow(@RequestBody StockBackDetailsVo vo) {
+        StockBackDetails stockBackDetails = stockBackDetailsService.getById(vo.getId());
+
+        StockBackDetailsVo stockBackDetailsVo = JSONObject.parseObject(stockBackDetails.getFlowData(), StockBackDetailsVo.class);
+        String materialId = stockBackDetailsVo.getMaterialId();
+        if (materialId != null) {
+            stockBackDetailsVo.setMaterialName(materialService.getById(materialId).getName());
+        }
+        return R.success();
+    }
+
+    @PostMapping("/handleFlow")
+    public R handleFlow(@RequestBody StockBackDetailsVo vo) {
+        StockBackDetails stockBackDetails = stockBackDetailsService.getById(vo.getId());
+
+        stockBackDetails.setFlowStatus(1);
 
-        if (stockBackDetails.getOperationTime() != null) {
-            StockBackDetails byId = stockBackDetailsService.getById(stockBackDetails.getId());
-            Long stockBackId = byId.getStockBackId();
-            stockBackService.update(Wrappers.<StockBack>lambdaUpdate()
-                    .eq(StockBack::getId, stockBackId)
-                    .set(StockBack::getOperationTime, stockBackDetails.getOperationTime())
-            );
+        // 审批跳过
+        if (vo.getFlowResult() == 1) {
+
+            StockBackDetailsVo flowData = JSONObject.parseObject(stockBackDetails.getFlowData(), StockBackDetailsVo.class);
+            stockBackDetails.setMaterialId(flowData.getMaterialId());
+            stockBackDetails.setMaterialMeters(flowData.getMaterialMeters());
+
+            if (vo.getOperationTime() != null) {
+                Long stockBackId = stockBackDetails.getStockBackId();
+                stockBackService.update(Wrappers.<StockBack>lambdaUpdate()
+                        .eq(StockBack::getId, stockBackId)
+                        .set(StockBack::getOperationTime, vo.getOperationTime())
+                );
+            }
         }
+        stockBackDetailsService.updateById(stockBackDetails);
 
         return R.success();
     }
 
+
 }
 

+ 2 - 0
hx-service/storage/src/main/java/com/fjhx/stock/mapper/StockBackMapper.xml

@@ -261,6 +261,8 @@
                sbd.material_meters                   meters,
                (m.Width * sbd.material_meters / 100) area,
                sb.status,
+               m.id                                  materialId,
+               sbd.flow_status                       flowStatus,
                sbd.id
         from stock_back sb
                  inner join stock_back_details sbd on sb.id = sbd.stock_back_id