123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875 |
- package com.xy.service;
- import cn.hutool.core.bean.BeanUtil;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.collection.ListUtil;
- import cn.hutool.core.date.DatePattern;
- import cn.hutool.core.date.DateTime;
- import cn.hutool.core.date.DateUtil;
- import cn.hutool.core.map.MapUtil;
- import cn.hutool.core.text.StrBuilder;
- import cn.hutool.core.util.BooleanUtil;
- import cn.hutool.core.util.NumberUtil;
- import cn.hutool.core.util.ObjectUtil;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.json.JSONUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.xy.collections.list.JArrayList;
- import com.xy.collections.list.JList;
- import com.xy.collections.map.JMap;
- import com.xy.config.DeviceThreadPoolConfig;
- import com.xy.consts.DictConsts;
- import com.xy.device.*;
- import com.xy.dto.*;
- import com.xy.dto.api.biz.ContainerAddDTO;
- import com.xy.dto.be.MercDto;
- import com.xy.dto.common.MercPlaceDto;
- import com.xy.dto.device.DeviceQueryDTO;
- import com.xy.dto.device.DeviceRegDTO;
- import com.xy.dto.mini.MiniDeviceInfoDto;
- import com.xy.entity.*;
- import com.xy.enums.FileExportType;
- import com.xy.error.CommRuntimeException;
- import com.xy.mapper.DeviceInfoMapper;
- import com.xy.mapper.entity.DeviceInfoQueryPage;
- import com.xy.service.be.MercFeignService;
- import com.xy.service.be.MercService;
- import com.xy.service.common.MercPlaceService;
- import com.xy.service.common.MercRegionService;
- import com.xy.sys.EnumDataClearSize;
- import com.xy.util.ExcelUtils;
- import com.xy.utils.*;
- import com.xy.utils.Enum.AlgorithmTypeEnum;
- import com.xy.utils.enums.*;
- import com.xy.vo.DeviceQueryVO;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import jodd.introspector.MapperFunction;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.Valid;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.time.LocalDateTime;
- import java.util.*;
- import java.util.stream.Collectors;
- import static com.xy.utils.PlusBeans.*;
- /**
- * <p>
- * 设备-信息 服务实现类
- * </p>
- *
- * @author lijin
- * @since 2022-12-23
- */
- @Slf4j
- @Service
- @RequiredArgsConstructor
- @Api(tags = "设备-信息")
- public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceInfo> implements DeviceInfoService {
- /**
- * 质检商户code
- */
- public static final String QA_MERC_CODE = "10001";
- private final CloudWalkApiService cloudWalkApiService;
- private final AlgorithmService algorithmService;
- private final CountApiService countApiService;
- private final TyApiService tyApiService;
- private final MercFeignService mercFeignService;
- private final DeviceSysinfoServiceImpl deviceSysinfoService;
- private final DeviceStatusServiceImpl deviceStatusService;
- private final DeviceRegisterServiceImpl deviceRegisterService;
- private final DeviceEventMsgServiceImpl deviceEventMsgService;
- private final DeviceDataServiceImpl deviceDataService;
- private final DeviceTempRecordsServiceImpl deviceTempRecordsService;
- private final DeviceNetRecordServiceImpl deviceNetRecordService;
- private final GoodsDeviceService goodsDeviceService;
- private final FileExportService fileExportService;
- private final RedisService<String> redisService;
- private final GoodsService goodsService;
- private final AlipayDeviceService alipayDeviceService;
- private final String keyPrefix = "device:history:";
- private final MercRegionService mercRegionService;
- private final DeviceAlgorithmChargingServiceImpl deviceAlgorithmChargingService;
- private final MercPlaceService mercPlaceService;
- private final MercUserBindDeviceService mercUserBindDeviceService;
- private final DevicePartServiceImpl devicePartService;
- private final MercService mercService;
- @Override
- @ApiOperation("设备列表-管理员")
- public R<List<DeviceInfoDto.ListByAdminName>> listByAdminName(@RequestBody @Validated DeviceInfoDto.GroupByAdminNameDto dto) {
- String noAdmin = "未分配管理员";
- List<DeviceInfoDto.ListByAdminName> deviceInfoList = baseMapper.listByAdminName(dto);
- deviceInfoList.forEach(i -> {
- SysDictRedis dictDeviceType = SysDictUtils.get(DictConsts.DEVICE_TYPE, String.valueOf(i.getDeviceType()));
- i.setDeviceTypeName(dictDeviceType.getMsg());
- if (!Emptys.check(i.getDeviceName())) {
- i.setDeviceName("");
- }
- });
- // 没有管理员的的设置默认值
- deviceInfoList.stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName(noAdmin));
- return R.ok(deviceInfoList);
- }
- //@Override
- @ApiOperation("设备分页-管理员")
- @Override
- public R<PageBean<DeviceInfoDto.ListByAdminName>> pageByAdminName(@RequestBody @Validated DeviceInfoDto.PageByAdminNameDto dto) {
- PageBean page = dto.getPage();
- String noAdmin = "未分配管理员";
- IPage<DeviceInfoDto.ListByAdminName> deviceInfoList = baseMapper.pageByAdminName(toIPage(page), dto);
- deviceInfoList.getRecords().forEach(i -> {
- SysDictRedis dictDeviceType = SysDictUtils.get(DictConsts.DEVICE_TYPE, String.valueOf(i.getDeviceType()));
- i.setDeviceTypeName(dictDeviceType.getMsg());
- if (!Emptys.check(i.getDeviceName())) {
- i.setDeviceName("");
- }
- });
- // 没有管理员的的设置默认值
- deviceInfoList.getRecords().stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName(noAdmin));
- return R.ok(toPageBean(DeviceInfoDto.ListByAdminName.class, deviceInfoList));
- }
- @Override
- @ApiOperation("设备分组-管理员")
- public R<List<DeviceInfoDto.GroupByAdminNameVo>> groupByAdminName(@RequestBody @Validated DeviceInfoDto.GroupByAdminNameDto dto) {
- String noAdmin = "未分配管理员";
- List<DeviceInfoDto.ListByAdminName> deviceInfoList = listByAdminName(dto).getData();
- // 根据管理员名字分组
- Map<String, List<DeviceInfoDto.ListByAdminName>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.ListByAdminName::getAdminName));
- List<DeviceInfoDto.GroupByAdminNameVo> list = new ArrayList<>();
- // 不包含未分配管理员的
- deviceMap.forEach(
- (k, i) -> {
- DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
- if (!noAdmin.equals(k)) {
- vo.setAdminName(k)
- .setDeviceNum(i.size())
- .setDeviceInfos(i);
- list.add(vo);
- }
- }
- );
- // 包含分配管理员的
- List<DeviceInfoDto.ListByAdminName> noAdminNamesList = deviceMap.get(noAdmin);
- if (Emptys.check(noAdminNamesList)) {
- DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
- vo.setAdminName(noAdmin)
- .setDeviceNum(noAdminNamesList.size())
- .setDeviceInfos(noAdminNamesList);
- list.add(vo);
- }
- return R.ok(list);
- }
- public R<List<DeviceInfoDto.GroupByAdminNameVo>> groupByAdminCount(@RequestBody @Validated DeviceInfoDto.GroupByAdminNameDto dto) {
- String noAdmin = "未分配管理员";
- List<DeviceInfoDto.ListByAdminName> deviceInfoList = listByAdminName(dto).getData();
- // 根据管理员名字分组
- Map<String, List<DeviceInfoDto.ListByAdminName>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.ListByAdminName::getAdminName));
- List<DeviceInfoDto.GroupByAdminNameVo> list = new ArrayList<>();
- // 不包含未分配管理员的
- deviceMap.forEach(
- (k, i) -> {
- DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
- if (!noAdmin.equals(k)) {
- vo.setAdminName(k)
- .setDeviceNum(i.size())
- .setDeviceInfos(i);
- list.add(vo);
- }
- }
- );
- // 包含分配管理员的
- List<DeviceInfoDto.ListByAdminName> noAdminNamesList = deviceMap.get(noAdmin);
- if (Emptys.check(noAdminNamesList)) {
- DeviceInfoDto.GroupByAdminNameVo vo = new DeviceInfoDto.GroupByAdminNameVo();
- vo.setAdminName(noAdmin)
- .setDeviceNum(noAdminNamesList.size())
- .setDeviceInfos(noAdminNamesList);
- list.add(vo);
- }
- return R.ok(list);
- }
- @PostMapping("eventList")
- @ApiOperation("根据事件编码查询设备")
- public R<PageBean<DeviceInfoDto.EventListVo>> eventList(@RequestBody @Validated DeviceInfoDto.EventList eventList) {
- String countAs = "id";
- QueryWrapper<DeviceEventMsg> queryWrapper = new QueryWrapper<DeviceEventMsg>()
- .select(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId) + " as " + LambdaUtils.getProperty(DeviceEventMsg::getDeviceId), "count(*) as " + countAs)
- .eq(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getCode), eventList.getCode())
- .between(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getCreateTime), eventList.getBeginTime(), eventList.getEndTime())
- .groupBy(LambdaUtils.getUnderlineCaseName(DeviceEventMsg::getDeviceId))
- .last("HAVING " + countAs + " >= " + eventList.getSize());
- IPage<DeviceEventMsg> iPage = deviceEventMsgService.page(toIPage(eventList.getPage()), queryWrapper);
- PageBean<DeviceInfoDto.EventListVo> pageBean = new PageBean<DeviceInfoDto.EventListVo>()
- .setSize(iPage.getSize())
- .setCurrent(iPage.getCurrent())
- .setTotal(iPage.getTotal());
- List<DeviceEventMsg> list = iPage.getRecords();
- if (!Emptys.check(list)) {
- return R.ok(pageBean);
- }
- List<DeviceInfo> deviceInfos = listByIds(new JArrayList<>(list).getProperty(DeviceEventMsg::getDeviceId));
- List<DeviceInfoDto.EventListVo> eventListVos = copy(DeviceInfoDto.EventListVo.class, deviceInfos);
- List<DeviceInfoDto.EventListVo> builder = copy(eventListVos)
- .target(list, DeviceInfoDto.EventListVo::getDeviceId, DeviceInfoDto.EventListVo::getSize, DeviceEventMsg::getDeviceId, DeviceEventMsg::getId)
- .builder();
- return R.ok(pageBean.setRecords(builder));
- }
- @ApiOperation("拓元算法设备列表")
- @PostMapping("tyDeviceList")
- public R<PageBean<DeviceInfoDto.Vo>> tyDeviceList(@RequestBody @Validated DeviceInfoDto.TyDeviceDTO dto) {
- PageBean pageBean = dto.getPage();
- String searchKey = dto.getSearchKey();
- Integer thirdStatus = dto.getThirdStatus();
- List<String> statusList = new ArrayList<>();
- // 1待审核,2已审核
- if (thirdStatus != null && thirdStatus.intValue() == 1) {
- statusList = CollUtil.newArrayList("1000", "2000", "3000", "5000");
- }
- // 2已审核 4000: 设备登记成功
- if (thirdStatus != null && thirdStatus.intValue() == 2) {
- statusList.add("4000");
- }
- LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
- lqw.eq(DeviceInfo::getAlgorithmId, AlgorithmTypeEnum.TY.getId());
- lqw.in(CollUtil.isNotEmpty(statusList), DeviceInfo::getThirdStatus, statusList);
- lqw.and(StrUtil.isNotEmpty(searchKey), wrapper -> wrapper
- .eq(DeviceInfo::getDeviceId, searchKey)
- .or()
- .likeRight(DeviceInfo::getDeviceName, searchKey));
- IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
- List<DeviceInfo> records = iPage.getRecords();
- if (CollUtil.isNotEmpty(records)) {
- ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.TY_DEVICE_STATUS, records.size());
- records.forEach(deviceInfo -> execute.execute(() -> {
- Long deviceId = deviceInfo.getDeviceId();
- /**
- * 请求状态码。
- * 1000: 未知的设备CPUID
- * 2000: 设备登记 审批中
- * 3000: 设备登记已拒绝
- * 4000: 设备登记成功
- * 5000: 设备已禁⽤
- */
- String tyStatus = deviceInfo.getThirdStatus();
- if (!"4000".equals(tyStatus)) {
- // 未登记成功的需要实时查询
- // 查询登记设备
- DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));
- Integer status = deviceQueryVO.getStatus();
- String message = deviceQueryVO.getMessage();
- deviceInfo.setThirdStatus(String.valueOf(status));
- deviceInfo.setThirdResult(message);
- updateById(deviceInfo);
- }
- }));
- execute.end();
- }
- PageBean<DeviceInfoDto.Vo> voPageBean = toPageBean(DeviceInfoDto.Vo.class, iPage);
- return R.ok(voPageBean);
- }
- /**
- * 商户设备列表分页-穿梭框用
- *
- * @param dto
- * @return {@link R}<{@link List}<{@link DeviceInfoDto.MyDeviceInfo}>>
- */
- public R<PageBean<DeviceInfoDto.MyDeviceInfo>> myDeviceList(@RequestBody @Validated DeviceInfoDto.MyDeviceDTO dto) {
- PageBean pageBean = dto.getPage();
- String searchKey = dto.getSearchKey();
- Long mercId = dto.getMercId();
- Integer type = dto.getType();
- Long strategyId = dto.getStrategyId();
- GoodsDeviceDto.SelectList selectList = new GoodsDeviceDto.SelectList();
- if (strategyId != null) {
- selectList.setMercId(mercId).setPriceStrategyId(strategyId);
- }
- List<GoodsDeviceDto.Vo> goodsDevices = R.feignCheckData(goodsDeviceService.list(selectList));
- if (type == 2 && CollUtil.isEmpty(goodsDevices)) {
- // 右侧已选的
- return R.ok(new PageBean<>());
- }
- List<Long> deviceIds = goodsDevices.stream().map(GoodsDeviceDto.Vo::getDeviceId).collect(Collectors.toList());
- LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
- .build();
- lqw.in(type == 2 && CollUtil.isNotEmpty(deviceIds), DeviceInfo::getDeviceId, deviceIds);
- // 左侧排除掉已关联的
- lqw.notIn(type == 1 && CollUtil.isNotEmpty(deviceIds), DeviceInfo::getDeviceId, deviceIds);
- lqw.and(StrUtil.isNotEmpty(searchKey), wrapper -> wrapper
- .eq(DeviceInfo::getDeviceId, searchKey)
- .or()
- .likeRight(DeviceInfo::getDeviceName, searchKey));
- IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
- return R.ok(toPageBean(DeviceInfoDto.MyDeviceInfo.class, iPage));
- }
- @ApiOperation("点位设备数量查询")
- @Override
- public R<List<DeviceInfoDto.PlaceDeviceNumVo>> placeDeviceNum(@RequestBody @Validated DeviceInfoDto.PlaceDeviceNumDto dto) {
- return R.ok(baseMapper.placeDeviceNum(dto));
- }
- @Override
- @ApiOperation("设备列表带卡包数")
- public R<PageBean<DeviceInfoDto.AlgorithmChargingVo>> algorithmChargingDevice(@RequestBody @Validated DeviceInfoDto.AlgorithmCharging algorithmCharging) {
- PageBean pageBean = algorithmCharging.getPage();
- // 查询设备
- Integer value = SysDictUtils.getValue(EnumDeviceActiveStatus.Code.CODE.getCode(), EnumDeviceActiveStatus.N_1.getCode(), Integer.class);
- LambdaUpdateWrapper<DeviceInfo> lambdaUpdateWrapper = new LambdaUpdateWrapper<DeviceInfo>()
- .eq(DeviceInfo::getMercId, algorithmCharging.getMercId())
- .eq(DeviceInfo::getActiveState, value)
- .in(Emptys.check(algorithmCharging.getDeviceIds()), DeviceInfo::getDeviceId, algorithmCharging.getDeviceIds())
- .orderByDesc(DeviceInfo::getCreateTime);
- IPage<DeviceInfo> page = page(toIPage(pageBean), lambdaUpdateWrapper);
- PageBean<DeviceInfoDto.AlgorithmChargingVo> algorithmChargingVoPageBean = toPageBean(DeviceInfoDto.AlgorithmChargingVo.class, page);
- List<DeviceInfoDto.AlgorithmChargingVo> algorithmChargingVos = algorithmChargingVoPageBean.getRecords();
- if (!Emptys.check(algorithmChargingVos)) {
- return R.ok(algorithmChargingVoPageBean);
- }
- // 查询卡包数量
- List<DeviceAlgorithmChargingDto.CountVo> data = deviceAlgorithmChargingService.count(new DeviceAlgorithmChargingDto.Count()
- .setDeviceIds(new JArrayList<>(algorithmChargingVos).getProperty(DeviceInfoDto.AlgorithmChargingVo::getDeviceId))
- .setMercId(algorithmCharging.getMercId())
- ).getData();
- JMap<Long, DeviceAlgorithmChargingDto.CountVo> cover = new JArrayList<>(data).toMap(DeviceAlgorithmChargingDto.CountVo::getDeviceId).cover();
- algorithmChargingVos.forEach(algorithmChargingVo -> {
- DeviceAlgorithmChargingDto.CountVo countVo = cover.get(algorithmChargingVo.getDeviceId());
- Beans.copy(algorithmChargingVo, countVo);
- });
- return R.ok(algorithmChargingVoPageBean);
- }
- @Override
- @ApiOperation("设备在线数查询")
- public R<Map<Long, DeviceInfoDto.NetStateCountVo>> netStateCount(DeviceInfoDto.NetStateCountDto dto) {
- List<DeviceInfoDto.NetStateCount> netStateCountList = baseMapper.netStateCount(dto.getMercIdList());
- List<Long> netStateCountMercList = netStateCountList.stream().map(DeviceInfoDto.NetStateCount::getMercId).distinct().collect(Collectors.toList());
- Map<Long, DeviceInfoDto.NetStateCountVo> voMap = new HashMap<>();
- List<Long> mercIdList = Emptys.check(dto.getMercIdList()) ? dto.getMercIdList() : netStateCountMercList;
- if (!Emptys.check(mercIdList)) {
- return R.ok();
- }
- for (Long mercId : mercIdList) {
- Integer count = 0;
- Integer offline = 0;
- DeviceInfoDto.NetStateCountVo vo = new DeviceInfoDto.NetStateCountVo().setMercId(mercId);
- for (DeviceInfoDto.NetStateCount i : netStateCountList) {
- if (Objects.equals(i.getMercId(), mercId)) {
- count += i.getCount();
- if ("1".equals(i.getNetState())) {
- vo.setOnLineCount(i.getCount());
- } else {
- offline += i.getCount();
- }
- }
- }
- vo.setCount(count).setOffLineCount(offline);
- voMap.put(mercId, vo);
- }
- return R.ok(voMap);
- }
- @Override
- @ApiOperation("分页")
- public R<PageBean<DeviceInfoDto.Vo>> pageSingle(DeviceInfoDto.PageSingle dto) {
- PageBean pageBean = dto.getPage();
- LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
- .build();
- IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
- return R.ok(toPageBean(DeviceInfoDto.Vo.class, iPage));
- }
- @Override
- @ApiOperation("设备流水统计分页")
- public R<PageBean<DeviceDataDto.DeviceFlowCountVO>> deviceFlowCountPage(@RequestBody @Valid DeviceDataDto.DeviceFlowCountDTO dto) {
- Long curMercId = dto.getCurMercId();
- PageBean pageBean = dto.getPage();
- List<Long> mercIds = new ArrayList<>();
- Long chooseMercId = dto.getChooseMercId();
- if (chooseMercId == null) {
- // 未指定商户 查下级商户含自身
- mercIds = R.feignCheckData(mercService.getAllSubMercIds(new MercDto.QuerySubDTO().setParentMercID(curMercId)));
- } else {
- mercIds.add(chooseMercId);
- }
- LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
- .ge(DeviceInfo::getActiveTime, dto.getActiveStartTime())
- .le(DeviceInfo::getActiveTime, dto.getActiveEndStartTime())
- .build().in(DeviceInfo::getMercId, mercIds).eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode());
- IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
- PageBean<DeviceDataDto.DeviceFlowCountVO> dataPage = toPageBean(DeviceDataDto.DeviceFlowCountVO.class, iPage);
- List<DeviceDataDto.DeviceFlowCountVO> records = dataPage.getRecords();
- if (CollUtil.isNotEmpty(records)) {
- List<Long> placeIds = records.stream().filter(s -> s.getPlaceId() != null).map(DeviceDataDto.DeviceFlowCountVO::getPlaceId).distinct().collect(Collectors.toList());
- List<MercPlaceDto.Vo> merPlaceList = R.feignCheckData(mercPlaceService.list(new MercPlaceDto.ListDto().setIds(placeIds)));
- if (Emptys.check(merPlaceList)) {
- Map<Long, MercPlaceDto.Vo> placeMap = merPlaceList.stream().collect(Collectors.toMap(MercPlaceDto.Vo::getId, p -> p));
- for (DeviceDataDto.DeviceFlowCountVO record : records) {
- Long placeId = record.getPlaceId();
- if (placeId == null) {
- continue;
- }
- // 点位 区域 反显
- MercPlaceDto.Vo placeVo = placeMap.get(placeId);
- if (placeVo != null) {
- record.setDistrictName(placeVo.getRegionName());
- record.setPlaceName(placeVo.getPlaceName());
- }
- }
- dataPage.setRecords(records);
- }
- }
- return R.ok(dataPage);
- }
- /**
- * 按商户分页查设备
- *
- * @param dto
- * @return {@link PageBean}<{@link DeviceInfoDto.Vo}>
- */
- public PageBean<DeviceInfoDto.Vo> pageByMerc(DeviceInfoDto.PageByMercDto dto) {
- PageBean pageBean = dto.getPage();
- String deviceSearch = dto.getDeviceSearch();
- List<Long> myDeviceIds = dto.getMyDeviceIds();
- LambdaQueryWrapper<DeviceInfo> lqw = new MybatisPlusQuery().eqWrapper(dto, DeviceInfo.class)
- .build();
- List<Long> deviceIds = dto.getDeviceIds();
- Boolean choosed = dto.getChoosed();
- if (BooleanUtil.isFalse(choosed)) {
- // 未选择 排除已选择
- if (CollUtil.isNotEmpty(deviceIds)) {
- lqw.notIn(DeviceInfo::getDeviceId, deviceIds);
- } else {
- if (CollUtil.isEmpty(myDeviceIds)) {
- return new PageBean<>();
- }
- lqw.in(DeviceInfo::getDeviceId, myDeviceIds);
- }
- } else {
- // 已选择
- // 指定设备 已选择
- if (CollUtil.isNotEmpty(deviceIds)) {
- lqw.in(DeviceInfo::getDeviceId, deviceIds);
- } else {
- return new PageBean<>();
- }
- }
- // 设备搜索
- lqw.and(StrUtil.isNotEmpty(deviceSearch),
- wrapper -> wrapper
- .likeRight(DeviceInfo::getDeviceName, deviceSearch)
- .or()
- .likeRight(DeviceInfo::getDeviceId, deviceSearch)
- );
- IPage<DeviceInfo> iPage = page(toIPage(pageBean), lqw);
- return toPageBean(DeviceInfoDto.Vo.class, iPage);
- }
- @Override
- @ApiOperation("对象查询")
- public R<DeviceInfoDto.Vo> obj(DeviceInfoDto.Obj obj) {
- // 设备信息
- LambdaQueryWrapper<DeviceInfo> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(obj, DeviceInfo.class).build();
- List<DeviceInfo> list = list(lambdaQueryWrapper);
- if (!Emptys.check(list)) {
- return R.ok();
- }
- DeviceInfoDto.Vo deviceInfo = copy(DeviceInfoDto.Vo.class, list.get(0));
- int num = 0;
- if (obj.getIsSysinfo()) {
- num++;
- }
- if (obj.getIsStatus()) {
- num++;
- }
- if (obj.getIsRegister()) {
- num++;
- }
- if (num > 0) {
- ThreadPoolUtils.Execute execute = ThreadPoolUtils.excPoll(DeviceThreadPoolConfig.DEVICE_COMMON_POLL, num);
- if (obj.getIsSysinfo()) {
- execute.execute(() -> {
- // 系统信息
- DeviceSysinfoDto.Vo deviceSysinfo = deviceSysinfoService.get(new DeviceSysinfoDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
- deviceInfo.setDeviceSysinfo(deviceSysinfo);
- });
- }
- if (obj.getIsStatus()) {
- execute.execute(() -> {
- // 状态信息
- DeviceStatusDto.Vo deviceStatus = deviceStatusService.obj(new DeviceStatusDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
- deviceInfo.setDeviceStatus(deviceStatus);
- });
- }
- if (obj.getIsRegister()) {
- execute.execute(() -> {
- // 注册信息
- DeviceRegisterDto.Vo deviceRegister = deviceRegisterService.obj(new DeviceRegisterDto.Vo().setDeviceId(deviceInfo.getDeviceId())).getData();
- deviceInfo.setDeviceRegister(deviceRegister);
- });
- }
- execute.end();
- }
- return R.ok(deviceInfo);
- }
- @ApiOperation("反显设备名称")
- @Override
- public R<Map<Long, String>> getDeviceNameList(DeviceInfoDto.DeviceIdDto dto) {
- LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<DeviceInfo>()
- .in(DeviceInfo::getDeviceId, dto.getDeviceId())
- .select(DeviceInfo::getDeviceId, DeviceInfo::getDeviceName);
- List<DeviceInfo> deviceInfoList = list(lqw);
- return R.ok(deviceInfoList.stream().collect(Collectors.toMap(DeviceInfo::getDeviceId, i -> Optional.ofNullable(i.getDeviceName()).orElse(""))));
- }
- @Override
- public R<DeviceSysinfoDto.Vo> getDeviceSysinfo(DeviceSysinfoDto.DeviceSysInfo dto) {
- String dtoDeviceSN = dto.getDeviceSN();
- DeviceSysinfo one = deviceSysinfoService.getOne(Wrappers.<DeviceSysinfo>lambdaQuery().eq(DeviceSysinfo::getDeviceSn, dtoDeviceSN));
- return R.ok(BeanUtil.copyProperties(one, DeviceSysinfoDto.Vo.class));
- }
- @Override
- @ApiOperation("设备访问历史添加")
- public R history(DeviceInfoDto.Obj obj) {
- // 获取字典
- SysDictRedis sysDictRedis = SysDictUtils.get(EnumDataClearSize.Code.CODE.getCode(), EnumDataClearSize.DEVICE_HISTORY_TWIG.getCode());
- Integer value = Integer.valueOf(sysDictRedis.getValue());
- // 获取redis
- String key = keyPrefix + AuthorizeUtils.getLoginId(Long.class);
- List<String> list = redisService.getList(key);
- list.add(0, String.valueOf(obj.getDeviceId()));
- // 去重
- List<String> redisList = new ArrayList<>();
- JList<String> comparing = new JArrayList<>(list).comparing();
- if (comparing.size() > value) {
- for (int i = 0; i < value; i++) {
- redisList.add(comparing.get(i));
- }
- } else {
- redisList = comparing;
- }
- redisService.removeList(key);
- redisService.setList(key, redisList);
- return R.ok();
- }
- @Override
- @ApiOperation("开门检测")
- public R<DeviceInfoDto.Vo> checkOpenDoor(DeviceInfoDto.Obj obj) {
- DeviceInfoDto.Vo deviceInfo = obj(new DeviceInfoDto.Obj()
- .setDeviceId(obj.getDeviceId())
- .setIsStatus(true)
- ).getData();
- if (deviceInfo == null) {
- return R.fail("设备不存在");
- }
- DeviceStatusDto.Vo deviceStatus = deviceInfo.getDeviceStatus();
- SysDictRedis qualitySets = SysDictUtils.get(EnumQualityMercSets.Code.CODE.getCode(), EnumQualityMercSets.MERC_CODE.getCode());
- List<String> qualitySetList = Arrays.asList(qualitySets.getValue().split(","));
- // 设备当前商户是质检时不检查
- if (!qualitySetList.contains(deviceInfo.getMercCode())) {
- check(deviceInfo.getActiveState(), 2, "设备未激活");
- check(deviceInfo.getFreezeStatus(), 2, "设备已冻结");
- check(obj.getDoor() != null && obj.getDoor() == 1 ? deviceStatus.getLockStateR() : deviceStatus.getLockStateL(), 2, "设备已锁机");
- check(deviceStatus.getIsPay(), Boolean.FALSE, "设备不可交易");
- check(deviceInfo.getBusyState(), 2, "设备已停运");
- SysDictRedis sysDictRedis = SysDictUtils.get(EnumDeviceFaultLevelPayThreshold.Code.CODE.getCode(), EnumDeviceFaultLevelPayThreshold.NOT_PAY.getCode());
- check(deviceInfo.getFaultLevel(), sysDictRedis.getValue(), "设备故障");
- }
- check(deviceStatus.getNetState(), 2, "设备已离线");
- check(obj.getDoor() != null && obj.getDoor() == 1 ? deviceStatus.getDoorStateR() : deviceStatus.getDoorStateL(), 1, "设备正在使用中,请稍后");
- return R.ok(deviceInfo);
- }
- @PostMapping("historyList")
- @ApiOperation("设备访问历史查询")
- public R<List<DeviceInfoDto.Vo>> historyList() {
- // 获取redis
- String key = keyPrefix + AuthorizeUtils.getLoginId(Long.class);
- List<String> deviceIds = redisService.getList(key);
- if (!Emptys.check(deviceIds)) {
- return R.ok();
- }
- // 查询数据库
- List<DeviceInfo> list = list(new LambdaQueryWrapper<DeviceInfo>().in(DeviceInfo::getDeviceId, deviceIds));
- return R.ok(copy(DeviceInfoDto.Vo.class, list));
- }
- @ApiOperation("根据点位ID更新坐标")
- public R updateLonByPlaceId(@RequestBody @Validated DeviceInfoDto.UpdateLonByPlaceId dto) {
- LambdaUpdateWrapper<DeviceInfo> luw = new LambdaUpdateWrapper<DeviceInfo>()
- .eq(DeviceInfo::getPlaceId, dto.getPlaceId())
- .set(DeviceInfo::getLon, dto.getLon())
- .set(DeviceInfo::getLat, dto.getLat());
- update(luw);
- return R.ok();
- }
- @ApiOperation("修改")
- @PostMapping("update")
- public R update(@RequestBody @Validated DeviceInfoDto.Update update) {
- DeviceInfo deviceInfo = getById(update.getDeviceId());
- // 判断是否更新了点位
- if (Emptys.check(update.getPlaceId()) && !Objects.equals(deviceInfo.getPlaceId(), update.getPlaceId())) {
- // 把设备绑定给点位管理员
- MercUserBindDeviceDto.BindByDeviceUpdate bindByPlaceIdDTto = new MercUserBindDeviceDto.BindByDeviceUpdate();
- bindByPlaceIdDTto.setDeviceId(update.getDeviceId())
- .setPlaceId(update.getPlaceId())
- .setMercId(deviceInfo.getMercId());
- mercUserBindDeviceService.bindByDeviceUpdate(bindByPlaceIdDTto);
- // 更新坐标为点位的坐标
- MercPlaceDto.ObjVo place = mercPlaceService.obj(new MercPlaceDto.Obj().setId(update.getPlaceId())).getData();
- update.setLat(place.getLat()).setLon(place.getLon());
- }
- DeviceInfo deviceSave = copy(DeviceInfo.class, update)
- .setUpdateTime(LocalDateTime.now());
- updateById(deviceSave);
- Long deviceId = deviceSave.getDeviceId();
- DeviceInfoDto.Vo device = R.feignCheckData(this.obj(new DeviceInfoDto.Obj().setDeviceId(deviceId).setIsSysinfo(true)));
- Long algorithmId = update.getAlgorithmId();
- if (algorithmId != null && AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
- // 云从算法
- boolean b = cloudWalkApiService.checkDeviceExist(deviceId);
- if (!b) {
- // 货柜不存在,新增
- cloudWalkApiService.containerAdd(new ContainerAddDTO().setContainerCode(String.valueOf(deviceId)));
- }
- } else if (algorithmId != null && AlgorithmTypeEnum.TY.getId() == algorithmId) {
- // 拓元算法
- // 查询登记设备
- DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));
- Integer status = deviceQueryVO.getStatus();
- if (status != null && 1000 == status.intValue()) {
- // 未知的设备CPUID,进行登记
- tyApiService.deviceReg(new DeviceRegDTO()
- .setCpuId(String.valueOf(deviceId))
- .setDeviceNumber(String.valueOf(deviceId))
- );
- }
- }
- Integer deviceType = device.getDeviceType();
- if (ObjectUtil.equals(DeviceTypeEnum.TYPE5.getCode(), deviceType)) {
- DeviceUpdateDTO deviceUpdateDTO = new DeviceUpdateDTO();
- if (StrUtil.isNotEmpty(update.getDeviceName())) {
- deviceUpdateDTO.setDeviceName(update.getDeviceName());
- }
- String deviceSn = device.getDeviceSysinfo().getDeviceSn();
- if (deviceUpdateDTO != null) {
- deviceUpdateDTO.setTerminalId(String.valueOf(update.getDeviceId()));
- deviceUpdateDTO.setBoardSn(deviceSn);
- alipayDeviceService.deviceUpdate(deviceUpdateDTO);
- }
- }
- return R.ok();
- }
- @Override
- @ApiOperation("批量修改")
- public R updateBatch(@RequestBody List<DeviceInfoDto.Update> updates) {
- LocalDateTime now = LocalDateTime.now();
- List<DeviceInfo> deviceInfos = new ArrayList<>(updates.size());
- updates.forEach(update -> deviceInfos.add(copy(DeviceInfo.class, update).setUpdateTime(now)));
- updateBatchById(deviceInfos);
- return R.ok();
- }
- @Override
- @ApiOperation("激活数量统计")
- public R<Integer> activationCount(DeviceInfoDto.ActivationCount activationCount) {
- LambdaQueryWrapper<DeviceInfo> lambdaQueryWrapper = new LambdaQueryWrapper<DeviceInfo>()
- .eq(DeviceInfo::getMercId, activationCount.getMercId())
- .eq(DeviceInfo::getActiveState, 1)
- .ne(Emptys.check(activationCount.getNotDeviceType()), DeviceInfo::getDeviceType, activationCount.getNotDeviceType())
- .between(Emptys.check(activationCount.getBeginTime()), DeviceInfo::getActiveTime, activationCount.getBeginTime(), activationCount.getEndTime());
- long count = count(lambdaQueryWrapper);
- return R.ok((int) count);
- }
- @Override
- @ApiOperation("更新商户线路")
- public R updateLine(@RequestBody @Validated DeviceInfoDto.UpdateLine updateLine) {
- LambdaUpdateWrapper<DeviceInfo> luw = new LambdaUpdateWrapper<DeviceInfo>().eq(DeviceInfo::getMercId, updateLine.getMercId());
- // 绑定线路,更换线路
- if (DeviceInfoDto.UPDATE.equals(updateLine.getType())) {
- DeviceInfo deviceInfo = new DeviceInfo();
- deviceInfo.setPlaceLineId(updateLine.getPlaceLineId());
- luw.in(DeviceInfo::getDeviceId, updateLine.getDeviceIds());
- baseMapper.update(deviceInfo, luw);
- }
- // 删除线路
- if (DeviceInfoDto.DEL.equals(updateLine.getType())) {
- luw.eq(DeviceInfo::getPlaceLineId, updateLine.getWherePlaceLineId());
- luw.set(DeviceInfo::getPlaceLineId, null);
- baseMapper.update(null, luw);
- }
- // 解绑线路 设置线路ID为null
- if (DeviceInfoDto.CLEAR.equals(updateLine.getType())) {
- luw.in(DeviceInfo::getDeviceId, updateLine.getDeviceIds());
- luw.set(DeviceInfo::getPlaceLineId, null);
- baseMapper.update(null, luw);
- }
- return R.ok();
- }
- @Override
- @ApiOperation("更新商户点位")
- public R updatePlace(@RequestBody @Validated DeviceInfoDto.UpdatePlace updatePlace) {
- LambdaUpdateWrapper<DeviceInfo> luw = new LambdaUpdateWrapper<DeviceInfo>().eq(DeviceInfo::getMercId, updatePlace.getMercId());
- // 绑定点位,更换点位
- if (DeviceInfoDto.UPDATE.equals(updatePlace.getType())) {
- DeviceInfo deviceInfo = new DeviceInfo();
- deviceInfo.setPlaceId(updatePlace.getPlaceId());
- luw.in(DeviceInfo::getDeviceId, updatePlace.getDeviceIds());
- baseMapper.update(deviceInfo, luw);
- }
- // 删除点位
- if (DeviceInfoDto.DEL.equals(updatePlace.getType())) {
- luw.eq(DeviceInfo::getPlaceId, updatePlace.getWherePlaceId());
- luw.set(DeviceInfo::getPlaceId, null);
- baseMapper.update(null, luw);
- }
- // 解绑点位 设置点位ID为null
- if (DeviceInfoDto.CLEAR.equals(updatePlace.getType())) {
- luw.in(DeviceInfo::getDeviceId, updatePlace.getDeviceIds());
- luw.set(DeviceInfo::getPlaceId, null);
- baseMapper.update(null, luw);
- }
- return R.ok();
- }
- @ApiOperation("分页查询")
- @Override
- public R<PageBean<DeviceInfoDto.Vo2>> page(@RequestBody DeviceInfoDto.Page page) {
- return R.ok(queryPage(page));
- }
- @ApiOperation("导出设备列表")
- @PostMapping("exportDevices")
- public void exportDevices(HttpServletResponse response, @RequestBody @Valid DeviceInfoDto.Page page) throws IOException {
- PageBean<DeviceInfoDto.Vo2> pageBean = queryPage(page);
- List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
- List<DeviceInfoDto.DeviceExcelVO> deviceExcelVOS = BeanUtil.copyToList(records, DeviceInfoDto.DeviceExcelVO.class);
- // 输出
- ExcelUtils.write(response, "设备列表.xls", "设备列表", DeviceInfoDto.DeviceExcelVO.class, deviceExcelVOS);
- }
- @ApiOperation("导出设备(异步)")
- @PostMapping("exportDevices/async")
- public void exportDevicesAsync(@RequestBody @Validated DeviceInfoDto.Page page) {
- PageBean<DeviceInfoDto.Vo2> pageBean = queryPage(page);
- List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
- List<DeviceInfoDto.DeviceExcelVO> deviceExcelVOS = BeanUtil.copyToList(records, DeviceInfoDto.DeviceExcelVO.class);
- // 异步导出参数封装
- ExcelDTO<DeviceInfoDto.DeviceExcelVO> excelDTO = new ExcelDTO<>();
- excelDTO.setData(deviceExcelVOS);
- excelDTO.setHead(DeviceInfoDto.DeviceExcelVO.class);
- excelDTO.setSheetName(FileExportType.DEVICE_INFO.getDescription());
- excelDTO.setFileExportType(FileExportType.DEVICE_INFO);
- // 执行导出
- fileExportService.exportExcelAsync(excelDTO);
- }
- @PostMapping("nearbyPage")
- @ApiOperation("附近设备分页查询")
- public R<PageBean<DeviceInfoDto.Vo2>> nearbyPage(@RequestBody DeviceInfoDto.Page page) {
- if (!Emptys.check(page.getLon()) || !Emptys.check(page.getLat())) {
- throw new CommRuntimeException("经纬度不能为空");
- }
- return R.ok(queryPage(page));
- }
- @ApiOperation(value = "商户设备授权", hidden = true)
- @Override
- @Transactional(rollbackFor = Exception.class)
- public R<Boolean> mercDeviceAuth(DeviceInfoDto.MercDeviceAuthDto auth) {
- Long mercId = auth.getMercId();
- String mercCode = auth.getMercCode();
- Long algorithmId = auth.getAlgorithmId();
- String mercName = auth.getMercName();
- // 商户最终设备列表
- List<Long> deviceIds = auth.getDeviceIds();
- List<DeviceInfo> devices = getDevicesByMercId(mercId);
- // 取消商户设备授权
- if (CollUtil.isEmpty(deviceIds)) {
- if (CollUtil.isEmpty(devices)) {
- return R.ok(Boolean.TRUE);
- }
- }
- // 更新商户设备授权
- List<DeviceInfo> deviceInfos = this.listByIds(deviceIds);
- // 绑定前,先进行旧的用户设备关联表清理
- R.feignCheckData(mercService.unBindSubMercDevice(new MiniDeviceInfoDto.MercDeviceUnBindDto().setDeviceIds(deviceIds)));
- List<DeviceStatus> deviceStatuses = new ArrayList<>();
- for (DeviceInfo deviceInfo : deviceInfos) {
- Integer deviceType = deviceInfo.getDeviceType();
- Long deviceId = deviceInfo.getDeviceId();
- // 清理点位
- deviceInfo.setPlaceId(-1L);
- if (ObjectUtil.equals(deviceType, DeviceTypeEnum.TYPE5.getCode())) {
- // 支付宝设备算法
- algorithmId = AlgorithmTypeEnum.ALIPAY.getId();
- } else {
- // 非支付宝算法
- if (AlgorithmTypeEnum.CLOUD.getId() == algorithmId) {
- // 云从算法
- boolean b = cloudWalkApiService.checkDeviceExist(deviceId);
- if (!b) {
- // 货柜不存在,新增
- cloudWalkApiService.containerAdd(new ContainerAddDTO().setContainerCode(String.valueOf(deviceId)));
- }
- } else if (AlgorithmTypeEnum.TY.getId() == algorithmId) {
- // 拓元算法
- // 查询登记设备
- DeviceQueryVO deviceQueryVO = tyApiService.deviceQuery(new DeviceQueryDTO().setCpuId(String.valueOf(deviceId)));
- Integer status = deviceQueryVO.getStatus();
- if (status != null && 1000 == status.intValue()) {
- // 未知的设备CPUID,进行登记
- tyApiService.deviceReg(new DeviceRegDTO()
- .setCpuId(String.valueOf(deviceId))
- .setDeviceNumber(String.valueOf(deviceId))
- );
- }
- }
- }
- int refMercId = deviceInfo.getMercId().intValue();
- String refMercCode = deviceInfo.getMercCode();
- if (BooleanUtil.isFalse(auth.getMercOperate())) {
- // 非商户操作
- // 只有解绑后,才能给顶级商户授权
- if (refMercId != -1 && refMercId != mercId.intValue()) {
- StrBuilder sb = StrBuilder.create();
- String errMsg = sb.append("设备[")
- .append(deviceInfo.getDeviceId())
- .append("]")
- .append("已被商户[")
- .append(deviceInfo.getMercName())
- .append("]绑定,请先进行解绑!")
- .toString();
- // 非质检商户需要进行判断,质检商户跳过
- if (!QA_MERC_CODE.equals(refMercCode)) {
- // 已关联别商户
- return R.fail(errMsg, Boolean.FALSE);
- }
- }
- } else {
- // 商户操作直接转移给子商户
- }
- // 绑定关系
- deviceInfo.setMercId(mercId).setMercCode(mercCode).setAlgorithmId(algorithmId).setMercName(mercName);
- // 标记机器可交易
- DeviceStatus deviceStatus = new DeviceStatus()
- .setDeviceId(deviceInfo.getDeviceId())
- .setIsPay(true);
- deviceStatuses.add(deviceStatus);
- }
- saveOrUpdateBatch(deviceInfos);
- if (Emptys.check(deviceStatuses)) {
- deviceStatusService.updateBatchById(deviceStatuses);
- }
- return R.ok(Boolean.TRUE);
- }
- /**
- * 解绑机器 回收
- *
- * @param dto
- * @return
- */
- @Override
- public R<Boolean> unBindMercDevice(DeviceInfoDto.MercDeviceUnBindDto dto) {
- List<DeviceInfo> deviceInfos = this.listByIds(dto.getDeviceIds());
- return R.ok(removeMerRefDevicesToTopMerc(deviceInfos));
- }
- /**
- * 商户解绑设备 --商家端
- *
- * @param dto
- * @return {@link Boolean}
- */
- public Boolean unBindDeviceByMerc(DeviceInfoDto.MercDeviceUnBindDto dto) {
- List<DeviceInfo> deviceInfos = this.listByIds(dto.getDeviceIds());
- if (CollUtil.isNotEmpty(deviceInfos)) {
- List<Long> mercIds = deviceInfos.stream().map(DeviceInfo::getMercId).collect(Collectors.toList());
- mercIds.forEach(mercId -> {
- if (mercId.longValue() == dto.getMercId().longValue()) {
- throw new CommRuntimeException("只能选择子商户设备进行解绑,请检查是否选择了当前商户下的设备!");
- }
- });
- }
- return removeMerDevicesByDeviceIds(dto, deviceInfos);
- }
- private Boolean removeMerDevicesByDeviceIds(DeviceInfoDto.MercDeviceUnBindDto dto, List<DeviceInfo> deviceInfos) {
- if (CollUtil.isNotEmpty(deviceInfos)) {
- deviceInfos.forEach(deviceInfo -> {
- // 回收 到当前操作商户
- deviceInfo.setMercId(dto.getMercId());
- deviceInfo.setMercDeviceCode(StrUtil.EMPTY);
- // 清理点位信息
- deviceInfo.setPlaceId(-1L);
- deviceInfo.setMercName(dto.getMercName());
- deviceInfo.setMercCode(dto.getMercCode());
- });
- // 用户设备关联表清理
- List<Long> deviceIds = deviceInfos.stream().map(DeviceInfo::getDeviceId).collect(Collectors.toList());
- R.feignCheckData(mercService.unBindSubMercDevice(new MiniDeviceInfoDto.MercDeviceUnBindDto().setDeviceIds(deviceIds)));
- // 批量更新
- return updateBatchById(deviceInfos);
- }
- return Boolean.FALSE;
- }
- /**
- * 回收机器
- *
- * @param deviceInfos
- * @return
- */
- private Boolean removeMerRefDevicesToTopMerc(List<DeviceInfo> deviceInfos) {
- MercDto.Vo mercCheck = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setMercCode(QA_MERC_CODE)));
- if (CollUtil.isNotEmpty(deviceInfos)) {
- deviceInfos.forEach(deviceInfo -> {
- // 回收
- deviceInfo.setMercId(mercCheck.getId());
- deviceInfo.setMercDeviceCode(StrUtil.EMPTY);
- deviceInfo.setMercName(mercCheck.getName());
- deviceInfo.setMercCode(QA_MERC_CODE);
- // 清理点位
- deviceInfo.setPlaceId(-1L);
- });
- // 批量更新
- return updateBatchById(deviceInfos);
- }
- return Boolean.FALSE;
- }
- /**
- * 批量移除商户设备绑定关系
- *
- * @param deviceInfos
- * @return
- */
- private Boolean removeMerRefDevices(List<DeviceInfo> deviceInfos, Long parentId) {
- if (CollUtil.isNotEmpty(deviceInfos) && parentId != null) {
- deviceInfos.forEach(deviceInfo -> {
- // 非顶级兴元商户,解绑后,机器归父商户
- if (parentId != 1) {
- MercDto.Vo mercParent = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setId(parentId)));
- if (mercParent != null) {
- deviceInfo.setMercId(mercParent.getId());
- deviceInfo.setMercName(mercParent.getName());
- deviceInfo.setMercCode(mercParent.getMercCode());
- } else {
- deviceInfo.setMercId(-1L);
- deviceInfo.setMercName(StrUtil.EMPTY);
- deviceInfo.setMercCode(StrUtil.EMPTY);
- }
- }
- // 一级商户,解绑后,直接释放
- if (parentId == 0) {
- MercDto.Vo mercCheck = R.feignCheckData(mercFeignService.obj(new MercDto.ListDTO().setMercCode(QA_MERC_CODE)));
- if (mercCheck != null) {
- deviceInfo.setMercId(mercCheck.getId());
- deviceInfo.setMercName(mercCheck.getName());
- deviceInfo.setMercCode(mercCheck.getMercCode());
- } else {
- deviceInfo.setMercId(-1L);
- deviceInfo.setMercName(StrUtil.EMPTY);
- deviceInfo.setMercCode(StrUtil.EMPTY);
- }
- }
- });
- // 批量更新
- return updateBatchById(deviceInfos);
- }
- return Boolean.FALSE;
- }
- @ApiOperation("集合查询")
- @Override
- public R<List<DeviceInfoDto.Vo>> list(DeviceInfoDto.ListDto dto) {
- List<DeviceInfo> list = list(new LambdaQueryWrapper<DeviceInfo>()
- .eq(Emptys.check(dto.getFreezeStatus()), DeviceInfo::getFreezeStatus, dto.getFreezeStatus())
- .in(CollUtil.isNotEmpty(dto.getDeviceIds()), DeviceInfo::getDeviceId, dto.getDeviceIds())
- .eq(Emptys.check(dto.getMercId()), DeviceInfo::getMercId, dto.getMercId())
- );
- return R.ok(copy(DeviceInfoDto.Vo.class, list));
- }
- @Override
- @ApiOperation("通用集合查询")
- public R<List<DeviceInfoDto.Vo>> listCommon(DeviceInfoDto.ListCommon dto) {
- String deviceSearch = dto.getDeviceSearch();
- DeviceInfoDto.Vo vo = dto.getVo();
- QueryWrapper<DeviceInfo> queryWrapper = new MybatisPlusQuery().eqWrapper(vo == null ? new DeviceInfoDto.Vo() : vo, DeviceInfo.class).buildQW();
- // List<Long> placeLineIds = dto.getPlaceLineIds();
- List<Long> deviceIds = dto.getDeviceIds();
- List<String> columnList = dto.getColumnList();
- // if (CollUtil.isNotEmpty(placeLineIds)) {
- // queryWrapper.in(LambdaUtils.getUnderlineCaseName(DeviceInfo::getPlaceLineId), placeLineIds);
- // }
- // fixed
- if (StrUtil.isNotEmpty(deviceSearch)) {
- queryWrapper.and(wrapper -> wrapper.likeRight(LambdaUtils.getUnderlineCaseName(DeviceInfo::getDeviceName), deviceSearch).or()
- .eq(LambdaUtils.getUnderlineCaseName(DeviceInfo::getDeviceId), deviceSearch));
- }
- if (CollUtil.isNotEmpty(columnList)) {
- queryWrapper.select(columnList.stream().toArray(String[]::new));
- }
- if (CollUtil.isNotEmpty(deviceIds)) {
- queryWrapper.in(LambdaUtils.getUnderlineCaseName(DeviceInfo::getDeviceId), deviceIds);
- }
- return R.ok(copy(DeviceInfoDto.Vo.class, list(queryWrapper)));
- }
- @Override
- @ApiOperation("商户设备算法列表")
- public R<List<Long>> mercAlgorithmIdList(DeviceInfoDto.MercAlgorithmIdListDto dto) {
- String algorithmIdStr = LambdaUtils.getProperty(DeviceInfo::getAlgorithmId);
- String mercStr = StringTools.humpToLine(LambdaUtils.getProperty(DeviceInfo::getMercId));
- QueryWrapper<DeviceInfo> lqw = new QueryWrapper<DeviceInfo>()
- .isNotNull(StringTools.humpToLine(algorithmIdStr))
- .eq(mercStr, dto.getMercId())
- .select(String.format("DISTINCT (%s) as %s", StringTools.humpToLine(algorithmIdStr), algorithmIdStr));
- List<Long> list = listObjs(lqw, (MapperFunction<Object, Long>) o -> (Long) o);
- return R.ok(list);
- }
- @Override
- @ApiOperation("小程序-商户设备首页统计")
- public R<DeviceInfoDto.MercHomeStatisticalVO> mercHomeStatistical(DeviceInfoDto.MercHomeQueryDTO dto) {
- Long mercId = dto.getMercId();
- List<Long> myDeviceIds = dto.getMyDeviceIds();
- // 初始化数据
- DeviceInfoDto.MercHomeStatisticalVO mercHomeStatisticalVO = new DeviceInfoDto.MercHomeStatisticalVO()
- .setClosedNum(0).setOfflineNum(0)
- .setOnlineNum(0).setOperatingNum(0).setNeedToFillNum(0);
- if (CollUtil.isEmpty(myDeviceIds)) {
- return R.ok(mercHomeStatisticalVO);
- }
- List<DeviceInfo> mercDevices = listByIds(myDeviceIds);
- if (CollUtil.isEmpty(mercDevices)) {
- return R.ok(mercHomeStatisticalVO);
- }
- // 在线、离线
- List<DeviceStatus> deviceStatuses = deviceStatusService.listByIds(myDeviceIds);
- // 分组统计
- Map<Integer, Long> countNetstateMap = deviceStatuses.stream().collect(Collectors
- .groupingBy(DeviceStatus::getNetState, Collectors.counting()));
- Integer onlineDictValue = SysDictUtils.getValue(EnumDeviceOnlineStatus.Code.CODE.getCode(), EnumDeviceOnlineStatus.CONNECTED.getCode(), Integer.class);
- Integer offlineDictValue = SysDictUtils.getValue(EnumDeviceOnlineStatus.Code.CODE.getCode(), EnumDeviceOnlineStatus.DISCONNECT.getCode(), Integer.class);
- int onlineNum = countNetstateMap.get(onlineDictValue) == null ? 0 : countNetstateMap.get(onlineDictValue).intValue();
- int offlineNum = countNetstateMap.get(offlineDictValue) == null ? 0 : countNetstateMap.get(offlineDictValue).intValue();
- mercHomeStatisticalVO.setOnlineNum(onlineNum);
- mercHomeStatisticalVO.setOfflineNum(offlineNum);
- // 锁机、未锁机
- // Map<Integer, Long> countLockLstateMap = deviceStatuses.stream().collect(Collectors
- // .groupingBy(DeviceStatus::getLockStateL, Collectors.counting()));
- // Long lockLStateNum = countLockLstateMap.get(DeviceLockState.LOCK.getCode());
- // Long unLockLStateNum = countLockLstateMap.get(DeviceLockState.UN_LOCK.getCode());
- Map<Integer, Long> countLockLstateMap = mercDevices.stream().collect(Collectors
- .groupingBy(DeviceInfo::getBusyState, Collectors.counting()));
- // 运营
- Long operatingNum = countLockLstateMap.get(DeviceBusySateType.OPERATING.getCode());
- // 停运
- Long suspendedNum = countLockLstateMap.get(DeviceBusySateType.SUSPENDED.getCode());
- mercHomeStatisticalVO.setOperatingNum(operatingNum == null ? 0 : operatingNum.intValue());
- mercHomeStatisticalVO.setClosedNum(suspendedNum == null ? 0 : suspendedNum.intValue());
- // 待补货
- Integer deviceNum = R.feignCheckData(goodsDeviceService.countOutOfStockDevice(new GoodsDeviceDto.CountOutOfStockDevice().setMercId(mercId).setDeviceIds(myDeviceIds)));
- mercHomeStatisticalVO.setNeedToFillNum(deviceNum);
- return R.ok(mercHomeStatisticalVO);
- }
- @Override
- @ApiOperation("小程序-商户设备首页列表")
- public R<List<DeviceInfoDto.MercHomeListVO>> mercHomeList(DeviceInfoDto.MercHomeQueryDTO dto) {
- String searchKey = dto.getSearchKey();
- Long mercId = dto.getMercId();
- String deviceName = dto.getDeviceName();
- Long deviceId = dto.getDeviceId();
- List<Long> searchPlaceIdList = new ArrayList<>();
- // 根据管理员名字查询点位ID列表
- if (Emptys.check(dto.getAdminName())) {
- MercPlaceDto.ListDto placeDto = new MercPlaceDto.ListDto();
- placeDto.setMercId(mercId).setAdminName(dto.getAdminName());
- List<MercPlaceDto.Vo> searchPlaceList = mercPlaceService.list(placeDto).getData();
- if (Emptys.check(searchPlaceList)) {
- searchPlaceIdList = searchPlaceList.stream().map(MercPlaceDto.Vo::getId).distinct().collect(Collectors.toList());
- } else {
- return R.ok();
- }
- }
- boolean isQa = false;
- if ("393010594508869".equals(String.valueOf(mercId)) || "498503052238597".equals(String.valueOf(mercId))) {
- isQa = true;
- } else {
- dto.setActiveState("1");
- }
- List<Long> searchDeviceIds = new ArrayList<>();
- if (StrUtil.isNotEmpty(searchKey) || StrUtil.isNotEmpty(dto.getAdminName())) {
- // 名称或者编号搜索设备
- LambdaQueryWrapper<DeviceInfo> deviceLqw = Wrappers.<DeviceInfo>lambdaQuery()
- .eq(DeviceInfo::getMercId, mercId)
- .in(Emptys.check(searchPlaceIdList), DeviceInfo::getPlaceId, searchPlaceIdList);
- if (Emptys.check(searchKey)) {
- deviceLqw.and(wrapper -> wrapper
- .eq(Emptys.check(searchKey), DeviceInfo::getDeviceId, searchKey)
- .or()
- .like(Emptys.check(searchKey), DeviceInfo::getDeviceName, searchKey)
- );
- }
- List<DeviceInfo> list = list(deviceLqw);
- if (CollUtil.isEmpty(list)) {
- return R.ok(new ArrayList<>());
- }
- searchDeviceIds = list.stream().map(DeviceInfo::getDeviceId).collect(Collectors.toList());
- }
- List<Long> myDeviceIds = dto.getDeviceIdList();
- Integer busyStatus = dto.getBusyStatus();
- Integer onlineStatus = dto.getOnlineStatus();
- Integer deviceType = dto.getDeviceType();
- // 条件查询 在线状态,运营状态,设备类型,
- List<Long> deviceIdList = new ArrayList<>();
- if (deviceId != null && myDeviceIds.indexOf(deviceId) > 0) {
- deviceIdList.add(deviceId);
- }
- if (CollUtil.isNotEmpty(myDeviceIds) && deviceId == null) {
- deviceIdList.addAll(myDeviceIds);
- }
- if (CollUtil.isNotEmpty(deviceIdList)) {
- dto.setDeviceIdList(deviceIdList);
- List<Long> queryDeviceIds = new ArrayList<>();
- if (CollUtil.isNotEmpty(searchDeviceIds)) {
- for (Long id : searchDeviceIds) {
- int index = deviceIdList.indexOf(id);
- if (index >= 0) {
- queryDeviceIds.add(id);
- }
- }
- // 无符合权限的搜索设备,返空
- if (CollUtil.isEmpty(queryDeviceIds)) {
- return R.ok(new ArrayList<>());
- } else {
- deviceIdList = queryDeviceIds;
- dto.setDeviceIdList(queryDeviceIds);
- }
- }
- } else {
- return R.ok(new ArrayList<>());
- }
- if (onlineStatus != null) {
- List<DeviceStatus> deviceStatusList = deviceStatusService.list(Wrappers.<DeviceStatus>lambdaQuery()
- .eq(DeviceStatus::getNetState, onlineStatus)
- .in(CollUtil.isNotEmpty(myDeviceIds), DeviceStatus::getDeviceId, deviceIdList)
- );
- if (CollUtil.isNotEmpty(deviceStatusList)) {
- List<Long> dbDeviceIdList = deviceStatusList.stream().map(DeviceStatus::getDeviceId).collect(Collectors.toList());
- deviceIdList = dbDeviceIdList;
- } else {
- return R.ok(new ArrayList<>());
- }
- }
- List<DeviceInfoDto.MercHomeCountVO> list = this.baseMapper.merHomeCountList(dto);
- if (CollUtil.isEmpty(list)) {
- return R.ok(Collections.emptyList());
- }
- List<DeviceInfoDto.MercHomeListVO> dataList = new ArrayList<>(list.size());
- LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
- // 非质检商户才需要激活
- lqw.eq(!isQa, DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode());
- lqw.eq(mercId != null, DeviceInfo::getMercId, mercId);
- lqw.eq(busyStatus != null, DeviceInfo::getBusyState, busyStatus);
- lqw.eq(deviceType != null, DeviceInfo::getDeviceType, deviceType);
- lqw.in(CollUtil.isNotEmpty(deviceIdList), DeviceInfo::getDeviceId, deviceIdList);
- lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName).orderByAsc(true, DeviceInfo::getDeviceName, DeviceInfo::getDeviceId);
- List<DeviceInfoDto.Vo> deviceInfoList = copy(DeviceInfoDto.Vo.class, this.list(lqw));
- // 根据点位ID查询管理员名字
- List<Long> placeIdList = deviceInfoList.stream().map(DeviceInfoDto.Vo::getPlaceId).distinct().filter(Objects::nonNull).collect(Collectors.toList());
- List<MercPlaceDto.Vo> mercPlaceList = mercPlaceService.list(new MercPlaceDto.ListDto().setIds(placeIdList)).getData();
- if (Emptys.check(mercPlaceList)) {
- // Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(Collectors.toMap(i -> i.getId(), i -> i.getAdminName()));
- Map<Long, String> mercPlaceMap = mercPlaceList.stream().collect(HashMap::new, (map, item) -> map.put(item.getId(), item.getAdminName()), HashMap::putAll);
- deviceInfoList.forEach(i -> i.setAdminName(mercPlaceMap.get(i.getPlaceId())));
- }
- // 没有管理员的的设置默认值
- deviceInfoList.stream().filter(s -> s.getAdminName() == null).forEach(s -> s.setAdminName("未分配管理员"));
- List<String> adminNameList = deviceInfoList.stream().map(DeviceInfoDto.Vo::getAdminName).distinct().collect(Collectors.toList());
- List<Long> dIds = deviceInfoList.stream().map(DeviceInfoDto.Vo::getDeviceId).distinct().collect(Collectors.toList());
- List<DeviceSysinfoDto.Vo> deviceSysList = R.feignCheckData(deviceSysinfoService.list(new DeviceSysinfoDto.SelectList().setDeviceIds(dIds)));
- Map<Long, DeviceSysinfoDto.Vo> deviceSysInfoMap = new HashMap<>();
- if (CollUtil.isNotEmpty(deviceSysList)) {
- deviceSysInfoMap = deviceSysList.stream().collect(Collectors.toMap(DeviceSysinfoDto.Vo::getDeviceId, i -> i));
- }
- // 根据管理员名字分组
- Map<String, List<DeviceInfoDto.Vo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfoDto.Vo::getAdminName));
- DateTime date = DateTime.now();
- DateTime start = DateUtil.beginOfDay(date);
- DateTime end = DateUtil.endOfDay(date);
- for (String adminName : adminNameList) {
- DeviceInfoDto.MercHomeListVO vo = new DeviceInfoDto.MercHomeListVO();
- vo.setAdminName(adminName);
- // 区域下的设备列表
- List<DeviceInfoDto.MercHomeDeviceVo> deviceInfos = BeanUtil.copyToList(deviceMap.get(adminName), DeviceInfoDto.MercHomeDeviceVo.class);
- vo.setDeviceNum(deviceInfos.size());
- if (CollUtil.isEmpty(deviceInfos)) {
- continue;
- }
- // 设备销售统计
- List<Long> deviceIds = deviceInfos.stream().map(DeviceInfoDto.MercHomeDeviceVo::getDeviceId).collect(Collectors.toList());
- // 设备状态查询
- List<DeviceStatusDto.Vo> deviceStatusList = deviceStatusService.list(new DeviceStatusDto.SelectList().setDeviceIds(deviceIds)).getData();
- Map<Long, DeviceStatusDto.Vo> datdeviceStatusMap = new HashMap<>();
- if (CollUtil.isNotEmpty(deviceStatusList)) {
- datdeviceStatusMap = deviceStatusList.stream().collect(Collectors.toMap(DeviceStatusDto.Vo::getDeviceId, d -> d));
- }
- List<GoodsDeviceDto.Vo> goodsDeviceList = R.feignCheckData(goodsService.queryGoodsDeviceInfo(new GoodsDto.QueryGoodsDeviceInfo().setMercId(mercId).setDeviceIds(deviceIds)));
- Map<Long, List<GoodsDeviceDto.Vo>> deviceIdGoodsMap = goodsDeviceList.stream()
- .collect(Collectors.groupingBy(GoodsDeviceDto.Vo::getDeviceId));
- List<AlgorithmDto.ListNameId> algorithmList = R.feignCheckData(algorithmService.ListNameId());
- Map<Long, String> algorithmListMap = algorithmList.stream().collect(Collectors.toMap(AlgorithmDto.ListNameId::getId, AlgorithmDto.ListNameId::getAlias));
- for (DeviceInfoDto.MercHomeDeviceVo device : deviceInfos) {
- Long dId = device.getDeviceId();
- // 设备类型 反显
- SysDictRedis dictDeviceType = SysDictUtils.get(DictConsts.DEVICE_TYPE, String.valueOf(device.getDeviceType()));
- device.setDeviceTypeName(dictDeviceType.getMsg());
- // 运营状态 反显
- SysDictRedis dictBusyState = SysDictUtils.get(DictConsts.DEVICE_BUSY_STATUS, String.valueOf(device.getBusyState()));
- device.setBusyStateName(dictBusyState.getMsg());
- Integer zero = new Integer(0);
- CountDto.OrderByCreateTimeAndMercId orderByCreateTimeAndMercId = new CountDto.OrderByCreateTimeAndMercId()
- .setMerdId(mercId).setBeginTime(start).setEndTime(end).setDeviceIds(CollUtil.newArrayList(dId));
- log.info("设备订单统计:{}", JSONUtil.toJsonPrettyStr(orderByCreateTimeAndMercId));
- // 完成订单
- CountDto.SuccessVo successVo = R.feignCheckData(countApiService.orderBySuccess(orderByCreateTimeAndMercId));
- // 今日销售、库存情况 反显
- device.setDayOrderNum(successVo != null ? successVo.getOrdersSize() : zero);
- device.setDaySalesPrice(successVo != null ? successVo.getOrderTotalMoney() : zero);
- DeviceStatusDto.Vo deviceStatus = datdeviceStatusMap.get(device.getDeviceId());
- if (CollUtil.isNotEmpty(deviceIdGoodsMap)) {
- List<GoodsDeviceDto.Vo> goodsDevice = deviceIdGoodsMap.get(dId);
- if (CollUtil.isNotEmpty(goodsDevice)) {
- device.setOnSaleNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum());
- device.setFillNum(goodsDevice.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum());
- }
- }
- // 温控仪 反显
- DeviceSysinfoDto.Vo dSysInfo = deviceSysInfoMap.get(dId);
- if (dSysInfo == null) {
- device.setIsHaveTemp(false);
- } else {
- device.setIsHaveTemp(BooleanUtil.isTrue(dSysInfo.getIsHaveTemp()));
- }
- // 算法類型
- Long algorithmId = device.getAlgorithmId();
- if (algorithmId != null) {
- String name = algorithmListMap.get(algorithmId);
- device.setAlgorithmAlias(name);
- }
- // 联网状态
- Integer netState = deviceStatus == null ? DeviceNetSateType.DISCONNECT.getCode() : deviceStatus.getNetState();
- device.setNetState(netState);
- if (netState == null) {
- device.setNetStateName(StrUtil.EMPTY);
- } else {
- device.setNetStateName(DeviceNetSateType.getEnumByCode(netState).getDescription());
- }
- if (deviceStatus != null) {
- Integer deviceStateL = deviceStatus.getLockStateL();
- Integer deviceStateR = deviceStatus.getLockStateR();
- device.setTempValue(deviceStatus.getTempValue());
- device.setDeviceStateL(deviceStateL);
- device.setDeviceStateR(deviceStateR);
- Boolean isUseBattery = deviceStatus.getIsUseBattery();
- if (BooleanUtil.isTrue(isUseBattery)) {
- // 使用电池。即断电状态
- device.setSysPower(2);
- } else {
- device.setSysPower(1);
- }
- DeviceLockState deviceLockStateL = DeviceLockState.getEnumByCode(deviceStateL);
- DeviceLockState deviceLockStateR = DeviceLockState.getEnumByCode(deviceStateR);
- device.setDeviceStateRName(deviceLockStateR == null ? "未知" : deviceLockStateR.getDescription());
- device.setDeviceStateLName(deviceLockStateL == null ? "未知" : deviceLockStateL.getDescription());
- }
- }
- // 名称排序
- if (CollUtil.isNotEmpty(deviceInfos)) {
- deviceInfos = ListUtil.sortByProperty(deviceInfos, LambdaUtils.getProperty(DeviceInfoDto.MercHomeDeviceVo::getDeviceName));
- deviceInfos = ListUtil.sortByProperty(deviceInfos, LambdaUtils.getProperty(DeviceInfoDto.MercHomeDeviceVo::getDeviceId));
- }
- vo.setDeviceInfos(deviceInfos);
- dataList.add(vo);
- }
- DeviceInfoDto.MercHomeListVO orderTemp = null;
- for (int i = 0; i < dataList.size(); i++) {
- if ("未分配管理员".equals(dataList.get(i).getAdminName())) {
- orderTemp = dataList.get(i);
- dataList.remove(i);
- dataList.add(orderTemp);
- break;
- }
- }
- return R.ok(dataList);
- }
- /**
- * 获取商户设备列表
- *
- * @param mercId
- * @return
- */
- private List<DeviceInfo> getDevicesByMercId(Long mercId) {
- return list(Wrappers.<DeviceInfo>lambdaQuery().eq(DeviceInfo::getMercId, mercId).eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode()));
- }
- @Override
- @ApiOperation("通用商户设备搜索组件")
- public R<PageBean<DeviceInfoDto.SimpleDeviceSearchPageVo>> simpleDeviceSearchPage(@RequestBody DeviceInfoDto.SimpleDeviceSearchPageDto dto) {
- LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<DeviceInfo>()
- .select(DeviceInfo::getDeviceId, DeviceInfo::getDeviceName)
- .and(Emptys.check(dto.getSearchKey()), wrapper -> {
- wrapper.like(DeviceInfo::getDeviceId, dto.getSearchKey())
- .or()
- .like(DeviceInfo::getDeviceName, dto.getSearchKey());
- })
- .in(Emptys.check(dto.getMyDeviceIds()), DeviceInfo::getDeviceId, dto.getMyDeviceIds())
- .eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode())
- .eq(Emptys.check(dto.getMercId()), DeviceInfo::getMercId, dto.getMercId());
- IPage page = page(toIPage(dto.getPage()), lqw);
- PageBean<DeviceInfoDto.SimpleDeviceSearchPageVo> simpleDeviceSearchPageVoPageBean = toPageBean(DeviceInfoDto.SimpleDeviceSearchPageVo.class, page);
- return R.ok(simpleDeviceSearchPageVoPageBean);
- }
- /**
- * 小程序商户设备搜索
- *
- * @param page
- * @return
- */
- @Override
- public R<PageBean<DeviceInfoDto.MerHomeSearchVO>> mercDeviceSearchPage(@RequestBody DeviceInfoDto.Page page) {
- PageBean<DeviceInfoDto.MerHomeSearchVO> pageData = new PageBean<>();
- // 小程序独有查询字段 缺货状态:stockStatus ,是否查故障设备:fault
- Boolean fault = page.getFault();
- Long mercId = page.getMercId();
- List<Long> myDeviceIds = page.getMyDeviceIds();
- if (CollUtil.isEmpty(myDeviceIds)) {
- // 无设备
- return R.ok(pageData);
- }
- if (BooleanUtil.isTrue(fault)) {
- // 查询故障设备
- List<DeviceEventMsg> deviceEventMsgs = deviceEventMsgService.list(Wrappers.<DeviceEventMsg>lambdaQuery()
- .eq(mercId != null, DeviceEventMsg::getMercId, page.getMercId())
- .in(DeviceEventMsg::getDeviceId, myDeviceIds));
- List<Long> deviceIdList = deviceEventMsgs.stream().map(DeviceEventMsg::getDeviceId).collect(Collectors.toList());
- if (CollUtil.isEmpty(deviceIdList)) {
- return R.ok(new PageBean<>());
- }
- page.setDeviceIdList(deviceIdList);
- } else {
- page.setDeviceIdList(myDeviceIds);
- }
- PageBean<DeviceInfoDto.Vo2> pageBean = queryPage(page);
- List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
- if (CollUtil.isEmpty(records)) {
- return R.ok(pageData);
- }
- List<DeviceInfoDto.MerHomeSearchVO> merHomeSearchRecords = new ArrayList<>();
- BeanUtil.copyProperties(pageBean, pageData);
- if (CollUtil.isNotEmpty(records)) {
- List<Long> deviceIds = records.stream().map(DeviceInfoDto.Vo2::getDeviceId).collect(Collectors.toList());
- String type = EnumDeviceDataType.DAY.getCode();
- String todayDate = DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN);
- // 查询当天
- DeviceDataDto.ListDTO dto = new DeviceDataDto.ListDTO()
- .setDeviceIds(deviceIds).setType(type).setDateValue(Integer.valueOf(todayDate)).setMercId(mercId);
- List<DeviceDataDto.Vo> deviceDataList = deviceDataService.list(dto);
- Map<Long, DeviceDataDto.Vo> dataMap = MapUtil.newHashMap();
- // 统计数据反显
- if (CollUtil.isNotEmpty(deviceDataList)) {
- dataMap = deviceDataList.stream().collect(Collectors.toMap(DeviceDataDto.Vo::getDeviceId, d -> d));
- }
- for (DeviceInfoDto.Vo2 v : records) {
- DeviceInfoDto.MerHomeSearchVO merHomeSearchVO = new DeviceInfoDto.MerHomeSearchVO();
- Long deviceId = v.getDeviceId();
- DeviceDataDto.Vo vo = dataMap.get(deviceId);
- if (vo != null) {
- // 今日订单数
- v.setDayOrderNum(vo != null ? vo.getSalesCount() : 0);
- v.setDaySalesPrice(vo != null ? vo.getSalesMoney() : 0);
- BeanUtil.copyProperties(vo, merHomeSearchVO);
- }
- DeviceSysinfoDto.Vo deviceSysinfo = v.getDeviceSysinfo();
- DeviceStatusDto.Vo deviceStatus = v.getDeviceStatus();
- merHomeSearchVO.setAppUpmVersion(deviceSysinfo.getAppUpmVersion());
- merHomeSearchVO.setTempValue(deviceStatus.getTempValue());
- merHomeSearchVO.setNetDbm(deviceStatus.getNetDbm());
- Integer deviceStateL = deviceStatus.getLockStateL();
- Integer deviceStateR = deviceStatus.getLockStateR();
- merHomeSearchVO.setDeviceStateL(deviceStateL);
- merHomeSearchVO.setDeviceStateR(deviceStateR);
- DeviceLockState deviceLockStateL = DeviceLockState.getEnumByCode(deviceStateL);
- DeviceLockState deviceLockStateR = DeviceLockState.getEnumByCode(deviceStateR);
- merHomeSearchVO.setDeviceStateRName(deviceLockStateR == null ? "未知" : deviceLockStateR.getDescription());
- merHomeSearchVO.setDeviceStateLName(deviceLockStateL == null ? "未知" : deviceLockStateL.getDescription());
- merHomeSearchRecords.add(merHomeSearchVO);
- }
- pageData.setRecords(merHomeSearchRecords);
- }
- return R.ok(pageData);
- }
- /**
- * 小程序商户设备详情-数据统计
- *
- * @param dto
- * @return
- */
- @Override
- @ApiOperation("商户设备详情-数据统计")
- public R<DeviceInfoDto.DeviceDataCountVO> dataCount(DeviceInfoDto.DeviceDataCountDTO dto) {
- // 统计类型(1=经营数据,2=经营图表,3=温度图表,4=信号图表,5=商品管理)
- Integer type = dto.getType();
- switch (type) {
- case 1:
- // 经营数据
- return R.ok(dataCount1(dto));
- case 2:
- // 经营图表
- return R.ok(dataCount2(dto));
- case 3:
- // 温度图表
- return R.ok(dataCount3(dto));
- case 4:
- // 信号图表
- return R.ok(dataCount4(dto));
- case 5:
- // 商品管理
- return R.ok(dataCount5(dto));
- default:
- break;
- }
- return R.ok();
- }
- /**
- * 经营数据
- *
- * @param dto
- * @return
- */
- private DeviceInfoDto.DeviceDataCountVO dataCount1(DeviceInfoDto.DeviceDataCountDTO dto) {
- Long deviceId = dto.getDeviceId();
- Long mercId = dto.getMercId();
- DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
- // 当天
- DateTime date = DateTime.now();
- DateTime start = DateUtil.beginOfDay(date);
- DateTime end = DateUtil.endOfDay(date);
- List<Long> deviceIds = CollUtil.newArrayList(deviceId);
- CountDto.OrderByCreateTimeAndMercId orderByCreateTimeAndMercId = new CountDto.OrderByCreateTimeAndMercId()
- .setMerdId(mercId).setBeginTime(start).setEndTime(end).setDeviceIds(deviceIds);
- // 完成订单
- CountDto.SuccessVo successVo = R.feignCheckData(countApiService.orderBySuccess(orderByCreateTimeAndMercId));
- DeviceDataDto.Vo dayData = new DeviceDataDto.Vo();
- if (successVo != null) {
- dayData.setSalesMoney(successVo.getOrderTotalMoney());
- dayData.setRefundMoney(successVo.getRefundMoney());
- dayData.setSalesCount(successVo.getOrdersSize());
- }
- // 当月
- DeviceDataDto.Vo monthData = new DeviceDataDto.Vo();
- // 月度统计
- DateTime startM = DateUtil.beginOfMonth(date);
- DateTime endM = DateUtil.endOfMonth(date);
- CountDto.OrderByCreateTimeAndMercId monthOrder = new CountDto.OrderByCreateTimeAndMercId()
- .setMerdId(mercId).setBeginTime(startM).setEndTime(endM).setDeviceIds(deviceIds);
- // 完成订单
- CountDto.SuccessVo successVoM = R.feignCheckData(countApiService.orderBySuccess(monthOrder));
- if (monthData != null) {
- monthData.setRefundMoney(successVoM.getRefundMoney());
- monthData.setSalesMoney(successVoM.getOrderTotalMoney());
- monthData.setSalesCount(successVoM.getOrdersSize());
- }
- vo.setDayBusinessData(copy(DeviceInfoDto.BusinessData.class, dayData));
- vo.setMonthBusinessData(copy(DeviceInfoDto.BusinessData.class, monthData));
- return vo;
- }
- /**
- * 经营图表
- *
- * @param dto
- * @return
- */
- private DeviceInfoDto.DeviceDataCountVO dataCount2(DeviceInfoDto.DeviceDataCountDTO dto) {
- Long deviceId = dto.getDeviceId();
- // 近一个月 (销售额,订单数,退款金额,退款数)
- DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
- DeviceInfoDto.BusinessChart businessChart = new DeviceInfoDto.BusinessChart();
- List<String> categories = DataTime.dayListByLastDay(30);
- List<Integer> dateList = new ArrayList<>(30);
- businessChart.setCategories(categories);
- categories.forEach(d -> {
- dateList.add(Integer.valueOf(d.replaceAll(StrUtil.DASHED, StrUtil.EMPTY)));
- });
- Integer startDay = dateList.get(0);
- Integer endDay = dateList.get(categories.size() - 1);
- List<DeviceDataDto.Vo> listByDay = deviceDataService.getListByDay(deviceId, startDay, endDay);
- if (CollUtil.isEmpty(listByDay)) {
- return vo;
- }
- // 每天的数据
- Map<Integer, DeviceDataDto.Vo> dataDayMap = listByDay.stream().collect(Collectors.toMap(DeviceDataDto.Vo::getDateValue, i -> i));
- List<DeviceInfoDto.MyChartSeries3> series = new ArrayList<>();
- String[] names = {"销售额", "订单数", "退款金额", "退款数"};
- for (int i = 0; i < names.length; i++) {
- DeviceInfoDto.MyChartSeries3 myChartSeries = new DeviceInfoDto.MyChartSeries3();
- // 某个类型每天的数据
- List<String> data = new ArrayList<>();
- if (i == 0) {
- // 销售额
- dateList.forEach(d -> {
- // 每日数据填充
- DeviceDataDto.Vo deviceData = dataDayMap.get(d);
- if (deviceData == null) {
- data.add(String.valueOf(BigDecimal.ZERO));
- } else {
- Integer salesMoney = deviceData.getSalesMoney() == null ? 0 : deviceData.getSalesMoney();
- BigDecimal day = BigDecimal.valueOf(salesMoney).divide(BigDecimal.valueOf(100));
- data.add(String.valueOf(day));
- }
- });
- } else if (i == 1) {
- // 订单数
- dateList.forEach(d -> {
- // 每日数据填充
- DeviceDataDto.Vo deviceData = dataDayMap.get(d);
- String value = "0";
- if (deviceData == null) {
- data.add(value);
- } else {
- data.add(deviceData == null ? value : String.valueOf(deviceData.getSalesCount()));
- }
- });
- } else if (i == 2) {
- // 退款金额
- dateList.forEach(d -> {
- // 每日数据填充
- DeviceDataDto.Vo deviceData = dataDayMap.get(d);
- if (deviceData == null) {
- data.add(String.valueOf(BigDecimal.ZERO));
- } else {
- Integer refundMoney = deviceData.getRefundMoney() == null ? 0 : deviceData.getRefundMoney();
- BigDecimal day = BigDecimal.valueOf(refundMoney).divide(BigDecimal.valueOf(100));
- data.add(String.valueOf(day));
- }
- });
- } else if (i == 3) {
- // 退款数
- dateList.forEach(d -> {
- // 每日数据填充
- DeviceDataDto.Vo deviceData = dataDayMap.get(d);
- if (deviceData == null) {
- data.add("0");
- } else {
- data.add(deviceData == null ? "0" : String.valueOf(deviceData.getRefundCount()));
- }
- });
- }
- myChartSeries.setName(names[i]);
- myChartSeries.setData(data);
- series.add(myChartSeries);
- }
- businessChart.setSeries(series);
- vo.setBusinessChart(businessChart);
- return vo;
- }
- /**
- * 温度图表
- *
- * @param dto
- * @return
- */
- private DeviceInfoDto.DeviceDataCountVO dataCount3(DeviceInfoDto.DeviceDataCountDTO dto) {
- DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
- Long deviceId = dto.getDeviceId();
- String choosDate = dto.getChoosDate();
- if (StrUtil.isEmpty(choosDate)) {
- choosDate = DateUtil.formatDate(new Date());
- }
- String startTime = choosDate + " 00:00:00";
- String endTime = choosDate + " 23:59:59";
- // 查询选定日期的温度数据
- List<DeviceTempRecords> deviceTempRecords = deviceTempRecordsService.list(Wrappers.<DeviceTempRecords>lambdaQuery()
- .eq(DeviceTempRecords::getDeviceId, deviceId).between(DeviceTempRecords::getCreateTime, startTime, endTime)
- .orderBy(true, true, DeviceTempRecords::getCreateTime));
- if (CollUtil.isEmpty(deviceTempRecords)) {
- return vo;
- }
- DeviceInfoDto.TemperatureChart temperatureChart = new DeviceInfoDto.TemperatureChart();
- List<String> categories = new ArrayList<>();
- String name = "温度";
- List<DeviceInfoDto.MyChartSeries2> series = new ArrayList<>();
- List<BigDecimal> data = new ArrayList<>();
- deviceTempRecords.forEach(d -> {
- Integer tempValue = d.getTempValue();
- LocalDateTime createTime = d.getCreateTime();
- String time = DateUtil.format(createTime, "HH:mm:ss");
- categories.add(time);
- data.add(tempValue == null ? null : NumberUtil.toBigDecimal(tempValue));
- });
- DeviceInfoDto.MyChartSeries2 myChartSeries = new DeviceInfoDto.MyChartSeries2();
- myChartSeries.setName(name);
- myChartSeries.setData(data);
- series.add(myChartSeries);
- temperatureChart.setSeries(series);
- temperatureChart.setCategories(categories);
- vo.setTemperatureChart(temperatureChart);
- return vo;
- }
- /**
- * 信号图表
- *
- * @param dto
- * @return
- */
- private DeviceInfoDto.DeviceDataCountVO dataCount4(DeviceInfoDto.DeviceDataCountDTO dto) {
- DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
- Long deviceId = dto.getDeviceId();
- String choosDate = dto.getChoosDate();
- if (StrUtil.isEmpty(choosDate)) {
- choosDate = DateUtil.formatDate(new Date());
- }
- String startTime = choosDate + " 00:00:00";
- String endTime = choosDate + " 23:59:59";
- // 查询选定日期的温度数据
- List<DeviceNetRecord> deviceNetRecords = deviceNetRecordService.list(Wrappers.<DeviceNetRecord>lambdaQuery()
- .eq(DeviceNetRecord::getDeviceId, deviceId).between(DeviceNetRecord::getCreateTime, startTime, endTime)
- .orderBy(true, true, DeviceNetRecord::getCreateTime));
- if (CollUtil.isEmpty(deviceNetRecords)) {
- return vo;
- }
- DeviceInfoDto.SignalChart signalChart = new DeviceInfoDto.SignalChart();
- List<String> categories = new ArrayList<>();
- String name = "信号";
- List<DeviceInfoDto.MyChartSeries> series = new ArrayList<>();
- List<Integer> data = new ArrayList<>();
- deviceNetRecords.forEach(d -> {
- Integer value = d.getSimDbm();
- LocalDateTime createTime = d.getCreateTime();
- String time = DateUtil.format(createTime, "HH:mm:ss");
- categories.add(time);
- data.add(value);
- });
- DeviceInfoDto.MyChartSeries myChartSeries = new DeviceInfoDto.MyChartSeries();
- myChartSeries.setName(name);
- myChartSeries.setData(data);
- series.add(myChartSeries);
- signalChart.setSeries(series);
- signalChart.setCategories(categories);
- vo.setSignalChart(signalChart);
- return vo;
- }
- /**
- * 商品管理
- *
- * @param dto
- * @return
- */
- private DeviceInfoDto.DeviceDataCountVO dataCount5(DeviceInfoDto.DeviceDataCountDTO dto) {
- Long deviceId = dto.getDeviceId();
- DeviceInfoDto.DeviceDataCountVO vo = new DeviceInfoDto.DeviceDataCountVO();
- DeviceInfoDto.GoodsData goodsData = new DeviceInfoDto.GoodsData();
- // 在售商品种类
- // 根据设备ID查商品id
- GoodsDeviceDto.SelectList selectList = new GoodsDeviceDto.SelectList();
- selectList.setDeviceIds(CollUtil.newArrayList(deviceId));
- selectList.setMercId(dto.getMercId());
- R<List<GoodsDeviceDto.Vo>> r = R.feignCheck(goodsDeviceService.list(selectList));
- List<GoodsDeviceDto.Vo> goodsDeviceList = r.getData();
- Integer stock = 0;
- Integer afterFillStock = 0;
- if (CollUtil.isNotEmpty(goodsDeviceList)) {
- stock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getStock).sum();
- afterFillStock = goodsDeviceList.stream().mapToInt(GoodsDeviceDto.Vo::getFillCount).sum();
- }
- goodsData.setAfterFillStock(afterFillStock);
- goodsData.setStock(stock);
- goodsData.setCategoryNum(CollUtil.isNotEmpty(goodsDeviceList) ? goodsDeviceList.size() : new Integer(0));
- vo.setGoodsData(goodsData);
- return vo;
- }
- public PageBean<DeviceInfoDto.Vo2> queryPage(DeviceInfoDto.Page page) {
- IPage<DeviceInfoQueryPage> iPage = baseMapper.queryPage(toIPage(page.getPage()), page);
- PageBean<DeviceInfoDto.Vo2> pageBean = toPageBean(DeviceInfoDto.Vo2.class, iPage);
- List<DeviceInfoDto.Vo2> records = pageBean.getRecords();
- JMap<Long, List<DevicePart>> cover;
- if (Emptys.check(records)) {
- List<DevicePart> deviceParts = devicePartService.list(new LambdaQueryWrapper<DevicePart>()
- .in(DevicePart::getDeviceId, new JArrayList<>(records).getProperty(DeviceInfoDto.Vo2::getDeviceId))
- .orderByDesc(DevicePart::getCode)
- );
- if (Emptys.check(deviceParts)) {
- cover = new JArrayList<>(deviceParts).toMap(DevicePart::getDeviceId).group();
- records.forEach(vo2 -> {
- List<DevicePart> devicePartss = cover.get(vo2.getDeviceId());
- if (Emptys.check(devicePartss)) {
- vo2.setDeviceParts(copy(DevicePartDto.Vo.class, deviceParts));
- }
- });
- }
- }
- return pageBean;
- }
- private <T> void check(T value, T value2, String msg) {
- if (value.toString().equals(value2.toString())) {
- throw new CommRuntimeException(msg);
- }
- }
- }
|