guoyujia před 4 dny
rodič
revize
0e2ba648e0

+ 10 - 0
src/main/java/cn/ezhizao/framework/web/domain/TreeSelect.java

@@ -38,6 +38,7 @@ public class TreeSelect implements Serializable {
     private Integer isCentralizedTurnover;
     private Integer isSortPackaging;
     private String deptKey;
+    private Long tenantId;
     /**
      * 子节点
      */
@@ -50,6 +51,7 @@ public class TreeSelect implements Serializable {
 
     public TreeSelect(SysDept dept) {
         this.id = dept.getDeptId();
+        this.tenantId = dept.getTenantId();
         this.label = dept.getDeptName();
         this.deptType = dept.getType();
         this.deptCode = dept.getDeptCode();
@@ -157,4 +159,12 @@ public class TreeSelect implements Serializable {
     public void setDeptKey(String deptKey) {
         this.deptKey = deptKey;
     }
+
+    public Long getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Long tenantId) {
+        this.tenantId = tenantId;
+    }
 }

+ 2 - 2
src/main/java/cn/ezhizao/project/business/supplier/controller/BizSupplierController.java

@@ -69,14 +69,14 @@ public class BizSupplierController extends BaseController {
     @Log(title = "外协工段选择外协商单位", businessType = BusinessType.SELECT)
     @GetMapping("/listByDept")
     public TableDataInfo listByDept(SysDept dept) throws NoSuchFieldException, IllegalAccessException, JsonProcessingException {
-        setTenantId(dept);
         startPage();
         List<BizSupplier> list = iBizSupplierService.getListByDept(dept);
         return getDataTable(list);
     }
     @GetMapping(value = "/getOutsourceDept")
     @Log(title = "查询内部外协工段", businessType = BusinessType.SELECT)
-    public AjaxResult getOutsourceDept(BizSupplier supplier) {
+    public AjaxResult getOutsourceDept(BizSupplier supplier) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(supplier);
         return success(iBizSupplierService.getOutsourceDept(supplier));
     }
 

+ 7 - 5
src/main/java/cn/ezhizao/project/system/controller/SysDeptController.java

@@ -159,9 +159,6 @@ public class SysDeptController extends BaseController
     @Transactional
     public AjaxResult save(@Validated @RequestBody SysDept dept) throws NoSuchFieldException, IllegalAccessException {
 
-        String tenantId = request.getHeader("tenantId");
-        dept.setTenantId(Long.parseLong(tenantId) == 0?1L:Long.valueOf(tenantId));
-
         Long deptId = dept.getDeptId();
         // 判断没有id的进行新增操作
         if(deptId == null){
@@ -197,6 +194,13 @@ public class SysDeptController extends BaseController
             } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
                 return error("该部门包含未停用的子部门!");
             }
+            //判断是否可以改厂别,如果当前工段下没有员工允许改
+            SysDept oldDept = deptService.getDeptByDeptId(deptId);
+            if(oldDept.getTenantId() != dept.getTenantId()){
+                if(deptUserService.query().eq("dept_id",deptId).count()>0){
+                    return error("该部门下存在员工,不允许修改厂别");
+                }
+            }
             dept.setUpdateBy(getUsername());
             return toAjax(deptService.updateDept(dept));
         }
@@ -209,8 +213,6 @@ public class SysDeptController extends BaseController
     @Log(title = "部门管理修改", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@Validated @RequestBody SysDept dept) throws NoSuchFieldException, IllegalAccessException {
-        String tenantId = request.getHeader("tenantId");
-        dept.setTenantId(Long.valueOf(tenantId));
         Long deptId = dept.getDeptId();
         deptService.checkDeptDataScope(deptId);
         if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))

+ 1 - 2
src/main/java/cn/ezhizao/project/system/controller/SysUserController.java

@@ -76,6 +76,7 @@ public class SysUserController extends BaseController {
     @Log(title = "用户查询,包装线添加员工", businessType = BusinessType.SELECT)
     @GetMapping("/notHasAddList")
     public TableDataInfo notHasAddList(SysUser user) throws NoSuchFieldException, IllegalAccessException {
+        setTenantId(user);
 //        String tenantId = request.getHeader("tenantId");
 //        user.setTenantId(Long.valueOf(tenantId));
         startPage();
@@ -370,11 +371,9 @@ public class SysUserController extends BaseController {
     @PostMapping(value = "saveDeptUser")
     @Transactional
     public AjaxResult saveDeptUser(@Validated @RequestBody List<SysDeptUser> deptUserList) {
-        String tenantId = request.getHeader("tenantId");
         List<SysDeptUser> deptUsers = new ArrayList<>();
         for (SysDeptUser deptUser: deptUserList
         ) {
-            deptUser.setTenantId(Long.valueOf(tenantId));
             List<SysDeptUser> list = deptUserService.query().eq("user_id", deptUser.getUserId()).eq("dept_id", deptUser.getDeptId()).eq("tenant_id", deptUser.getTenantId()).eq("deleted", 0).list();
             if (list.size() == 0) {
                 deptUsers.add(deptUser);

+ 1 - 0
src/main/resources/mybatis/business/supplier/BizSupplierMapper.xml

@@ -53,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getOutsourceDept" resultMap="BizSupplierResult">
         select t2.*,t1.dept_id as outsourceDeptId,t1.dept_name as outsourceDeptName from sys_dept t1 left join biz_supplier t2 on t1.supplier_id = t2.id where
         t1.is_outsourcing = 1 and t1.del_flag = 0 and t2.deleted = 0
+        <if test="tenantId != null and tenantId != 0"> AND t1.tenant_id = #{tenantId}</if>
     </select>
 
     <delete id="physicalDelete">

+ 1 - 0
src/main/resources/mybatis/system/SysUserMapper.xml

@@ -396,6 +396,7 @@
 			del_flag = '0' and user_type='02' and user_id !=1 and user_id != 2
 			<if test="userName != null  and userName != ''"> AND user_name like concat('%', #{userName}, '%')</if>
 			<if test="nickName != null  and nickName != ''"> AND nick_name like concat('%', #{nickName}, '%')</if>
+			<if test="tenantId != null  and tenantId != 0"> AND tenant_id = #{tenantId}</if>
         </trim>
     </select>