已重命名1个文件
已添加1个文件
已修改17个文件
已删除3个文件
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.dnc.response.*; |
| | | import org.jeecg.modules.dnc.service.IDevicePermissionService; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.dnc.entity.DeviceInfo; |
| | | import org.jeecg.modules.dnc.service.IDeviceInfoService; |
| | |
| | | public class DeviceInfoController extends JeecgController<DeviceInfo, IDeviceInfoService> { |
| | | @Autowired |
| | | private IDeviceInfoService deviceInfoService; |
| | | @Autowired |
| | | private IDevicePermissionService devicePermissionService; |
| | | |
| | | @AutoLog(value = "设å¤è¡¨-æ°å¢è®¾å¤") |
| | | @ApiOperation(value = "设å¤è¡¨-æ°å¢è®¾å¤", notes = "设å¤è¡¨-æ°å¢è®¾å¤") |
| | |
| | | @AutoLog(value = "设å¤è¡¨-è·åèç¹å·²åé
çç¨æ·") |
| | | @ApiOperation(value = "设å¤è¡¨-è·åèç¹å·²åé
çç¨æ·", notes = "设å¤è¡¨-è·åèç¹å·²åé
çç¨æ·") |
| | | @GetMapping("/get/perm/user/{nodeType}/{paramId}") |
| | | public QueryListResponseResult<UserDepartExt> getUserPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) { |
| | | List<UserDepartExt> list = deviceInfoService.getUserPermsList(nodeType, paramId); |
| | | public QueryListResponseResult<SysUser> getUserPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) { |
| | | List<SysUser> list = deviceInfoService.getUserPermsList(nodeType, paramId); |
| | | if(list == null) |
| | | list = Collections.emptyList(); |
| | | return new QueryListResponseResult(CommonCode.SUCCESS, list); |
| | |
| | | } |
| | | return new ResponseResult(CommonCode.SUCCESS); |
| | | } |
| | | |
| | | /** |
| | | * å è½½äº§çº¿è®¾å¤æ |
| | | */ |
| | | @AutoLog(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") |
| | | @ApiOperation(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ", notes = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") |
| | | @GetMapping(value = "/queryTreeListByProduction") |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = devicePermissionService.DncLoadTreeListByProduction(userId); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | | return Result.error("å è½½äº§çº¿è®¾å¤æ 失败ï¼" + e.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | |
| | | * @param paramId |
| | | * @return |
| | | */ |
| | | List<UserDepartExt> getUserPermsList(Integer nodeType, String paramId); |
| | | List<SysUser> getUserPermsList(Integer nodeType, String paramId); |
| | | /** |
| | | * è·åèç¹æªåé
çç¨æ· |
| | | * @param nodeType |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.dnc.entity.DevicePermission; |
| | | import org.jeecg.modules.dnc.ucenter.UserDepartExt; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | |
| | | import java.util.List; |
| | |
| | | * @return |
| | | */ |
| | | List<DevicePermission> getByDeviceId(String deviceId); |
| | | |
| | | |
| | | /** |
| | | * å è½½äº§çº¿è®¾å¤æ |
| | | */ |
| | | List<MdcEquipmentTree> DncLoadTreeListByProduction(String userId); |
| | | } |
| | |
| | | import org.jeecg.modules.dnc.ucenter.UserDepartExt; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.MdcUserProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.dnc.service.IDeviceGroupPermissionService; |
| | | import org.jeecg.modules.system.service.IMdcUserProductionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | @Lazy |
| | | private IDevicePermissionStreamService devicePermissionStreamService; |
| | | @Autowired |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | |
| | | @Override |
| | | public List<UserDepartExt> getUserPermsByGroupId(String groupId) { |
| | |
| | | public boolean assignAddUser(MdcProduction mdcProduction, Collection<SysUser> userList) { |
| | | if(mdcProduction == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<DeviceGroupPermission> permissionList = new ArrayList<>(); |
| | | List<MdcUserProduction> mdcUserProductions=new ArrayList<>(); |
| | | List<DevicePermissionStream> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | DeviceGroupPermission en = groupPermissionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); |
| | | MdcUserProduction en = mdcUserProductionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); |
| | | if(en == null) { |
| | | en = new DeviceGroupPermission(); |
| | | en.setUserId(item.getId()); |
| | | en.setGroupId(mdcProduction.getId()); |
| | | permissionList.add(en); |
| | | en = new MdcUserProduction(item.getId(),mdcProduction.getId()); |
| | | mdcUserProductions.add(en); |
| | | } |
| | | DevicePermissionStream stream = devicePermissionStreamService.getByGroupIdAndUserId(mdcProduction.getId(), item.getId()); |
| | | if(stream == null) { |
| | |
| | | permissionStreamList.add(stream); |
| | | } |
| | | }); |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = groupPermissionService.saveBatch(permissionList); |
| | | if(!mdcUserProductions.isEmpty()) { |
| | | boolean b = mdcUserProductionService.saveBatch(mdcUserProductions); |
| | | if(!b) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | |
| | | public boolean assignRemoveUser(MdcProduction mdcProduction, Collection<SysUser> userList) { |
| | | if(mdcProduction == null || userList == null || userList.isEmpty()) |
| | | ExceptionCast.cast(CommonCode.INVALID_PARAM); |
| | | List<DeviceGroupPermission> permissionList = new ArrayList<>(); |
| | | List<MdcUserProduction> mdcUserProductions=new ArrayList<>(); |
| | | List<DevicePermissionStream> permissionStreamList = new ArrayList<>(); |
| | | userList.forEach(item -> { |
| | | DeviceGroupPermission en = groupPermissionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); |
| | | MdcUserProduction en = mdcUserProductionService.getByUserIdAndGroupId(item.getId(), mdcProduction.getId()); |
| | | if(en != null) { |
| | | permissionList.add(en); |
| | | mdcUserProductions.add(en); |
| | | } |
| | | DevicePermissionStream stream = devicePermissionStreamService.getByGroupIdAndUserId(mdcProduction.getId(), item.getId()); |
| | | if(stream != null) { |
| | |
| | | } |
| | | }); |
| | | //æ ¡éªæ¸
空设å¤åç»æéæä½ |
| | | List<DeviceGroupPermission> existList = groupPermissionService.getByGroupId(mdcProduction.getId()); |
| | | if(existList.size() <= permissionList.size()) |
| | | List<MdcUserProduction> existList = mdcUserProductionService.list(new QueryWrapper<MdcUserProduction>().eq("pro_id",mdcProduction.getId())); |
| | | if(existList.size() <= mdcUserProductions.size()) |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_USER_NONE); |
| | | if(!permissionList.isEmpty()) { |
| | | boolean b = groupPermissionService.removeByCollection(permissionList); |
| | | if(!mdcUserProductions.isEmpty()) { |
| | | boolean b = mdcUserProductionService.removeByCollection(mdcUserProductions); |
| | | if(!b) { |
| | | ExceptionCast.cast(DeviceGroupCode.DEVICE_GROUP_PERM_ERROR); |
| | | } |
| | |
| | | import org.jeecg.modules.system.entity.MdcProductionEquipment; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.IMdcUserProductionService; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.jeecg.modules.dnc.response.DeviceCode; |
| | | import org.jeecg.modules.dnc.response.DeviceGroupCode; |
| | |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | @Autowired |
| | | private IMdcProductionEquipmentService mdcProductionEquipmentService; |
| | | |
| | | @Autowired |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean addDeviceInfo(DeviceInfo deviceInfo) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<UserDepartExt> getUserPermsList(Integer nodeType, String paramId) { |
| | | public List<SysUser> getUserPermsList(Integer nodeType, String paramId) { |
| | | if(!ValidateUtil.validateInteger(nodeType) || !ValidateUtil.validateString(paramId)) |
| | | return null; |
| | | if(nodeType == 1) { |
| | | return deviceGroupPermissionService.getUserPermsByGroupId(paramId); |
| | | return mdcUserProductionService.getUserPermsByGroupId(paramId); |
| | | }else if(nodeType == 2) { |
| | | return devicePermissionService.getUserPermsByDeviceId(paramId); |
| | | return mdcUserProductionService.getUserPermsByDeviceId(paramId); |
| | | }else { |
| | | return null; |
| | | } |
| | |
| | | if(!ValidateUtil.validateInteger(nodeType) || !ValidateUtil.validateString(paramId)) |
| | | return null; |
| | | if(nodeType == 1) { |
| | | return deviceGroupPermissionService.getUserNonPermsByGroupId(paramId); |
| | | return mdcUserProductionService.getUserNonPermsByGroupId(paramId); |
| | | }else if(nodeType == 2) { |
| | | return devicePermissionService.getUserNonPermsByDeviceId(paramId); |
| | | return mdcUserProductionService.getUserNonPermsByDeviceId(paramId); |
| | | }else { |
| | | return null; |
| | | } |
| | |
| | | package org.jeecg.modules.dnc.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.dnc.entity.DevicePermission; |
| | | import org.jeecg.modules.dnc.mapper.DevicePermissionMapper; |
| | | import org.jeecg.modules.dnc.ucenter.UserDepartExt; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | | import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.dnc.service.IDevicePermissionService; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.IMdcUserProductionService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class DevicePermissionServiceImpl extends ServiceImpl<DevicePermissionMapper, DevicePermission> implements IDevicePermissionService { |
| | | @Resource |
| | | private IMdcProductionService mdcProductionService; |
| | | @Resource |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | @Resource |
| | | private MdcEquipmentMapper mdcEquipmentMapper; |
| | | |
| | | @Override |
| | | public DevicePermission getByUserIdAndDeviceId(String userId, String deviceId) { |
| | | if(!ValidateUtil.validateString(userId) || !ValidateUtil.validateString(deviceId)) |
| | |
| | | list = Collections.emptyList(); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å è½½äº§çº¿è®¾å¤æ |
| | | */ |
| | | @Override |
| | | public List<MdcEquipmentTree> DncLoadTreeListByProduction(String userId){ |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå |
| | | List<String> productionIds = mdcUserProductionService.queryProductionIdsByUserId(userId); |
| | | List<String> allProductionIds = new ArrayList<>(); |
| | | //æ¾å°ææäº§çº¿idçä¸çº§id |
| | | if (productionIds != null && !productionIds.isEmpty()) { |
| | | for (String productionId : productionIds) { |
| | | this.getAllProductionIds(productionList, productionId, allProductionIds); |
| | | } |
| | | } |
| | | //è¿æ»¤äº§çº¿æ°æ® |
| | | List<MdcProduction> list = productionList.stream().filter((MdcProduction mdcProduction) -> allProductionIds.contains(mdcProduction.getId())).collect(Collectors.toList()); |
| | | //ç»è£
äº§çº¿è®¾å¤æ |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //å¡«å
è®¾å¤æ°æ® |
| | | FillEquipmentByProduction(treeList,userId); |
| | | return treeList; |
| | | } |
| | | |
| | | /** |
| | | * è·åææç产线idï¼å
嫿æä¸çº§ï¼ |
| | | */ |
| | | private void getAllProductionIds(List<MdcProduction> productionList, String productionId, List<String> allProductionIds) { |
| | | if (!allProductionIds.contains(productionId)) { |
| | | allProductionIds.add(productionId); |
| | | } |
| | | for (MdcProduction mdcProduction : productionList) { |
| | | if (StringUtils.isEmpty(mdcProduction.getParentId())) { |
| | | continue; |
| | | } |
| | | if (productionId.equals(mdcProduction.getId())) { |
| | | if (!allProductionIds.contains(mdcProduction.getParentId())) { |
| | | allProductionIds.add(mdcProduction.getParentId()); |
| | | getAllProductionIds(productionList, mdcProduction.getParentId(), allProductionIds); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * äº§çº¿è®¾å¤æ å¡«å
è®¾å¤æ°æ® |
| | | */ |
| | | private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList,String userId) { |
| | | //è·åå·²åé
æéè®¾å¤æ°æ® |
| | | List<String> deviceIds=super.list(new QueryWrapper<DevicePermission>().eq("user_id",userId)).stream().map(DevicePermission::getDeviceId).collect(Collectors.toList()); |
| | | if (!deviceIds.isEmpty()){ |
| | | for (MdcEquipmentTree mdcEquipmentTree : treeList) { |
| | | List<MdcEquipment> equipmentList = mdcEquipmentMapper.queryByProductionIdAndType(mdcEquipmentTree.getKey(),deviceIds); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); |
| | | tree.setParentId(mdcEquipmentTree.getKey()); |
| | | tree.setEntity(mdcEquipment); |
| | | tree.setType(2); |
| | | mdcEquipmentTree.getChildren().add(tree); |
| | | } |
| | | mdcEquipmentTree.setLeaf(false); |
| | | } |
| | | if (!mdcEquipmentTree.getChildren().isEmpty()) { |
| | | FillEquipmentByProduction(mdcEquipmentTree.getChildren(),userId); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | @AutoLog(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") |
| | | @ApiOperation(value = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ", notes = "设å¤è¡¨-å è½½äº§çº¿è®¾å¤æ ") |
| | | @GetMapping(value = "/queryTreeListByProduction") |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByProduction(String type) { |
| | | public Result<List<MdcEquipmentTree>> queryTreeListByProduction() { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId,type); |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProduction(userId); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | |
| | | @AutoLog(value = "设å¤è¡¨-éè¿è½¦é´idsè·åè®¾å¤æ ") |
| | | @ApiOperation(value = "设å¤è¡¨-éè¿è½¦é´idsè·åè®¾å¤æ ", notes = "设å¤è¡¨-éè¿è½¦é´idsè·åè®¾å¤æ ") |
| | | @GetMapping(value = "/loadTreeListByProductionIds") |
| | | public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids,@RequestParam(name = "type", required = true)String type) { |
| | | public Result<?> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { |
| | | Result<List<MdcEquipmentTree>> result = new Result<>(); |
| | | try { |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids,type); |
| | | List<MdcEquipmentTree> mdcEquipmentTreeList = mdcEquipmentService.loadTreeListByProductionIds(ids); |
| | | result.setSuccess(true); |
| | | result.setResult(mdcEquipmentTreeList); |
| | | } catch (Exception e) { |
| | |
| | | /** |
| | | * æ ¹æ®äº§çº¿idæ¥è¯¢è®¾å¤ |
| | | */ |
| | | List<MdcEquipment> queryByProductionId(@Param("productionId") String productionId,@Param("type")String type); |
| | | List<MdcEquipment> queryByProductionId(@Param("productionId") String productionId); |
| | | |
| | | /** |
| | | * æ ¹æ®äº§çº¿idãtypeãå·²åé
æéæ°æ® æ¥è¯¢è®¾å¤ |
| | | */ |
| | | List<MdcEquipment> queryByProductionIdAndType(@Param("productionId") String productionId, @Param("deviceIds") List<String> deviceIds); |
| | | |
| | | /** |
| | | * æ¥æ¾è®¾å¤çæ§ä¿¡æ¯ |
| | |
| | | WHERE |
| | | mpe.equipment_id = me.id |
| | | AND mpe.production_id = #{ productionId } |
| | | <if test="type == 'DNC'"> |
| | | AND me.device_type_dnc = '1' |
| | | </if> |
| | | <if test="type == 'MDC'"> |
| | | AND me.device_type_mdc = '1' |
| | | </if> |
| | | ORDER BY me.equipment_id |
| | | </select> |
| | | |
| | |
| | | WHERE |
| | | t1.id = #{ id } |
| | | </select> |
| | | <select id="queryByProductionIdAndType" resultType="org.jeecg.modules.mdc.entity.MdcEquipment"> |
| | | SELECT |
| | | me.* |
| | | FROM |
| | | mdc_production_equipment mpe, |
| | | mdc_equipment me |
| | | WHERE |
| | | mpe.equipment_id = me.id |
| | | AND mpe.production_id = #{ productionId } |
| | | AND me.device_type_dnc = '1' |
| | | <if test="deviceIds != null and deviceIds.size() > 0"> |
| | | AND me.id IN |
| | | <foreach collection = "deviceIds" item = "id" index = "index" open = "(" close= ")" separator = ","> |
| | | #{id} |
| | | </foreach> |
| | | </if> |
| | | ORDER BY me.equipment_id |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | /** |
| | | * å è½½äº§çº¿è®¾å¤æ |
| | | */ |
| | | List<MdcEquipmentTree> loadTreeListByProduction(String userId,String type); |
| | | List<MdcEquipmentTree> loadTreeListByProduction(String userId); |
| | | |
| | | /** |
| | | * 设å¤çæ§å表 |
| | |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | List<MdcEquipmentTree> loadTreeListByProductionIds(String ids,String type); |
| | | List<MdcEquipmentTree> loadTreeListByProductionIds(String ids); |
| | | |
| | | /** |
| | | * æ¥è¯¢åè¡¨æ°æ® |
| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDetailedDto; |
| | | import org.jeecg.modules.mdc.dto.MdcEquipmentDto; |
| | | import org.jeecg.modules.mdc.entity.*; |
| | | import org.jeecg.modules.mdc.mapper.DncDevicePermissionMapper; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; |
| | | import org.jeecg.modules.mdc.mapper.MdcTorqueConfigMapper; |
| | | import org.jeecg.modules.mdc.model.MdcEquipmentTree; |
| | |
| | | import org.jeecg.modules.mdc.util.FindsEquipmentProductionUtil; |
| | | import org.jeecg.modules.mdc.vo.*; |
| | | import org.jeecg.modules.system.entity.*; |
| | | import org.jeecg.modules.system.mapper.DncDevicePermissionMapper; |
| | | import org.jeecg.modules.system.mapper.MdcEquipmentDepartMapper; |
| | | import org.jeecg.modules.system.mapper.MdcProductionEquipmentMapper; |
| | | import org.jeecg.modules.system.service.*; |
| | |
| | | mdcProductionEquipmentMapper.insert(productionEquipment); |
| | | } |
| | | } |
| | | //step.4 ä¿®æ¹è®¾å¤æé |
| | | //å
å åå |
| | | dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getDeviceId, mdcEquipment.getId())); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | dncDevicePermission.setDeviceId(mdcEquipment.getId()); |
| | | dncDevicePermission.setUserId(userId); |
| | | dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | } |
| | | |
| | | @Override |
| | |
| | | line += mdcEquipmentDepartMapper.delete(new LambdaQueryWrapper<MdcEquipmentDepart>().eq(MdcEquipmentDepart::getEquipmentId, id)); |
| | | // 3. å é¤è®¾å¤äº§çº¿å
³ç³» |
| | | line += mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getEquipmentId, id)); |
| | | |
| | | // 4. å é¤è®¾å¤æé |
| | | line += dncDevicePermissionMapper.delete(new LambdaQueryWrapper<DncDevicePermission>().eq(DncDevicePermission::getDeviceId, id)); |
| | | return line != 0; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void removeEquipmentForProduction(String productionId, String equipmentId) { |
| | | mdcProductionEquipmentMapper.delete(new LambdaQueryWrapper<MdcProductionEquipment>().eq(MdcProductionEquipment::getProductionId, productionId).eq(MdcProductionEquipment::getEquipmentId, equipmentId)); |
| | | //ç§»é¤è®¾å¤æé |
| | | dncDevicePermissionMapper.delete(new LambdaQueryWrapper<DncDevicePermission>().eq(DncDevicePermission::getDeviceId, equipmentId)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<MdcEquipmentTree> loadTreeListByProduction(String userId,String type) { |
| | | public List<MdcEquipmentTree> loadTreeListByProduction(String userId) { |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | | //æ ¹æ®ç¨æ·idè·åæ¥æç产线信æ¯éå |
| | |
| | | //ç»è£
äº§çº¿è®¾å¤æ |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //å¡«å
è®¾å¤æ°æ® |
| | | FillEquipmentByProduction(treeList,type); |
| | | FillEquipmentByProduction(treeList); |
| | | return treeList; |
| | | } |
| | | |
| | |
| | | /** |
| | | * äº§çº¿è®¾å¤æ å¡«å
è®¾å¤æ°æ® |
| | | */ |
| | | private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList,String type) { |
| | | private void FillEquipmentByProduction(List<MdcEquipmentTree> treeList) { |
| | | for (MdcEquipmentTree mdcEquipmentTree : treeList) { |
| | | List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey(),type); |
| | | List<MdcEquipment> equipmentList = this.baseMapper.queryByProductionId(mdcEquipmentTree.getKey()); |
| | | if (equipmentList != null && !equipmentList.isEmpty()) { |
| | | for (MdcEquipment mdcEquipment : equipmentList) { |
| | | MdcEquipmentTree tree = new MdcEquipmentTree().convert(mdcEquipment); |
| | |
| | | mdcEquipmentTree.setLeaf(false); |
| | | } |
| | | if (!mdcEquipmentTree.getChildren().isEmpty()) { |
| | | FillEquipmentByProduction(mdcEquipmentTree.getChildren(),type); |
| | | FillEquipmentByProduction(mdcEquipmentTree.getChildren()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids,String type) { |
| | | public List<MdcEquipmentTree> loadTreeListByProductionIds(String ids) { |
| | | List<String> productionIds = Arrays.asList(ids.split(",")); |
| | | //è·åææäº§çº¿æ°æ® |
| | | List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().eq(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_0.toString()).orderByAsc(MdcProduction::getProductionOrder)); |
| | |
| | | //ç»è£
äº§çº¿è®¾å¤æ |
| | | List<MdcEquipmentTree> treeList = FindsEquipmentProductionUtil.wrapEquipmentProductionTreeList(list); |
| | | //å¡«å
è®¾å¤æ°æ® |
| | | FillEquipmentByProduction(treeList,type); |
| | | FillEquipmentByProduction(treeList); |
| | | return treeList; |
| | | } |
| | | |
ÎļþÃû´Ó lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/entity/DncDevicePermission.java ÐÞ¸Ä |
| | |
| | | package org.jeecg.modules.mdc.entity; |
| | | package org.jeecg.modules.system.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.jeecg.modules.system.entity.DncDevicePermission; |
| | | |
| | | /** |
| | | * @author: Lyh |
| | | * @description: è½¦é´æéMapperæ¥å£ |
| | | * @create: 2023-04-07 11:17 |
| | | */ |
| | | public interface DncDevicePermissionMapper extends BaseMapper<DncDevicePermission> { |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.system.entity.MdcUserProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿idéå |
| | | */ |
| | | List<String> queryProductionIdsByUserId(@Param("userId") String userId); |
| | | |
| | | /** |
| | | * è·åå·²åé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserPermsByGroupId(@Param("proId") String proId); |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserNonPermsByGroupId(@Param("proId") String proId); |
| | | |
| | | /** |
| | | * è·åè®¾å¤æªåé
çç¨æ· |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserNonPermsByDeviceId(String proId); |
| | | |
| | | |
| | | /** |
| | | * è·å设å¤å·²åé
çç¨æ· |
| | | * @param deviceId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserPermsByDeviceId(String deviceId); |
| | | } |
| | |
| | | <select id="queryProductionIdsByUserId" resultType="java.lang.String"> |
| | | SELECT pro_id FROM mdc_user_production WHERE user_id = #{userId} |
| | | </select> |
| | | </mapper> |
| | | <select id="getUserPermsByGroupId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select u.id |
| | | , u.username |
| | | , u.realname |
| | | , u.avatar |
| | | , u.phone |
| | | , u.email |
| | | from sys_user u |
| | | inner join |
| | | (select user_id from mdc_user_production where pro_id=#{proId}) p |
| | | on u.id=p.user_id |
| | | </select> |
| | | <select id="getUserNonPermsByGroupId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select u.id |
| | | , u.username |
| | | , u.realname |
| | | , u.avatar |
| | | , u.phone |
| | | , u.email |
| | | from sys_user u |
| | | where u.id not in (select user_id from mdc_user_production where pro_id=#{proId}) |
| | | </select> |
| | | <select id="getUserNonPermsByDeviceId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select u.id |
| | | , u.username |
| | | , u.realname |
| | | , u.avatar |
| | | , u.phone |
| | | , u.email |
| | | from sys_user u |
| | | where u.id not in (select user_id from nc_device_permission where device_id=#{deviceId}) |
| | | </select> |
| | | <select id="getUserPermsByDeviceId" resultType="org.jeecg.modules.system.entity.SysUser"> |
| | | select u.id |
| | | , u.username |
| | | , u.realname |
| | | , u.avatar |
| | | , u.phone |
| | | , u.email |
| | | from sys_user u |
| | | inner join |
| | | (select user_id from nc_device_permission where device_id=#{deviceId}) p |
| | | on u.id=p.user_id |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.jeecg.modules.system.entity.MdcUserProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.model.ProductionIdModel; |
| | | |
| | | import java.util.List; |
| | |
| | | * æ ¹æ®æå®ç¨æ·idæ¥è¯¢äº§çº¿idéå |
| | | */ |
| | | List<String> queryProductionIdsByUserId(String userId); |
| | | |
| | | /** |
| | | * å é¤ä¸ç»å¯¹è±¡ |
| | | * @param mdcUserProductions |
| | | * @return |
| | | */ |
| | | boolean removeByCollection(List<MdcUserProduction> mdcUserProductions); |
| | | |
| | | /** |
| | | * è·åå·²åé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserPermsByGroupId(String proId); |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserNonPermsByGroupId(String proId); |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ· |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserNonPermsByDeviceId(String proId); |
| | | |
| | | /** |
| | | * è·åå·²åé
çç¨æ· |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | List<SysUser> getUserPermsByDeviceId(String proId); |
| | | |
| | | |
| | | MdcUserProduction getByUserIdAndGroupId(String userId, String proId); |
| | | } |
| | |
| | | @Resource |
| | | private MdcProductionEquipmentMapper productionEquipmentMapper; |
| | | |
| | | @Resource |
| | | private DncDeviceGroupPermissionMapper dncDeviceGroupPermissionMapper; |
| | | /** |
| | | * queryTreeList å¯¹åº queryTreeList æ¥è¯¢ææçäº§çº¿æ°æ®,以æ ç»æå½¢å¼ååºç»å端 |
| | | */ |
| | |
| | | mdcProduction.setOrgType(String.valueOf(orgType)); |
| | | mdcProduction.setDelFlag(CommonConstant.DEL_FLAG_0.toString()); |
| | | this.save(mdcProduction); |
| | | //æ°å¢DNCè½¦é´æé |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String userId = user.getId(); |
| | | DncDeviceGroupPermission dncDeviceGroupPermission=new DncDeviceGroupPermission(); |
| | | dncDeviceGroupPermission.setGroupPermId(mdcProduction.getId()); |
| | | dncDeviceGroupPermission.setUserId(userId); |
| | | dncDeviceGroupPermissionMapper.insert(dncDeviceGroupPermission); |
| | | } |
| | | } |
| | | |
| | |
| | | package org.jeecg.modules.system.service.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.entity.MdcUserProduction; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.mapper.MdcUserProductionMapper; |
| | | import org.jeecg.modules.system.model.ProductionIdModel; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.jeecg.modules.system.service.IMdcUserProductionService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | |
| | | public List<String> queryProductionIdsByUserId(String userId) { |
| | | return this.baseMapper.queryProductionIdsByUserId(userId); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public boolean removeByCollection(List<MdcUserProduction> mdcUserProductions) { |
| | | if(mdcUserProductions == null || mdcUserProductions.isEmpty()) |
| | | return false; |
| | | if(mdcUserProductions.size() == 1){ |
| | | return super.removeById(mdcUserProductions.get(0).getId()); |
| | | } |
| | | List<String> ids = new ArrayList<>(); |
| | | mdcUserProductions.forEach(item -> { |
| | | ids.add(item.getId()); |
| | | }); |
| | | return super.removeByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * è·åå·²åé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> getUserPermsByGroupId(String proId){ |
| | | return super.getBaseMapper().getUserPermsByGroupId(proId); |
| | | } |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ·å表 |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> getUserNonPermsByGroupId(String proId){ |
| | | return super.getBaseMapper().getUserNonPermsByGroupId(proId); |
| | | } |
| | | |
| | | /** |
| | | * è·åæªåé
çç¨æ· |
| | | * @param proId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<SysUser> getUserNonPermsByDeviceId(String proId){ |
| | | return super.getBaseMapper().getUserNonPermsByDeviceId(proId); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUser> getUserPermsByDeviceId(String proId) { |
| | | return super.getBaseMapper().getUserPermsByDeviceId(proId); |
| | | } |
| | | |
| | | @Override |
| | | public MdcUserProduction getByUserIdAndGroupId(String userId, String proId){ |
| | | if(StrUtil.isNotEmpty(userId) || !StrUtil.isNotEmpty(proId)) |
| | | return null; |
| | | List<MdcUserProduction> list = super.lambdaQuery().eq(MdcUserProduction::getUserId, userId).eq(MdcUserProduction::getProId, proId).list(); |
| | | if(list == null || list.isEmpty()) |
| | | return null; |
| | | return list.get(0); |
| | | } |
| | | } |
| | |
| | | @Service |
| | | @Slf4j |
| | | public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService { |
| | | |
| | | |
| | | @Autowired |
| | | private SysUserMapper userMapper; |
| | | @Autowired |
| | |
| | | MdcUserProductionMapper mdcUserProductionMapper; |
| | | @Resource |
| | | private ISysDictService sysDictService; |
| | | @Resource |
| | | private MdcProductionEquipmentMapper mdcProductionEquipmentMapper; |
| | | @Resource |
| | | private DncDevicePermissionMapper dncDevicePermissionMapper; |
| | | |
| | | @Override |
| | | @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) |
| | |
| | | public SysUser getUserByName(String username) { |
| | | return userMapper.getUserByName(username); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addUserWithRole(SysUser user, String roles) { |
| | |
| | | roleIndex = list.get(0); |
| | | } |
| | | } |
| | | |
| | | |
| | | //妿componentUrl为空ï¼åè¿å空 |
| | | if(oConvertUtils.isEmpty(roleIndex.getComponent())){ |
| | | return null; |
| | |
| | | info.setSysUserName(sysUser.getRealname()); |
| | | info.setSysOrgCode(sysUser.getOrgCode()); |
| | | } |
| | | |
| | | |
| | | //å¤é¨é¨æ¯æinæ¥è¯¢ |
| | | List<SysDepart> list = sysDepartMapper.queryUserDeparts(sysUser.getId()); |
| | | List<String> sysMultiOrgCode = new ArrayList<String>(); |
| | |
| | | } |
| | | } |
| | | info.setSysMultiOrgCode(sysMultiOrgCode); |
| | | |
| | | |
| | | return info; |
| | | } |
| | | |
| | |
| | | sysUserDepartMapper.insert(userDeaprt); |
| | | } |
| | | } |
| | | String[] arr = {}; |
| | | //step.4 ä¿åæå±äº§çº¿ |
| | | if (oConvertUtils.isNotEmpty(selectedProductions)) { |
| | | String[] arr = selectedProductions.split(","); |
| | | arr = selectedProductions.split(","); |
| | | for (String productionId : arr) { |
| | | MdcUserProduction mdcUserProduction = new MdcUserProduction(user.getId(), productionId); |
| | | mdcUserProductionMapper.insert(mdcUserProduction); |
| | | } |
| | | } |
| | | //step.5 ä¿åè®¾å¤æé |
| | | List<String> EquipmentIds= mdcProductionEquipmentMapper.selectList(new QueryWrapper<MdcProductionEquipment>().in("production_id",arr)) |
| | | .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | if (oConvertUtils.isNotEmpty(EquipmentIds)) { |
| | | for (String equipmentId : EquipmentIds) { |
| | | DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | dncDevicePermission.setDeviceId(equipmentId); |
| | | dncDevicePermission.setUserId(user.getId()); |
| | | dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | } |
| | | } |
| | | } |
| | |
| | | mdcUserProductionMapper.insert(mdcUserProduction); |
| | | } |
| | | } |
| | | //step.5 ä¿®æ¹ææºå·åé®ç®± |
| | | //step.5 ä¿®æ¹è®¾å¤æé |
| | | //å
å åå |
| | | dncDevicePermissionMapper.delete(new QueryWrapper<DncDevicePermission>().lambda().eq(DncDevicePermission::getUserId, user.getId())); |
| | | List<String> EquipmentIds= mdcProductionEquipmentMapper.selectList(new QueryWrapper<MdcProductionEquipment>().in("production_id",array)) |
| | | .stream().map(MdcProductionEquipment::getEquipmentId).collect(Collectors.toList()); |
| | | if (oConvertUtils.isNotEmpty(EquipmentIds)) { |
| | | for (String equipmentId : EquipmentIds) { |
| | | DncDevicePermission dncDevicePermission=new DncDevicePermission(); |
| | | dncDevicePermission.setDeviceId(equipmentId); |
| | | dncDevicePermission.setUserId(user.getId()); |
| | | dncDevicePermissionMapper.insert(dncDevicePermission); |
| | | } |
| | | } |
| | | //step.6 ä¿®æ¹ææºå·åé®ç®± |
| | | // æ´æ°ææºå·ãé®ç®±ç©ºå符串为 null |
| | | userMapper.updateNullByEmptyString("email"); |
| | | userMapper.updateNullByEmptyString("phone"); |