jiangping
2024-07-30 995436f56f93874f19b8094fe5537e96d413b6fd
server/dmvisit_service/src/main/java/com/doumee/core/erp/ErpTool.java
@@ -17,11 +17,14 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.HttpsUtil;
import com.doumee.dao.business.InterfaceLogMapper;
import com.doumee.dao.business.model.InterfaceLog;
import com.doumee.dao.business.model.Member;
import com.doumee.service.business.InterfaceLogService;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -32,22 +35,26 @@
@Service
public class ErpTool {
    @Autowired
    private InterfaceLogService interfaceLogService;
    public static  InterfaceLogService interfaceLogService;
    public void saveInterfaceLog(Object param, String path,String result,Integer type) {
        InterfaceLog interfaceLog=new InterfaceLog();
        interfaceLog.setType(type);
        interfaceLog.setCreateDate(new Date());
        interfaceLog.setIsdeleted(Constants.ZERO);
        if(param!=null){
            interfaceLog.setRequest(JSONObject.toJSONString(param));
        try {
            if(interfaceLogService !=null) {
                InterfaceLog interfaceLog = new InterfaceLog();
                interfaceLog.setType(type);
                interfaceLog.setCreateDate(new Date());
                interfaceLog.setIsdeleted(Constants.ZERO);
                if (param != null) {
                    interfaceLog.setRequest(JSONObject.toJSONString(param));
                }
                interfaceLog.setPlat(Constants.ONE);
                interfaceLog.setRepose(result);
                interfaceLog.setName(path);
                interfaceLog.setUrl(path);
                interfaceLogService.create(interfaceLog);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        interfaceLog.setPlat(Constants.ONE);
        interfaceLog.setRepose(result);
        interfaceLog.setName(path);
        interfaceLog.setUrl(path);
        interfaceLogService.create(interfaceLog);
    }
@@ -86,7 +93,7 @@
                }
            }
        }catch (Exception e){
            throw e;
            e.printStackTrace();
        }finally {
            saveInterfaceLog(param,url,JSONArray.toJSONString(list),Constants.ZERO);
        }
@@ -107,6 +114,7 @@
            int pageSize  = 100;
            boolean hasLast = true;
            while (hasLast){
                hasLast = false;
                PageWrap<UserListRequest> pageWrap  = new PageWrap<>();
                pageWrap.setModel(param);
                pageWrap.setPage(page);
@@ -115,20 +123,18 @@
                if(StringUtils.isNotBlank(result)){
                    TypeReference typeReference =
                            new TypeReference<ERPApiResponse<PageData<ErpUserListResponse>>>(){};
                    ERPApiResponse<PageData <ErpUserListResponse>> response = JSONObject.parseObject(result, typeReference.getType());
                   ERPApiResponse<PageData <ErpUserListResponse>> response = JSONObject.parseObject(result, typeReference.getType());
                    if(response!=null && response.getData()!=null && response.getData().getRecords()!=null){
                        list.addAll(response.getData().getRecords());
                        if(pageSize*page < response.getData().getTotal() ){
                            hasLast =false;//还有下一页
                            hasLast =true;//还有下一页
                        }
                    }else{
                        hasLast =false;//还有下一页
                    }
                    page++;
                }
            }
        }catch (Exception e){
            throw e;
            e.printStackTrace();
        }finally {
            saveInterfaceLog(param,url, JSONArray.toJSONString(list),Constants.ZERO);
        }
@@ -158,8 +164,10 @@
                    throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),response.getMessage());
                }
            }
        }catch (Exception e){
        }catch (BusinessException e){
            throw e;
        }catch (Exception e){
            e.printStackTrace();
        }finally {
           saveInterfaceLog(param,url,JSONObject.toJSONString(result),Constants.ZERO);
        }
@@ -184,7 +192,7 @@
                }
            }
        }catch (Exception e){
            throw e;
            e.printStackTrace();
        }finally {
            saveInterfaceLog(param,url,JSONObject.toJSONString(result),Constants.ZERO);
        }