Search in sources :

Example 6 with DateParam

use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.

the class DescriptionManagerImpl method lastDateparam.

private DateParam lastDateparam(DateParam date, String type) {
    DateParam lastDateParam = new DateParam();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date.startDate());
    lastDateParam.setEndDate(date.getStartDate());
    if (type.equals("week")) {
        calendar.add(Calendar.WEEK_OF_MONTH, -1);
        SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd");
        lastDateParam.setStartDate(dateFormater.format(calendar.getTime()));
    } else if (type.equals("month")) {
        calendar.add(Calendar.MONTH, -1);
        SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM");
        lastDateParam.setStartDate(dateFormater.format(calendar.getTime()));
    }
    return lastDateParam;
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateParam(com.topcom.cms.common.page.DateParam)

Example 7 with DateParam

use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.

the class WarningLogManagerImpl method getWarningInfo.

@Override
public Page getWarningInfo(WarningLog warningLog, int pageNum, int limit) {
    if (warningLog == null) {
        return new PageImpl<>(new ArrayList<>());
    }
    BoolQueryRequest request = new BoolQueryRequest();
    request.setType(null);
    request.setFiled(warningLog.getField());
    request.setKeyword(new Keyword(warningLog.getMustWord(), warningLog.getShouldWord(), warningLog.getMustNotWord()));
    /**
     * 数据发布时间:暂定三天内
     */
    // TODO:三天内合适不?
    // Date now = new Date();
    // request.setDate(new DateParam(DateUtil.dateToString(DateUtils.addDays(now, -3)), DateUtil.dateToString(now)));
    /**
     * 数据保存时间
     */
    request.setDateCreated(new DateParam(warningLog.getStartDate(), warningLog.getEndDate()));
    Date now = request.getDateCreated().endDate();
    request.setDate(new DateParam(DateUtil.dateToString(DateUtils.addDays(now, -3)), DateUtil.dateToString(now)));
    request.setPage(new PageRequest(pageNum, limit, new Order(Sort.Direction.DESC, "pubTime")));
    List<KV> kvList = new ArrayList<>();
    // 媒体类型
    String[] type = warningLog.getType();
    if (type != null && type.length > 0) {
        request.setType(type);
    }
    String[] sentimentLabel = warningLog.getSentimentLabel();
    // 情感类型
    if (sentimentLabel != null && sentimentLabel.length > 0) {
        kvList.add(new KV("nlp.sentiment.label", sentimentLabel));
    }
    request.setSearchKv(kvList);
    final Page page = newsService.findByMustShouldDateInType(request);
    return page;
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) Order(com.topcom.cms.common.page.Order) BoolQueryRequest(com.topcom.cms.es.vo.BoolQueryRequest) Keyword(com.topcom.cms.es.vo.Keyword) ArrayList(java.util.ArrayList) Page(org.springframework.data.domain.Page) KV(com.topcom.cms.es.vo.KV) Date(java.util.Date) PageRequest(com.topcom.cms.common.page.PageRequest) DateParam(com.topcom.cms.common.page.DateParam)

Example 8 with DateParam

use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.

the class CreateCompanyTest method createCompany.

@Test
public void createCompany() {
    List<TjsSpecialCompany> companyList = new ArrayList<>();
    List<DBObject> dbObjectList = MongoDBUtil.selectAll("mine_base");
    List<String> fillList = CreateDataUtil.getRandomName(dbObjectList.size() / 20);
    List<String> nameList = CreateDataUtil.getRandomName(dbObjectList.size() + 2);
    for (int i = 0; i < dbObjectList.size(); i++) {
        try {
            DBObject object = dbObjectList.get(i);
            TjsSpecialCompany company = new TjsSpecialCompany();
            company.setAddress(object.get("cityinfo").toString());
            // 注销 与 不注销 10:1
            company.setCancellation(random.nextInt(100) / 10 == 0 ? true : false);
            company.setCity(object.get("市").toString());
            // 行政隶属关系  ○央企  ○省属  ○市地属  ○区县属   ○其他
            company.setCompanyAttribute(companyAttribute[random.nextInt(companyAttribute.length - 1)]);
            company.setCompanyName(object.get("企业名称").toString());
            company.setCompanyType(type[random.nextInt(type.length - 1)]);
            company.setCounty(object.get("县").toString());
            // 表的创建时间  2016-01-01 2018-03-31
            company.setCreateTableDate(CreateDataUtil.getRandomDate(new DateParam("2016-01-01", "2018-03-31")));
            // 填表人 平均20个公司对应一个填表人
            company.setFillPerson(fillList.get(random.nextInt(fillList.size() - 1)));
            company.setHazardousChemicals(random.nextBoolean());
            // 负责人
            company.setHead(nameList.get(i));
            // 行业分类代码 与所属行业对应
            company.setIndustryNumber(random.nextInt(5));
            company.setIndustryType(industryType[company.getIndustryNumber()]);
            company.setLat(object.get("lat").toString());
            company.setLawPlan(random.nextBoolean());
            company.setLicence(session[random.nextInt(2)]);
            company.setLicenceStartDate(CreateDataUtil.getRandomDate(new DateParam("2016-01-01", "2017-12-12")));
            // 结束时间为开始时间加上6个月
            company.setLicenceEndDate(new Date((long) (company.getLicenceStartDate().getTime() + 6 * 30.5 * 24 * 60 * 60)));
            company.setLng(object.get("lng").toString());
            company.setLogoType(logoType[random.nextInt(logoType.length - 1)]);
            company.setNumber(random.nextLong());
            // 发证机关
            company.setOrganName("");
            // 从业人员数量
            company.setPersonNumber(CreateDataUtil.getGaussianRandom(10, 500));
            company.setProductType(productType[random.nextInt(productType.length - 1)]);
            company.setProvince(object.get("省").toString());
            company.setScale(random.nextBoolean());
            company.setSCC("xxxxxxxxxxxxxxxxxxx");
            company.setSpecial(random.nextBoolean());
            companyList.add(company);
        } catch (Exception e) {
            e.printStackTrace();
            continue;
        }
    }
    tjsSpecialCompanyManager.save(companyList);
}
Also used : TjsSpecialCompany(com.topcom.tjs.domain.TjsSpecialCompany) ArrayList(java.util.ArrayList) DBObject(com.mongodb.DBObject) Date(java.util.Date) DateParam(com.topcom.cms.common.page.DateParam) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 9 with DateParam

use of com.topcom.cms.common.page.DateParam in project topcom-cloud by 545314690.

the class CreateEnforcement method create.

