|
|
@@ -1,48 +1,154 @@ |
|
|
|
//package cn.com.taiji.iaw.manager; |
|
|
|
// |
|
|
|
//import cn.com.taiji.common.manager.AbstractManager; |
|
|
|
//import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
//import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
// |
|
|
|
//import cn.com.taiji.iaw.entity.Sample; |
|
|
|
//import cn.com.taiji.iaw.repo.jpa.SampleRepo; |
|
|
|
//import cn.com.taiji.iaw.repo.jpa.request.SamplePageRequest1; |
|
|
|
//import cn.com.taiji.iaw.repo.jpa.request.SamplePageRequest2; |
|
|
|
// |
|
|
|
//@SpringBootTest |
|
|
|
//public class TestSampleRepo extends AbstractManager { |
|
|
|
// |
|
|
|
// @Autowired |
|
|
|
// private SampleRepo repo; |
|
|
|
// |
|
|
|
// @org.junit.jupiter.api.Test |
|
|
|
// public void testRepo() { |
|
|
|
// Sample sample = new Sample(); |
|
|
|
// sample.setName("张三"); |
|
|
|
// sample.setIdNum("123456789"); |
|
|
|
// sample.setIntValue(1); |
|
|
|
// sample.setAddress("贵州"); |
|
|
|
// System.out.println("*****************-2" + sample); |
|
|
|
// repo.persist(sample); |
|
|
|
// System.out.println("*****************-1" + sample); |
|
|
|
// System.out.println("******************0" + repo.findById(sample.getId()).orElse(null)); |
|
|
|
// System.out.println("******************0" + sample); |
|
|
|
// System.out.println("******************1" + repo.listByName("张三"));// 正确 |
|
|
|
// System.out.println("******************2" + repo.listByNameSql("张三"));// 使用原生sql(nativeQuery)查不出来 |
|
|
|
// System.out.println("******************3" + repo.listByName("张三-encrypt"));// 查不出来 |
|
|
|
// System.out.println("******************4" + repo.listByNameSql("张三-encrypt"));// 能查出来,不建议用,结果明文 |
|
|
|
// System.out.println("******************5" + repo.listPropertyByName("张三"));// 正确 |
|
|
|
// System.out.println("******************6" + repo.page(new SamplePageRequest1("张三")).getResult()); |
|
|
|
// System.out.println( |
|
|
|
// "******************6" + repo.page(new SamplePageRequest2("张三")).getResult(Object[].class).get(0)[0]); |
|
|
|
// repo.updateName("张三2", "张三"); |
|
|
|
// System.out.println("*****************11" + sample); |
|
|
|
// Sample newSample = repo.findById(sample.getId()).orElse(null); |
|
|
|
// System.out.println("*****************12" + newSample); |
|
|
|
// newSample.setName("张三3"); |
|
|
|
// repo.merge(newSample); |
|
|
|
// System.out.println("*****************13" + repo.findById(sample.getId()).orElse(null)); |
|
|
|
// |
|
|
|
// } |
|
|
|
// |
|
|
|
//} |
|
|
|
package cn.com.taiji.iaw.manager; |
|
|
|
|
|
|
|
|
|
|
|
import cn.com.taiji.core.entity.dict.basic.*; |
|
|
|
import cn.com.taiji.core.entity.issue.*; |
|
|
|
import cn.com.taiji.core.repo.jpa.issue.*; |
|
|
|
import cn.com.taiji.iaw.Application; |
|
|
|
import org.apache.commons.compress.utils.Lists; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@SpringBootTest(classes = Application.class) |
|
|
|
public class TestSampleRepo extends AbstractCommManager { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ErrorExtLogRepo errorExtLogRepo; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CsmsnOrderinfoExtRepo csmsnOrderinfoExtRepo; |
|
|
|
@Autowired |
|
|
|
private IssueOrderinfoExtRepo issueOrderinfoExtRepo; |
|
|
|
@Test |
|
|
|
public void test444() throws Exception{ |
|
|
|
ArrayList<HashSet<String>> alll = Lists.newArrayList(); |
|
|
|
// ArrayList<String> ll = Lists.newArrayList(); |
|
|
|
HashSet<String> ll = new HashSet<>(); |
|
|
|
List<String> collect = errorExtLogRepo.findAll().stream().map(ErrorExtLog::getOrderNo).collect(Collectors.toList()); |
|
|
|
for (String s : collect) { |
|
|
|
ll.add(s); |
|
|
|
if (ll.size() >= 1000) { |
|
|
|
alll.add(ll); |
|
|
|
ll = new HashSet<>(); |
|
|
|
} |
|
|
|
} |
|
|
|
alll.add(ll); |
|
|
|
for (HashSet<String> strings : alll) { |
|
|
|
ArrayList<String> hhh = new ArrayList<>(strings); |
|
|
|
List<CsmsnOrderinfoExt> all = csmsnOrderinfoExtRepo.findByOrderInfoIdIn(hhh); |
|
|
|
// List<CsmsnOrderinfoExt> all = csmsnOrderinfoExtRepo.findAll(); |
|
|
|
logger.info("开始数据量{}",all.size()); |
|
|
|
ArrayList<ArrayList<ErrorExtLog>> err = Lists.newArrayList(); |
|
|
|
ArrayList<ErrorExtLog> errOrderNo = Lists.newArrayList(); |
|
|
|
ArrayList<IssueOrderinfoExt> data = Lists.newArrayList(); |
|
|
|
int i = 0; |
|
|
|
for (CsmsnOrderinfoExt csmsnOrderinfoExt : all) { |
|
|
|
i++; |
|
|
|
// logger.info("执行第{}条",i); |
|
|
|
try { |
|
|
|
ErrorExtLog errorExtLog = new ErrorExtLog(); |
|
|
|
errorExtLog.setOrderNo(csmsnOrderinfoExt.getOrderInfoId()); |
|
|
|
errOrderNo.add(errorExtLog); |
|
|
|
|
|
|
|
IssueOrderinfoExt orderinfoExt = new IssueOrderinfoExt(); |
|
|
|
orderinfoExt.setId(csmsnOrderinfoExt.getId()); |
|
|
|
orderinfoExt.setOrderNo(csmsnOrderinfoExt.getOrderInfoId()); |
|
|
|
orderinfoExt.setCancelOpId(csmsnOrderinfoExt.getCancelOpId()); |
|
|
|
orderinfoExt.setCancelReason(csmsnOrderinfoExt.getCancelReason()); |
|
|
|
orderinfoExt.setCustomerDepartment(csmsnOrderinfoExt.getCustomerDepartment()); |
|
|
|
orderinfoExt.setCustomerAddress(csmsnOrderinfoExt.getCustomerAddress()); |
|
|
|
orderinfoExt.setCustomerPositiveImageUrl(csmsnOrderinfoExt.getCustomerPositiveImageUrl()); |
|
|
|
orderinfoExt.setCustomerNegativeImageUrl(csmsnOrderinfoExt.getCustomerNegativeImageUrl()); |
|
|
|
orderinfoExt.setProxyUrl(csmsnOrderinfoExt.getProxyUrl()); |
|
|
|
orderinfoExt.setAgentPosImgUrl(csmsnOrderinfoExt.getAgentPosImgUrl()); |
|
|
|
orderinfoExt.setAgentNegImgUrl(csmsnOrderinfoExt.getAgentNegImgUrl()); |
|
|
|
// orderinfoExt.setAgentGender(Gender.valueOfCode(csmsnOrderinfoExt.getAgentGender())); |
|
|
|
orderinfoExt.setAgentTel(csmsnOrderinfoExt.getAgentTel()); |
|
|
|
orderinfoExt.setAgentAddress(csmsnOrderinfoExt.getAgentAddress()); |
|
|
|
orderinfoExt.setAgentIdVld(csmsnOrderinfoExt.getAgentIdVld()); |
|
|
|
orderinfoExt.setVehicleApprovedCount(csmsnOrderinfoExt.getVehicleApprovedCount()); |
|
|
|
orderinfoExt.setVehicleTotalMass(csmsnOrderinfoExt.getVehicleTotalMass()); |
|
|
|
orderinfoExt.setVehicleMaintenaceMass(csmsnOrderinfoExt.getVehicleMaintenaceMass()); |
|
|
|
orderinfoExt.setVehiclePermittedWeight(csmsnOrderinfoExt.getVehiclePermittedWeight()); |
|
|
|
orderinfoExt.setVehicleEngineNum(csmsnOrderinfoExt.getVehicleEngineNum()); |
|
|
|
orderinfoExt.setVehicleVin(csmsnOrderinfoExt.getVehicleVin()); |
|
|
|
orderinfoExt.setVehicleModel(csmsnOrderinfoExt.getVehicleModel()); |
|
|
|
orderinfoExt.setVehicleDimensions(csmsnOrderinfoExt.getVehicleDimensions()); |
|
|
|
orderinfoExt.setVehiclePermittedTwoWeight(csmsnOrderinfoExt.getVehiclePermittedTwoWeight()); |
|
|
|
orderinfoExt.setVehPosImgUrl(csmsnOrderinfoExt.getVehPosImgUrl()); |
|
|
|
orderinfoExt.setVehNegImgUrl(csmsnOrderinfoExt.getVehNegImgUrl()); |
|
|
|
orderinfoExt.setVehBodyUrl(csmsnOrderinfoExt.getVehBodyUrl()); |
|
|
|
if (csmsnOrderinfoExt.getUseUserType() != null) { |
|
|
|
orderinfoExt.setUseUserType(UseUserType.valueOfCode(csmsnOrderinfoExt.getUseUserType())); |
|
|
|
} |
|
|
|
orderinfoExt.setTractorSign(csmsnOrderinfoExt.getTractorSign()); |
|
|
|
orderinfoExt.setRoadTransportPermitPicUrl(csmsnOrderinfoExt.getRoadTransportPermitPicUrl()); |
|
|
|
orderinfoExt.setLongitude(csmsnOrderinfoExt.getLongitude()); |
|
|
|
orderinfoExt.setLatitude(csmsnOrderinfoExt.getLatitude()); |
|
|
|
orderinfoExt.setDetailedAddress(csmsnOrderinfoExt.getDetailedAddress()); |
|
|
|
orderinfoExt.setAuditReason(csmsnOrderinfoExt.getAuditReason()); |
|
|
|
orderinfoExt.setRejectReason(csmsnOrderinfoExt.getRejectReason()); |
|
|
|
orderinfoExt.setAuditFailureCase(csmsnOrderinfoExt.getAuditFailureCase()); |
|
|
|
orderinfoExt.setCouponIds(csmsnOrderinfoExt.getCouponIds()); |
|
|
|
orderinfoExt.setSignConfigId(csmsnOrderinfoExt.getSignConfigId()); |
|
|
|
orderinfoExt.setAgreements(csmsnOrderinfoExt.getAgreements()); |
|
|
|
orderinfoExt.setVehicleAxleCount(csmsnOrderinfoExt.getVehicleAxleCount()); |
|
|
|
if (csmsnOrderinfoExt.getUseCharacter() != null) { |
|
|
|
orderinfoExt.setUseCharacter(VehicleUseCharacter.valueOfCode(csmsnOrderinfoExt.getUseCharacter())); |
|
|
|
} |
|
|
|
orderinfoExt.setRegisterDate(csmsnOrderinfoExt.getRegisterDate()); |
|
|
|
// orderinfoExt.setIssueDate(csmsnOrderinfoExt.getIssueDate()); |
|
|
|
orderinfoExt.setAgreeTime(csmsnOrderinfoExt.getAgreeTime()); |
|
|
|
orderinfoExt.setConsignee(csmsnOrderinfoExt.getConsignee()); |
|
|
|
orderinfoExt.setConsigneeTel(csmsnOrderinfoExt.getConsigneeTel()); |
|
|
|
orderinfoExt.setRegion(csmsnOrderinfoExt.getRegion()); |
|
|
|
orderinfoExt.setAddress(csmsnOrderinfoExt.getAddress()); |
|
|
|
orderinfoExt.setPostCode(csmsnOrderinfoExt.getPostCode()); |
|
|
|
orderinfoExt.setTrackingNumber(csmsnOrderinfoExt.getTrackingNumber()); |
|
|
|
orderinfoExt.setCourierCompany(csmsnOrderinfoExt.getCourierCompany()); |
|
|
|
data.add(orderinfoExt); |
|
|
|
if (data.size() >= 1) { |
|
|
|
logger.info("开始批量插入===="); |
|
|
|
issueOrderinfoExtRepo.persistAll(data); |
|
|
|
data = Lists.newArrayList(); |
|
|
|
errOrderNo = Lists.newArrayList(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("dadadada{}",e.getMessage()); |
|
|
|
logger.info("出错了====={}",e); |
|
|
|
err.add(errOrderNo); |
|
|
|
errorExtLogRepo.persistAll(errOrderNo); |
|
|
|
data = Lists.newArrayList(); |
|
|
|
errOrderNo = Lists.newArrayList(); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
issueOrderinfoExtRepo.persistAll(data); |
|
|
|
} catch (Exception e){ |
|
|
|
logger.error("dadadada{}",e.getMessage()); |
|
|
|
err.add(errOrderNo); |
|
|
|
logger.info("出错了====={}",e); |
|
|
|
errorExtLogRepo.persistAll(errOrderNo); |
|
|
|
} |
|
|
|
System.out.println("执行结束===="+err.size()); |
|
|
|
System.out.println(err); |
|
|
|
} |
|
|
|
System.out.println("0000000000000================"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |