大数据与最优化研究所 hace 1 año
padre
commit
77a658534a

+ 7 - 13
src/main/java/com/xjrsoft/module/personnel/controller/LaborManagementController.java

@@ -61,19 +61,13 @@ public class LaborManagementController {
 
     @GetMapping("/export")
     @ApiOperation(value = "导出")
-    public ResponseEntity<byte[]> exportData(@Valid LaborManagementPageDto dto, @RequestParam(defaultValue = "false") Boolean isTemplate) {
-        List<LaborManagement> list = laborManagementService.list();
+    public ResponseEntity<byte[]> exportData() {
+        List<LaborManagementPageVo> list = laborManagementService.listLaborManagementPageVo();
 
-        List<LaborManagementPageVo> customerList = new ArrayList<>();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
-
-        for (LaborManagement vo : list) {
-            LaborManagementPageVo listVo = BeanUtil.toBean(vo, LaborManagementPageVo.class);
-//            LaborManagementPageDto listDto = BeanUtil.toBean(vo, LaborManagementPageDto.class);
-//            listDto.setStartWorkTime(sdf.format(dto.getStartWorkTime()));
-
-            customerList.add(listVo);
-        }
+//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
+//        for (LaborManagementPageVo vo : list) {
+//            vo.setStartWorkTime(sdf.format(vo.getStartWorkTime()));
+//        }
 
         // 写入Excel
         ByteArrayOutputStream bot = new ByteArrayOutputStream();
@@ -81,7 +75,7 @@ public class LaborManagementController {
                 .automaticMergeHead(false)
                 .excelType(ExcelTypeEnum.XLSX)
                 .sheet()
-                .doWrite(customerList);
+                .doWrite(list);
 
         // 返回文件流
         return RT.fileStream(bot.toByteArray(), "LaborManagement" + ExcelTypeEnum.XLSX.getValue());

+ 4 - 0
src/main/java/com/xjrsoft/module/personnel/mapper/LaborManagementMapper.java

@@ -10,6 +10,8 @@ import com.xjrsoft.module.textbook.dto.TextbookIssueRecordPageDto;
 import com.xjrsoft.module.textbook.vo.TextbookIssueRecordPageVo;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
 * @title: 劳资管理信息表
 * @Author brealinxx
@@ -19,4 +21,6 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface LaborManagementMapper extends MPJBaseMapper<LaborManagement> {
     Page<LaborManagementPageVo> getPage(Page<LaborManagementPageDto> page, LaborManagementPageDto dto);
+
+    List<LaborManagementPageVo> listLaborManagementPageVo();
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/personnel/service/ILaborManagementService.java

@@ -12,6 +12,8 @@ import com.xjrsoft.module.textbook.dto.TextbookIssueRecordPageDto;
 import com.xjrsoft.module.textbook.vo.TextbookIssueRecordPageVo;
 import com.xjrsoft.module.weekly.entity.WeeklyDutySchedule;
 
+import java.util.List;
+
 /**
 * @title: 劳资管理信息表
 * @Author brealinxx
@@ -21,4 +23,6 @@ import com.xjrsoft.module.weekly.entity.WeeklyDutySchedule;
 
 public interface ILaborManagementService extends MPJBaseService<LaborManagement>  {
     Page<LaborManagementPageVo> getPage(Page<LaborManagementPageDto> page, LaborManagementPageDto dto);
+
+    List<LaborManagementPageVo> listLaborManagementPageVo();
 }

+ 7 - 0
src/main/java/com/xjrsoft/module/personnel/service/impl/LaborManagementServiceImpl.java

@@ -14,6 +14,8 @@ import com.xjrsoft.module.textbook.vo.TextbookIssueRecordPageVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @title: 劳资管理信息表
  * @Author brealinxx
@@ -31,4 +33,9 @@ public class LaborManagementServiceImpl extends MPJBaseServiceImpl<LaborManageme
         return laborManagementMapper.getPage(page, dto);
     }
 
+    @Override
+    public List<LaborManagementPageVo> listLaborManagementPageVo() {
+        return laborManagementMapper.listLaborManagementPageVo();
+    }
+
 }

+ 2 - 1
src/main/java/com/xjrsoft/module/personnel/vo/LaborManagementPageVo.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.personnel.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ContentStyle;
 import io.swagger.annotations.ApiModelProperty;
@@ -20,7 +21,7 @@ public class LaborManagementPageVo {
     * 主键
     */
     @ContentStyle(dataFormat = 49)
-    @ExcelProperty("主键")
+    @ExcelIgnore
     @ApiModelProperty("主键")
     private String id;
 

+ 62 - 17
src/main/resources/mapper/personnel/LaborManagementMapper.xml

@@ -4,19 +4,32 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.xjrsoft.module.personnel.mapper.LaborManagementMapper">
     <select id="getPage" parameterType="com.xjrsoft.module.personnel.dto.LaborManagementPageDto" resultType="com.xjrsoft.module.personnel.vo.LaborManagementPageVo">
-        SELECT
-        t.id, t.user_name, t.name, t1.name AS gender, t2.start_work_time, t3.name AS jobState, t4.nature_organization, t5.name, t6.name AS job
+        SELECT t.id,
+        t.user_name,
+        t.name,
+        t1.name AS gender,
+        t2.start_work_time,
+        t3.name AS jobState,
+        t4.name as nature_organization,
+        t5.name,
+        t9.name AS job
         FROM xjr_user t
         inner JOIN base_teacher t2 ON t2.user_id = t.id
-        LEFT JOIN xjr_dictionary_detail t1 ON t1.item_id = (SELECT id FROM xjr_dictionary_item WHERE code = 'gender') AND t1.code = (CASE t.gender
-            WHEN 1 THEN 'SB10001'
-            WHEN 2 THEN 'SB10002'
-            WHEN 3 THEN 'SB10003'
-            ELSE t.gender END)
-        LEFT JOIN xjr_dictionary_detail t3 ON t3.item_id = (SELECT id FROM xjr_dictionary_item WHERE code = 'job_state') AND t3.value = t2.job_state
-        LEFT JOIN wf_teacher_depart t4 ON t4.applicant_user_id = t2.user_id
-        LEFT JOIN xjr_department t5 ON t4.dept_name = t5.id
-        LEFT JOIN xjr_dictionary_detail t6 ON t6.code = t4.job
+        LEFT JOIN xjr_dictionary_detail t1
+        ON t1.item_id = (SELECT id FROM xjr_dictionary_item WHERE code = 'gender') AND
+        t1.code = (CASE t.gender
+        WHEN 1 THEN 'SB10001'
+        WHEN 2 THEN 'SB10002'
+        WHEN 3 THEN 'SB10003'
+        ELSE t.gender END)
+        LEFT JOIN xjr_dictionary_detail t3
+        ON t3.item_id = (SELECT id FROM xjr_dictionary_item WHERE code = 'job_state') AND
+        t3.value = t2.job_state
+        LEFT JOIN xjr_dictionary_detail t4 ON t4.code = t2.employ_way
+        LEFT JOIN xjr_user_dept_relation t7 ON t7.user_id = t.id
+        LEFT JOIN xjr_department t5 ON t5.id = t7.dept_id
+        LEFT JOIN xjr_user_post_relation t8 ON t8.user_id = t.id
+        LEFT JOIN xjr_post t9 ON t9.id = t8.post_id
         WHERE t.delete_mark = 0
         <if test="dto.userName != null">
             AND t.user_name = #{dto.userName}
@@ -56,14 +69,46 @@
         ORDER BY t.id;
 
     </select>
+
+    <select id="listLaborManagementPageVo" resultType="com.xjrsoft.module.personnel.vo.LaborManagementPageVo">
+        SELECT t.id,
+               t.user_name,
+               t.name,
+               t1.name AS gender,
+               t2.start_work_time,
+               t3.name AS jobState,
+               t4.name as nature_organization,
+               t5.name,
+               t9.name AS job
+        FROM xjr_user t
+                 inner JOIN base_teacher t2 ON t2.user_id = t.id
+                 LEFT JOIN xjr_dictionary_detail t1
+                           ON t1.item_id = (SELECT id FROM xjr_dictionary_item WHERE code = 'gender') AND
+                              t1.code = (CASE t.gender
+                                             WHEN 1 THEN 'SB10001'
+                                             WHEN 2 THEN 'SB10002'
+                                             WHEN 3 THEN 'SB10003'
+                                             ELSE t.gender END)
+                 LEFT JOIN xjr_dictionary_detail t3
+                           ON t3.item_id = (SELECT id FROM xjr_dictionary_item WHERE code = 'job_state') AND
+                              t3.value = t2.job_state
+                 LEFT JOIN xjr_dictionary_detail t4 ON t4.code = t2.employ_way
+                 LEFT JOIN xjr_user_dept_relation t7 ON t7.user_id = t.id
+                 LEFT JOIN xjr_department t5 ON t5.id = t7.dept_id
+                 LEFT JOIN xjr_user_post_relation t8 ON t8.user_id = t.id
+                 LEFT JOIN xjr_post t9 ON t9.id = t8.post_id
+        WHERE t.delete_mark = 0
+        ORDER BY t.id;
+    </select>
 <!--
 工号:xjruser-username;
 姓名:xjruser-name;
-性别:xjruser-gender->xjritem-性别id->sjrdition-itemid-code;
-入职时间:baseteacher-startworktime
-在职状态:baseteacher-jobstate
-人员类别:wf_teacher_depart-natureorigan 1
-任职部门:wf_teacher_depart-deptname-xjrdepart->name
-工作岗位:wf_teacher_depart-job
+性别:xjruser-gender->xjritem;
+性别id->sjrdition-itemid-code;
+入职时间:baseteacher-startworktime;
+在职状态:baseteacher-jobstate;
+人员类别:wf_teacher_depart-natureorigan;
+任职部门:wf_teacher_depart-deptname-xjrdepart->name;
+工作岗位:wf_teacher_depart-job;
 -->
 </mapper>

+ 34 - 18
src/test/java/com/xjrsoft/xjrsoftboot/DataMaintenanceTest.java

@@ -76,7 +76,7 @@ public class DataMaintenanceTest {
         differentProperties.removeAll(propertyList2);
 
         System.out.println("集合一中有,集合二中没有的的属性值:");
-        differentProperties.forEach(System.out::println);
+        //differentProperties.forEach(System.out::println);
 
         List<Object> differentProperties1 = new ArrayList<>(propertyList2);
         differentProperties1.removeAll(propertyList1);
@@ -139,10 +139,10 @@ public class DataMaintenanceTest {
         modifyBSFMSqlSb.append("INSERT INTO base_student_family_member (id, create_user_id, create_date, delete_mark, enabled_mark, user_id, name, mobile, is_guardian) \nVALUES ");
         //学生学籍信息修改
         StringBuilder modifyBSSRSqlSb = new StringBuilder();
-        modifyBSSRSqlSb.append("# base_student_school_roll学生学籍信息修改 \n");
+        modifyBSSRSqlSb.append("# base_student_school_roll学生学籍信息修改\nBEGIN;\n");
         //学生学号信息修改
         StringBuilder modifyBSSqlSb = new StringBuilder();
-        modifyBSSqlSb.append("# base_student学生学号信息修改 \n");
+        modifyBSSqlSb.append("# base_student学生学号信息修改 \nBEGIN;\n");
 
         long BSFMId = 456789123462290L;
         for (int i = 0; i < studentInfoList.size(); i++) {
@@ -168,13 +168,25 @@ public class DataMaintenanceTest {
                     + studentInfo.getXjh()
                     + "', archives_number = '"
                     + studentInfo.getXsdabh()
-                    + "', grade_id = "
-                    + ((gradeByNameAndIdMap.get(studentInfo.getBjnj())==null) ? "" : (gradeByNameAndIdMap.get(studentInfo.getBjnj())))
-                    + ", major_set_id = "
-                    + ((baseMajorSetByNameAndIdMap.get(studentInfo.getZdzyfx())==null) ? "" : (baseMajorSetByNameAndIdMap.get(studentInfo.getZdzyfx())))
-                    + ", class_id = "
-                    + ((baseClassByNameAndIdMap.get(studentInfo.getBjmc())==null) ? "" : (baseClassByNameAndIdMap.get(studentInfo.getBjmc())))
-                    + ", student_type = '"
+                    + "', ");
+            if(gradeByNameAndIdMap.get(studentInfo.getBjnj()) != null){
+                modifyBSSRSqlSb.append("grade_id = "
+                                    + (gradeByNameAndIdMap.get(studentInfo.getBjnj()))
+                                    + ", ");
+
+            }
+            if(baseMajorSetByNameAndIdMap.get(studentInfo.getZdzyfx()) != null){
+                modifyBSSRSqlSb.append("major_set_id = "
+                        + baseMajorSetByNameAndIdMap.get(studentInfo.getZdzyfx())
+                        + ", ");
+            }
+            if(baseClassByNameAndIdMap.get(studentInfo.getBjmc()) != null){
+                modifyBSSRSqlSb.append("class_id = "
+                        + baseClassByNameAndIdMap.get(studentInfo.getBjmc())
+                        + ", ");
+            }
+
+            modifyBSSRSqlSb.append( "student_type = '"
                     + studentTypeByNameAndCodeMap.get(studentInfo.getXslb())
                     + "', stduy_status = '"
                     + stduyStatusByNameAndCodeMap.get(studentInfo.getJdfs())
@@ -182,12 +194,16 @@ public class DataMaintenanceTest {
                     + credentialNumberAndUserId.get(studentInfo.getSfzh())
                     + ";\n");
 
-            modifyBSSqlSb.append("UPDATE base_student SET student_id = '"
-                    + studentInfo.getXh()
-                    + "' WHERE user_id = "
-                    + credentialNumberAndUserId.get(studentInfo.getSfzh())
-                    + ";\n");
+            if(credentialNumberAndUserId.get(studentInfo.getSfzh()) != null){
+                modifyBSSqlSb.append("UPDATE base_student SET student_id = '"
+                        + studentInfo.getXh()
+                        + "' WHERE user_id = "
+                        + credentialNumberAndUserId.get(studentInfo.getSfzh())
+                        + ";\n");
+            }
         }
+        modifyBSSRSqlSb.append("COMMIT;\n");
+        modifyBSSqlSb.append("COMMIT;\n");
         //System.err.println(modifyBSFMSqlSb.toString());
         if (modifyBSFMSqlSb.length() > 0) {
             char lastChar = modifyBSFMSqlSb.charAt(modifyBSFMSqlSb.length() - 2);
@@ -201,16 +217,16 @@ public class DataMaintenanceTest {
         modifyBSSRSqlSb.append("\n\n");
         modifyBSSqlSb.append("\n\n");
 
-        /*String filePath = "C:\\Users\\大数据与最优化研究所\\Downloads\\output.sql";
+        String filePath = "C:\\Users\\大数据与最优化研究所\\Desktop\\公司-沈祖山\\output.sql";
 
-        try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
+        try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))){
             writer.write(modifyBSFMSqlSb.toString());
             writer.write(modifyBSSRSqlSb.toString());
             writer.write(modifyBSSqlSb.toString());
             //System.out.println("StringBuilder content has been written to the file: " + filePath);
         } catch (IOException e) {
             //System.err.println("Error writing to the file: " + e.getMessage());
-        }*/
+        }
     }
 
     public static Object getProperty(Object object, String propertyName) {