| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceGoOut; |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation; |
| | | import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomRepository; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomDto; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl; |
| | | import me.zhengjie.modules.system.domain.CustomerResources; |
| | | import me.zhengjie.modules.system.domain.Role; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationDto; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationQueryCriteria; |
| | | import me.zhengjie.modules.conferenceRoom.service.mapstruct.MeetingRoomReservationMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2023-02-09 |
| | | **/ |
| | | * @author wcd |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @date 2023-02-09 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MeetingRoomReservationServiceImpl implements MeetingRoomReservationService { |
| | |
| | | private final UserRepository userRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(MeetingRoomReservationQueryCriteria criteria, Pageable pageable){ |
| | | Page<MeetingRoomReservation> page = meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | public Map<String, Object> queryAll(MeetingRoomReservationQueryCriteria criteria, Pageable pageable) { |
| | | Page<MeetingRoomReservation> page = meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); |
| | | //将实体转换为Dto(重写) |
| | | Function<MeetingRoomReservation, MeetingRoomReservationDto> func = new Function<MeetingRoomReservation, MeetingRoomReservationDto>(){ |
| | | Function<MeetingRoomReservation, MeetingRoomReservationDto> func = new Function<MeetingRoomReservation, MeetingRoomReservationDto>() { |
| | | @Override |
| | | public MeetingRoomReservationDto apply(MeetingRoomReservation meetingRoomReservation) { |
| | | // 将实体类转换成DTO |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<MeetingRoomReservationDto> queryAll(MeetingRoomReservationQueryCriteria criteria){ |
| | | return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | public List<MeetingRoomReservationDto> queryAll(MeetingRoomReservationQueryCriteria criteria) { |
| | | return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public MeetingRoomReservationDto findById(Long id) { |
| | | MeetingRoomReservation meetingRoomReservation = meetingRoomReservationRepository.findById(id).orElseGet(MeetingRoomReservation::new); |
| | | ValidationUtil.isNull(meetingRoomReservation.getId(),"MeetingRoomReservation","id",id); |
| | | ValidationUtil.isNull(meetingRoomReservation.getId(), "MeetingRoomReservation", "id", id); |
| | | return meetingRoomReservationMapper.toDto(meetingRoomReservation); |
| | | } |
| | | |
| | |
| | | String startTime = df.format(resources.getStartTime()); |
| | | String endTime = df.format(resources.getEndTime()); |
| | | //验证约时间是否冲突 |
| | | List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTime(startTime,endTime,resources.getMeetingId()); |
| | | if(meetingRoomReservations.size() > 0){ |
| | | List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTime(startTime, endTime, resources.getMeetingId()); |
| | | if (meetingRoomReservations.size() > 0) { |
| | | MeetingRoomReservation errorMeetingRoomReservation = meetingRoomReservations.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | throw new BadRequestException("预约时间冲突," + errorFormat.format(errorMeetingRoomReservation.getStartTime()) + "至" + errorFormat.format(errorMeetingRoomReservation.getEndTime()) |
| | | + "已经存在会议室预约,请调整时间"); |
| | | }else{ |
| | | } else { |
| | | // 发送通知 |
| | | sendNotice(resources); |
| | | } |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(MeetingRoomReservation resources) throws Exception { |
| | | MeetingRoomReservation meetingRoomReservation = meetingRoomReservationRepository.findById(resources.getId()).orElseGet(MeetingRoomReservation::new); |
| | | ValidationUtil.isNull( meetingRoomReservation.getId(),"MeetingRoomReservation","id",resources.getId()); |
| | | ValidationUtil.isNull(meetingRoomReservation.getId(), "MeetingRoomReservation", "id", resources.getId()); |
| | | meetingRoomReservation.copy(resources); |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String startTime = df.format(resources.getStartTime()); |
| | |
| | | Set<Long> ids = new HashSet<>(); |
| | | ids.add(meetingRoomReservation.getId()); |
| | | //验证时间是否冲突 |
| | | List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTimeEdit(startTime,endTime, resources.getMeetingId(), ids); |
| | | if(meetingRoomReservations.size() > 0){ |
| | | List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTimeEdit(startTime, endTime, resources.getMeetingId(), ids); |
| | | if (meetingRoomReservations.size() > 0) { |
| | | MeetingRoomReservation errorMeetingRoomReservation = meetingRoomReservations.get(0); |
| | | SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | throw new BadRequestException("预约时间冲突," + errorFormat.format(errorMeetingRoomReservation.getStartTime()) + "至" + errorFormat.format(errorMeetingRoomReservation.getEndTime()) |
| | | + "已经存在会议室预约,请调整时间"); |
| | | }else{ |
| | | } else { |
| | | // 发送通知 |
| | | sendNotice(resources); |
| | | } |
| | |
| | | MeetingRoom meetingRoom = meetingRoomRepository.findById(resources.getMeetingId()).orElseGet(MeetingRoom::new); |
| | | // 发送内容至企微 |
| | | weComService.sendNotice(weComList, "会议室预约提示", String.format("<div class=\"normal\">会议主题:%s</div>" + |
| | | "<div class=\"normal\">预订者:%s</div>" + |
| | | "<div class=\"normal\">会议室:%s</div>" + |
| | | "<div class=\"normal\">开始时间:%s</div>" + |
| | | "<div class=\"normal\">结束时间:%s</div>" + |
| | | "<div class=\"highlight\">会议室预约有变更,请登录PMS系统查看。</div>", |
| | | resources.getMeetingTheme(), |
| | | SecurityUtils.getCurrentUsername(), |
| | | meetingRoom.getConferenceRoomName(), |
| | | resources.getStartTime().toString().substring(0,19), |
| | | resources.getEndTime().toString().substring(0,19)), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | "<div class=\"normal\">预订者:%s</div>" + |
| | | "<div class=\"normal\">会议室:%s</div>" + |
| | | "<div class=\"normal\">开始时间:%s</div>" + |
| | | "<div class=\"normal\">结束时间:%s</div>" + |
| | | "<div class=\"highlight\">会议室预约有变更,请登录PMS系统查看。</div>", |
| | | resources.getMeetingTheme(), |
| | | SecurityUtils.getCurrentUsername(), |
| | | meetingRoom.getConferenceRoomName(), |
| | | resources.getStartTime().toString().substring(0, 19), |
| | | resources.getEndTime().toString().substring(0, 19)), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } |
| | | |
| | | @Override |
| | |
| | | for (MeetingRoomReservationDto meetingRoomReservation : all) { |
| | | // 查询会议室 |
| | | MeetingRoom meetingRoom = meetingRoomRepository.findById(meetingRoomReservation.getMeetingId()).orElseGet(MeetingRoom::new); |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("会议室", meetingRoom.getConferenceRoomName()); |
| | | map.put("会议主题", meetingRoomReservation.getMeetingTheme()); |
| | | map.put("开始时间", meetingRoomReservation.getStartTime()); |
| | |
| | | |
| | | /** |
| | | * 中午12点30或凌晨02:30执行定时任务 |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | public void getWeComAttendanceListOfNoonOrNight(String attendDate, List attUser) throws Exception { |
| | |
| | | * 发送企微应用消息 |
| | | * |
| | | * @param userWeComIdList 接收消息用户企微ID |
| | | * @param content 消息内容 |
| | | * @param type 消息类型 |
| | | * @param content 消息内容 |
| | | * @param type 消息类型 |
| | | */ |
| | | public void sendNotice(List<String> userWeComIdList, String title, String content, String type) { |
| | | if (userWeComIdList.size() > 0) { |
| | |
| | | package me.zhengjie.modules.quartz.task; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.zhengjie.modules.constant.Constant; |
| | |
| | | import me.zhengjie.modules.system.repository.SysConfigProportionRepository; |
| | | import me.zhengjie.modules.system.repository.SysUserContractRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.SecurityUtils; |
| | | import me.zhengjie.utils.StringUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.*; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 合同是否到期提醒 |
| | | * |
| | | * @author 魏传栋 |
| | | * @date 2023-01-10 |
| | | */ |
| | |
| | | List<String> weComList = new ArrayList<>(); |
| | | // 查询用户 |
| | | List<User> userList = userRepository.findAll(); |
| | | for(User user : userList){ |
| | | for (User user : userList) { |
| | | // 获取用户角色 |
| | | Role role = user.getRoles().iterator().next(); |
| | | // 高级别 |
| | | if(Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_SUPER) || Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_GENERAL)){ |
| | | if (Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_SUPER) || Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_GENERAL)) { |
| | | if (StringUtils.isNotBlank(user.getWeComId())) { |
| | | weComList.add(user.getWeComId()); |
| | | } |
| | |
| | | |
| | | // 查询合同 |
| | | List<SysUserContract> sysUserContractList = sysUserContractRepository.findAll(); |
| | | for(SysUserContract sysUserContract : sysUserContractList){ |
| | | for (SysUserContract sysUserContract : sysUserContractList) { |
| | | // 当合同结束时间大于今天 |
| | | if(sysUserContract.getContractEndTime().compareTo(today) > 0){ |
| | | if (sysUserContract.getContractEndTime().compareTo(today) > 0) { |
| | | // 查询合同即将到期的员工 |
| | | User user1 = userRepository.findById(sysUserContract.getUserId()).orElseGet(User::new); |
| | | // date转LocalDateTime |
| | |
| | | ZoneId zoneId = ZoneId.systemDefault(); |
| | | LocalDateTime todayLocalDateTime = instant.atZone(zoneId).toLocalDateTime(); |
| | | // 今天到合同结束时间的差值 |
| | | Long chronoUnit = ChronoUnit.DAYS.between(todayLocalDateTime.toLocalDate(), sysUserContract.getContractEndTime().toLocalDateTime().toLocalDate()); |
| | | Long chronoUnit = ChronoUnit.DAYS.between(todayLocalDateTime.toLocalDate(), sysUserContract.getContractEndTime().toLocalDateTime().toLocalDate()); |
| | | Integer count = 0; |
| | | for (Integer i = 0; i <= chronoUnit; i++) { |
| | | count++; |
| | | } |
| | | // 相差天数等于配置表的数值时给高级别用户发钉钉信息 |
| | | if(Double.valueOf(count).equals(sysConfigProportion.getProportion())){ |
| | | if (Double.valueOf(count).equals(sysConfigProportion.getProportion())) { |
| | | weComService.sendNotice(weComList, "合同将到期提醒", String.format("<div class=\"normal\">所属员工:%s</div>" + |
| | | "<div class=\"normal\">合同名称:%s</div>" + |
| | | "<div class=\"normal\">合同到期时间:%s</div>" + |
| | | "<div class=\"highlight\">所属员工合同即将到期,请登录PMS系统查看。</div>", |
| | | user1.getNickName(), |
| | | sysUserContract.getContractName(), |
| | | sysUserContract.getContractEndTime().toString().substring(0,10)), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | "<div class=\"normal\">合同名称:%s</div>" + |
| | | "<div class=\"normal\">合同到期时间:%s</div>" + |
| | | "<div class=\"highlight\">所属员工合同即将到期,请登录PMS系统查看。</div>", |
| | | user1.getNickName(), |
| | | sysUserContract.getContractName(), |
| | | sysUserContract.getContractEndTime().toString().substring(0, 10)), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } |
| | | } |
| | | } |
| | |
| | | package me.zhengjie.modules.quartz.task; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import me.zhengjie.modules.constant.Constant; |
| | |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 客户资源管理提醒(延时) |
| | | * |
| | | * @author 魏传栋 |
| | | * @date 2023-01-10 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 客户资源管理提醒 |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | public void resourceReminder() throws Exception { |
| | |
| | | String nowTime = sdf.format(new Date()); |
| | | // 查询客户资源管理表 |
| | | List<CustomerResources> customerResourcesList = customerResourcesRepository.findAll(); |
| | | for(CustomerResources customerResources : customerResourcesList){ |
| | | for (CustomerResources customerResources : customerResourcesList) { |
| | | // 表中的提醒时间与当前的时间一致,发送钉钉消息 |
| | | if(customerResources.getOpeningTime() != null && customerResources.getOpeningTime().compareTo(Timestamp.valueOf(nowTime)) == 0){ |
| | | if (customerResources.getOpeningTime() != null && customerResources.getOpeningTime().compareTo(Timestamp.valueOf(nowTime)) == 0) { |
| | | // 企微ID |
| | | List<String> weComList = new ArrayList<>(); |
| | | // 查询中间表 |
| | |
| | | } |
| | | // 发送信息至被提醒人企微 |
| | | weComService.sendNotice(weComList, "客户资源管理提示", String.format("<div class=\"normal\">标题:%s</div>" + |
| | | "<div class=\"normal\">分类:%s</div>" + |
| | | "<div class=\"highlight\">新增客户资源,请登录PMS系统查看。</div>", |
| | | customerResources.getTitle(), |
| | | customerResources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | "<div class=\"normal\">分类:%s</div>" + |
| | | "<div class=\"highlight\">新增客户资源,请登录PMS系统查看。</div>", |
| | | customerResources.getTitle(), |
| | | customerResources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | } |
| | | } |
| | | } |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.system.service.impl; |
| | | |
| | | import me.zhengjie.modules.business.service.BusinessPlanService; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2023-02-02 |
| | | **/ |
| | | * @author wcd |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @date 2023-02-02 |
| | | **/ |
| | | @Service |
| | | @Transactional |
| | | @RequiredArgsConstructor |
| | |
| | | private final BusinessPlanService businessPlanService; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable){ |
| | | Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | public Map<String, Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable) { |
| | | Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable); |
| | | // 将实体类转换为DTO(重写) |
| | | Function<CustomerResources, CustomerResourcesDto> func = new Function<CustomerResources, CustomerResourcesDto>(){ |
| | | Function<CustomerResources, CustomerResourcesDto> func = new Function<CustomerResources, CustomerResourcesDto>() { |
| | | @Override |
| | | public CustomerResourcesDto apply(CustomerResources t) { |
| | | // 将实体类转换成DTO |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria){ |
| | | return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria) { |
| | | return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public CustomerResourcesDto findById(Long id) { |
| | | CustomerResources customerResources = customerResourcesRepository.findById(id).orElseGet(CustomerResources::new); |
| | | ValidationUtil.isNull(customerResources.getId(),"CustomerResources","id",id); |
| | | ValidationUtil.isNull(customerResources.getId(), "CustomerResources", "id", id); |
| | | return customerResourcesMapper.toDto(customerResources); |
| | | } |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(CustomerResources resources) throws Exception { |
| | | // 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息 |
| | | if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){ |
| | | if (ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)) { |
| | | // 发送通知 |
| | | resources = sendNotice(resources); |
| | | } |
| | | // 保存 |
| | | customerResourcesRepository.save(resources); |
| | | // 中间表添加数据 |
| | | if(resources.getRemindPeople().size() != 0){ |
| | | for(int i = 0; i < resources.getRemindPeople().size(); i++){ |
| | | if (resources.getRemindPeople().size() != 0) { |
| | | for (int i = 0; i < resources.getRemindPeople().size(); i++) { |
| | | // 中间表添加数据 |
| | | CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser(); |
| | | customerResourcesUser.setCustomerResourcesId(resources.getId()); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(CustomerResources resources) throws Exception { |
| | | CustomerResources customerResources = customerResourcesRepository.findById(resources.getId()).orElseGet(CustomerResources::new); |
| | | ValidationUtil.isNull( customerResources.getId(),"CustomerResources","id",resources.getId()); |
| | | ValidationUtil.isNull(customerResources.getId(), "CustomerResources", "id", resources.getId()); |
| | | customerResources.copy(resources); |
| | | // 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息 |
| | | if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){ |
| | | if (ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)) { |
| | | // 发送通知 |
| | | customerResources = sendNotice(customerResources); |
| | | }else if(resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)){ |
| | | } else if (resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)) { |
| | | customerResources.setOpeningTime(null); |
| | | } |
| | | customerResourcesRepository.save(customerResources); |
| | | // 删除中间表数据 |
| | | List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(customerResources.getId()); |
| | | for(int i = 0; i < customerResourcesUserList.size(); i++){ |
| | | for (int i = 0; i < customerResourcesUserList.size(); i++) { |
| | | customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId()); |
| | | } |
| | | // 中间表添加数据 |
| | | if(resources.getRemindPeople().size() != 0){ |
| | | for(int i = 0; i < resources.getRemindPeople().size(); i++){ |
| | | if (resources.getRemindPeople().size() != 0) { |
| | | for (int i = 0; i < resources.getRemindPeople().size(); i++) { |
| | | // 中间表添加数据 |
| | | CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser(); |
| | | customerResourcesUser.setCustomerResourcesId(resources.getId()); |
| | |
| | | } |
| | | // 发送内容至企微 |
| | | weComService.sendNotice(weComList, "客户资源管理提示", String.format("<div class=\"normal\">标题:%s</div>" + |
| | | "<div class=\"normal\">分类:%s</div>" + |
| | | "<div class=\"highlight\">客户资源有变动,请登录PMS系统查看。</div>", |
| | | resources.getTitle(), |
| | | resources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | "<div class=\"normal\">分类:%s</div>" + |
| | | "<div class=\"highlight\">客户资源有变动,请登录PMS系统查看。</div>", |
| | | resources.getTitle(), |
| | | resources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD); |
| | | return resources; |
| | | } |
| | | |
| | |
| | | for (Long id : ids) { |
| | | // 查询中间表 |
| | | List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(id); |
| | | for(int i = 0; i < customerResourcesUserList.size(); i++){ |
| | | for (int i = 0; i < customerResourcesUserList.size(); i++) { |
| | | customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId()); |
| | | } |
| | | customerResourcesRepository.deleteById(id); |
| | |
| | | public void download(List<CustomerResourcesDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (CustomerResourcesDto customerResources : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("标题", customerResources.getTitle()); |
| | | map.put("分类", customerResources.getClassification()); |
| | | map.put("记录时间", customerResources.getRecordTime()); |
| | |
| | | |
| | | /** |
| | | * 查询被提醒人 |
| | | * |
| | | * @param resources |
| | | * @return |
| | | */ |
| | |
| | | List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(resources.getId()); |
| | | // 用户信息 |
| | | List<User> userList = new ArrayList<>(); |
| | | for(int i = 0; i < customerResourcesUserList.size(); i++){ |
| | | for (int i = 0; i < customerResourcesUserList.size(); i++) { |
| | | // 查询用户表 |
| | | User user = userRepository.findById(customerResourcesUserList.get(i).getUserId()).orElseGet(User::new); |
| | | userList.add(user); |
| | |
| | | import java.math.RoundingMode;
|
| | | import java.net.URLEncoder;
|
| | | import java.text.DecimalFormat;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.time.*;
|
| | | import java.time.temporal.ChronoUnit;
|
| | |
| | |
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import cn.hutool.core.bean.BeanUtil;
|
| | | import cn.hutool.core.bean.copier.CopyOptions;
|
| | | import me.zhengjie.exception.BadRequestException;
|
| | | import me.zhengjie.modules.project.domain.Project;
|
| | | import me.zhengjie.modules.project.repository.ProjectRepository;
|
| | | import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
|
| | | import me.zhengjie.modules.system.repository.DictDetailRepository;
|
| | | import me.zhengjie.modules.system.repository.SysUserLevelWageRepository;
|
| | | import me.zhengjie.modules.task.domain.*;
|
| | | import me.zhengjie.modules.task.repository.TaskRepository;
|
| | | import me.zhengjie.modules.task.service.dto.*;
|
| | | import me.zhengjie.modules.treatment.domain.UserLevelWage;
|
| | | import me.zhengjie.modules.treatment.repository.UserLevelWageRepository;
|
| | |
| | | import me.zhengjie.modules.system.repository.UserRepository;
|
| | | import me.zhengjie.modules.system.service.UserService;
|
| | | import me.zhengjie.modules.system.service.dto.UserDto;
|
| | | import me.zhengjie.modules.task.repository.TaskUserRepository;
|
| | | import me.zhengjie.modules.task.service.TaskUserService;
|
| | | import me.zhengjie.modules.task.service.mapstruct.TaskUserMapper;
|
| | | import org.apache.poi.ss.usermodel.*;
|
| | | import org.apache.poi.ss.util.CellRangeAddressList;
|
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
| | |
| | | if (StringUtils.isNotBlank(user.getWeComId())) {
|
| | | weComList.add(user.getWeComId());
|
| | | weComService.sendNotice(weComList, "任务变更提醒", String.format("<div class=\"gray\">任务创建提示</div>" +
|
| | | "<div class=\"normal\">项目:%s</div>" +
|
| | | "<div class=\"normal\">任务:%s</div>" +
|
| | | "<div class=\"normal\">任务区间:%s</div>" +
|
| | | "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
|
| | | project.getName(),
|
| | | taskMongos.get(0).getName() + " > " + taskUserMongo.getName(),
|
| | | sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
|
| | | "<div class=\"normal\">项目:%s</div>" +
|
| | | "<div class=\"normal\">任务:%s</div>" +
|
| | | "<div class=\"normal\">任务区间:%s</div>" +
|
| | | "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
|
| | | project.getName(),
|
| | | taskMongos.get(0).getName() + " > " + taskUserMongo.getName(),
|
| | | sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // taskUserMongoDto.setPerformanceHours(Double.valueOf(format));
|
| | | // taskUserMongo.setPerformanceHours(Double.valueOf(format));
|
| | | // } else {
|
| | | taskUserMongoDto.setPerformanceHours(taskUserMongo.getTaskHours());
|
| | | taskUserMongoDto.setPerformanceHours(taskUserMongo.getTaskHours());
|
| | | // }
|
| | |
|
| | | // mongoTemplate.save(taskUserMongo);
|
| | |
| | | if (StringUtils.isNotBlank(user.getWeComId())) {
|
| | | weComList.add(user.getWeComId());
|
| | | weComService.sendNotice(weComList, "任务变更提醒", String.format("<div class=\"gray\">任务创建提示</div>" +
|
| | | "<div class=\"normal\">项目:%s</div>" +
|
| | | "<div class=\"normal\">任务:%s</div>" +
|
| | | "<div class=\"normal\">任务区间:%s</div>" +
|
| | | "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
|
| | | project.getName(),
|
| | | resources.getTask().getName() + " > " + resources.getName(),
|
| | | sdf.format(resources.getTaskStartDate()) + "~" + sdf.format(resources.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
|
| | | "<div class=\"normal\">项目:%s</div>" +
|
| | | "<div class=\"normal\">任务:%s</div>" +
|
| | | "<div class=\"normal\">任务区间:%s</div>" +
|
| | | "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
|
| | | project.getName(),
|
| | | resources.getTask().getName() + " > " + resources.getName(),
|
| | | sdf.format(resources.getTaskStartDate()) + "~" + sdf.format(resources.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (StringUtils.isNotBlank(user.getWeComId())) {
|
| | | weComList.add(user.getWeComId());
|
| | | weComService.sendNotice(weComList, "任务变更提醒", String.format("<div class=\"gray\">任务创建提示</div>" +
|
| | | "<div class=\"normal\">项目:%s</div>" +
|
| | | "<div class=\"normal\">任务:%s</div>" +
|
| | | "<div class=\"normal\">任务区间:%s</div>" +
|
| | | "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
|
| | | project.getName(),
|
| | | taskUserMongo.getTask().getName() + " > " + taskUserMongo.getName(),
|
| | | sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
|
| | | "<div class=\"normal\">项目:%s</div>" +
|
| | | "<div class=\"normal\">任务:%s</div>" +
|
| | | "<div class=\"normal\">任务区间:%s</div>" +
|
| | | "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
|
| | | project.getName(),
|
| | | taskUserMongo.getTask().getName() + " > " + taskUserMongo.getName(),
|
| | | sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | String projectName = projectRepository.findById(taskMongo.getProjectId()).orElseGet(Project::new).getName();
|
| | | String userNickName = taskUser.getUserNickName();
|
| | | String taskStatus = taskUser.getTaskStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.TASK_STATUS, taskUser.getTaskStatus()).getLabel() : "";
|
| | | Map<String,Object> map = new LinkedHashMap<>();
|
| | | Map<String, Object> map = new LinkedHashMap<>();
|
| | | map.put("项目名称", projectName);
|
| | | map.put("任务名称", taskName);
|
| | | map.put("任务分配", taskUserName);
|