| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Integer create(YwContractBill ywContractBill) { |
| | | if(Objects.isNull(ywContractBill) |
| | |
| | | || Objects.isNull(ywContractBill.getCostType()) |
| | | || Objects.isNull(ywContractBill.getBillType()) |
| | | || Objects.isNull(ywContractBill.getCompanyId()) |
| | | || Objects.isNull(ywContractBill.getStartDate()) |
| | | || Objects.isNull(ywContractBill.getEndDate()) |
| | | || com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywContractBill.getYwContractRoomList()) |
| | | || Objects.nonNull(ywContractBill.getFeeType()) |
| | | || (Constants.equalsInteger(ywContractBill.getFeeType(),Constants.ZERO)&& (Objects.isNull(ywContractBill.getStartDate()) |
| | | || Objects.isNull(ywContractBill.getEndDate()))) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | |
| | | ywContractBill.setCreateDate(new Date()); |
| | | ywContractBill.setCreator(loginUserInfo.getId()); |
| | | ywContractBill.setIsdeleted(Constants.ZERO); |
| | | ywContractBill.setType(Constants.contractBillType.create); |
| | | ywContractBill.setType(Constants.ONE); |
| | | ywContractBill.setStatus(Constants.ZERO); |
| | | ywContractBillMapper.insert(ywContractBill); |
| | | |
| | |
| | | ywContractRoom.setIsdeleted(Constants.ZERO); |
| | | ywContractRoom.setContractId(ywContractBill.getId()); |
| | | ywContractRoom.setType(Constants.ONE); |
| | | |
| | | } |
| | | ywContractRoomMapper.insert(ywContractBill.getYwContractRoomList()); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public YwContractBill getDetail(Integer id) { |
| | | YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class, |
| | | new MPJLambdaWrapper<YwContractBill>().selectAll(YwContractBill.class) |
| | |
| | | ); |
| | | //楼宇名称 |
| | | List<YwContractRoom> ywContractRoomList = ywContractBill.getYwContractRoomList(); |
| | | // String roomPathName = new StringBuffer(); |
| | | // for (: |
| | | // ) { |
| | | // |
| | | // } |
| | | |
| | | |
| | | StringBuilder roomPathName = new StringBuilder(); |
| | | for (YwContractRoom ywContractRoom:ywContractRoomList) { |
| | | if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){ |
| | | roomPathName.append(ywContractRoom.getProjectName()); |
| | | } |
| | | if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){ |
| | | roomPathName.append(ywContractRoom.getBuildingName()); |
| | | } |
| | | if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){ |
| | | roomPathName.append(ywContractRoom.getFloorName()); |
| | | } |
| | | if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){ |
| | | roomPathName.append(ywContractRoom.getRoomName()); |
| | | } |
| | | if(StringUtils.isNotBlank(roomPathName)){ |
| | | roomPathName.append(";"); |
| | | } |
| | | } |
| | | ywContractBill.setRoomPathName(roomPathName.toString()); |
| | | |
| | | } |
| | | |
| | | return PageData.from(iPage); |
| | | } |
| | | |
| | | |
| | | |
| | | public void dealRoomDetail(List<YwContractBill> ywContractBillList){ |
| | | //查询账单下的楼宇数据 |
| | |
| | | .selectAs(YwProject::getName,YwRoom::getProjectName) |
| | | .selectAs(YwFloor::getName,YwRoom::getFloorName) |
| | | .selectAs(YwBuilding::getName,YwRoom::getBuildingName) |
| | | .selectAs(YwRoom::getName,YwContractRoom::getRoomName) |
| | | .leftJoin(YwRoom.class,YwRoom::getId,YwContractRoom::getRoomId) |
| | | .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor) |
| | | .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId) |
| | |
| | | QueryWrapper<YwContractBill> wrapper = new QueryWrapper<>(ywContractBill); |
| | | return ywContractBillMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void dealDayBillCode(){ |
| | | List<YwContractBill> ywContractBillList = ywContractBillMapper.selectJoinList(YwContractBill.class, |
| | | new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class) |
| | | .select(" DATE(CREATE_DATE) as codeDate") |
| | | .isNull(YwContractBill::getCode) |
| | | .orderByAsc(YwContractBill::getId) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBillList)){ |
| | | List<String> codeDateList = ywContractBillList.stream().map(i->i.getCodeDate()).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(codeDateList)){ |
| | | Set<String> codeDateSet = new HashSet<String>(codeDateList); |
| | | for (String codeDate:codeDateSet) { |
| | | //获取当前日期的数据 |
| | | List<YwContractBill> codeDateBillList = |
| | | ywContractBillList.stream().filter(i->i.getCodeDate().equals(codeDate)).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(codeDateBillList)){ |
| | | continue; |
| | | } |
| | | //查询最大的单号 |
| | | YwContractBill ywContractBill = ywContractBillMapper.selectOne(new QueryWrapper<YwContractBill>().lambda() |
| | | .isNotNull(YwContractBill::getCode) |
| | | .apply(" CREATE_DATE like '"+codeDate+"%' ") |
| | | .orderByDesc(YwContractBill::getId) |
| | | ); |
| | | Integer maxCode = Constants.ONE; |
| | | if(Objects.nonNull(ywContractBill)){ |
| | | maxCode = Integer.valueOf(ywContractBill.getCode().replace("ZD"+codeDate,"")); |
| | | } |
| | | for (YwContractBill contractBill:codeDateBillList) { |
| | | maxCode = maxCode + 1; |
| | | contractBill.setCode("ZD" + codeDate + "-" + StringUtils.leftPad(maxCode.toString() , 4,"0")); |
| | | ywContractBillMapper.update(null, new UpdateWrapper<YwContractBill>().lambda().set(YwContractBill::getCode,contractBill.getCode()) |
| | | .eq(YwContractBill::getId,ywContractBill.getId())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |