From 3b672cb508eded355fb158138f73dd2efe1e4b0c Mon Sep 17 00:00:00 2001 From: renkang <8417338+k94314517@user.noreply.gitee.com> Date: 星期五, 03 一月 2025 15:31:04 +0800 Subject: [PATCH] 客户资料 巡检任务业务 --- server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java | 69 ++++++++++++++++++++++++++++++++-- 1 files changed, 65 insertions(+), 4 deletions(-) diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java index 11080ec..e96dd30 100644 --- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java +++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java @@ -7,13 +7,19 @@ import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Constants; +import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.Utils; import com.doumee.dao.business.YwDeviceMapper; +import com.doumee.dao.business.YwDeviceRecordMapper; import com.doumee.dao.business.model.Category; +import com.doumee.dao.business.model.Company; import com.doumee.dao.business.model.YwDevice; +import com.doumee.dao.business.model.YwDeviceRecord; +import com.doumee.dao.business.vo.YwDeviceDataVO; import com.doumee.dao.system.MultifileMapper; import com.doumee.dao.system.model.Multifile; import com.doumee.dao.system.model.SystemUser; +import com.doumee.service.business.YwDeviceRecordService; import com.doumee.service.business.YwDeviceService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -30,6 +36,7 @@ import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * 杩愮淮璁惧淇℃伅琛⊿ervice瀹炵幇 @@ -46,6 +53,8 @@ private SystemDictDataBiz systemDictDataBiz; @Autowired private MultifileMapper multifileMapper; + @Autowired + private YwDeviceRecordMapper ywDeviceRecordMapper; @Autowired private RedisTemplate<String,Object> redisTemplate; @@ -85,10 +94,15 @@ @Override public void deleteById(Integer id, LoginUserInfo user) { - ywDeviceMapper.update(new UpdateWrapper<YwDevice>().lambda().set(YwDevice::getIsdeleted,Constants.ONE) - .set(YwDevice::getEditDate," now() ") + //鏌ヨ璁惧鏄惁瀛樺湪杩愮淮璁板綍 + if(ywDeviceRecordMapper.selectCount(new QueryWrapper<YwDeviceRecord>().lambda().eq(YwDeviceRecord::getDeviceId,id).eq(YwDeviceRecord::getIsdeleted,Constants.ZERO))>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠璁惧瀛樺湪杩愮淮璁板綍锛屾棤娉曞垹闄�"); + }; + ywDeviceMapper.update(new UpdateWrapper<YwDevice>() + .lambda().set(YwDevice::getIsdeleted,Constants.ONE) + .set(YwDevice::getEditDate, DateUtil.getCurrDateTime()) .set(YwDevice::getEditor,user.getId()) - .eq(YwDevice::getId,user.getId()) + .eq(YwDevice::getId,id) ); } @@ -160,7 +174,8 @@ @Override public YwDevice getDetail(Integer id) { YwDevice ywDevice = ywDeviceMapper.selectById(id); - Multifile multifile = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda().eq(Multifile::getObjId,id).eq(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_FILE).last(" limit 1")); + Multifile multifile = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda() + .eq(Multifile::getObjId,id).eq(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_FILE.getKey()).last(" limit 1")); if(Objects.nonNull(multifile)){ String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_DEVICE).getCode(); @@ -168,6 +183,30 @@ } return ywDevice; } + + + /** + * 鏍规嵁缂栫爜鏌ヨ + * @param deviceCode + * @return + */ + @Override + public YwDevice findByCode(String deviceCode) { + YwDevice ywDevice = ywDeviceMapper.selectOne( + new QueryWrapper<YwDevice>() + .lambda() + .eq(YwDevice::getIsdeleted,Constants.ZERO) + .eq(YwDevice::getCode,deviceCode) + .last(" limit 1 ") + ); + if(Objects.isNull(ywDevice)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY); + } + + return ywDevice; + } + + @Override @@ -207,4 +246,26 @@ QueryWrapper<YwDevice> wrapper = new QueryWrapper<>(ywDevice); return ywDeviceMapper.selectCount(wrapper); } + + + + @Override + public YwDeviceDataVO getYwDeviceData(){ + YwDeviceDataVO ywDeviceDataVO = new YwDeviceDataVO(); + List<YwDevice> ywDeviceList = ywDeviceMapper.selectList(new QueryWrapper<YwDevice>().lambda().eq(YwDevice::getIsdeleted,Constants.ZERO)); + if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywDeviceList)){ + ywDeviceDataVO.setQualityNum(ywDeviceList.size()); + ywDeviceDataVO.setTotalNum(ywDeviceList.size()); + ywDeviceDataVO.setNormalNum(ywDeviceList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.ZERO)).collect(Collectors.toList()).size()); + ywDeviceDataVO.setAbnormalNum(ywDeviceList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.ONE)).collect(Collectors.toList()).size()); + ywDeviceDataVO.setScrapNum(ywDeviceList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.TWO)).collect(Collectors.toList()).size()); + } + return ywDeviceDataVO; + } + + + } + + + -- Gitblit v1.9.3