| | |
| | | |
| | | @Override |
| | | public R addRota(List<ComSwRotaSaveDTO> comSwRotaSaveDTOs) { |
| | | comSwRotaSaveDTOs.forEach(comSwRotaSaveDTO -> { |
| | | if (comSwRotaSaveDTO.getId() != null && comSwRotaSaveDTO.getId() != 0) { |
| | | ComSwRotaDO comSwRotaDO = new ComSwRotaDO(); |
| | | BeanUtils.copyProperties(comSwRotaSaveDTO, comSwRotaDO); |
| | | try { |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | comSwRotaDAO.updateById(comSwRotaDO); |
| | | } else { |
| | | ComSwRotaDO comSwRotaDO = new ComSwRotaDO(); |
| | | BeanUtils.copyProperties(comSwRotaSaveDTO, comSwRotaDO); |
| | | comSwRotaDO.setId(Snowflake.getId()); |
| | | try { |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | comSwRotaDAO.insert(comSwRotaDO); |
| | | for (ComSwRotaSaveDTO comSwRotaSaveDTO : comSwRotaSaveDTOs){ |
| | | if (comSwRotaSaveDTO.getId() != null && comSwRotaSaveDTO.getId() != 0) { |
| | | ComSwRotaDO comSwRotaDO = comSwRotaDAO.selectById(comSwRotaSaveDTO.getId()); |
| | | if (null == comSwRotaDO) { |
| | | return R.fail("该值班表不存在"); |
| | | } |
| | | }); |
| | | ComSwRotaDO checkCreditCode = comSwRotaDAO.selectOne(new QueryWrapper<ComSwRotaDO>().lambda().eq(ComSwRotaDO::getRotaDate, comSwRotaSaveDTO.getRotaDate())); |
| | | if (null != checkCreditCode && comSwRotaDO.getId() != checkCreditCode.getId()) { |
| | | return R.fail("该值班表已存在,值班日期重复"); |
| | | } |
| | | BeanUtils.copyProperties(comSwRotaSaveDTO, comSwRotaDO); |
| | | try { |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | comSwRotaDAO.updateById(comSwRotaDO); |
| | | } else { |
| | | Integer count = comSwRotaDAO.selectCount(new QueryWrapper<ComSwRotaDO>().lambda().eq(ComSwRotaDO::getRotaDate, comSwRotaSaveDTO.getRotaDate())); |
| | | if (count > 0) { |
| | | return R.fail("该值班表已存在,值班日期重复"); |
| | | } |
| | | ComSwRotaDO comSwRotaDO = new ComSwRotaDO(); |
| | | BeanUtils.copyProperties(comSwRotaSaveDTO, comSwRotaDO); |
| | | comSwRotaDO.setId(Snowflake.getId()); |
| | | try { |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | comSwRotaDAO.insert(comSwRotaDO); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public R listSaveSwRotaExcelVO(List<ComSwRotaExcelVO> list, Long communityId) { |
| | | List<ComSwRotaDO> comSwRotaDOS = new ArrayList<>(); |
| | | list.forEach(comSwRotaExcelVO -> { |
| | | for (ComSwRotaExcelVO comSwRotaExcelVO : list){ |
| | | Integer count = comSwRotaDAO.selectCount(new QueryWrapper<ComSwRotaDO>().lambda().eq(ComSwRotaDO::getRotaDate, comSwRotaExcelVO.getRotaDate())); |
| | | if (count > 0) { |
| | | return R.fail("值班日期已存在," + comSwRotaExcelVO.getRotaDate() + "重复"); |
| | | } |
| | | ComSwRotaDO comSwRotaDO = new ComSwRotaDO(); |
| | | String[] leaderPhones = comSwRotaExcelVO.getLeaderPhone().split(","); |
| | | String[] leaderPhones = comSwRotaExcelVO.getLeaderPhone().split("、"); |
| | | List<String> leaderIds = new ArrayList<>(); |
| | | for (String leaderPhone : leaderPhones) { |
| | | String id = comSwRotaDAO.getTeamIdsByTeamPhone(leaderPhone); |
| | | leaderIds.add(id); |
| | | } |
| | | |
| | | String[] personPhones = comSwRotaExcelVO.getPersonPhone().split(","); |
| | | String[] personPhones = comSwRotaExcelVO.getPersonPhone().split("、"); |
| | | List<String> personIds = new ArrayList<>(); |
| | | for (String personPhone : personPhones) { |
| | | String id = comSwRotaDAO.getTeamIdsByTeamPhone(personPhone); |
| | |
| | | } |
| | | comSwRotaDO.setRotaLeader(StringUtils.join(leaderIds, ",")); |
| | | comSwRotaDO.setRotaPerson(StringUtils.join(personIds, ",")); |
| | | comSwRotaDO.setLeaderName(comSwRotaExcelVO.getLeaderName().replace("、",",")); |
| | | comSwRotaDO.setPersonName(comSwRotaExcelVO.getPersonName().replace("、",",")); |
| | | comSwRotaDOS.add(comSwRotaDO); |
| | | }); |
| | | } |
| | | this.saveBatch(comSwRotaDOS); |
| | | return R.ok(); |
| | | } |