@Test
public void create() {
    DecimalFormat df = new DecimalFormat("######0");
    List<TjsSpecialCompany> companyList = tjsSpecialCompanyManager.findAll();
    List<TjsEnforcement> enforcementList = new ArrayList<>();
    for (TjsSpecialCompany company : companyList) {
        try {
            TjsEnforcement enforcement = new TjsEnforcement();
            enforcement.setBJCDWMC(company.getCompanyName());
            // 查处项 全部 0-20
            enforcement.setCCAQSCWFWGXWX(CreateDataUtil.getGaussianRandomBigLeft(0, 20));
            // 查处重大 0-全部
            enforcement.setCCZDSGYHX(CreateDataUtil.getGaussianRandomBigLeft(0, enforcement.getCCAQSCWFWGXWX()));
            // 查处项一般 全部-重大
            enforcement.setCCYBSGYHX(enforcement.getCCAQSCWFWGXWX() - enforcement.getCCZDSGYHX());
            enforcement.setCompany(company);
            // 大类
            enforcement.setDL("");
            // 处罚 重大隐患>2处罚
            enforcement.setDSCJYDWXZCF(enforcement.getCCZDSGYHX() > 2);
            // 对生产经营单位行政处罚
            enforcement.setDSCJYDWZYFZRXZCF(enforcement.getCCZDSGYHX() > 2);
            // 罚款  如果有处罚  罚款为2000到重大隐患*3000的高斯分布随机数
            enforcement.setFKE((double) (enforcement.getDSCJYDWXZCF() ? CreateDataUtil.getGaussianRandom(2000, enforcement.getCCZDSGYHX() * 3000) : 0));
            // 负责人
            enforcement.setFZR(nameList.get(random.nextInt(nameList.size() - 1)));
            // 管理分类
            enforcement.setGLFL(company.getGLFL());
            // 挂牌督办项  0-重大
            enforcement.setGPDBX(enforcement.getCCZDSGYHX());
            enforcement.setJFJCLB(ZFJCLB[random.nextInt(2)]);
            enforcement.setJJCF(enforcement.getCCZDSGYHX() > 2);
            enforcement.setLASPB(enforcement.getCCZDSGYHX() > 2);
            // 门类
            enforcement.setML("");
            // 其他文书
            enforcement.setQTWS("");
            enforcement.setQYFZR(nameList.get(random.nextInt(nameList.size() - 1)));
            enforcement.setQYLB(company.getCompanyType());
            enforcement.setQYZCDZP(company.getProvince());
            enforcement.setQZCZJDS(enforcement.getCCZDSGYHX() > 4);
            enforcement.setQYZCDZS(company.getCity());
            enforcement.setQYZCDZX(company.getCounty());
            enforcement.setSCJJDZP(company.getProvince());
            enforcement.setSCJJDZS(company.getCity());
            enforcement.setSCJJDZX(company.getCounty());
            enforcement.setSFHZYWSZFJC(random.nextBoolean());
            enforcement.setSFWSJCQJCDW(random.nextBoolean());
            enforcement.setSFJBHSZFJC(random.nextBoolean());
            enforcement.setSFZGFC(random.nextBoolean());
            enforcement.setSHXYDM(company.getSCC());
            enforcement.setSJGB(random.nextBoolean());
            // 实际缴罚款
            enforcement.setSJSJFK((double) (enforcement.getCCZDSGYHX() > 2 ? CreateDataUtil.getGaussianRandom(2000, Integer.parseInt(df.format(enforcement.getFKE()))) : 0));
            // 中类
            enforcement.setSL("");
            enforcement.setSSHY(company.getIndustryType());
            enforcement.setTBR(nameList.get(random.nextInt(nameList.size() - 1)));
            enforcement.setTBRQ(CreateDataUtil.getRandomDate(new DateParam("2016-01-01", "2018-03-31")));
            enforcement.setTQGB(random.nextBoolean());
            enforcement.setXCCLCSJDS(random.nextBoolean());
            enforcement.setXCJCJL(random.nextBoolean());
            // 小类
            enforcement.setXL("");
            enforcement.setXWBL(random.nextBoolean());
            enforcement.setXZCFJDSDW(CreateDataUtil.getGaussianRandom(0, enforcement.getCCAQSCWFWGXWX()));
            enforcement.setXZCFJDSGR(CreateDataUtil.getGaussianRandom(0, enforcement.getXZCFJDSDW()));
            enforcement.setXZDCCFJDSDW(enforcement.getXZCFJDSDW());
            enforcement.setYZGAQSCWFWGXW(CreateDataUtil.getGaussianRandom(0, enforcement.getXZCFJDSDW()));
            enforcement.setYZGYBSGYH(CreateDataUtil.getGaussianRandom(0, enforcement.getCCYBSGYHX()));
            enforcement.setYZGZDSGYH(CreateDataUtil.getGaussianRandom(0, enforcement.getCCZDSGYHX()));
            // 截至时间为填报时间加一个月
            enforcement.setZFJCJZSJ(new Date(enforcement.getTBRQ().getTime() + 30 * 24 * 3600 * 1000));
            // 起始时间为填报时间
            enforcement.setZFJCKSSS(enforcement.getTBRQ());
            enforcement.setZFJCXZ(random.nextBoolean() ? "执法监察" : "工作性检测");
            enforcement.setZFWF(CreateDataUtil.getGaussianRandom(0, enforcement.getCCYBSGYHX()));
            enforcement.setZGFCYJS(random.nextBoolean());
            // 5个重大隐患  整顿
            enforcement.setZLTCZD(enforcement.getCCZDSGYHX() > 4);
            enforcement.setZLXQZGZLS(enforcement.getCCZDSGYHX() > 4);
            enforcementList.add(enforcement);
        } catch (Exception e) {
            e.printStackTrace();
            continue;
        }
    }
    manager.save(enforcementList);
}
Also used : TjsSpecialCompany(com.topcom.tjs.domain.TjsSpecialCompany) TjsEnforcement(com.topcom.tjs.domain.TjsEnforcement) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) Date(java.util.Date) DateParam(com.topcom.cms.common.page.DateParam) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

DateParam (com.topcom.cms.common.page.DateParam)9 Date (java.util.Date)5 ArrayList (java.util.ArrayList)4 Order (com.topcom.cms.common.page.Order)3 PageRequest (com.topcom.cms.common.page.PageRequest)3 BoolQueryRequest (com.topcom.cms.es.vo.BoolQueryRequest)3 KV (com.topcom.cms.es.vo.KV)3 Keyword (com.topcom.cms.es.vo.Keyword)3 Page (org.springframework.data.domain.Page)3 TjsSpecialCompany (com.topcom.tjs.domain.TjsSpecialCompany)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 PageImpl (org.springframework.data.domain.PageImpl)2 DBObject (com.mongodb.DBObject)1 News (com.topcom.cms.data.domain.News)1 WarningTask (com.topcom.cms.yuqing.domain.WarningTask)1 TjsEnforcement (com.topcom.tjs.domain.TjsEnforcement)1 QueryWord (com.topcom.yzswf.util.QueryWord)1 ESQueryBuilderConstructor (com.topcom.yzswf.util.es.ESQueryBuilderConstructor)1 ESQueryBuilders (com.topcom.yzswf.util.es.ESQueryBuilders)1