소스 검색

凌云集团修改二级部门

peiguo 5 년 전
부모
커밋
109184aa4b

+ 15 - 3
whepi-doc/login.sql

@@ -180,8 +180,9 @@ CREATE TABLE sys_uptown_unit  (
 
 DROP TABLE IF EXISTS sys_uptown_house;
 CREATE TABLE sys_uptown_house  (
-  house_id         bigint(20) NOT NULL DEFAULT 0 COMMENT '门牌ID',
-  unit_id          bigint(20) NOT NULL DEFAULT 0 COMMENT '单元ID',
+  house_id          bigint(20) NOT NULL DEFAULT 0 COMMENT '门牌ID',
+  unit_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '单元ID',
+  department_id     bigint(20) NOT NULL DEFAULT 0 COMMENT '二级部门ID',
   doorplate         varchar(20)  NOT NULL DEFAULT '' COMMENT '门牌',
   status            int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
@@ -275,4 +276,15 @@ CREATE TABLE return_work_ly  (
   user_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '人员ID',
   time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
   PRIMARY KEY (rw_id) USING BTREE
-) ENGINE = InnoDB default charset=utf8mb4 comment = '凌云复工人员';
+) ENGINE = InnoDB default charset=utf8mb4 comment = '凌云复工人员';
+
+DROP TABLE IF EXISTS sys_department;
+CREATE TABLE sys_department  (
+  department_id     bigint(20) NOT NULL DEFAULT 0 COMMENT '二级部门ID',
+  unit_id           bigint(20) NOT NULL DEFAULT 0 COMMENT '上级部门(对应的一级部门)',
+  department_name   varchar(20)  NOT NULL DEFAULT '' COMMENT '二级部门名称',
+  status            int(11) NOT NULL DEFAULT 0 COMMENT '状态:1正常,0草稿,-1删除',
+  time_create       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '新增时间',
+  time_update       datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '修改时间',
+  PRIMARY KEY (department_id) USING BTREE
+) ENGINE = InnoDB default charset=utf8mb4 comment = '二级部门表';

+ 77 - 0
whepi-ui/templates/home/home.ftl

@@ -90,6 +90,11 @@
         ribao_add();
         ribao_cancel();
         getUptownUnitLY();
+      $("#newUnitId").on("change", function () {
+        var unitId = $("#newUnitId").val()
+        $("#newDepartmentId").empty();
+        getDepartmentIdLY(unitId);
+      });
 
 
         var msReport = {};
@@ -188,8 +193,79 @@
             }
         });
     }
+    var isAll = false;
+    // 更换二级单位
+    function getDepartmentIdLY(unitId) {
+        $.ajax({
+            type: "GET",
+            url: "/home/getDepartmentIdLY.json?unitId=" + unitId,
+            data: {},
+            dataType: "json",
+            success: function (data) {
+                if (data.length > 0) {
+                   isAll = true;
+                   $("#newDepartmentId").empty();
+                   $('#newDepartmentId').append("<option>请选择</option>");
+                   var html = "";
+                   for (var i = 0; i < data.length; i++) {
+                     html += '<option value="' + data[i].departmentId + '">' + data[i].departmentName + '</option>';
+                   }
+                   $('#newDepartmentId').append(html);
+                   $("#newDepartmentId").val('0');
+                } else {
+                   isAll = false;
+                }
+            }
+        });
+    }
 
     // 凌云更换单位后保存
