| | |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComSwPatrolRecordVO; |
| | | import com.panzhihua.common.model.vos.community.ComSwRotaExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComSwRotaPersonVO; |
| | | import com.panzhihua.common.model.vos.community.ComSwRotaVO; |
| | | import com.panzhihua.common.model.vos.partybuilding.PartyBuildingComPbDynVO; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComOpsAccUserDAO; |
| | | import com.panzhihua.service_community.dao.ComSwPatrolRecordDAO; |
| | | import com.panzhihua.service_community.dao.ComSwRotaDAO; |
| | | import com.panzhihua.service_community.model.dos.ComMngUserTagDO; |
| | | import com.panzhihua.service_community.model.dos.ComSwRotaDO; |
| | | import com.panzhihua.service_community.service.ComSwRotaService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private UserService userService; |
| | | |
| | | @Resource |
| | | private ComSwPatrolRecordDAO comSwPatrolRecordDAO; |
| | | |
| | | @Override |
| | | public R pageRota(ComSwRotaPageDTO comSwRotaPageDTO) { |
| | | Page page = new Page<>(); |
| | |
| | | page.setCurrent(pageNum); |
| | | |
| | | IPage<ComSwRotaVO> iPage = comSwRotaDAO.pageRota(page, comSwRotaPageDTO); |
| | | if (null != iPage.getRecords()) { |
| | | iPage.getRecords().forEach(comSwRotaVO -> { |
| | | comSwRotaVO.setWeekDay(DateUtils.dateToWeek(comSwRotaVO.getRotaDate())); |
| | | StringBuilder leaderNameString = new StringBuilder(); |
| | | StringBuilder leaderPhoneString = new StringBuilder(); |
| | | //值班领导id查询值班领导的名字和电话 |
| | | if(StringUtils.isNotEmpty(comSwRotaVO.getRotaLeader())){ |
| | | String[] leaderIds = comSwRotaVO.getRotaLeader().split(","); |
| | | for (int i = 0; i < leaderIds.length ; i++) { |
| | | Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(leaderIds[i]); |
| | | if(leader != null){ |
| | | if(i != 0){ |
| | | leaderNameString.append(","); |
| | | leaderPhoneString.append(","); |
| | | } |
| | | leaderNameString.append(leader.get("name")); |
| | | leaderPhoneString.append(leader.get("phone")); |
| | | } |
| | | } |
| | | comSwRotaVO.setLeaderName(leaderNameString.toString()); |
| | | comSwRotaVO.setLeaderPhone(leaderPhoneString.toString()); |
| | | } |
| | | //值班人员id查询值班人员的名字和电话 |
| | | StringBuilder personNameString = new StringBuilder(); |
| | | StringBuilder personPhoneString = new StringBuilder(); |
| | | if(StringUtils.isNotEmpty(comSwRotaVO.getRotaPerson())){ |
| | | String[] personIds = comSwRotaVO.getRotaPerson().split(","); |
| | | for (int i = 0; i < personIds.length ; i++) { |
| | | Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]); |
| | | if(person != null){ |
| | | if(i != 0){ |
| | | personNameString.append(","); |
| | | personPhoneString.append(","); |
| | | } |
| | | personNameString.append(person.get("name")); |
| | | personPhoneString.append(person.get("phone")); |
| | | } |
| | | } |
| | | comSwRotaVO.setPersonName(personNameString.toString()); |
| | | comSwRotaVO.setPersonPhone(personPhoneString.toString()); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(iPage); |
| | | } |
| | | |
| | | @Override |
| | | public R detailRota(Long rotaId) { |
| | | ComSwRotaVO comSwRotaVO = new ComSwRotaVO(); |
| | | ComSwRotaDO comSwRotaDO = comSwRotaDAO.selectById(rotaId); |
| | | if (null == comSwRotaDO) { |
| | | return R.fail("该值班表不存在"); |
| | | } |
| | | BeanUtils.copyProperties(comSwRotaDO,comSwRotaVO); |
| | | comSwRotaVO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").format(comSwRotaDO.getRotaDate())); |
| | | comSwRotaVO.setWeekDay(DateUtils.dateToWeek(comSwRotaVO.getRotaDate())); |
| | | StringBuilder leaderNameString = new StringBuilder(); |
| | | StringBuilder leaderPhoneString = new StringBuilder(); |
| | | //值班领导id查询值班领导的名字和电话 |
| | | if(StringUtils.isNotEmpty(comSwRotaDO.getRotaLeader())){ |
| | | String[] leaderIds = comSwRotaDO.getRotaLeader().split(","); |
| | | for (int i = 0; i < leaderIds.length ; i++) { |
| | | Map<String,String> leader = comSwPatrolRecordDAO.getPbServiceTeamById(leaderIds[i]); |
| | | if(leader != null){ |
| | | if(i != 0){ |
| | | leaderNameString.append(","); |
| | | leaderPhoneString.append(","); |
| | | } |
| | | leaderNameString.append(leader.get("name")); |
| | | leaderPhoneString.append(leader.get("phone")); |
| | | } |
| | | } |
| | | comSwRotaVO.setLeaderName(leaderNameString.toString()); |
| | | comSwRotaVO.setLeaderPhone(leaderPhoneString.toString()); |
| | | } |
| | | //值班人员id查询值班人员的名字和电话 |
| | | StringBuilder personNameString = new StringBuilder(); |
| | | StringBuilder personPhoneString = new StringBuilder(); |
| | | if(StringUtils.isNotEmpty(comSwRotaDO.getRotaPerson())){ |
| | | String[] personIds = comSwRotaDO.getRotaPerson().split(","); |
| | | for (int i = 0; i < personIds.length ; i++) { |
| | | Map<String,String> person = comSwPatrolRecordDAO.getPbServiceTeamById(personIds[i]); |
| | | if(person != null){ |
| | | if(i != 0){ |
| | | personNameString.append(","); |
| | | personPhoneString.append(","); |
| | | } |
| | | personNameString.append(person.get("name")); |
| | | personPhoneString.append(person.get("phone")); |
| | | } |
| | | } |
| | | comSwRotaVO.setPersonName(personNameString.toString()); |
| | | comSwRotaVO.setPersonPhone(personPhoneString.toString()); |
| | | } |
| | | return R.ok(comSwRotaVO); |
| | | } |
| | | |
| | | @Override |
| | | public R addRota(List<ComSwRotaSaveDTO> comSwRotaSaveDTOs) { |
| | | comSwRotaSaveDTOs.forEach(comSwRotaSaveDTO -> { |
| | | try { |
| | | if (comSwRotaSaveDTO.getId() != null && comSwRotaSaveDTO.getId() != 0) { |
| | | ComSwRotaDO comSwRotaDO = new ComSwRotaDO(); |
| | | BeanUtils.copyProperties(comSwRotaSaveDTO, comSwRotaDO); |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | 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()); |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | try { |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaSaveDTO.getRotaDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | comSwRotaDAO.insert(comSwRotaDO); |
| | | } |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | return R.ok(); |
| | | } |
| | |
| | | List<ComSwRotaPersonVO> rotaPersons = new ArrayList<>(); |
| | | if (null != comSwRotaDO){ |
| | | String rotaPerson = comSwRotaDO.getRotaPerson(); |
| | | String rotaPersonName = comSwRotaDO.getPersonName(); |
| | | String[] rotaPersonArray = rotaPerson.split(","); |
| | | String[] rotaPersonNameArray = rotaPersonName.split(","); |
| | | for (int i = 0; i <= rotaPersonArray.length - 1; i++){ |
| | | ComSwRotaPersonVO comSwRotaPersonVO = new ComSwRotaPersonVO(); |
| | | comSwRotaPersonVO.setId(Long.valueOf(rotaPersonArray[i])); |
| | | comSwRotaPersonVO.setName(rotaPersonNameArray[i]); |
| | | 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); |
| | | } |
| | |
| | | List<ComSwRotaPersonVO> rotaLeaders = new ArrayList<>(); |
| | | if (null != comSwRotaDO){ |
| | | String rotaPerson = comSwRotaDO.getRotaLeader(); |
| | | String rotaPersonName = comSwRotaDO.getLeaderName(); |
| | | String[] rotaPersonArray = rotaPerson.split(","); |
| | | String[] rotaPersonNameArray = rotaPersonName.split(","); |
| | | for (int i = 0; i <= rotaPersonArray.length - 1; i++){ |
| | | ComSwRotaPersonVO comSwRotaPersonVO = new ComSwRotaPersonVO(); |
| | | comSwRotaPersonVO.setId(Long.valueOf(rotaPersonArray[i])); |
| | | comSwRotaPersonVO.setName(rotaPersonNameArray[i]); |
| | | 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); |
| | | } |
| | |
| | | public R getTotlePerson(String param, Long communityId) { |
| | | return userService.listActivityManager(param,communityId); |
| | | } |
| | | |
| | | @Override |
| | | public R listSaveSwRotaExcelVO(List<ComSwRotaExcelVO> list, Long communityId) { |
| | | List<ComSwRotaDO> comSwRotaDOS = new ArrayList<>(); |
| | | list.forEach(comSwRotaExcelVO -> { |
| | | ComSwRotaDO comSwRotaDO = new ComSwRotaDO(); |
| | | 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(","); |
| | | List<String> personIds = new ArrayList<>(); |
| | | for (String personPhone : personPhones) { |
| | | String id = comSwRotaDAO.getTeamIdsByTeamPhone(personPhone); |
| | | personIds.add(id); |
| | | } |
| | | BeanUtils.copyProperties(comSwRotaExcelVO, comSwRotaDO); |
| | | comSwRotaDO.setId(Snowflake.getId()); |
| | | comSwRotaDO.setCommunityId(communityId); |
| | | try { |
| | | comSwRotaDO.setRotaDate(new SimpleDateFormat("yyyy-MM-dd").parse(comSwRotaExcelVO.getRotaDate())); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | comSwRotaDO.setRotaLeader(StringUtils.join(leaderIds, ",")); |
| | | comSwRotaDO.setRotaPerson(StringUtils.join(personIds, ",")); |
| | | comSwRotaDOS.add(comSwRotaDO); |
| | | }); |
| | | this.saveBatch(comSwRotaDOS); |
| | | return R.ok(); |
| | | } |
| | | } |