xiaochen před 2 roky
rodič
revize
60317e79ec

+ 9 - 0
src/main/java/com/tld/controller/QueryListController.java

@@ -386,5 +386,14 @@ public class QueryListController {
         return queryListService.getInviteInfo(user);
     }
 
+    /**
+     * 查询错误日志添加到Excel表
+     * @return 返回结果
+     */
+    @GetMapping("getErrorAddExcel")
+    public void getErrorExcel(){
+        queryListService.getErrorAddExcel();
+    }
+
 }
 

+ 10 - 0
src/main/java/com/tld/mapper/QueryListMapper.java

@@ -125,4 +125,14 @@ public interface QueryListMapper {
     List<AskGoods> getAskGoodsInfo(User user);
 
     List<AskGoods> getInviteInfo(User user);
+
+    List<Error> getErrorList();
+
+    String getOrderNumber(@Param("giReqBillID") String giReqBillID);
+
+    String getOrderNumberNot(@Param("giReqBillID") String giReqBillID);
+
+    String getMaterialCode(@Param("material") String material);
+
+    void addErrorExcel(Error error1);
 }

+ 16 - 0
src/main/java/com/tld/model/Error.java

@@ -56,4 +56,20 @@ public class Error implements Serializable {
      * 传输类型
      */
     private String transmissionType;
+    /**
+     * 单号
+     */
+    private String orderNumber;
+    /**
+     * 物料code
+     */
+    private String materialCode;
+    /**
+     * 数量
+     */
+    private String num;
+    /**
+     * 生产领料/非生产领料
+     */
+    private String classify;
 }

+ 2 - 0
src/main/java/com/tld/service/QueryListService.java

@@ -79,4 +79,6 @@ public interface QueryListService {
     Map<String, Object> getAskGoodsInfo(User user);
 
     Map<String, Object> getInviteInfo(User user);
+
+    void getErrorAddExcel();
 }

+ 6 - 6
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -413,7 +413,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                                 //如果失败存入报错信息跟数据
                                                 error.setErrorInfo(map1.get("FailReason").toString());
                                                 error.setUrl(url);
-                                                error.setDataVal(ReqOutStocks2.toString()).setType("出库回传");
+                                                error.setDataVal(ReqOutStocks2.toJSONString()).setType("出库回传");
                                                 errorMapper.addError(error);
                                                 List<JSONObject> list1 = (List<JSONObject>) jsonObject2.get("BillItems");
                                                 for(JSONObject jsonObject3 : list1){
@@ -867,7 +867,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                                 //如果失败存入报错信息跟数据
                                                 error.setErrorInfo(map1.get("FailReason").toString());
                                                 error.setUrl(url);
-                                                error.setDataVal(ReqOutStocks2.toString()).setType("销售出库");
+                                                error.setDataVal(ReqOutStocks2.toJSONString()).setType("销售出库");
                                                 errorMapper.addError(error);
                                                 List<JSONObject> list1 = (List<JSONObject>) jsonObject2.get("BillItems");
                                                 for(JSONObject jsonObject3 : list1){
@@ -1037,7 +1037,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                                 //如果失败存入报错信息跟数据
                                                 error.setErrorInfo(map1.get("FailReason").toString());
                                                 error.setUrl(url);
-                                                error.setDataVal(ReqOutStocks2.toString()).setType("移库");
+                                                error.setDataVal(ReqOutStocks2.toJSONString()).setType("移库");
                                                 errorMapper.addError(error);
                                             }
                                         }
@@ -1289,7 +1289,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                                     //如果失败存入报错信息跟数据
                                                     error.setErrorInfo(map1.get("FailReason").toString());
                                                     error.setUrl(url);
-                                                    error.setDataVal(ReqOutStocks2.toString()).setType("其它入库");
+                                                    error.setDataVal(ReqOutStocks2.toJSONString()).setType("其它入库");
                                                     errorMapper.addError(error);
                                                 }
                                             }
@@ -1412,7 +1412,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                                 //如果失败存入报错信息跟数据
                                                 error.setErrorInfo(map1.get("FailReason").toString());
                                                 error.setUrl(url);
-                                                error.setDataVal(ReqOutStocks2.toString()).setType("其它出库");
+                                                error.setDataVal(ReqOutStocks2.toJSONString()).setType("其它出库");
                                                 errorMapper.addError(error);
                                             }
                                         }
@@ -1536,7 +1536,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                                                 //如果失败存入报错信息跟数据
                                                 error.setErrorInfo(map1.get("FailReason").toString());
                                                 error.setUrl(url);
-                                                error.setDataVal(ReqOutStocks2.toString()).setType("其它出库");
+                                                error.setDataVal(ReqOutStocks2.toJSONString()).setType("其它出库");
                                                 errorMapper.addError(error);
                                             }
                                         }

+ 68 - 0
src/main/java/com/tld/service/impl/QueryListServiceImpl.java