+    function changeDepartmentId() {
+      console.log(isAll);
+      var unitId = $("#unitId").val();
+      var newUnitId = $("#newUnitId").val();
+      var newUnitText = $("#newUnitId").find("option:selected").text();
+      if (!newUnitId || newUnitId == "请选择") {
+        $.alert("请选择部门")
+        return false;
+      }
+      // if (newUnitId == unitId) {
+      //   $.alert("您选择的部门和原来的部门一样")
+      //   return false;
+      // }
+      var departmentId = $("#departmentId").val();
+      var newDepartmentId = $("#newDepartmentId").val();
+      var newDepartmentText = $("#newDepartmentId").find("option:selected").text();
+      if (isAll) {
+        if (!newDepartmentId || newDepartmentId == "请选择") {
+          $.alert("请选择二级部门")
+          return false;
+        }
+        if (newDepartmentId == departmentId) {
+          $.alert("您选择的二级部门和原来的二级部门一样")
+          return false;
+        }
+      } else {
+        newDepartmentId = 0;
+      }
+      $.ajax({
+        url: '/home/changeUnitId.json',
+        type: "post",
+        data: {
+          userId: $('#userId').val(),
+          newUnitId: newUnitId,
+          newDepartmentId: newDepartmentId,
+        }, success: function (date) {
+          $("#unitId").val(newUnitId);
+          $("#unitMsg").text(newUnitText);
+          $("#departmentId").val(newDepartmentId);
+          $("#departmentMsg").text(newDepartmentText);
+          $.alert("更改成功")
+          return false;
+        }
+      });
+    }
+
     function changeUnitId() {
         var unitId = $("#unitId").val();
         var newUnitId = $("#newUnitId").val();
@@ -208,6 +284,7 @@
             data: {
                 userId: $('#userId').val(),
                 newUnitId: newUnitId,
+                newDepartmentId: 0,
             }, success: function (date) {
                 $("#unitId").val(newUnitId);
                 $("#unitMsg").text(newUnitText);

+ 56 - 0
whepi-ui/templates/home/ribao.ftl

@@ -12,6 +12,11 @@
                 更改部门
             </a>
             </#if>
+            <#if (uptownId??) && (uptownId == 100000002 )>
+                <a class="weui-navbar__item" target="#rb_nav4" module="ri_bao">
+                    更改部门
+                </a>
+            </#if>
         </div>
         <div class="weui-tab__panel">
             <div id="rb_nav1" class="weui-tab__bd-item ri_bao_weui_tab_bd_item_active">
@@ -418,9 +423,60 @@
                     <div class="weui-panel__hd" style=" font-size: large">员工姓名:${linkman!''}</div>
                     <div class="weui-panel__hd" style=" font-size: large">所在部门:<span
                             id="unitMsg">${ridgepole!''}${unit!''}</span></div>
+                    <div class="weui-panel__hd" style=" font-size: large">二级部门:<span
+                                id="departmentMsg">${departmentName!''}</span></div>
                     <div class="weui-panel__hd" style=" font-size: large">员工编号:<span
                             id="doorplateMsg">${doorplate!''}</span></div>
                     <input id="unitId" type="text" hidden="hidden" value="${unitId!''}"/>
+                    <input id="departmentId" type="text" hidden="hidden" value="${departmentId!''}"/>
+                    <input id="uptownId" type="text" hidden="hidden" value="${uptownId!''}"/>
+                    <div class="weui-cell weui-cell_select weui-cell_select-after">
+                        <div class="weui-cell__hd">
+                            <label for="" class="weui-label" id="danweiTitle">更改部门</label>
+                        </div>
+                        <div class="weui-cell__bd">
+                            <select class="weui-select" id="newUnitId">
+                                <option>请选择</option>
+                            </select>
+                        </div>
+                    </div>
+                    <div class="weui-cell weui-cell_select weui-cell_select-after">
+                        <div class="weui-cell__hd">
+                            <label for="" class="weui-label" id="danwei2Title">二级部门</label>
+                        </div>
+                        <div class="weui-cell__bd">
+                            <select class="weui-select" id="newDepartmentId">
+<#--                                <option>请选择</option>-->
+                            </select>
+                        </div>
+                    </div>
+                    <div class="weui-form__opr-area">
+                        <a class="weui-btn weui-btn_primary" href="javascript:;" onclick="changeDepartmentId();">确定部门更改</a>
+                    </div>
+                    <div>
+                        <div class="weui-cells__title" id="menpaiTitle">更改工号</div>
+                        <div class="weui-cells">
+                            <div class="weui-cell">
+                                <div class="weui-cell__bd">
+                                    <input class="weui-input" type="text" id="newDoorplate" placeholder="请输入工号"/>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="weui-form__opr-area">
+                        <a class="weui-btn weui-btn_primary" href="javascript:;" onclick="changeDoorplate();">确定工号更改</a>
+                    </div>
+                </div>
+            </div>
+            <div id="rb_nav4" class="weui-tab__bd-item ">
+                <div class="weui-panel weui-panel_access">
+                    <#--                    <div class="weui-panel__hd" style=" font-size: large">${uptown_name!''}小区</div>-->
+                    <div class="weui-panel__hd" style=" font-size: large">员工姓名:${linkman!''}</div>
+                    <div class="weui-panel__hd" style=" font-size: large">所在部门:<span
+                                id="unitMsg">${ridgepole!''}${unit!''}</span></div>
+                    <div class="weui-panel__hd" style=" font-size: large">员工编号:<span
+                                id="doorplateMsg">${doorplate!''}</span></div>
+                    <input id="unitId" type="text" hidden="hidden" value="${unitId!''}"/>
                     <input id="uptownId" type="text" hidden="hidden" value="${uptownId!''}"/>
                     <div class="weui-cell weui-cell_select weui-cell_select-after">
                         <div class="weui-cell__hd">

+ 18 - 0
whepi-web/src/main/java/com/bofeng/dao/DepartmentMapper.java

@@ -0,0 +1,18 @@
+package com.bofeng.dao;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.Department;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface DepartmentMapper extends BaseMapper<Department> {
+
+//    @Select("select * from sys_department where status = 1 and unit_id = #{unitId}")
+//    List<Department> getDepartmentByUnit(@Param("unitId") Long unitId);
+}

+ 5 - 2
whepi-web/src/main/java/com/bofeng/dao/UptownUnitMapper.java

@@ -1,6 +1,7 @@
 package com.bofeng.dao;
 
 import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.bofeng.entity.Department;
 import com.bofeng.entity.UptownUnit;
 import com.yvan.PageDb;
 import org.apache.ibatis.annotations.Mapper;
@@ -36,14 +37,16 @@ public interface UptownUnitMapper extends BaseMapper<UptownUnit> {
 
     List<UptownUnit> queryYiChangList(@Param("uptownId") Long uptownId, @Param("reportDate") String reportDate);
 
-    @Select("SELECT u.uptown_id,u.uptown_name as uptownName,uu.ridgepole,uu.unit,uu.unit_id,uh.doorplate FROM sys_user_role ur INNER JOIN sys_uptown_house uh " +
+    @Select("SELECT u.uptown_id,u.uptown_name as uptownName,uu.ridgepole,uu.unit,uu.unit_id,uh.doorplate,d.department_name as departmentName,d.department_id as departmentId FROM sys_user_role ur INNER JOIN sys_uptown_house uh " +
             "ON uh.house_id = ur.property_id INNER JOIN sys_uptown_unit uu ON uh.unit_id = uu.unit_id INNER JOIN " +
-            "sys_uptown u ON u.uptown_id = uu.uptown_id WHERE ur.user_id = #{userId} AND ur.role_id = 1")
+            "sys_uptown u ON u.uptown_id = uu.uptown_id left JOIN sys_department d ON d.department_id = uh.department_id WHERE ur.user_id = #{userId} AND ur.role_id = 1")
     UptownUnit getUptownUnitByUser(@Param("userId") Long userId);
 
     @Select("select * from sys_uptown_unit where status = 1 and uptown_id = #{uptownId}")
     List<UptownUnit> getUptownUnitLY(@Param("uptownId") Long uptownId);
 
+    @Select("select * from sys_department where status = 1 and unit_id = #{unitId}")
+    List<Department> getDepartmentByUnit(@Param("unitId") Long unitId);
 
     @Select("select * from(select unit_id,CONCAT(ridgepole,unit) as unit from sys_uptown_unit where status = 1 and uptown_id = 1238790987234) tt where unit like concat('%', #{unit}, '%')")
     List<UptownUnit> getDLYbumen(@Param("unit") String unit);

+ 44 - 0
whepi-web/src/main/java/com/bofeng/entity/Department.java

@@ -0,0 +1,44 @@
+package com.bofeng.entity;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import lombok.Getter;
+import lombok.Setter;
+import org.joda.time.DateTime;
+
+/**
+ * 二级部门表
+ */
+@Getter
+@Setter
+@TableName("sys_department")
+public class Department {
+
+    /**
+     * 主键
+     */
+    @TableId("department_id")
+    private Long departmentId;
+
+    @TableField("unit_id")
+    private Long unitId;
+
+    /**
+     * 二级部门名称
+     */
+    @TableField("department_name")
+    private String departmentName;
+
+    /**
+     * 状态:1正常,0草稿,-1删除
+     */
+    @TableField("status")
+    private Integer status;
+
+    @TableField(exist = false)
+    private DateTime timeCreate;
+
+    @TableField(exist = false)
+    private DateTime timeUpdate;
+}

+ 3 - 0
whepi-web/src/main/java/com/bofeng/entity/SysUptownHouse.java

@@ -30,6 +30,9 @@ public class SysUptownHouse implements Serializable {
     private String unit;
 
     @TableField(exist = false)
+    private Long departmentId;
+
+    @TableField(exist = false)
     private String reportId;
 
     @TableField(exist = false)

+ 3 - 0
whepi-web/src/main/java/com/bofeng/entity/UptownHouse.java

@@ -24,6 +24,9 @@ public class UptownHouse {
     @TableField("doorplate")
     private String doorplate;
 
+    @TableField("department_id")
+    private Long departmentId;
+
     /**
      * 状态:1正常,0草稿,-1删除
      */

+ 4 - 0
whepi-web/src/main/java/com/bofeng/entity/UptownUnit.java

@@ -59,6 +59,10 @@ public class UptownUnit {
     private Date reportDate;
     @TableField(exist = false)
     private Integer doorplateNum;
+    @TableField(exist = false)
+    private Long departmentId;
+    @TableField(exist = false)
+    private String departmentName;
 
     @TableField(exist = false)
     private Integer yiBaoNum;

+ 3 - 1
whepi-web/src/main/java/com/bofeng/service/UserOpenService.java

@@ -74,6 +74,7 @@ public class UserOpenService {
             uptownHouse.setHouseId(IdWorker.getId());
             uptownHouse.setUnitId(unitId);
             uptownHouse.setDoorplate(doorplate);
+            uptownHouse.setDepartmentId(0L);
             uptownHouse.setStatus(1);
             uptownHouseMapper.insert(uptownHouse);
             UptownHome uptownHome = new UptownHome();
@@ -92,9 +93,10 @@ public class UserOpenService {
     }
 
     @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
-    public void changeUnitId(Long userId, Long unitId) {
+    public void changeUnitId(Long userId, Long unitId, Long departmentId) {
         UptownHouse uptownHouse = uptownHouseMapper.getUptownHouseByUser(userId);
         uptownHouse.setUnitId(unitId);
+        uptownHouse.setDepartmentId(departmentId);
         uptownHouseMapper.updateById(uptownHouse);
     }
 

+ 27 - 8
whepi-web/src/main/java/com/bofeng/wx/controller/UserOpenController.java

@@ -6,6 +6,7 @@ import com.bofeng.excel.ExcelUtils;
 import com.bofeng.service.*;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.yvan.ModelOps;
+import com.yvan.mvc.Pd;
 import com.yvan.platform.JsonWapper;
 import com.yvan.platform.YvanUtil;
 import com.yvan.springmvc.ResultModel;
@@ -65,13 +66,13 @@ public class UserOpenController {
                              @RequestParam(value = "userType", required = false, defaultValue = "0") Integer userType) throws JsonProcessingException {
         List<UserRole> list = new ArrayList<>();
         if (userId == 0) {
-            UserOpen userOpen = homeService.getUserOpen();
-            if (userOpen == null) {
-                return null;
-            }
-            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
-//            list = userRoleMapper.getUserRoleByUserId(1234L);
-//            UserOpen userOpen = userOpenMapper.selectByUserId(1234L);
+//            UserOpen userOpen = homeService.getUserOpen();
+//            if (userOpen == null) {
+//                return null;
+//            }
+//            list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
+            list = userRoleMapper.getUserRoleByUserId(1228565481837944834L);
+            UserOpen userOpen = userOpenMapper.selectByUserId(1228565481837944834L);
             userId = userOpen.getUserId();
             model.put("user", userOpen);
             model.put("user_id", "\"" + userOpen.getUserId() + "\"");
@@ -90,6 +91,8 @@ public class UserOpenController {
                     model.put("unit", unit.getUnit());
                     model.put("unitId", unit.getUnitId());
                     model.put("doorplate", unit.getDoorplate());
+                    model.put("departmentId", unit.getDepartmentId());
+                    model.put("departmentName", unit.getDepartmentName());
                     List<UptownHome> uptownHomes =  uptownHomeMapper.getUptownHomeByUserId(userOpen.getUserId());
                     model.put("linkman", uptownHomes.get(0).getLinkman());
                 }
@@ -129,6 +132,8 @@ public class UserOpenController {
                     model.put("unit", unit.getUnit());
                     model.put("unitId", unit.getUnitId());
                     model.put("doorplate", unit.getDoorplate());
+                    model.put("departmentId", unit.getDepartmentId());
+                    model.put("departmentName", unit.getDepartmentName());
                     List<UptownHome> uptownHomes =  uptownHomeMapper.getUptownHomeByUserId(userId);
                     model.put("linkman", uptownHomes.get(0).getLinkman());
                 }
@@ -206,6 +211,8 @@ public class UserOpenController {
                     model.put("unit", unit.getUnit());
                     model.put("unitId", unit.getUnitId());
                     model.put("doorplate", unit.getDoorplate());
+                    model.put("departmentId", unit.getDepartmentId());
+                    model.put("departmentName", unit.getDepartmentName());
                     List<UptownHome> uptownHomes =  uptownHomeMapper.getUptownHomeByUserId(userId);
                     model.put("linkman", uptownHomes.get(0).getLinkman());
                 }
@@ -253,6 +260,17 @@ public class UserOpenController {
     }
 
     /**
+     * 更改二级部门
+     * @param request
+     * @return
+     */
+    @GetMapping("/home/getDepartmentIdLY.json")
+    public List<Department> getDepartmentIdLY(HttpServletRequest request) {
+        Long unitId = Long.parseLong(request.getParameter("unitId"));
+        return uptownUnitMapper.getDepartmentByUnit(unitId);
+    }
+
+    /**
      * 凌云集团更改部门
      * @return
      */
@@ -260,7 +278,8 @@ public class UserOpenController {
     public void changeUnitId(ModelMap model, HttpServletRequest request) {
         Long userId = Long.parseLong(request.getParameter("userId"));
         Long unitId = Long.parseLong(request.getParameter("newUnitId"));
-        userOpenService.changeUnitId(userId, unitId);
+        Long departmentId = Long.parseLong(request.getParameter("newDepartmentId"));
+        userOpenService.changeUnitId(userId, unitId, departmentId);
     }
 
     /**