|
|
@@ -52,103 +52,15 @@ public class SyncInsAreaCompany {
|
|
|
@Autowired
|
|
|
private InsAreaCompanyService insAreaCompanyService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private InsOrdersService insOrdersService;
|
|
|
+
|
|
|
public Runnable workThread(InsAreaCompanyVo insAreaCompanyOld) throws IOException {
|
|
|
try {
|
|
|
|
|
|
// List<InsAreaCompany> insAreaCompanies = new ArrayList<>();
|
|
|
+ //orders 信息
|
|
|
|
|
|
- InsAreaCompany insAreaCompany = new InsAreaCompany();
|
|
|
- if (Objects.isNull(insAreaCompanyOld)) {
|
|
|
- System.out.printf("insAreaCompanyOld is null");
|
|
|
- }
|
|
|
- BeanUtils.copyProperties(insAreaCompanyOld, insAreaCompany);
|
|
|
- //1 处理车主信息
|
|
|
-// sysCarInfoService.getCarInfoByFrameNo(insAreaCompanyOld.getFrameNo());
|
|
|
- InsOrdersCarInfo insOrdersCarInfo = insOrdersCarInfoService.getById(insAreaCompanyOld.getCarInfoId());
|
|
|
- InsAreaCompanyCarInfo carInfo = new InsAreaCompanyCarInfo();
|
|
|
- BeanUtils.copyProperties(insOrdersCarInfo, carInfo);
|
|
|
- insAreaCompanyCarInfoService.saveOrUpdate(carInfo);
|
|
|
- insAreaCompany.setCarInfoId(carInfo.getId());
|
|
|
- insAreaCompany.setId(IdGenerate.nextId());
|
|
|
-
|
|
|
- //2 处理车险用户信息
|
|
|
- List<String> userIds = new ArrayList<>();
|
|
|
- userIds.add(insAreaCompanyOld.getOwnerId());
|
|
|
- userIds.add(insAreaCompanyOld.getApplyId());
|
|
|
- userIds.add(insAreaCompanyOld.getInsureId());
|
|
|
- List<InsOrdersCarUserInfo> userInfoList = insOrdersCarUserInfoService.list(new LambdaQueryWrapper<>(InsOrdersCarUserInfo.class).in(InsOrdersCarUserInfo::getId, userIds));
|
|
|
-
|
|
|
- List<InsAreaCompanyCarUserInfo> insAreaCompanyCarUserInfos = new ArrayList<>();
|
|
|
- userInfoList.forEach(item->{
|
|
|
- String id = item.getId();
|
|
|
- boolean isOwner = false,isApply = false,isInsure = false;
|
|
|
- if(id.equals(insAreaCompanyOld.getOwnerId())){
|
|
|
- isOwner = true;
|
|
|
- }
|
|
|
- if(id.equals(insAreaCompanyOld.getApplyId())){
|
|
|
- isApply = true;
|
|
|
- }
|
|
|
- if(id.equals(insAreaCompanyOld.getInsureId())){
|
|
|
- isInsure = true;
|
|
|
- }
|
|
|
- InsAreaCompanyCarUserInfo userInfo = new InsAreaCompanyCarUserInfo();
|
|
|
- BeanUtils.copyProperties(item, userInfo);
|
|
|
- userInfo.setId(IdGenerate.nextId());
|
|
|
- if(isOwner){
|
|
|
- insAreaCompany.setOwnerId(userInfo.getId());
|
|
|
- }
|
|
|
- if(isApply){
|
|
|
- insAreaCompany.setApplyId(userInfo.getId());
|
|
|
- }
|
|
|
- if(isInsure){
|
|
|
- insAreaCompany.setInsureId(userInfo.getId());
|
|
|
- }
|
|
|
- insAreaCompanyCarUserInfos.add(userInfo);
|
|
|
- });
|
|
|
- insAreaCompanyCarUserInfoService.saveOrUpdateBatch(insAreaCompanyCarUserInfos);
|
|
|
-
|
|
|
- //3 处理 risk
|
|
|
- List<InsAreaCompanyRisk> insAreaCompanyRisks = new ArrayList<>();
|
|
|
- if (insAreaCompanyOld.getRiskinfo() != null) {
|
|
|
- insAreaCompanyOld.getRiskinfo().forEach(riskObj -> {
|
|
|
- InsAreaCompanyRisk insAreaCompanyRisk = new InsAreaCompanyRisk();
|
|
|
- JSONObject risk = (JSONObject) riskObj;
|
|
|
- insAreaCompanyRisk = JSONObject.parseObject(risk.toJSONString(), InsAreaCompanyRisk.class);
|
|
|
- insAreaCompanyRisk.setId(IdGenerate.nextId());
|
|
|
- insAreaCompanyRisk.setCompanyId(insAreaCompany.getId());
|
|
|
- insAreaCompanyRisks.add(insAreaCompanyRisk);
|
|
|
- });
|
|
|
- insAreaCompanyRiskService.saveBatch(insAreaCompanyRisks);
|
|
|
- }
|
|
|
-
|
|
|
- //4 处理 kind
|
|
|
- List<InsAreaCompanyKind> insAreaCompanyKinds = new ArrayList<>();
|
|
|
- if (insAreaCompanyOld.getKindinfo() != null) {
|
|
|
-
|
|
|
- insAreaCompanyOld.getKindinfo().forEach(kindObj -> {
|
|
|
- InsAreaCompanyKind insAreaCompanyKind = new InsAreaCompanyKind();
|
|
|
- JSONObject kind = (JSONObject) kindObj;
|
|
|
- insAreaCompanyKind = JSONObject.parseObject(kind.toJSONString(), InsAreaCompanyKind.class);
|
|
|
- insAreaCompanyKind.setId(IdGenerate.nextId());
|
|
|
- insAreaCompanyKind.setCompanyId(insAreaCompany.getId());
|
|
|
- insAreaCompanyKinds.add(insAreaCompanyKind);
|
|
|
- });
|
|
|
- insAreaCompanyKindService.saveBatch(insAreaCompanyKinds);
|
|
|
- }
|
|
|
- //5 处理 task
|
|
|
- List<InsAreaCompanyTaxArrears> insAreaCompanyTaxArrears = new ArrayList<>();
|
|
|
- if (insAreaCompanyOld.getTaxArrears() != null) {
|
|
|
- insAreaCompanyOld.getTaxArrears().forEach(taskObj -> {
|
|
|
- InsAreaCompanyTaxArrears insAreaCompanyTaxArrear = new InsAreaCompanyTaxArrears();
|
|
|
- JSONObject task = (JSONObject) taskObj;
|
|
|
- insAreaCompanyTaxArrear = JSONObject.parseObject(task.toJSONString(), InsAreaCompanyTaxArrears.class);
|
|
|
- insAreaCompanyTaxArrear.setId(IdGenerate.nextId());
|
|
|
- insAreaCompanyTaxArrear.setCompanyId(insAreaCompany.getId());
|
|
|
- insAreaCompanyTaxArrears.add(insAreaCompanyTaxArrear);
|
|
|
- });
|
|
|
- insAreaCompanyTaxArrearsService.saveBatch(insAreaCompanyTaxArrears);
|
|
|
- }
|
|
|
- insAreaCompanyService.saveOrUpdate(insAreaCompany);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -160,12 +72,103 @@ public class SyncInsAreaCompany {
|
|
|
long count = insAreaCompanyOldService.count();
|
|
|
//查出全部数据
|
|
|
List<InsAreaCompanyVo> list = insAreaCompanyOldService.queryAll(new Page(1,count));
|
|
|
- list.forEach(item->{
|
|
|
- try {
|
|
|
- workThread(item);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ list.forEach(insAreaCompanyOld->{
|
|
|
+ InsOrders insOrders = insOrdersService.getOne(new LambdaQueryWrapper<>(InsOrders.class).eq(InsOrders::getOrderno, insAreaCompanyOld.getOrderno()));
|
|
|
+ if(insOrders != null) {
|
|
|
+ InsAreaCompany insAreaCompany = new InsAreaCompany();
|
|
|
+ if (Objects.isNull(insAreaCompanyOld)) {
|
|
|
+ System.out.printf("insAreaCompanyOld is null");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(insAreaCompanyOld, insAreaCompany);
|
|
|
+// insAreaCompany.setId(IdGenerate.nextId());
|
|
|
+ //1 处理车主信息
|
|
|
+ InsOrdersCarInfo ordersCarInfo = insOrdersCarInfoService.getById(insAreaCompanyOld.getCarInfoId());
|
|
|
+ InsAreaCompanyCarInfo carInfo = new InsAreaCompanyCarInfo();
|
|
|
+ BeanUtils.copyProperties(ordersCarInfo, carInfo);
|
|
|
+ carInfo.setId(IdGenerate.nextId());
|
|
|
+ insAreaCompany.setCarInfoId(carInfo.getId());
|
|
|
+ insAreaCompanyCarInfoService.saveOrUpdate(carInfo);
|
|
|
+
|
|
|
+ //2 处理车险用户信息
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ userIds.add(insOrders.getOwnerId());
|
|
|
+ userIds.add(insOrders.getApplyId());
|
|
|
+ userIds.add(insOrders.getInsureId());
|
|
|
+ List<InsOrdersCarUserInfo> userInfoList = insOrdersCarUserInfoService.list(new LambdaQueryWrapper<>(InsOrdersCarUserInfo.class).in(InsOrdersCarUserInfo::getId, userIds));
|
|
|
+
|
|
|
+ List<InsAreaCompanyCarUserInfo> insAreaCompanyCarUserInfos = new ArrayList<>();
|
|
|
+ userInfoList.forEach(item -> {
|
|
|
+ String id = item.getId();
|
|
|
+ boolean isOwner = false, isApply = false, isInsure = false;
|
|
|
+ if (id.equals(insOrders.getOwnerId())) {
|
|
|
+ isOwner = true;
|
|
|
+ }
|
|
|
+ if (id.equals(insOrders.getApplyId())) {
|
|
|
+ isApply = true;
|
|
|
+ }
|
|
|
+ if (id.equals(insOrders.getInsureId())) {
|
|
|
+ isInsure = true;
|
|
|
+ }
|
|
|
+ InsAreaCompanyCarUserInfo userInfo = new InsAreaCompanyCarUserInfo();
|
|
|
+ BeanUtils.copyProperties(item, userInfo);
|
|
|
+ userInfo.setId(IdGenerate.nextId());
|
|
|
+ if (isOwner) {
|
|
|
+ insAreaCompany.setOwnerId(userInfo.getId());
|
|
|
+ }
|
|
|
+ if (isApply) {
|
|
|
+ insAreaCompany.setApplyId(userInfo.getId());
|
|
|
+ }
|
|
|
+ if (isInsure) {
|
|
|
+ insAreaCompany.setInsureId(userInfo.getId());
|
|
|
+ }
|
|
|
+ insAreaCompanyCarUserInfos.add(userInfo);
|
|
|
+ });
|
|
|
+ insAreaCompanyCarUserInfoService.saveOrUpdateBatch(insAreaCompanyCarUserInfos);
|
|
|
+
|
|
|
+ //3 处理 risk
|
|
|
+ List<InsAreaCompanyRisk> insAreaCompanyRisks = new ArrayList<>();
|
|
|
+ if (insAreaCompanyOld.getRiskinfo() != null) {
|
|
|
+ insAreaCompanyOld.getRiskinfo().forEach(riskObj -> {
|
|
|
+ InsAreaCompanyRisk insAreaCompanyRisk = new InsAreaCompanyRisk();
|
|
|
+ JSONObject risk = (JSONObject) riskObj;
|
|
|
+ insAreaCompanyRisk = JSONObject.parseObject(risk.toJSONString(), InsAreaCompanyRisk.class);
|
|
|
+ insAreaCompanyRisk.setId(IdGenerate.nextId());
|
|
|
+ insAreaCompanyRisk.setCompanyId(insAreaCompany.getId());
|
|
|
+ insAreaCompanyRisks.add(insAreaCompanyRisk);
|
|
|
+ });
|
|
|
+ insAreaCompanyRiskService.saveBatch(insAreaCompanyRisks);
|
|
|
+ }
|
|
|
+
|
|
|
+ //4 处理 kind
|
|
|
+ List<InsAreaCompanyKind> insAreaCompanyKinds = new ArrayList<>();
|
|
|
+ if (insAreaCompanyOld.getKindinfo() != null) {
|
|
|
+
|
|
|
+ insAreaCompanyOld.getKindinfo().forEach(kindObj -> {
|
|
|
+ InsAreaCompanyKind insAreaCompanyKind = new InsAreaCompanyKind();
|
|
|
+ JSONObject kind = (JSONObject) kindObj;
|
|
|
+ insAreaCompanyKind = JSONObject.parseObject(kind.toJSONString(), InsAreaCompanyKind.class);
|
|
|
+ insAreaCompanyKind.setId(IdGenerate.nextId());
|
|
|
+ insAreaCompanyKind.setCompanyId(insAreaCompany.getId());
|
|
|
+ insAreaCompanyKinds.add(insAreaCompanyKind);
|
|
|
+ });
|
|
|
+ insAreaCompanyKindService.saveBatch(insAreaCompanyKinds);
|
|
|
+ }
|
|
|
+ //5 处理 task
|
|
|
+ List<InsAreaCompanyTaxArrears> insAreaCompanyTaxArrears = new ArrayList<>();
|
|
|
+ if (insAreaCompanyOld.getTaxArrears() != null) {
|
|
|
+ insAreaCompanyOld.getTaxArrears().forEach(taskObj -> {
|
|
|
+ InsAreaCompanyTaxArrears insAreaCompanyTaxArrear = new InsAreaCompanyTaxArrears();
|
|
|
+ JSONObject task = (JSONObject) taskObj;
|
|
|
+ insAreaCompanyTaxArrear = JSONObject.parseObject(task.toJSONString(), InsAreaCompanyTaxArrears.class);
|
|
|
+ insAreaCompanyTaxArrear.setId(IdGenerate.nextId());
|
|
|
+ insAreaCompanyTaxArrear.setCompanyId(insAreaCompany.getId());
|
|
|
+ insAreaCompanyTaxArrears.add(insAreaCompanyTaxArrear);
|
|
|
+ });
|
|
|
+ insAreaCompanyTaxArrearsService.saveBatch(insAreaCompanyTaxArrears);
|
|
|
+ }
|
|
|
+ insAreaCompanyService.saveOrUpdate(insAreaCompany);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
-}
|
|
|
+}
|