| | |
| | | |
| | | @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(); |
| | | } |
| | | |
| | |
| | | String[] rotaPersonArray = rotaPerson.split(","); |
| | | for (int i = 0; i <= rotaPersonArray.length - 1; i++){ |
| | | ComSwRotaPersonVO comSwRotaPersonVO = new ComSwRotaPersonVO(); |
| | | Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(rotaPersonArray[i]); |
| | | comSwRotaPersonVO.setId(Long.valueOf(rotaPersonArray[i])); |
| | | comSwRotaPersonVO.setName(person.get("name")); |
| | | comSwRotaPersonVO.setPhone(Long.valueOf(person.get("phone"))); |
| | | Map<String,String> userMap = this.comSwRotaDAO.getImageUrl(Long.valueOf(rotaPersonArray[i])); |
| | | if(userMap != null){ |
| | | comSwRotaPersonVO.setPhone(userMap.get("phone")); |
| | | comSwRotaPersonVO.setImageUrl(userMap.get("url")); |
| | | comSwRotaPersonVO.setName(userMap.get("name")); |
| | | } |
| | | rotaPersons.add(comSwRotaPersonVO); |
| | | } |
| | | } |
| | |
| | | String[] rotaPersonArray = rotaPerson.split(","); |
| | | for (int i = 0; i <= rotaPersonArray.length - 1; i++){ |
| | | ComSwRotaPersonVO comSwRotaPersonVO = new ComSwRotaPersonVO(); |
| | | Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(rotaPersonArray[i]); |
| | | comSwRotaPersonVO.setId(Long.valueOf(rotaPersonArray[i])); |
| | | comSwRotaPersonVO.setName(leader.get("name")); |
| | | comSwRotaPersonVO.setPhone(Long.valueOf(leader.get("phone"))); |
| | | Map<String,String> userMap = this.comSwRotaDAO.getImageUrl(Long.valueOf(rotaPersonArray[i])); |
| | | if(userMap != null){ |
| | | comSwRotaPersonVO.setPhone(userMap.get("phone")); |
| | | comSwRotaPersonVO.setImageUrl(userMap.get("url")); |
| | | comSwRotaPersonVO.setName(userMap.get("name")); |
| | | } |
| | | rotaLeaders.add(comSwRotaPersonVO); |
| | | } |
| | | } |
| | |
| | | @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(); |
| | | } |