@@ -1009,6 +1009,74 @@ public class QueryListServiceImpl implements QueryListService {
         return map;
     }
 
+    /**
+     * 查询错误日志添加到Excel表
+     * @return 返回结果
+     */
+    @Override
+    public void getErrorAddExcel() {
+        //查询error表信息
+        List<Error> list = queryListMapper.getErrorList();
+        for (Error error : list) {
+            JSONObject jsonObject = JSONObject.parseObject(error.getDataVal());
+            JSONObject jsonObject3 = JSONObject.parseObject(jsonObject.get("strJson").toString());
+            List<JSONObject>  jsonObject1 = (List<JSONObject>) jsonObject3.get("ReqOutStocks");
+            for (JSONObject reqOutStock : jsonObject1) {
+                List<JSONObject> jsonObject2 = (List<JSONObject>) reqOutStock.get("BillItems");
+                for (JSONObject billItem : jsonObject2) {
+
+                    String orderNumber = null ; //单号
+                    String materialCode = null ; //物料code
+                    String num = null ; //数量
+                    String classify = null ; //生产领料/非生产领料
+
+                    String giReqBillID = reqOutStock.get("GIReqBillID").toString();//单号
+                    String material = billItem.get("Material").toString();//物料ID
+                    String Quantity = billItem.get("Quantity").toString();//数量
+                    String moveType = reqOutStock.get("MoveType").toString();//类型Z05非生产领料/207生产领料
+
+                    System.out.println("单号:"+giReqBillID);
+                    System.out.println("物料ID:"+material);
+                    System.out.println("类型:"+moveType);
+                    System.out.println("数量:"+Quantity);
+
+                    //查询单号
+                    if (moveType.equals("207")){
+                        String orderNumber1 = queryListMapper.getOrderNumber(giReqBillID);//207生产领料
+                        orderNumber = orderNumber1;
+                        classify = "生产领料" ;
+                    }else {
+                        String orderNumber1 = queryListMapper.getOrderNumberNot(giReqBillID);//Z05非生产领料
+                        orderNumber = orderNumber1;
+                        classify = "非生产领料" ;
+                    }
+                    //查询物料code
+                    String materialCode1 = queryListMapper.getMaterialCode(material);
+                    materialCode = materialCode1 ;
+
+                    //数量
+                    num = Quantity;
+
+                    Error error1 = new Error()
+                            .setUrl(error.getUrl())
+                            .setErrorInfo(error.getErrorInfo())
+                            .setDataVal(error.getDataVal())
+                            .setScrq(error.getScrq())
+                            .setType(error.getType())
+                            .setTransmissionType(error.getTransmissionType())
+                            .setOrderNumber(orderNumber)
+                            .setMaterialCode(materialCode)
+                            .setNum(num)
+                            .setClassify(classify);
+
+                    //添加
+                    queryListMapper.addErrorExcel(error1);
+                }
+            }
+
+        }
+    }
+
     /**
      * @Description: 查询领料日期
      * @Param: User

+ 21 - 0
src/main/resources/mapper/QueryListMappeer.xml

@@ -2,6 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.tld.mapper.QueryListMapper">
+    <!--添加errorExcel-->
+    <insert id="addErrorExcel">
+        insert into tld_error_excel(url,error_info,data_val,scrq,type,transmission_type,order_number,material_code,num,classify)
+        values (#{url},#{errorInfo},#{dataVal},#{scrq},#{type},#{transmissionType},#{orderNumber},#{materialCode},#{num},#{classify})
+    </insert>
     <!-- 呆滞品查询 -->
     <select id="dullGoods" resultType="java.util.Map">
         SELECT
@@ -1531,4 +1536,20 @@
           AND e.code IN ( SELECT material_id FROM tld_user_material WHERE user_id = #{userId} )
           AND e.part_type != '半成品' AND e.part_type != '产成品' AND (a.num + 0) <![CDATA[>]]> (IFNULL(a.out_num, 0) + 0)
     </select>
+    <!--查询错误日志添加到Excel表-->
+    <select id="getErrorList" resultType="com.tld.model.Error">
+        select id,url,error_info,data_val,scrq,type,transmission_type from tld_error where type = '出库回传' and transmission_type = '1' and error_info = '异常:“是否允许负库存”附近有语法错误。'
+    </select>
+    <!--207生产领料-->
+    <select id="getOrderNumber" resultType="java.lang.String">
+        select ask_goods_code from tld_ask_goods_f where  ask_goods_id = #{giReqBillID}
+    </select>
+    <!--Z05非生产领料-->
+    <select id="getOrderNumberNot" resultType="java.lang.String">
+        select ask_goods_code from tld_invite_f where  ask_goods_id = #{giReqBillID}
+    </select>
+    <!--查询物料code-->
+    <select id="getMaterialCode" resultType="java.lang.String">
+        select code from tld_material where tld_id = #{material}
+    </select>
 </mapper>