| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.dao.business.WarningMapper; |
| | | import com.doumee.dao.business.WarningPushMapper; |
| | | import com.doumee.dao.business.WarningRuleMapper; |
| | | import com.doumee.dao.business.dto.TelecomCabinetLogDTO; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.vo.TelecomJkCabinetLogVO; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 钥匙柜开关门记录Service实现 |
| | |
| | | @Autowired |
| | | private JkCabinetLogMapper jkCabinetLogMapper; |
| | | |
| | | @Autowired |
| | | private WarningMapper warningMapper; |
| | | @Autowired |
| | | private WarningRuleMapper warningRuleMapper; |
| | | |
| | | @Autowired |
| | | private WarningPushMapper warningPushMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | @Override |
| | | public Integer create(JkCabinetLog jkCabinetLog) { |
| | | jkCabinetLogMapper.insert(jkCabinetLog); |
| | |
| | | .ge(Objects.nonNull(model.getStartDate()),JkCabinetLog::getCreateDate, Utils.Date.getStart(model.getStartDate())) |
| | | .le(Objects.nonNull(model.getEndDate()),JkCabinetLog::getCreateDate, Utils.Date.getEnd(model.getEndDate())) |
| | | .eq(JkCabinetLog::getIsdeleted, Constants.ZERO) |
| | | .eq(JkCabinetLog::getType,Constants.ONE) |
| | | .eq(JkCabinetLog::getKeyStatus,Constants.TWO) |
| | | .orderByDesc(JkCabinetLog::getCreateDate); |
| | | List<JkCabinetLog> jkCabinetLogs = jkCabinetLogMapper.selectJoinList(JkCabinetLog.class,wrapper); |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void timeOutUnBackAlarm(JkCabinetGridServiceImpl impl){ |
| | | Constants.WarningConfig warningConfig = Constants.WarningConfig.KEY_TIME_OUT_BACK; |
| | | Warning warning = warningMapper.selectOne(new QueryWrapper<Warning>().lambda() |
| | | .eq(Warning::getType,Constants.THREE).eq(Warning::getCode,warningConfig.getKey()).eq(Warning::getIsdeleted,Constants.ZERO).last("limt 1")); |
| | | if(Objects.isNull(warning)){ |
| | | return; |
| | | } |
| | | MPJLambdaWrapper<JkCabinetLog> wrapper = new MPJLambdaWrapper<JkCabinetLog>() |
| | | .selectAll(JkCabinetLog.class) |
| | | .selectAs(Member::getName,JkCabinetLog::getMemberName) |
| | | .selectAs(JkKeys::getCode,JkCabinetLog::getCarCode) |
| | | .selectAs(JkCabinet::getLocation,JkCabinetLog::getLocation) |
| | | .leftJoin(JkCabinet.class,JkCabinet::getId,JkCabinetLog::getCabinetId) |
| | | .leftJoin(JkKeys.class,JkKeys::getId,JkCabinetLog::getKeyId) |
| | | .leftJoin(Member.class,Member::getId,JkCabinetLog::getMemberId) |
| | | .eq(JkCabinetLog::getIsdeleted,Constants.ZERO) |
| | | .eq(JkCabinetLog::getType,Constants.ONE) |
| | | .eq(JkCabinetLog::getIsNotice,Constants.ZERO) |
| | | .eq(JkKeys::getStatus,Constants.TWO) |
| | | .isNull(JkCabinetLog::getCloseLogId) |
| | | .apply(" now() > DATE_ADD(t.CREATE_DATE, INTERVAL ifnull(t1.USE_TIME,0) MINUTE) ") |
| | | .orderByDesc(JkCabinetLog::getCreateDate); |
| | | List<JkCabinetLog> jkCabinetLogs = jkCabinetLogMapper.selectJoinList(JkCabinetLog.class,wrapper); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(jkCabinetLogs)){ |
| | | List<Member> memberList = impl.getWarningList(warning); |
| | | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(memberList)){ |
| | | for (JkCabinetLog jkCabinetLog:jkCabinetLogs) { |
| | | WarningPush warningPush = new WarningPush(); |
| | | warningPush.setCreateDate(new Date()); |
| | | warningPush.setIsdeleted(Constants.ZERO); |
| | | warningPush.setWarningId(warning.getId()); |
| | | warningPush.setTitle(warningConfig.getInfo()); |
| | | String content = "【车辆-"+jkCabinetLog.getCarCode()+"钥匙】由+"+(StringUtils.isNotBlank(jkCabinetLog.getMemberName())?jkCabinetLog.getMemberName():"未知人员")+"借出,超时未归还"; |
| | | warningPush.setContent(content); |
| | | warningPush.setStatus(Constants.ZERO); |
| | | warningPush.setPushType(Constants.ZERO); |
| | | warningPush.setRegion( StringUtils.isNotBlank(jkCabinetLog.getLocation())?jkCabinetLog.getLocation():"未知位置"); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberIds( |
| | | StringUtils.join(memberList.stream().map(i->i.getId()).collect(Collectors.toList()),",") |
| | | ); |
| | | warningPush.setMemberNames(StringUtils.join(memberList.stream().map(i->i.getName()).collect(Collectors.toList()),",") |
| | | ); |
| | | //todo 暂时关闭 钉钉通知 |
| | | |
| | | // Boolean noticeFlag = dingTalk.workInfoOANotice(Long.valueOf(systemDictDataBiz.queryByCode(Constants.DD_TALK,Constants.AGENT_ID).getCode()), |
| | | // StringUtils.join(memberList.stream().filter(i->StringUtils.isNotBlank(i.getDdId())).map(i->i.getDdId()).collect(Collectors.toList()),","), |
| | | // dingTalk.getAlarmNoticeMsg(warningPush.getRegion(),DateUtil.getCurrDateTime(),content)); |
| | | // warningPush.setStatus(noticeFlag?Constants.ONE:Constants.TWO); |
| | | warningPushMapper.insert(warningPush); |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |