lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/controller/ProductInfoController.java
@@ -1,21 +1,24 @@
package org.jeecg.modules.dnc.controller;
import cn.hutool.core.util.StrUtil;
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.entity.DocInfo;
import org.jeecg.modules.dnc.entity.ProductInfo;
import org.jeecg.modules.dnc.request.TreeInfoRequest;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.CommonGenericTree;
import org.jeecg.modules.dnc.response.QueryListResponseResult;
import org.jeecg.modules.dnc.response.ResponseResult;
import org.jeecg.modules.dnc.service.IProductInfoService;
import org.jeecg.modules.dnc.ucenter.Department;
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.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -59,7 +62,7 @@
    public QueryListResponseResult<CommonGenericTree> loadProductTree() {
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!StrUtil.isEmpty(userId))
        if(!ValidateUtil.validateString(userId))
            return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
        List<CommonGenericTree> list = productInfoService.loadProductTree(userId);
        if(list == null)
@@ -73,7 +76,7 @@
    public QueryListResponseResult<CommonGenericTree> loadBaseTree() {
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!StrUtil.isEmpty(userId))
        if(!ValidateUtil.validateString(userId))
            return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
        List<CommonGenericTree> list = productInfoService.loadBaseTree(userId);
        if(list == null)
@@ -87,7 +90,7 @@
    public QueryListResponseResult<CommonGenericTree> loadTree(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId) {
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!StrUtil.isEmpty(userId))
        if(!ValidateUtil.validateString(userId))
            return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
        List<CommonGenericTree> list = productInfoService.loadTree(userId, nodeType, paramId);
        if(list == null)
@@ -141,8 +144,8 @@
    @AutoLog(value = "产品表-获取已分配的部门")
    @ApiOperation(value = "产品表-获取已分配的部门", notes = "产品表-获取已分配的部门")
    @GetMapping("/get/perm/depart/{nodeType}/{paramId}")
    public QueryListResponseResult<Department> getDepartPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId")  String paramId) {
        List<Department> list = productInfoService.getDepartPermsList(nodeType, paramId);
    public QueryListResponseResult<MdcProduction> getDepartPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId")  String paramId) {
        List<MdcProduction> list = productInfoService.getDepartPermsList(nodeType, paramId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, list);
@@ -151,8 +154,8 @@
    @AutoLog(value = "产品表-获取未分配的部门")
    @ApiOperation(value = "产品表-获取未分配的部门", notes = "产品表-获取未分配的部门")
    @GetMapping("/get/non/perm/depart/{nodeType}/{paramId}")
    public QueryListResponseResult<Department> getDepartNonPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId")  String paramId) {
        List<Department> list = productInfoService.getDepartNonPermsList(nodeType, paramId);
    public QueryListResponseResult<MdcProduction> getDepartNonPermsList(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId")  String paramId) {
        List<MdcProduction> list = productInfoService.getDepartNonPermsList(nodeType, paramId);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult(CommonCode.SUCCESS, list);
@@ -170,7 +173,7 @@
    @ApiOperation(value = "产品表-指派产品树节点的用户权限", notes = "产品表-指派产品树节点的用户权限")
    @PostMapping("/assign/add/user/{nodeType}/{paramId}/{relativeFlag}")
    public ResponseResult assignAddUser(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) {
        boolean b = productInfoService.assignAddUser(nodeType, paramId, relativeFlag, userIds);
        boolean b = productInfoService.assignAddUserAll(nodeType, paramId, relativeFlag, userIds);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
@@ -189,7 +192,7 @@
    @ApiOperation(value = "产品表-移除产品树节点的用户权限", notes = "产品表-移除产品树节点的用户权限")
    @PostMapping("/assign/remove/user/{nodeType}/{paramId}/{relativeFlag}")
    public ResponseResult assignRemoveUser(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] userIds) {
        boolean b = productInfoService.assignRemoveUser(nodeType, paramId, relativeFlag, userIds);
        boolean b = productInfoService.assignRemoveUserAll(nodeType, paramId, relativeFlag, userIds);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
@@ -208,7 +211,7 @@
    @ApiOperation(value = "产品表-指派产品树节点的部门权限", notes = "产品表-指派产品树节点的部门权限")
    @PostMapping("/assign/add/department/{nodeType}/{paramId}/{relativeFlag}")
    public ResponseResult assignAddDepartment(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) {
        boolean b = productInfoService.assignAddDepartment(nodeType, paramId, relativeFlag, departmentIds);
        boolean b = productInfoService.assignAddDepartmentAll(nodeType, paramId, relativeFlag, departmentIds);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
@@ -227,7 +230,7 @@
    @ApiOperation(value = "产品表-移除产品树节点的部门权限", notes = "产品表-移除产品树节点的部门权限")
    @PostMapping("/assign/remove/department/{nodeType}/{paramId}/{relativeFlag}")
    public ResponseResult assignRemoveDepartment(@PathVariable("nodeType") Integer nodeType, @PathVariable("paramId") String paramId, @PathVariable("relativeFlag") Integer relativeFlag, @RequestBody String[] departmentIds) {
        boolean b = productInfoService.assignRemoveDepartment(nodeType, paramId, relativeFlag, departmentIds);
        boolean b = productInfoService.assignRemoveDepartmentAll(nodeType, paramId, relativeFlag, departmentIds);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
@@ -245,11 +248,59 @@
    public QueryListResponseResult<CommonGenericTree> searchProductTree(String queryParam) {
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        if(!StrUtil.isEmpty(userId))
        if(!ValidateUtil.validateString(userId))
            return new QueryListResponseResult<>(CommonCode.SUCCESS, Collections.emptyList());
        List<CommonGenericTree> list = productInfoService.searchProductTree(userId,  queryParam);
        if(list == null)
            list = Collections.emptyList();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
    }
    /**
     * 产品结构树-通过类型就行删除
     * @param id
     * @param type
     * @return
     */
    @AutoLog(value = "产品结构树-通过类型就行删除")
    @ApiOperation(value = "产品结构树-通过类型就行删除", notes = "产品结构树-通过类型就行删除")
    @DeleteMapping("/delete/{id}/{type}")
    public Result<?> deleteProductTreeByType(@PathVariable("id") String id, @PathVariable("type") Integer type) {
        boolean b =productInfoService.deleteProductTree(id, type);
        if (b){
            return Result.ok("删除成功!");
        }
        return Result.error("删除失败!");
    }
    /**
     * 通过零件号、材质等查询对应电子样板
     * @param treeInfoRequest
     * @return
     */
    @AutoLog(value = "零件信息表-通过零件号、材质等查询对应电子样板")
    @ApiOperation(value = "零件信息表-通过零件号、材质等查询对应电子样板", notes = "零件信息表-通过零件号、材质等查询对应电子样板")
    @GetMapping("/query")
    public Result<?> queryPartsInfo(TreeInfoRequest treeInfoRequest) {
        List<DocInfo> list = productInfoService.getByTreeOtherFileInfo(treeInfoRequest);
        if (list == null)
            list = Collections.emptyList();
        return Result.ok(list);
    }
    /**
     * 通过代号、名称、材质等查询对应NC文件
     * @param treeInfoRequest
     * @return
     */
    @AutoLog(value = "零件信息表-通过代号、名称、材质等查询对应NC文件")
    @ApiOperation(value = "零件信息表-通过代号、名称、材质等查询对应NC文件", notes = "零件信息表-通过代号、名称、材质等查询对应NC文件")
    @GetMapping("/query/nc")
    public Result<?> queryOtherFileInfo(TreeInfoRequest treeInfoRequest) {
        List<DocInfo> list = productInfoService.getByTreeNcFileInfo(treeInfoRequest);
        if (list == null)
            list = Collections.emptyList();
        return Result.ok(list);
    }
}