| | |
| | | @Autowired |
| | | private IPayFeeDetailDiscountNewV1InnerServiceSMO payFeeDetailDiscountNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ImportRoomFeeQueueDataAdapt importRoomFeeQueueDataAdapt; |
| | | |
| | | @Override |
| | | public void importData(List<AssetImportLogDetailDto> assetImportLogDetailDtos) { |
| | | importDatas(assetImportLogDetailDtos); |
| | | |
| | | for (AssetImportLogDetailDto assetImportLogDetailDto : assetImportLogDetailDtos) { |
| | | try { |
| | | importDatas(assetImportLogDetailDto); |
| | | updateImportLogDetailState(assetImportLogDetailDto.getDetailId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | updateImportLogDetailState(assetImportLogDetailDto.getDetailId(), e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | private void importDatas(List<AssetImportLogDetailDto> infos) { |
| | | private void importDatas(AssetImportLogDetailDto assetImportLogDetailDto) { |
| | | |
| | | List<ImportRoomFee> importRoomFees = new ArrayList<>(); |
| | | List<ImportRoomFee> importCarFees = new ArrayList<>(); |
| | | for (AssetImportLogDetailDto assetImportLogDetailDto : infos) { |
| | | List<ImportRoomFee> importContractFees = new ArrayList<>(); |
| | | List<CarInoutPo> carInoutPos = new ArrayList<>(); |
| | | String communityId = assetImportLogDetailDto.getCommunityId(); |
| | | JSONObject data = JSONObject.parseObject(assetImportLogDetailDto.getContent()); |
| | | ImportRoomFee importRoomFee = BeanConvertUtil.covertBean(data, ImportRoomFee.class); |
| | |
| | | carInout.setCreateTime(JSONObject.parseObject(assetImportLogDetailDto.getContent().toString()).getString("inputTime")); |
| | | carInout.setbId(JSONObject.parseObject(assetImportLogDetailDto.getContent().toString()).getString("batchId")); |
| | | |
| | | List<CarInoutPo> carInoutPos = new ArrayList<>(); |
| | | carInout.setInoutId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_inoutId)); |
| | | carInout.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | carInoutPos.add(carInout); |
| | | |
| | | // 如果有结束时间,创建新的对象作为出口记录 |
| | |
| | | exitCarInout.setState("100400"); |
| | | exitCarInout.setInoutId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_inoutId)); |
| | | exitCarInout.setPaymentAmount(JSONObject.parseObject(assetImportLogDetailDto.getContent().toString()).getString("chargeAmount")); |
| | | |
| | | exitCarInout.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | | carInoutPos.add(exitCarInout); |
| | | } |
| | | |
| | | try { |
| | | carInoutInnerServiceSMOImpl.batchSaveCarInout2(carInoutPos); |
| | | }catch (Exception e){ |
| | | |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | updateImportLogDetailState(importRoomFee.getDetailId()); |
| | | } |
| | | else if(contractTypes.contains(importRoomFee.getSecondaryFeeTypeCd())){ |
| | | importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); |
| | |
| | | // if(importRoomFee.getPayerObjName()) |
| | | importCarFees.add(importRoomFee); |
| | | } |
| | | else if(carTypes.contains(JSONObject.parseObject(infos.get(0).getContent()).get("category22"))){ |
| | | else if(carTypes.contains(JSONObject.parseObject(assetImportLogDetailDto.getContent()).get("category22"))){ |
| | | importRoomFee.setCommunityId(communityId); |
| | | importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); |
| | | importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); |
| | |
| | | // if(importRoomFee.getPayerObjName()) |
| | | importRoomFees.add(importRoomFee); |
| | | } |
| | | } |
| | | importFeeDetailsByCarInout(carInoutPos); |
| | | |
| | | if (ListUtil.isNull(importRoomFees) && ListUtil.isNull(importCarFees)) { |
| | | return; |
| | |
| | | if(!(ListUtil.isNull(importCarFees))){ |
| | | importCarHistoryFeeDetailQueueDataAdapt.importCarFeeDetails(importCarFees.get(0).getStoreId(), importCarFees.get(0).getUserId(), importCarFees, importCarFees.get(0).getBatchId()); |
| | | } |
| | | // |
| | | // |
| | | |
| | | } |
| | | |
| | | private void importFeeDetailsByCarInout(List<CarInoutPo> carInoutPos) { |
| | | |
| | | for (CarInoutPo carInoutPo : carInoutPos) { |
| | | try { |
| | | ArrayList<CarInoutPo> carInoutPos1 = new ArrayList<>(); |
| | | carInoutPos1.add(carInoutPo); |
| | | carInoutInnerServiceSMOImpl.batchSaveCarInout2(carInoutPos1); |
| | | updateImportLogDetailState(carInoutPo.getDetailId()); |
| | | }catch (Exception e){ |
| | | updateImportLogDetailState(carInoutPo.getDetailId(),e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | updateImportLogDetailState(importRoomFee.getDetailId(), e); |
| | | throw new IllegalArgumentException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | private void importFeeDetail(ImportRoomFee importRoomFee, String storeId, String userId, String batchId) { |
| | | |
| | | RoomDto roomDto = new RoomDto(); |
| | | roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); |
| | | // roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); |
| | | roomDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | if(importRoomFee.getDoorRoomNum()!=null){ |
| | | String[] split = importRoomFee.getDoorRoomNum().split("-"); |
| | | if(split.length==2){ |
| | | roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); |
| | | }else if(split.length > 2){ |
| | | roomDto.setFloorNum(split[0]); |
| | | roomDto.setUnitNum(split[1]); |
| | | roomDto.setRoomNum(split[2]); |
| | | } |
| | | } |
| | | List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); |
| | | try { |
| | | importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); |
| | |
| | | } |
| | | FeeDto feeDto2 = new FeeDto(); |
| | | feeDto2.setFeeName(importRoomFee.getFeeName()); |
| | | List<FeeDto> feeDtos2 = feeInnerServiceSMOImpl.queryFees(feeDto2); |
| | | if(feeDtos2.size() == 0){ |
| | | feeDto2.setPayerObjId(importRoomFee.getRoomId()); |
| | | feeDto2.setCommunityId(importRoomFee.getCommunityId()); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto2); |
| | | if(feeDtos.size() == 0){ |
| | | updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); |
| | | |
| | | throw new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在"); |
| | | } |
| | | FeeConfigDto feeConfigDto = new FeeConfigDto(); |
| | | feeConfigDto.setFeeName(importRoomFee.getFeeName().trim()); |
| | | feeConfigDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | |
| | | if (ListUtil.isNull(feeConfigDtos)) { |
| | | throw new IllegalArgumentException("收费项"+feeConfigDto.getFeeName()+"不存在"); |
| | | } |
| | | |
| | | FeeConfigDto tmpFeeConfigDto = feeConfigDtos.get(0); |
| | | |
| | | FeeDto feeDto = new FeeDto(); |
| | | feeDto.setConfigId(tmpFeeConfigDto.getConfigId()); |
| | | feeDto.setCommunityId(importRoomFee.getCommunityId()); |
| | | feeDto.setPayerObjId(importRoomFee.getRoomId()); |
| | | feeDto.setPayerObjType(importRoomFee.getObjType() ==null?FeeDto.PAYER_OBJ_TYPE_ROOM:importRoomFee.getObjType()); |
| | | feeDto.setFeeTypeCd(feeConfigDtos.get(0).getFeeTypeCd()); |
| | | feeDto.setConfigId(tmpFeeConfigDto.getConfigId()); |
| | | // 解析日期字符串 |
| | | LocalDateTime startDate = LocalDateTime.parse(importRoomFee.getStartTime(), formatter); |
| | | LocalDateTime endDate = LocalDateTime.parse(importRoomFee.getEndTime(), formatter); |
| | | importRoomFee.setCycle(String.valueOf(ChronoUnit.MONTHS.between(startDate, endDate))); |
| | | List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | importRoomFee.setPayObjId(importRoomFee.getRoomId()); |
| | | if (ListUtil.isNull(feeDtos)) { |
| | | throw new IllegalArgumentException("查询不到该记录的费用项:"+importRoomFee.getFeeName()+startDate+endDate); |
| | | throw new IllegalArgumentException("查询不到该记录的费用项:"+importRoomFee.getFeeName()); |
| | | // List<FeeAttrPo> feeAttrsPos = new ArrayList<>(); |
| | | // PayFeePo payFeePo = new PayFeePo(); |
| | | // payFeePo.setCommunityId(importRoomFee.getCommunityId()); |
| | |
| | | // feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); |
| | | } |
| | | if(feeDtos.size()>1){ |
| | | throw new IllegalArgumentException("该初始化缴费记录信息中包含多个费用记录"+importRoomFee.getFeeName()+startDate+endDate); |
| | | throw new IllegalArgumentException("该初始化缴费记录信息中包含多个费用记录"+importRoomFee.getFeeName()); |
| | | } |
| | | for (FeeDto tmpFeeDto : feeDtos) { |
| | | if(DateUtil.getDateFromStringB(importRoomFee.getEndTime()).getTime() > tmpFeeDto.getEndTime().getTime()){ |
| | | if(DateUtil.getDateFromStringB(importRoomFee.getEndTime()).getTime() > tmpFeeDto.getMaxEndTime().getTime()){ |
| | | throw new IllegalArgumentException("该费用记录结束时间大于费用记录最大缴费时间"); |
| | | } |
| | | doImportFeeDetail(tmpFeeDto, importRoomFee); |
| | |
| | | PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo(); |
| | | payFeeDetailPo.setCommunityId(importRoomFee.getCommunityId()); |
| | | payFeeDetailPo.setReceivedAmount(importRoomFee.getAmount()); |
| | | payFeeDetailPo.setCycles(importRoomFee.getCycle()); |
| | | payFeeDetailPo.setPrimeRate("1.0"); |
| | | payFeeDetailPo.setFeeId(tmpFeeDto.getFeeId()); |
| | | payFeeDetailPo.setStartTime(importRoomFee.getStartTime()); |
| | | payFeeDetailPo.setEndTime(importRoomFee.getEndTime()); |
| | | payFeeDetailPo.setRemark(importRoomFee.getRemark()); |
| | | payFeeDetailPo.setCreateTime(importRoomFee.getCreateTime()); |
| | | payFeeDetailPo.setState("1400"); |
| | |
| | | payFeeDetailPo.setB("T"); |
| | | double cycle = (DateUtil.dayCompare( |
| | | DateUtil.getDateFromStringA(payFeeDetailPo.getStartTime()), |
| | | DateUtil.getDateFromStringA(payFeeDetailPo.getEndTime()) |
| | | DateUtil.getDateFromStringA(importRoomFee.getEndTime()) |
| | | )); |
| | | payFeeDetailPo.setCycles(cycle+""); |
| | | int count = feeDetailInnerServiceSMOImpl.queryFeeDetailsCountByVo(payFeeDetailPo); |
| | | |
| | | payFeeDetailPo.setPayableAmount(importRoomFee.getAmount()); |
| | | |
| | | |
| | | payFeeDetailPo.setCycles(importRoomFee.getCycle()); |
| | | payFeeDetailPo.setCycles(cycle+""); |
| | | payFeeDetailPo.setEndTime(importRoomFee.getEndTime()); |
| | | if (count > 0) { |
| | | throw new IllegalStateException("重复的缴费记录"); |
| | | } |
| | |
| | | payFeeDetailPo.setReceivableAmount((Double.parseDouble(payFeeDetailPo.getReceivedAmount()) + Double.parseDouble(payFeeDetailPo.getDiscountAmount()))+""); |
| | | payFeeDetailDiscount.setDiscountId(discountId); |
| | | payFeeDetailDiscount.setDiscountPrice(discountPrice); |
| | | }else{ |
| | | payFeeDetailPo.setReceivableAmount(payFeeDetailPo.getReceivedAmount()+""); |
| | | } |
| | | } |
| | | } catch (ParseException e) { |
| | | throw new RuntimeException(e); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | |
| | | |
| | |
| | | payFeeDetailDiscount.setCommunityId(feeDtos.get(0).getCommunityId()); |
| | | payFeeDetailDiscount.setFeeId(feeDtos.get(0).getFeeId()); |
| | | payFeeDetailDiscount.setDetailDiscountId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_discountId)); |
| | | } |
| | | |
| | | payFeeDetailDiscountNewV1InnerServiceSMOImpl.savePayFeeDetailDiscountNew(payFeeDetailDiscount); |
| | | payFeeDetailDiscountNewV1InnerServiceSMOImpl.savePayFeeDetailDiscountNew(payFeeDetailDiscount); |
| | | } |
| | | |
| | | if (saved < 1) { |
| | | return; |