Search in sources :

Example 1 with TjsSpecialCompany

use of com.topcom.tjs.domain.TjsSpecialCompany in project topcom-cloud by 545314690.

the class RowMappers method tjsSpecialCompanyRowMapper.

public static RowMapper<TjsSpecialCompany> tjsSpecialCompanyRowMapper() {
    return new RowMapper<TjsSpecialCompany>() {

        @Override
        public TjsSpecialCompany mapRow(ResultSet resultSet, int i) throws SQLException {
            TjsSpecialCompany company = new TjsSpecialCompany();
            company.setId(resultSet.getLong("id"));
            company.setCompanyName(resultSet.getString("companyName"));
            company.setLng(resultSet.getString("lng"));
            company.setLat(resultSet.getString("lat"));
            return company;
        }
    };
}
Also used : TjsSpecialCompany(com.topcom.tjs.domain.TjsSpecialCompany) ResultSet(java.sql.ResultSet) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 2 with TjsSpecialCompany

use of com.topcom.tjs.domain.TjsSpecialCompany in project topcom-cloud by 545314690.

the class CreateAccidentTest method createAndSave.

@Test
public void createAndSave() {
    List<TjsSpecialCompany> all = tjsSpecialCompanyManager.findAll();
    List<DBObject> dbObjectList = MongoDBUtil.selectAll("acc");
    List<TjsAccident> accidentList = new ArrayList<>();
    for (int i = 30000; i < dbObjectList.size(); i++) {
        try {
            TjsSpecialCompany company = all.get(random.nextInt(all.size() - 1));
            DBObject object = dbObjectList.get(i);
            TjsAccident tjsAccident = new TjsAccident();
            tjsAccident.setAddress(company.getAddress());
            tjsAccident.setCity(company.getCity());
            tjsAccident.setCompany(company);
            tjsAccident.setCompanyAttribute(company.getCompanyAttribute());
            tjsAccident.setCompanyIndustry(company.getIndustryType());
            tjsAccident.setCompanyName(company.getCompanyName());
            // 企业的详细情况
            tjsAccident.setCompanyProfile("");
            tjsAccident.setCompanyScale(company.getCompanyType());
            tjsAccident.setCompanyType(company.getLogoType());
            tjsAccident.setCounty(company.getCounty());
            // 死亡人数  0-100 左边重的正态分布
            tjsAccident.setDeathNumber((Integer) object.get("deathnumber"));
            tjsAccident.setDescription("");
            tjsAccident.setFactors(factors[random.nextInt(factors.length - 1)]);
            tjsAccident.setHaddenedTime((Date) object.get("adate"));
            tjsAccident.setInjuredNumber(CreateDataUtil.getGaussianRandomBigLeft(0, 100));
            tjsAccident.setLat(company.getLat());
            tjsAccident.setLng(company.getLng());
            // 经济损失单位万
            tjsAccident.setLoss((double) CreateDataUtil.getGaussianRandom(10, 9000));
            tjsAccident.setManageType(company.getIndustryType());
            tjsAccident.setProfile("");
            tjsAccident.setReport(random.nextBoolean());
            tjsAccident.setProvince(company.getProvince());
            tjsAccident.setSCC(company.getSCC());
            tjsAccident.setTerribleNumber(CreateDataUtil.getGaussianRandomBigLeft(0, tjsAccident.getInjuredNumber()));
            tjsAccident.setType(object.get("atype").toString());
            accidentList.add(tjsAccident);
        } catch (Exception e) {
            e.printStackTrace();
            continue;
        }
        if (accidentList.size() % 5000 == 0) {
            accidentManager.save(accidentList);
            accidentList.clear();
            System.out.println(i);
        }
    }
    accidentManager.save(accidentList);
}
Also used : TjsAccident(com.topcom.tjs.domain.TjsAccident) TjsSpecialCompany(com.topcom.tjs.domain.TjsSpecialCompany) ArrayList(java.util.ArrayList) DBObject(com.mongodb.DBObject) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with TjsSpecialCompany

use of com.topcom.tjs.domain.TjsSpecialCompany 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 4 with TjsSpecialCompany

use of com.topcom.tjs.domain.TjsSpecialCompany 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

TjsSpecialCompany (com.topcom.tjs.domain.TjsSpecialCompany)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 DBObject (com.mongodb.DBObject)2 DateParam (com.topcom.cms.common.page.DateParam)2 Date (java.util.Date)2 TjsAccident (com.topcom.tjs.domain.TjsAccident)1 TjsEnforcement (com.topcom.tjs.domain.TjsEnforcement)1 ResultSet (java.sql.ResultSet)1 DecimalFormat (java.text.DecimalFormat)1 RowMapper (org.springframework.jdbc.core.RowMapper)1