LAPTOP-KB9HII50\70708 2 gadi atpakaļ
vecāks
revīzija
cf90dcfa72

+ 88 - 49
svr/svr-basic/src/main/java/com/yihu/jw/basic/agadmin/controller/quota/TjQuotaController.java

@ -1,10 +1,8 @@
package com.yihu.jw.basic.agadmin.controller.quota;
package com.yihu.jw.basic.agadmin.controller.quota;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.type.TypeReference;
import com.yihu.jw.basic.dict.service.SystemDictEntryService;
import com.yihu.jw.basic.dict.service.SystemDictEntryService;
import com.yihu.jw.basic.quota.controller.JobController;
import com.yihu.jw.basic.quota.controller.JobController;
import com.yihu.jw.basic.quota.model.SaveModel;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.quota.service.*;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.resource.service.RsResourceQuotaService;
import com.yihu.jw.basic.util.TemPath;
import com.yihu.jw.basic.util.TemPath;
@ -17,9 +15,12 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateTimeUtil;
import com.yihu.jw.util.date.DateTimeUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -74,6 +75,10 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    private QuotaService quotaService;
    private QuotaService quotaService;
    @Resource
    @Resource
    TjQuotaLogService tjQuotaLogService;
    TjQuotaLogService tjQuotaLogService;
    @Resource
    private HttpClientUtil httpClientUtil;
    @Value("${url.svr_quota}")
    private String quotaUrl;
    @GetMapping("/getTjQuota")
    @GetMapping("/getTjQuota")
    public Envelop searchTjQuota(String name, Integer quotaType, int page, int rows) {
    public Envelop searchTjQuota(String name, Integer quotaType, int page, int rows) {
@ -266,11 +271,16 @@ public class TjQuotaController extends EnvelopRestEndpoint {
     */
     */
    @PostMapping("firstExecuteQuota")
    @PostMapping("firstExecuteQuota")
    public Envelop firstExecuteQuota(Long tjQuotaId) {
    public Envelop firstExecuteQuota(Long tjQuotaId) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", tjQuotaId);
        try {
        try {
            String url = "/job/firstExecuteQuota";
            return jobController.firstExecuteQuota(tjQuotaId);
            String url = quotaUrl + "/api/v1.0/job/firstExecuteQuota";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("id", tjQuotaId+""));
            String infoResponse = httpClientUtil.post(url,params,"UTF-8");
//            return jobController.firstExecuteQuota(tjQuotaId);
            if("true".equals(infoResponse)){
                return success("执行成功");
            }
            return Envelop.getError("执行失败");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
            return failed(ERR_SYSTEM_DES);
@ -283,8 +293,18 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    @PostMapping("execuQuota")
    @PostMapping("execuQuota")
    public Envelop execuQuota(Long tjQuotaId, String startDate, String endDate) {
    public Envelop execuQuota(Long tjQuotaId, String startDate, String endDate) {
        try {
        try {
            String url = "/job/execuJob";
            return jobController.executeQuota(tjQuotaId,startDate,endDate);
            String url = quotaUrl + "/api/v1.0/job/execuJob";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("id", tjQuotaId+""));
            params.add(new BasicNameValuePair("startDate", startDate));
            params.add(new BasicNameValuePair("endDate", endDate));
//            return jobController.executeQuota(tjQuotaId,startDate,endDate);
            String infoResponse = httpClientUtil.post(url,params,"UTF-8");
//            return jobController.firstExecuteQuota(tjQuotaId);
            if("true".equals(infoResponse)){
                return success("执行成功");
            }
            return Envelop.getError("执行失败");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
            return failed(ERR_SYSTEM_DES);
@ -324,48 +344,67 @@ public class TjQuotaController extends EnvelopRestEndpoint {
    public Envelop selectQuotaResult(Long tjQuotaId, int page, int rows,
    public Envelop selectQuotaResult(Long tjQuotaId, int page, int rows,
                                    String startTime, String endTime, String orgName,
                                    String startTime, String endTime, String orgName,
                                    String province, String city, String district,String res) {
                                    String province, String city, String district,String res) {
        String url = "/tj/tjGetQuotaResult";
        try {
        try {
            Map<String, Object> filters = new HashMap<>();
            Map<String, Object> filters = new HashMap<>();
            if(StringUtils.isNotBlank(startTime)){
                filters.put("startTime", startTime);
            }
            if(StringUtils.isNotBlank(endTime)){
                filters.put("endTime", endTime);
            }
            if(StringUtils.isNotBlank(orgName)){
                filters.put("orgName", orgName);
            }
            if(StringUtils.isNotBlank(province)){
                filters.put("province", province);
            }
            if(StringUtils.isNotBlank(city)){
                filters.put("city", city);
            }
            if(StringUtils.isNotBlank(district)){
                filters.put("district", district);
            }
            if(StringUtils.isNotBlank(res)){
                // 结果大于0
                filters.put("result", res);
            }
            try {
                List<SaveModel> saveModelList = new ArrayList<>();
                List<Map<String, Object>> resultList = quotaService.queryResultPage(tjQuotaId, filters.toString(), page, rows);
                if(resultList != null && resultList.size() > 0){
                    for(Map<String, Object> map : resultList){
                        SaveModel saveModel =  objectMapper.convertValue(map, SaveModel.class);
                        if(saveModel != null){
                            saveModelList.add(saveModel);
                        }
                    }
                }
                long totalCount = quotaService.getQuotaTotalCount(tjQuotaId,filters.toString());
                return PageEnvelop.getSuccessListWithPage("查询成功",saveModelList,page,rows,totalCount);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return failed("查询失败");
            filters.put("startTime", startTime);
            filters.put("endTime", endTime);
            filters.put("org", orgName);
            filters.put("province", province);
            filters.put("town", city);
            filters.put("district", district);
            // 结果大于0
            filters.put("result", res);
            String url = quotaUrl + "/api/v1.0/tj/tjGetQuotaResult";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("id", tjQuotaId+""));
            params.add(new BasicNameValuePair("pageNo", page+""));
            params.add(new BasicNameValuePair("pageSize", rows+""));
            params.add(new BasicNameValuePair("filters", objectMapper.writeValueAsString(filters)));
            String infoResponse = httpClientUtil.get(url,params,"UTF-8");
            return toModel(infoResponse,MixEnvelop.class);
//            Map<String, Object> filters = new HashMap<>();
//            if(StringUtils.isNotBlank(startTime)){
//                filters.put("startTime", startTime);
//            }
//            if(StringUtils.isNotBlank(endTime)){
//                filters.put("endTime", endTime);
//            }
//            if(StringUtils.isNotBlank(orgName)){
//                filters.put("orgName", orgName);
//            }
//            if(StringUtils.isNotBlank(province)){
//                filters.put("province", province);
//            }
//            if(StringUtils.isNotBlank(city)){
//                filters.put("city", city);
//            }
//            if(StringUtils.isNotBlank(district)){
//                filters.put("district", district);
//            }
//            if(StringUtils.isNotBlank(res)){
//                // 结果大于0
//                filters.put("result", res);
//            }
//            try {
//                List<SaveModel> saveModelList = new ArrayList<>();
//                List<Map<String, Object>> resultList = quotaService.queryResultPage(tjQuotaId, filters.toString(), page, rows);
//                if(resultList != null && resultList.size() > 0){
//                    for(Map<String, Object> map : resultList){
//                        SaveModel saveModel =  objectMapper.convertValue(map, SaveModel.class);
//                        if(saveModel != null){
//                            saveModelList.add(saveModel);
//                        }
//                    }
//                }
//                long totalCount = quotaService.getQuotaTotalCount(tjQuotaId,filters.toString());
//                return PageEnvelop.getSuccessListWithPage("查询成功",saveModelList,page,rows,totalCount);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//            return failed("查询失败");
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return failed(ERR_SYSTEM_DES);
            return failed(ERR_SYSTEM_DES);

+ 2 - 0
svr/svr-basic/src/main/resources/application.yml

@ -220,3 +220,5 @@ activemq:
  username: admin
  username: admin
  password: admin
  password: admin
  url: tcp://172.26.0.116:61616
  url: tcp://172.26.0.116:61616
url:
  svr_quota: http://172.26.0.153:10031

+ 120 - 0
svr/svr-quota/doc/es/新增索引es7.txt

@ -0,0 +1,120 @@
es7没有type的概念
查询索引
get http://172.26.0.56:9200/quota_index
创建索引
PUT http://172.26.0.56:9200/quota_index
{
      "mappings" : {
        "properties" : {
          "areaLevel" : {
            "type" : "integer"
          },
          "city" : {
            "type" : "keyword"
          },
          "cityName" : {
            "type" : "keyword"
          },
          "createDate" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"
          },
          "createTime" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"
          },
          "economic" : {
            "type" : "keyword"
          },
          "economicName" : {
            "type" : "keyword"
          },
          "id" : {
            "type" : "keyword"
          },
          "level" : {
            "type" : "keyword"
          },
          "levelName" : {
            "type" : "keyword"
          },
          "org" : {
            "type" : "keyword"
          },
          "orgName" : {
            "type" : "keyword"
          },
          "provice" : {
            "type" : "keyword"
          },
          "provinceName" : {
            "type" : "keyword"
          },
          "quotaCode" : {
            "type" : "keyword"
          },
          "quotaDate" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"
          },
          "quotaName" : {
            "type" : "keyword"
          },
          "result" : {
            "type" : "double"
          },
          "saasId" : {
            "type" : "keyword"
          },
          "slaveKey1" : {
            "type" : "keyword"
          },
          "slaveKey1Name" : {
            "type" : "keyword"
          },
          "slaveKey2" : {
            "type" : "keyword"
          },
          "slaveKey2Name" : {
            "type" : "keyword"
          },
          "slaveKey3" : {
            "type" : "keyword"
          },
          "slaveKey3Name" : {
            "type" : "keyword"
          },
          "slaveKey4" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"
          },
          "slaveKey4Name" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"
          },
          "team" : {
            "type" : "keyword"
          },
          "teamName" : {
            "type" : "keyword"
          },
          "timeLevel" : {
            "type" : "integer"
          },
          "town" : {
            "type" : "keyword"
          },
          "townName" : {
            "type" : "keyword"
          },
          "year" : {
            "type" : "keyword"
          },
          "yearName" : {
            "type" : "keyword"
          }
        }
      }
    }

+ 2 - 1
svr/svr-quota/src/main/java/com/yihu/jw/quota/service/job/JobService.java

@ -47,7 +47,7 @@ public class JobService {
            params.put("startTime", startDate);
            params.put("startTime", startDate);
            params.put("endTime", endDate);
            params.put("endTime", endDate);
            String quotaCode = quotaVo.getCode().replace("_", "");
            String quotaCode = quotaVo.getCode().replace("_", "");
            String quotaCodeImmediately = quotaCode + "immediately";
            String quotaCodeImmediately = quotaCode + "immediately1";
            boolean existJob = quartzHelper.isExistJob(quotaCode);
            boolean existJob = quartzHelper.isExistJob(quotaCode);
            boolean existJobImmediately = quartzHelper.isExistJob(quotaCodeImmediately);
            boolean existJobImmediately = quartzHelper.isExistJob(quotaCodeImmediately);
            if (existJob && "0".equals(quotaVo.getJobStatus())) {
            if (existJob && "0".equals(quotaVo.getJobStatus())) {
@ -64,6 +64,7 @@ public class JobService {
               try {
               try {
                   quartzHelper.startNow(Class.forName(quotaVo.getJobClazz()), quotaCodeImmediately, params);
                   quartzHelper.startNow(Class.forName(quotaVo.getJobClazz()), quotaCodeImmediately, params);
               }catch (Exception e){
               }catch (Exception e){
                   e.printStackTrace();
                   throw  new ObjectAlreadyExistsException(quotaCodeImmediately + "," + tjQuota.getName() + "指标正在执行!");
                   throw  new ObjectAlreadyExistsException(quotaCodeImmediately + "," + tjQuota.getName() + "指标正在执行!");
               }
               }
            } else {
            } else {