Search in sources :

Example 1 with TjsDeathPerson

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

the class CreateDeathPerson method create.

@Test
public void create() {
    List<TjsAccident> accList = tjsAccidentManager.findAll();
    List<TjsDeathPerson> personList = new ArrayList<>();
    int count = 0;
    for (int i = 0; i < accList.size(); i++) {
        TjsAccident acc = accList.get(i);
        // 死亡人数
        Integer deathNumber = acc.getDeathNumber();
        // 重伤人数
        Integer terribleNumber = acc.getTerribleNumber();
        if (deathNumber != null && deathNumber > 0) {
            for (int j = 0; j < deathNumber; j++) {
                TjsDeathPerson person = new TjsDeathPerson();
                person.setStatus("死亡");
                person = initDeathNuber(acc, person);
                personList.add(person);
            }
        }
        if (terribleNumber != null && terribleNumber > 0) {
            for (int j = 0; j < terribleNumber; j++) {
                TjsDeathPerson person = new TjsDeathPerson();
                person.setStatus("重伤");
                person = initDeathNuber(acc, person);
                personList.add(person);
            }
        }
        if (personList.size() % 5000 == 0) {
            count = count + personList.size();
            tjsDeathPersonManager.save(personList);
            personList.clear();
            System.out.println("-----------------------------------------------------------");
            System.out.println(i);
            System.out.println("保存:" + count + "条");
            System.out.println("-----------------------------------------------------------");
        }
    }
    tjsDeathPersonManager.save(personList);
}
Also used : TjsAccident(com.topcom.tjs.domain.TjsAccident) TjsDeathPerson(com.topcom.tjs.domain.TjsDeathPerson) ArrayList(java.util.ArrayList) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TjsAccident (com.topcom.tjs.domain.TjsAccident)1 TjsDeathPerson (com.topcom.tjs.domain.TjsDeathPerson)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1