huanghongfa
2021-09-02 177249c76aeea0b4bf8d8816d4994e3b445b45ce
springcloud_k8s_panzhihuazhihuishequ/service_api/src/test/java/com/panzhihua/serviceapi/biz/impl/LcApiServiceImplTest.java
@@ -1,9 +1,15 @@
package com.panzhihua.serviceapi.biz.impl;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
@@ -27,15 +33,12 @@
import com.panzhihua.serviceapi.biz.LcApiService;
import com.panzhihua.serviceapi.model.dto.GridMemberPageListDTO;
import com.panzhihua.serviceapi.model.dto.LcGridData;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import javax.annotation.Resource;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@SpringBootTest(classes = ServiceApiApplication.class)
@@ -65,12 +68,10 @@
        log.info(result);
    }
    @Test
    void automationUploadEventAndFile() {
        lcApiService.automationUploadEventAndFile();
    }
    @Test
    void submitEventRegister() {
@@ -125,7 +126,7 @@
        String lcGridUserId = gridService.getLcUserIdByLocalUserId(eventInfoVo.getGridMemberId().toString());
        eventInfo.setGridId(lcGrid);
        R grid = gridService.eventGridDataDetails(eventInfoVo.getGridId());
        EventGridDataDetailsVO gridData = (EventGridDataDetailsVO) grid.getData();
        EventGridDataDetailsVO gridData = (EventGridDataDetailsVO)grid.getData();
        eventInfo.setGridName(gridData.getGridName());
        eventInfo.setCaseTypeCode(LocalEventToLangChaoEventTypeEnum.getCodeByName(eventInfoVo.getEventType()));
        String caseTypeName = LocalEventToLangChaoEventTypeEnum.getEventNameByCode(eventInfoVo.getEventType());
@@ -140,7 +141,7 @@
        eventInfo.setHandleType("REPORT");
        eventInfo.setHandleDescription(eventInfoVo.getProcessDesc());
        eventInfo.setDataId(eventInfoVo.getId().toString());
        //获取系统网格员映射的浪潮网格员对于的用户ID
        // 获取系统网格员映射的浪潮网格员对于的用户ID
        eventInfo.setUserId(lcGridUserId);
        eventInfo.setHandleTime(String.valueOf(eventInfoVo.getHappenTime().getTime()));
        eventInfo.setCaseName(gridData.getGridName().concat(caseTypeName).concat(eventInfoVo.getEventTitle()));
@@ -180,29 +181,26 @@
        log.info("结束上传附件图片信息");
    }
    @Test
    void getGridListByAreaId() {
        //jhRxqEQp 代表西区
        // jhRxqEQp 代表西区
        List<LcGridData> list = lcApiService.getGridTreeByAreaId("jhRxqEQp");
        String pretty = JSONArray.toJSONString(list, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        String pretty = JSONArray.toJSONString(list, SerializerFeature.PrettyFormat,
            SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat);
        log.info(pretty);
    }
    @Test
    void getGridDataListByAreaId() {
        //jhRxqEQp 代表西区
        // jhRxqEQp 代表西区
        List<LcGridData> list = lcApiService.getGridDataListByAreaId("2Fxq97CC");
        String pretty = JSONArray.toJSONString(list, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
                SerializerFeature.WriteDateUseDateFormat);
        String pretty = JSONArray.toJSONString(list, SerializerFeature.PrettyFormat,
            SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat);
        log.info(pretty);
    }
    @Test
    void requestLcFlowPersonVisitRecord() {
    }
    void requestLcFlowPersonVisitRecord() {}
    @Test
    void automationUploadVisitRecord() {
@@ -211,15 +209,16 @@
    @Test
    void getGridMemberListByAreaIdOrName() {
        List<GridMemberPageListDTO> data = lcApiService.getGridMemberListByAreaIdOrName("jhRxqEQp", "",1L,20L);
        List<GridMemberPageListDTO> data = lcApiService.getGridMemberListByAreaIdOrName("jhRxqEQp", "", 1L, 20L);
        // log.info(data);
    }
    @Test
    void downloadDiction() {
        //获取字典全部大类
        // 获取字典全部大类
        HttpRequest request = HttpUtil.createPost("http://171.217.92.33:53301/dict/getTypeTree");
        request.cookie("SESSION=ZTQ1ZGRmZjktNWU1MC00ZjEyLWJhOGItNDdjZjlmODc1MjQy; UISESSIONMEMBER=C6FE0698B29832B18CBAEB71CCD3A2BA");
        request.cookie(
            "SESSION=ZTQ1ZGRmZjktNWU1MC00ZjEyLWJhOGItNDdjZjlmODc1MjQy; UISESSIONMEMBER=C6FE0698B29832B18CBAEB71CCD3A2BA");
        HttpResponse result = request.execute();
        List<DictionData> remoteData = JSONArray.parseArray(result.body(), DictionData.class);
        remoteData.forEach(dictionData -> {
@@ -231,7 +230,7 @@
            dictionaryVO.setLevelIndex(1);
            dictionaryVO.setParentId(0L);
            communityService.insertDiction(dictionaryVO);
            //获取二级字典项
            // 获取二级字典项
            dictionData.getChildren().forEach(children -> {
                DictionaryVO dictionaryChiVO = new DictionaryVO();
                long erparentzId = Snowflake.getId();
@@ -241,12 +240,16 @@
                dictionaryChiVO.setLevelIndex(2);
                dictionaryChiVO.setParentId(dictionaryVO.getId());
                communityService.insertDiction(dictionaryChiVO);
                //获取字典全部值
                HttpRequest requestDictionValue = HttpUtil.createPost("http://171.217.92.33:53301/dict/getDictByTypeCodeAndParentId?typeCode=" + children.getId() + "&parentId=0");
                requestDictionValue.cookie("SESSION=ZTQ1ZGRmZjktNWU1MC00ZjEyLWJhOGItNDdjZjlmODc1MjQy; UISESSIONMEMBER=C6FE0698B29832B18CBAEB71CCD3A2BA");
                // 获取字典全部值
                HttpRequest requestDictionValue =
                    HttpUtil.createPost("http://171.217.92.33:53301/dict/getDictByTypeCodeAndParentId?typeCode="
                        + children.getId() + "&parentId=0");
                requestDictionValue.cookie(
                    "SESSION=ZTQ1ZGRmZjktNWU1MC00ZjEyLWJhOGItNDdjZjlmODc1MjQy; UISESSIONMEMBER=C6FE0698B29832B18CBAEB71CCD3A2BA");
                HttpResponse childResult = requestDictionValue.execute();
                LcReturnObject remoteDataChild = JSONObject.parseObject(childResult.body(), LcReturnObject.class);
                List<DictionValueData> dictionValueData = JSONArray.parseArray(remoteDataChild.getData(), DictionValueData.class);
                List<DictionValueData> dictionValueData =
                    JSONArray.parseArray(remoteDataChild.getData(), DictionValueData.class);
                dictionValueData.forEach(dictionValueData1 -> {
                    BcDictionaryVO dictionaryItemVO = new BcDictionaryVO();
                    dictionaryItemVO.setDictName(dictionValueData1.getDictName());
@@ -255,9 +258,10 @@
                    dictionaryItemVO.setDictId(erparentzId);
                    communityService.insertDictionItem(dictionaryItemVO);
                });
//                String pretty = JSONArray.toJSONString(dictionValueData, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
//                        SerializerFeature.WriteDateUseDateFormat);
//                log.info(pretty);
                // String pretty = JSONArray.toJSONString(dictionValueData, SerializerFeature.PrettyFormat,
                // SerializerFeature.WriteMapNullValue,
                // SerializerFeature.WriteDateUseDateFormat);
                // log.info(pretty);
            });
        });
    }