wangggziwen 2 سال پیش
والد
کامیت
459462be71

+ 27 - 4
master/src/main/java/com/ruoyi/project/production/controller/TSaiController.java

@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.file.ExcelUtils;
 import com.ruoyi.project.production.controller.vo.SaiQueryVO;
 import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.service.ISysDeptService;
 import com.ruoyi.project.system.service.ISysDictTypeService;
 import com.ruoyi.project.system.service.ISysUserService;
@@ -52,6 +53,9 @@ public class TSaiController extends BaseController
     @Autowired
     private ISysDeptService iSysDeptService;
 
+    @Autowired
+    private SysDeptMapper sysDeptMapper;
+
     /**
      * 查询SAI信息列表
      */
@@ -94,7 +98,7 @@ public class TSaiController extends BaseController
         //字典查询
 //        List<SysDictData> tempStateDict = iSysDictTypeService.selectDictDataByType("TEMP_STATE");
         //部门查询
-        List<SysDept> dept = iSysDeptService.selectDeptList(new SysDept());
+        List<SysDept> sysDeptList = iSysDeptService.selectDeptList(new SysDept());
         int rowNum = sheet.getPhysicalNumberOfRows();
         int failNumber = 0;
         for (int i = 2; i <= rowNum; i++) {
@@ -104,14 +108,18 @@ public class TSaiController extends BaseController
                 int cellNum = row.getPhysicalNumberOfCells();
                 TSai entity = new TSai();
                 entity.setDelFlag("0");
-//                entity.setDeptId(userService.selectUserById(userId).getDeptId());
+                entity.setDeptId(userService.selectUserById(userId).getDeptId());
                 for (int j = 0; j < cellNum; j++) {
                     Cell cell = row.getCell(j);
                     //  cell.setCellType(CellType.STRING);
                     String cellValue = ExcelUtils.getCellValue(cell);
                     logger.info("cellValue:" + cellValue);
                     if (j == 0) {
-                        entity.setPlantId(cellValue);
+                        for (SysDept sysDept : sysDeptList) {
+                            if (sysDept.getDeptName().equals(cellValue)) {
+                                entity.setPlantId(sysDept.getDeptId().toString());
+                            }
+                        }
                     } else if (j == 1) {
                         if (cellValue.length() > 3) {
                             entity.setInspectionDate(new SimpleDateFormat(DateUtils.getDateFormat(cellValue)).parse(cellValue));
@@ -125,7 +133,11 @@ public class TSaiController extends BaseController
                     } else if (j == 5) {
                         entity.setActions(cellValue);
                     } else if (j == 6) {
-                        entity.setUserDept(cellValue);
+                        for (SysDept sysDept : sysDeptList) {
+                            if (sysDept.getDeptName().equals(cellValue)) {
+                                entity.setUserDept(sysDept.getDeptId().toString());
+                            }
+                        }
                     } else if (j == 7) {
                         entity.setSource(cellValue);
                     }
@@ -168,6 +180,17 @@ public class TSaiController extends BaseController
     public AjaxResult export(TSai tSai)
     {
         List<TSai> list = tSaiService.selectTSaiList(tSai);
+        List<SysDept> sysDepts = sysDeptMapper.selectDeptList(new SysDept());
+        for (TSai sai : list) {
+            for (SysDept sysDept : sysDepts) {
+                if (sysDept.getDeptId().toString().equals(sai.getPlantId())) {
+                    sai.setPlantName(sysDept.getDeptName());
+                }
+                if (sysDept.getDeptId().toString().equals(sai.getUserDept())) {
+                    sai.setUserDeptName(sysDept.getDeptName());
+                }
+            }
+        }
         ExcelUtil<TSai> util = new ExcelUtil<TSai>(TSai.class);
         return util.exportExcel(list, "sai");
     }

+ 2 - 4
master/src/main/java/com/ruoyi/project/production/domain/TSai.java

@@ -21,9 +21,8 @@ public class TSai extends BaseEntity
     private Long saiId;
 
     /** 检查的装置/设施 */
-    @Excel(name = "检查的装置/设施")
     private String plantId;
-
+    @Excel(name = "检查的装置/设施")
     private String plantName;
 
     /** 检查日期/时间 */
@@ -48,9 +47,8 @@ public class TSai extends BaseEntity
     private String actions;
 
     /** 用户 */
-    @Excel(name = "用户")
     private String userDept;
-
+    @Excel(name = "用户")
     private String userDeptName;
 
     /** 数据来源 */

+ 10 - 0
master/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java

@@ -94,6 +94,16 @@ public class SysDeptController extends BaseController
         return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
     }
 
+    /**
+     * 获取部门下拉树列表(全部)
+     */
+    @GetMapping("/alltreeselect")
+    public AjaxResult alltreeselect(SysDept dept)
+    {
+        List<SysDept> depts = deptService.selectAllDeptList(dept);
+        return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
+    }
+
     /**
      * 加载对应角色部门列表树
      */

+ 1 - 1
master/src/main/resources/mybatis/production/TSaiMapper.xml

@@ -34,9 +34,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="source != null  and source != ''"> and source like concat(concat('%', #{source}), '%') </if>
             and d.del_flag = 0
         </where>
-        order by d.inspection_date asc
         <!-- 数据范围过滤 -->
         ${params.dataScope}
+        order by d.inspection_date asc
     </select>
 
     <select id="selectTSaiList" parameterType="TSai" resultMap="TSaiResult">

+ 8 - 0
ui/src/api/system/dept.js

@@ -33,6 +33,14 @@ export function treeselect() {
   })
 }
 
+// 查询部门下拉树结构(全部)
+export function alltreeselect() {
+  return request({
+    url: '/system/dept/alltreeselect',
+    method: 'get'
+  })
+}
+
 // 根据角色ID查询部门树结构
 export function roleDeptTreeselect(roleId) {
   return request({

+ 6 - 6
ui/src/views/production/sai/index.vue

@@ -228,7 +228,7 @@
 
 <script>
 import { listSai, listSaiByYear, getSai, delSai, addSai, updateSai, exportSai, importTemplate} from "@/api/production/sai";
-import { treeselect } from "@/api/system/dept";
+import { treeselect, alltreeselect } from "@/api/system/dept";
 import { getToken } from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@@ -341,7 +341,7 @@ export default {
     },
      /** 查询部门下拉树结构 */
      getTreeselect() {
-          treeselect().then(response => {
+          alltreeselect().then(response => {
               this.deptOptions = response.data;
           });
      },
@@ -410,13 +410,13 @@ export default {
             updateSai(this.form).then(response => {
               this.msgSuccess("修改成功");
               this.open = false;
-              this.getList();
+              this.getListByYear();
             });
           } else {
             addSai(this.form).then(response => {
               this.msgSuccess("新增成功");
               this.open = false;
-              this.getList();
+              this.getListByYear();
             });
           }
         }
@@ -432,7 +432,7 @@ export default {
         }).then(function() {
           return delSai(saiIds);
         }).then(() => {
-          this.getList();
+          this.getListByYear();
           this.msgSuccess("删除成功");
         })
     },
@@ -483,7 +483,7 @@ export default {
         }else {
           this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
         }
-        this.getList();
+        this.getListByYear();
       },
       // 提交上传文件
       submitFileForm() {