| | |
| | | import com.java110.dto.parking.ParkingSpaceDto; |
| | | import com.java110.dto.room.RoomDto; |
| | | import com.java110.fee.dao.IApplyRoomDiscountServiceDao; |
| | | import com.java110.intf.community.ICommunityV1InnerServiceSMO; |
| | | import com.java110.intf.community.IParkingAreaV1InnerServiceSMO; |
| | | import com.java110.intf.community.IParkingSpaceV1InnerServiceSMO; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | | import com.java110.intf.community.*; |
| | | import com.java110.intf.dev.IDictV1InnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeAttrInnerServiceSMO; |
| | | import com.java110.intf.fee.IFeeConfigInnerServiceSMO; |
| | |
| | | import java.math.BigDecimal; |
| | | import java.security.acl.Owner; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 车辆导入 适配器 |
| | |
| | | private IRoomInnerServiceSMO iroomInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl; |
| | | ICommunityInnerServiceSMO communityInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMOImpl; |
| | |
| | | OwnerCarDto ownerCarDto = null; |
| | | doImportData(assetImportLogDetailDto,ownerCarDto); |
| | | updateImportLogDetailState(assetImportLogDetailDto.getDetailId()); |
| | | // try { |
| | | // Thread.sleep(500); |
| | | // } catch (InterruptedException e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | |
| | | String otherItem = data.getString("otherItem"); |
| | | data.put("otherItem", null); |
| | | ownerCarDto = BeanConvertUtil.covertBean(data, OwnerCarDto.class); |
| | | if (ownerCarDto.getOwnerName() == null || "".equals(ownerCarDto.getOwnerName())) { |
| | | { |
| | | RoomDto roomDto = new RoomDto(); |
| | | roomDto.setRoadName(ownerCarDto.getRoadName()); |
| | | roomDto.setFloorNum(ownerCarDto.getFloorNum()); |
| | | roomDto.setCommunityId(ownerCarDto.getCommunityId()); |
| | | roomDto.setUnitNum(ownerCarDto.getUnitNum()); |
| | | roomDto.setRoomNum(ownerCarDto.getRoomNum()); |
| | | if (Vtil.defaultValue(roomDto.getRoomNum()).equals("")){ |
| | | if (Vtil.defaultValue(roomDto.getRoomNum()) == null){ |
| | | roomDto.setPropertyType("商铺"); |
| | | } |
| | | List<RoomDto> roomDtos = iroomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | if (roomDtos.isEmpty()) { |
| | | ownerCarDto.setRemark("房屋:" + roomDto.getRoadName() + "-" + roomDto.getFloorNum() + "-" + roomDto.getUnitNum() + "-" + Vtil.defaultValue(ownerCarDto.getRoomName()) + "未查询到"); |
| | | ownerCarDto.setRemark("房屋:" + roomDto.getRoadName() + "-" + roomDto.getFloorNum() + "-" + roomDto.getUnitNum() + "-" + Vtil.defaultValue(ownerCarDto.getRoomNum(),"空") + "未查询到"); |
| | | // throw new IllegalArgumentException("未填写业主且房屋不存在"); |
| | | } else if (roomDtos.size() > 1) { |
| | | ownerCarDto.setRemark("房屋:" + roomDto.getRoadName() + "-" + roomDto.getFloorNum() + "-" + roomDto.getUnitNum() + "-" + Vtil.defaultValue(ownerCarDto.getRoomName()) + "查询到多个房屋"); |
| | |
| | | if (ownerRoomRelDtos.isEmpty()) { |
| | | ownerCarDto.setRemark("房屋:" + roomDto.getRoadName() + "-" + roomDto.getFloorNum() + "-" + roomDto.getUnitNum() + "-" + Vtil.defaultValue(ownerCarDto.getRoomName()) + "未查询到业主"); |
| | | // throw new IllegalArgumentException("未填写业主且该房屋未绑定业主"); |
| | | } else { |
| | | } |
| | | else { |
| | | OwnerDto ownerDto = new OwnerDto(); |
| | | ownerDto.setOwnerId(ownerRoomRelDtos.get(0).getOwnerId()); |
| | | List<OwnerDto> ownerDtos = ownerV1InnerServiceSMOImpl.queryOwners(ownerDto); |
| | |
| | | ownerCarDto.setOtherItem(o); |
| | | ownerCarDto.setLeaseType("H"); |
| | | CommunityDto communityDto = new CommunityDto(); |
| | | Object[] os = ownerCarDto.getOtherItem(); |
| | | // 原代码 |
| | | Object[] os2 = ownerCarDto.getOtherItem(); |
| | | Object[] os = new Object[102]; |
| | | |
| | | // 数组复制核心代码 |
| | | if (os2.length > 101) { |
| | | throw new IllegalArgumentException("长度超过限制(100列)"); |
| | | } |
| | | if (os2 != null) { // 先判空,避免空指针异常 |
| | | // 参数说明:源数组、源数组起始位置、目标数组、目标数组起始位置、复制长度 |
| | | System.arraycopy(os2, 0, os, 0, os2.length); |
| | | } |
| | | |
| | | String communityId = ownerCarDto.getCommunityId(); |
| | | JSONArray objects = JSONObject.parseArray(otherItem); |
| | | while (objects.size() < 100) { |
| | | objects.add(null); // 也可以填 ""、0 等自定义默认值 |
| | | } |
| | | |
| | | OwnerCarDto carDto = new OwnerCarDto(); |
| | | carDto.setCommunityId(ownerCarDto.getCommunityId()); |
| | | carDto.setCarNum(ownerCarDto.getCarNum()); |
| | | communityDto.setCommunityCode(defaultValue(os[1])); |
| | | communityDto.setName(defaultValue(os[2])); |
| | | List<CommunityDto> communityDtos = communityV1InnerServiceSMOImpl.queryCommunitys(communityDto); |
| | | if (communityDto.getCommunityCode() == null && communityDto.getName() == null) { |
| | | throw new IllegalArgumentException("导入失败:小区编码和小区名称都为空"); |
| | | } |
| | | List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto); |
| | | if (communityDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("不存在小区编码为:" + communityDto.getCommunityCode() + "的小区"); |
| | | throw new IllegalArgumentException("不存在的小区:" + communityDto.getCommunityCode() + communityDto.getName() + ""); |
| | | } |
| | | assetImportLogDetailDto.setCommunityId(communityDtos.get(0).getCommunityId()); |
| | | ownerCarDto.setCommunityId(communityDtos.get(0).getCommunityId()); |
| | |
| | | |
| | | |
| | | //获取房屋名称 |
| | | String carTypeCd = defaultValue(os[12]); |
| | | if (!carTypeCd.equals("")){ |
| | | DictDto dictDto = new DictDto(); |
| | | dictDto.setTableName("owner_car"); |
| | | dictDto.setTableColumns("car_type_cd"); |
| | | dictDto.setName(carTypeCd); |
| | | List<DictDto> dictDtos = dictV1InnerServiceSMOImpl.queryDicts(dictDto); |
| | | if (dictDtos.isEmpty()) { |
| | | dictDto.setName(null); |
| | | List<DictDto> dictDtos1 = dictV1InnerServiceSMOImpl.queryDicts(dictDto); |
| | | DictPo dictPo = new DictPo(); |
| | | dictPo.setTableName("owner_car"); |
| | | dictPo.setTableColumns("car_type_cd"); |
| | | dictPo.setName(carTypeCd); |
| | | dictPo.setStatusCd(dictDtos1.get(dictDtos1.size() - 1).getStatusCd() + 100); |
| | | int i = dictV1InnerServiceSMOImpl.saveDict(dictPo); |
| | | if (i == 0) { |
| | | throw new IllegalArgumentException("添加字典失败!"); |
| | | } |
| | | } else { |
| | | ownerCarPo.setCarTypeCd(dictDtos.get(0).getStatusCd()); |
| | | } |
| | | } |
| | | else { |
| | | ownerCarPo.setCarTypeCd("1001"); //默认主车辆 |
| | | } |
| | | // String carTypeCd = defaultValue(os[12]); |
| | | // if (!carTypeCd.equals("")){ |
| | | // DictDto dictDto = new DictDto(); |
| | | // dictDto.setTableName("owner_car"); |
| | | // dictDto.setTableColumns("car_type_cd"); |
| | | // dictDto.setName(carTypeCd); |
| | | // List<DictDto> dictDtos = dictV1InnerServiceSMOImpl.queryDicts(dictDto); |
| | | // if (dictDtos.isEmpty()) { |
| | | // dictDto.setName(null); |
| | | // List<DictDto> dictDtos1 = dictV1InnerServiceSMOImpl.queryDicts(dictDto); |
| | | // DictPo dictPo = new DictPo(); |
| | | // dictPo.setTableName("owner_car"); |
| | | // dictPo.setTableColumns("car_type_cd"); |
| | | // dictPo.setName(carTypeCd); |
| | | // dictPo.setStatusCd(String.valueOf(Integer.parseInt(dictDtos1.get(dictDtos1.size() - 1).getStatusCd()) + 100)); |
| | | // int i = dictV1InnerServiceSMOImpl.saveDict(dictPo); |
| | | // if (i == 0) { |
| | | // throw new IllegalArgumentException("添加字典失败!"); |
| | | // } |
| | | // } else { |
| | | // ownerCarPo.setCarTypeCd(dictDtos.get(0).getStatusCd()); |
| | | // } |
| | | // } |
| | | // else { |
| | | // ownerCarPo.setCarTypeCd("1001"); //默认主车辆 |
| | | // } |
| | | |
| | | |
| | | ownerCarPo.setCarTypeCd("1001"); //默认主车辆 |
| | | int i1 = ownerCarInnerServiceSMOImpl.queryOwnerCarsCount(carDto); |
| | | if (i1 > 0) { |
| | | carDto.setOwnerId(ownerCarDto.getOwnerId()); |
| | | carDto.setCommunityId(ownerCarDto.getCommunityId()); |
| | | carDto.setParkingType(Vtil.defaultValue(os[13])); |
| | | carDto.setCarNum(null); |
| | | carDto.setCarNumLikeRight_(ownerCarDto.getCarNum()); |
| | |
| | | carDto.setCarTypeCd(ownerCarPo.getCarTypeCd()); |
| | | carDto.setUnitPricePerMonth(defaultValue(os[18])); |
| | | int i2 = ownerCarInnerServiceSMOImpl.queryOwnerCarsCount(carDto); |
| | | if (i2 > 0) { |
| | | throw new IllegalArgumentException("重复的车辆:" + ownerCarDto.getCarNum()); |
| | | } else { |
| | | ownerCarDto.setCarNum(ownerCarDto.getCarNum() + "_" + i1); |
| | | } |
| | | ownerCarPo.setCarNum(ownerCarDto.getCarNum() + "_" + (i2 + 1)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | //导入车辆 |
| | | saveFee(ownerCarPo, os, ownerCarDto, assetImportLogDetailDto); |
| | | if (Vtil.processCount(ownerCarPo.getUnitPricePerMonth(), 2, null) == null) { |
| | | ownerCarPo.setRemark(Vtil.defaultValue(ownerCarPo.getRemark(), "") + "\n未传入收费单价"); |
| | | }else { |
| | | saveFee(ownerCarPo, os, ownerCarDto, assetImportLogDetailDto); |
| | | } |
| | | ownerCarPo.setParkingType(Vtil.defaultValue(os[12])); |
| | | |
| | | ownerCarPo.setRoadName(defaultValue(os[3])); |
| | | ownerCarPo.setFloorNum(defaultValue(os[4])); |
| | | ownerCarPo.setUnitNum(defaultValue(os[5])); |
| | | ownerCarPo.setRoomNum(defaultValue(os[6])); |
| | | ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | ownerCarPo.setParkingLocation(defaultValue(os[12])); |
| | | try { |
| | | ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | } catch (Exception e) { |
| | | if (e.getMessage().contains("for column 'end_time' at row 1")){ |
| | | ownerCarPo.setRemark(Vtil.defaultValue(ownerCarPo.getRemark(), "") + "\n注销日期:" + ownerCarPo.getEndTime() + "格式错误"); |
| | | ownerCarPo.setEndTime(null); |
| | | try { |
| | | ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | } catch (Exception e2) { |
| | | if (e2.getMessage().contains("for column 'start_time' at row 1")) { |
| | | ownerCarPo.setRemark(Vtil.defaultValue(ownerCarPo.getRemark(), "") + "\n启用日期:" + ownerCarPo.getStartTime() + "格式错误"); |
| | | ownerCarPo.setStartTime(null); |
| | | ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | } |
| | | } |
| | | } |
| | | else if (e.getMessage().contains("for column 'start_time' at row 1")){ |
| | | ownerCarPo.setRemark(Vtil.defaultValue(ownerCarPo.getRemark(), "") + "\n启用日期:" + ownerCarPo.getStartTime() + "格式错误"); |
| | | ownerCarPo.setStartTime(null); |
| | | ownerCarV1InnerServiceSMOImpl.saveOwnerCar(ownerCarPo); |
| | | |
| | | } |
| | | |
| | | } |
| | | ParkingSpacePo parkingSpacePo = new ParkingSpacePo(); |
| | | parkingSpacePo.setPsId(psId); //车位id |
| | | parkingSpacePo.setState(ownerCarDto.getSpaceSate()); |
| | |
| | | FeeConfigDto feeConfigDto = new FeeConfigDto(); |
| | | feeConfigDto.setCommunityId(ownerCarPo.getCommunityId()); |
| | | feeConfigDto.setSquarePrice(Vtil.processCount(ownerCarPo.getUnitPricePerMonth(), 2, null)); |
| | | switch (Vtil.defaultValue(os[12])) { |
| | | case "地面停车": feeConfigDto.setFeeTypeCd("630000003");break; |
| | | case "地下停车": feeConfigDto.setFeeTypeCd("630000004");break; |
| | | default: feeConfigDto.setFeeTypeCds(new String[]{"630000003","630000004"}); |
| | | } |
| | | feeConfigDto.setFeeTypeCds(new String[]{"630000003","630000004","630000005"}); |
| | | if (feeConfigDto.getSquarePrice() == null) { |
| | | throw new IllegalArgumentException("未查询到收费项"); |
| | | throw new IllegalArgumentException(Vtil.defaultValue(ownerCarPo.getRemark(), "") + "未传入收费单价"); |
| | | } |
| | | feeDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | if (feeDtos.isEmpty()) { |
| | | throw new IllegalArgumentException("单价`"+ownerCarPo.getUnitPricePerMonth()+"`未查询到收费项"); |
| | | ownerCarPo.setRemark("单价`"+ownerCarPo.getUnitPricePerMonth()+"`未查询到收费项"); |
| | | return; |
| | | } else if (feeDtos.size() > 1) { |
| | | switch (Vtil.defaultValue(os[12])) { |
| | | case "地面停车": feeConfigDto.setFeeTypeCd("630000003");break; |
| | | case "地下停车": feeConfigDto.setFeeTypeCd("630000004");break; |
| | | default: feeConfigDto.setFeeTypeCd("630000005");break; |
| | | } |
| | | feeDtos.removeIf(feeConfigDto1 -> !feeConfigDto1.getFeeTypeCd().equals(feeConfigDto.getFeeTypeCd())); |
| | | } |
| | | |
| | | if (feeDtos.isEmpty()) { |
| | | ownerCarPo.setRemark("单价`"+ownerCarPo.getUnitPricePerMonth()+"`未查询到收费项"); |
| | | return; |
| | | } |
| | | else if (feeDtos.size() > 1) { |
| | | throw new IllegalArgumentException("系统错误,查询到的费用项超过一个"); |
| | | } |
| | | } |
| | | FeeConfigDto feeDto = feeDtos.get(0); |