From 4f4df0f6637c1e377ac2980c89a99a83dd691871 Mon Sep 17 00:00:00 2001 From: huangzj <826100833@qq.com> Date: Fri, 22 Sep 2023 14:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/param/CsStatisticalSetAddParam.java | 18 +++ .../CsStatisticalSetController.java | 13 +-- .../service/CsStatisticalSetPOService.java | 3 +- .../impl/CsStatisticalSetPOServiceImpl.java | 110 ++++++++++++------ .../njcn/user/pojo/param/AppInfoSetParam.java | 6 + .../com/njcn/user/pojo/po/app/AppInfoSet.java | 6 + .../user/service/impl/AppRoleServiceImpl.java | 16 ++- .../user/service/impl/AppUserServiceImpl.java | 2 + 8 files changed, 129 insertions(+), 45 deletions(-) create mode 100644 pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/CsStatisticalSetAddParam.java diff --git a/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/CsStatisticalSetAddParam.java b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/CsStatisticalSetAddParam.java new file mode 100644 index 000000000..435d108d0 --- /dev/null +++ b/pqs-system/system-api/src/main/java/com/njcn/system/pojo/param/CsStatisticalSetAddParam.java @@ -0,0 +1,18 @@ +package com.njcn.system.pojo.param; + +import lombok.Data; + +import java.util.List; + +/** + * Description: + * Date: 2023/9/19 16:18【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Data +public class CsStatisticalSetAddParam { + private String id ; + private List ids; +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/CsStatisticalSetController.java b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/CsStatisticalSetController.java index aff9ca25c..b078e2773 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/controller/CsStatisticalSetController.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/controller/CsStatisticalSetController.java @@ -8,6 +8,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; +import com.njcn.system.pojo.param.CsStatisticalSetAddParam; import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.vo.CsStatisticalSetVO; @@ -48,14 +49,10 @@ public class CsStatisticalSetController extends BaseController { @PostMapping("/addStatistical") @OperateInfo(info = LogEnum.BUSINESS_COMMON) @ApiOperation("绑定指标") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "统计类型id", required = true), - @ApiImplicitParam(name = "ids", value = "统计指标id集合", required = true) - }) - public HttpResult addStatistical(@RequestParam("id")String id,@RequestParam("ids")List ids){ + public HttpResult addStatistical(@RequestBody List csStatisticalSetAddParams){ log.info("根据模板录入字典数据"); String methodDescribe = getMethodDescribe("addstatistical"); - Boolean result = csStatisticalSetPOService.saveData(id,ids); + Boolean result = csStatisticalSetPOService.saveData(csStatisticalSetAddParams); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } @@ -71,7 +68,7 @@ public class CsStatisticalSetController extends BaseController { @PostMapping("/queryStatisticalSelect") @OperateInfo(info = LogEnum.BUSINESS_COMMON) - @ApiOperation("根据统计类型id查询已绑定指标下拉框") + @ApiOperation("根据统计类型id组查询已绑定指标") public HttpResult> queryStatisticalSelect(@RequestParam("id")String id){ log.info("根据模板录入字典数据"); String methodDescribe = getMethodDescribe("EleEpdPqd"); @@ -82,5 +79,7 @@ public class CsStatisticalSetController extends BaseController { + + } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/CsStatisticalSetPOService.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/CsStatisticalSetPOService.java index 6335b7bc3..9ad371e50 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/CsStatisticalSetPOService.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/CsStatisticalSetPOService.java @@ -1,6 +1,7 @@ package com.njcn.system.service; import com.github.jeffreyning.mybatisplus.service.IMppService; +import com.njcn.system.pojo.param.CsStatisticalSetAddParam; import com.njcn.system.pojo.po.CsStatisticalSetPO; import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.system.pojo.po.EleEpdPqd; @@ -19,7 +20,7 @@ import java.util.List; public interface CsStatisticalSetPOService extends IMppService { - Boolean saveData(String id, List ids); + Boolean saveData(List csStatisticalSetAddParams); CsStatisticalSetVO queryStatistical(String id); diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/CsStatisticalSetPOServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/CsStatisticalSetPOServiceImpl.java index 32493255f..f45b7d7a5 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/CsStatisticalSetPOServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/CsStatisticalSetPOServiceImpl.java @@ -3,11 +3,16 @@ package com.njcn.system.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; -import com.njcn.system.pojo.po.EleEpdPqd; +import com.njcn.system.pojo.param.CsStatisticalSetAddParam; +import com.njcn.system.pojo.po.*; import com.njcn.system.pojo.vo.CsStatisticalSetVO; +import com.njcn.system.pojo.vo.DictTreeVO; import com.njcn.system.pojo.vo.EleEpdPqdListVO; +import com.njcn.system.service.IDicService; import com.njcn.system.service.IEleEpdPqdService; +import com.njcn.system.service.SysDicTreePOService; import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.*; @@ -16,9 +21,9 @@ import java.util.stream.Stream; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.system.mapper.CsStatisticalSetPOMapper; -import com.njcn.system.pojo.po.CsStatisticalSetPO; import com.njcn.system.service.CsStatisticalSetPOService; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; /** * @@ -33,55 +38,90 @@ import org.springframework.transaction.annotation.Transactional; public class CsStatisticalSetPOServiceImpl extends MppServiceImpl implements CsStatisticalSetPOService{ private final IEleEpdPqdService epdPqdService; + private final IDicService dicService; + private final SysDicTreePOService sysDicTreePOService; @Override @Transactional(rollbackFor = {Exception.class}) - public Boolean saveData(String id, List ids) { - List csStatisticalSetPOList = new ArrayList<>(); - QueryWrapper queryWrap = new QueryWrapper<>(); - queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, id); - this.getBaseMapper().delete(queryWrap); - ids.forEach(tempId -> { - CsStatisticalSetPO csStatisticalSetPO = new CsStatisticalSetPO(); - csStatisticalSetPO.setStatisicalId(id); - csStatisticalSetPO.setTargetId(tempId); - csStatisticalSetPOList.add(csStatisticalSetPO); + public Boolean saveData(List csStatisticalSetAddParams) { + csStatisticalSetAddParams.forEach(temp->{ + List csStatisticalSetPOList = new ArrayList<>(); + QueryWrapper queryWrap = new QueryWrapper<>(); + queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, temp.getId()); + this.getBaseMapper().delete(queryWrap); + temp.getIds().forEach(tempId -> { + CsStatisticalSetPO csStatisticalSetPO = new CsStatisticalSetPO(); + csStatisticalSetPO.setStatisicalId(temp.getId()); + csStatisticalSetPO.setTargetId(tempId); + csStatisticalSetPOList.add(csStatisticalSetPO); + }); + boolean b = this.saveBatch(csStatisticalSetPOList); }); - boolean b = this.saveBatch(csStatisticalSetPOList); - return b; + + return true; } @Override public CsStatisticalSetVO queryStatistical(String id) { CsStatisticalSetVO csStatisticalSetVO = new CsStatisticalSetVO(); - QueryWrapper queryWrap = new QueryWrapper<>(); - queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, id); - List result = this.baseMapper.selectList(queryWrap); - List collect = result.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList()); + List allList = epdPqdService.selectAll(); List selectedList = new ArrayList<>(); List unSelectedList = new ArrayList<>(); + List dictTreeVOS = sysDicTreePOService.queryByPid(id); +// SysDicTreePO sysDicTreePO = sysDicTreePOService.queryById(id); +// DictTreeVO dictTreeVO = new DictTreeVO(); +// BeanUtils.copyProperties(sysDicTreePO,dictTreeVO); +// dictTreeVOS.add(dictTreeVO); + List collect; + if(!CollectionUtils.isEmpty(dictTreeVOS)){ + List collect3 = dictTreeVOS.stream().map(DictTreeVO::getId).collect(Collectors.toList()); + collect3.add(id); + QueryWrapper queryWrap = new QueryWrapper<>(); + queryWrap.lambda().in(CsStatisticalSetPO::getStatisicalId, collect3); + List result = this.baseMapper.selectList(queryWrap); + collect = result.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList()); + Map> collect1 = result.stream().collect(Collectors.groupingBy(CsStatisticalSetPO::getStatisicalId)); + dictTreeVOS.forEach(temp->{ + EleEpdPqdListVO vo = new EleEpdPqdListVO(); + vo.setDataType(temp.getId()); + List collect2 = result.stream().filter(csStatisticalSetPO -> Objects.equals(csStatisticalSetPO.getStatisicalId(), temp.getId())).collect(Collectors.toList()); + List eleEpdPqds = new ArrayList<>(); + if(!CollectionUtil.isEmpty(collect2)){ + List collect4 = collect2.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList()); + eleEpdPqds = epdPqdService.getBaseMapper().selectBatchIds(collect4); + } - for (EleEpdPqdListVO temp :allList){ - EleEpdPqdListVO selected = new EleEpdPqdListVO(); - EleEpdPqdListVO unSelected = new EleEpdPqdListVO(); - List all = temp.getEleEpdPqdVOS(); - List selectedELe = all.stream().filter(tempEleEpdPqd -> collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList()); - List unSelectedELe = all.stream().filter(tempEleEpdPqd -> !collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList()); + vo.setEleEpdPqdVOS(eleEpdPqds); + vo.setDataTypeName(temp.getName()); + selectedList.add(vo); + }); + } else { + collect = new ArrayList<>(); + } - selected.setDataTypeName(temp.getDataTypeName()); - selected.setDataType(temp.getDataTypeName()); - selected.setEleEpdPqdVOS(selectedELe); - unSelected.setDataTypeName(temp.getDataTypeName()); - unSelected.setDataType(temp.getDataTypeName()); - unSelected.setEleEpdPqdVOS(unSelectedELe); - selectedList.add(selected); - unSelectedList.add(unSelected); - } - csStatisticalSetVO.setUnSelectedList(unSelectedList); - csStatisticalSetVO.setSelectedList(selectedList); + + for (EleEpdPqdListVO temp :allList){ +// EleEpdPqdListVO selected = new EleEpdPqdListVO(); + EleEpdPqdListVO unSelected = new EleEpdPqdListVO(); + List all = temp.getEleEpdPqdVOS(); + +// List selectedELe = all.stream().filter(tempEleEpdPqd -> collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList()); + List unSelectedELe = all.stream().filter(tempEleEpdPqd -> !collect.contains(tempEleEpdPqd.getId())).collect(Collectors.toList()); + +// selected.setDataTypeName(temp.getDataTypeName()); +// selected.setDataType(temp.getDataTypeName()); +// selected.setEleEpdPqdVOS(selectedELe); + unSelected.setDataTypeName(temp.getDataTypeName()); + unSelected.setDataType(temp.getDataType()); + unSelected.setEleEpdPqdVOS(unSelectedELe); +// selectedList.add(selected); + unSelectedList.add(unSelected); + } + csStatisticalSetVO.setUnSelectedList(unSelectedList); + csStatisticalSetVO.setSelectedList(selectedList); diff --git a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/AppInfoSetParam.java b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/AppInfoSetParam.java index 891350b62..86e22d5f0 100644 --- a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/AppInfoSetParam.java +++ b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/param/AppInfoSetParam.java @@ -26,6 +26,12 @@ public class AppInfoSetParam { @ApiModelProperty(value = "设备告警") private Integer alarmInfo; + @ApiModelProperty("是否开启出厂调试0:false ;1:true") + private Integer exFactoryBug; + + @ApiModelProperty("是否开启功能调试0:false ;1:true") + private Integer functionBug; + @Data @EqualsAndHashCode(callSuper = true) public static class AppInfoSetUpdateParam extends AppInfoSetParam { diff --git a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/app/AppInfoSet.java b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/app/AppInfoSet.java index e6adf59d8..26b0e9fe0 100644 --- a/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/app/AppInfoSet.java +++ b/pqs-user/user-api/src/main/java/com/njcn/user/pojo/po/app/AppInfoSet.java @@ -50,5 +50,11 @@ public class AppInfoSet { @ApiModelProperty("设备告警") private Integer alarmInfo; + @ApiModelProperty("是否开启出厂调试0:false ;1:true") + private Integer exFactoryBug; + + @ApiModelProperty("是否开启功能调试0:false ;1:true") + private Integer functionBug; + } diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppRoleServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppRoleServiceImpl.java index 90d0ae30a..159e8f817 100644 --- a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppRoleServiceImpl.java +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppRoleServiceImpl.java @@ -5,8 +5,12 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.utils.PubUtils; import com.njcn.redis.pojo.enums.RedisKeyEnum; import com.njcn.redis.utils.RedisUtil; +import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.enums.UserResponseEnum; +import com.njcn.user.pojo.po.Role; import com.njcn.user.pojo.po.UserRole; +import com.njcn.user.pojo.po.app.AppInfoSet; +import com.njcn.user.service.IAppInfoSetService; import com.njcn.user.service.IAppRoleService; import com.njcn.user.service.IRoleService; import com.njcn.user.service.IUserRoleService; @@ -33,7 +37,7 @@ public class AppRoleServiceImpl implements IAppRoleService { private final RedisUtil redisUtil; private final IRoleService roleService; - + private final IAppInfoSetService iAppInfoSetService; private final IUserRoleService userRoleService; @Override @@ -47,10 +51,18 @@ public class AppRoleServiceImpl implements IAppRoleService { if (Objects.isNull(map.get(referralCode))){ throw new BusinessException(UserResponseEnum.REFERRAL_CODE_ERROR); } + Role roleByCode = roleService.getRoleByCode(map.get(referralCode)); //修改用户和角色的关系 LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); - lambdaUpdateWrapper.eq(UserRole::getUserId,userId).set(UserRole::getRoleId,roleService.getRoleByCode(map.get(referralCode)).getId()); + lambdaUpdateWrapper.eq(UserRole::getUserId,userId).set(UserRole::getRoleId,roleByCode.getId()); userRoleService.update(lambdaUpdateWrapper); + if(Objects.equals(roleByCode.getCode(), AppRoleEnum.ENGINEERING_USER)){ + iAppInfoSetService.lambdaUpdate(). + eq(AppInfoSet::getUserId,userId). + set(AppInfoSet::getExFactoryBug,1). + set(AppInfoSet::getFunctionBug,1). + update(); + } //重新生成新的推荐码 // LinkedHashMap roleMap = new LinkedHashMap<>(); // for (Map.Entry entry : map.entrySet()) { diff --git a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppUserServiceImpl.java b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppUserServiceImpl.java index 449d1d50c..b9fe70eaf 100644 --- a/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppUserServiceImpl.java +++ b/pqs-user/user-boot/src/main/java/com/njcn/user/service/impl/AppUserServiceImpl.java @@ -142,6 +142,8 @@ public class AppUserServiceImpl extends ServiceImpl impleme appInfoSet.setEventInfo(1); appInfoSet.setRunInfo(1); appInfoSet.setAlarmInfo(1); + appInfoSet.setFunctionBug(0); + appInfoSet.setExFactoryBug(0); appInfoSetService.save(appInfoSet); //发送用户初始密码 try {