Pārlūkot izejas kodu

作业分配时间查询correct表
注册老师批量导入

shenhao 3 gadi atpakaļ
vecāks
revīzija
020d220a78

+ 100 - 8
src/main/java/com/ssj/api/controller/ApiManagerTeacherController.java

@@ -12,6 +12,8 @@ import com.ssj.api.domain.vo.teacher.TeacherAddReq;
 import com.ssj.api.domain.vo.teacher.TeacherChangeReq;
 import com.ssj.api.domain.vo.teacher.TeacherDelReq;
 import com.ssj.api.domain.vo.teacher.TeacherReq;
+import com.ssj.bean.common.framework.core.domain.Response;
+import com.ssj.bean.sys.imlibuser.TbClassStudentTemp;
 import com.ssj.bean.sys.imlibuser.TbClassTeacherTemp;
 import com.ssj.bean.weixin.libmy.domain.TbLibManager;
 import com.ssj.framework.core.common.controller.BaseController;
@@ -19,7 +21,6 @@ import com.ssj.framework.core.util.Constant;
 import com.ssj.framework.core.util.PasswordUtil;
 import com.ssj.framework.core.util.ResponseConstant;
 import com.ssj.framework.core.util.ResponseEntity;
-import com.ssj.framework.weixin.util.DateUtil;
 import com.ssj.service.kmt.correctsys.dto.HomeworkPictureCheckDto;
 import com.ssj.service.kmt.correctsys.service.KmtCorrectSysService;
 import com.ssj.service.sys.homework.service.HomeworkPictureService;
@@ -27,17 +28,23 @@ import com.ssj.service.sys.imlibuser.service.TbClassTeacherTempService;
 import com.ssj.service.weixin.library.service.IBookManagerService;
 import com.ssj.service.weixin.user.service.UserService;
 import com.ssj.statistics.service.IStatisticsService;
+import com.ssj.statistics.service.ITeacherEnrollment;
 import com.ssj.statistics.service.ITeacherPayService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
+import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
@@ -66,6 +73,9 @@ public class ApiManagerTeacherController extends BaseController {
     @Autowired
     private KmtCorrectSysService kmtCorrectSysService;
 
+    @Autowired
+    private ITeacherEnrollment teacherEnrollment;
+
 
 	@RequestMapping(value = "/list", method = RequestMethod.POST)
     @ApiOperation(value = "获取平台批改老师列表接口",  notes = "获取平台批改老师列表接口")
@@ -456,12 +466,14 @@ public class ApiManagerTeacherController extends BaseController {
     private List<Map<String,Object>> getSalaryList(String userId){
         //计算今天日期
         LocalDate date = LocalDate.now();
-        int day = date.getDayOfMonth();
-        LocalTime time = LocalTime.now();
-        boolean lastMonth = day< 4 || (day==4 && time.getHour()<12);
-        LocalDate localDate = lastMonth?date.minusMonths(2):date.minusMonths(1);
-        int month = localDate.getMonthValue();
-        int year = localDate.getYear();
+//        int day = date.getDayOfMonth();
+//        LocalTime time = LocalTime.now();
+//        boolean lastMonth = day< 4 || (day==4 && time.getHour()<12);
+//        LocalDate localDate = lastMonth?date.minusMonths(2):date.minusMonths(1);
+//        int month = localDate.getMonthValue();
+//        int year = localDate.getYear();
+        int month = date.getMonthValue();
+        int year = date.getYear();
         return teacherPayService.salaryList(userId,month,year);
     }
 
@@ -482,4 +494,84 @@ public class ApiManagerTeacherController extends BaseController {
         response.setContentType("application/vnd.ms-excel;charset=UTF-8");
         response.setCharacterEncoding("utf-8");
     }
+
+    /**
+     * 注册老师信息导入
+     * @param model
+     * @param file
+     * @return
+     */
+    @RequestMapping(value="/registerTeacherImport")
+    @ResponseBody
+    public Response registerTeacherImport(Model model, @RequestParam("file") MultipartFile file) {
+        Response response = new  Response();
+        try {
+            List<Map<String,String>> datas=analysisExFile(file);
+            if(datas!=null && datas.size()>0){
+                teacherEnrollment.registerTeacherImport(datas);
+            }
+            response.success("导入成功!");
+        } catch (Exception e) {
+            logger.error("异常", e);
+            response.failure("导入异常:"+e.getMessage());
+        }
+        return response;
+    }
+
+    /**
+     * ----------------解析文档相关功能-----------------------
+     */
+
+    public static List<Map<String,String>> analysisExFile(MultipartFile file) throws Exception {
+        List<Map<String,String>> datas=new ArrayList<Map<String,String>>();
+        Map<String,String> map=null;
+
+        @SuppressWarnings("resource")
+        Workbook wb = new XSSFWorkbook(file.getInputStream());
+        Sheet sheet = wb.getSheetAt(0);
+        Row row = null;
+        Cell cell = null;
+        for (Iterator<Row> it = sheet.rowIterator(); it.hasNext();) {
+            map=new LinkedHashMap<String, String>();
+            row = it.next();
+            if (row == null) {
+                break;
+            }
+            if(row.getRowNum()<=0){
+                continue;
+            }
+            if(StringUtils.isEmpty(getValue(row.getCell(0)))){
+                continue;
+            }
+            for (Iterator<Cell> cit =row.cellIterator(); cit.hasNext();) {
+                cell = cit.next();
+                if (cell == null) {
+                    break;
+                }
+                if(StringUtils.isEmpty(getValue(cell))){
+                    continue;
+                }
+                map.put("data_"+cell.getColumnIndex(), getValue(cell));
+            }
+            datas.add(map);
+        }
+        return datas;
+    }
+
+    public static String getValue(Cell cell){
+        if(cell==null) {
+            return "";
+        }
+        if (Cell.CELL_TYPE_NUMERIC == cell.getCellType()){
+            if(DateUtil.isCellDateFormatted(cell)){
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");  //设置转成的时间格式
+                Date date = cell.getDateCellValue();//取得的是date类型
+                String datestr = sdf.format(date);//这里是转成String类型了,要哪种按个人需求
+                return datestr;
+            }
+        }
+        cell.setCellType(Cell.CELL_TYPE_STRING);
+        String text=cell.getStringCellValue()!=null ? String.valueOf(cell.getStringCellValue()):"";
+        return text.trim();
+    }
 }

+ 2 - 2
src/main/java/com/ssj/dao/sys/homework/dao/HomeworkPictureDao.java

@@ -599,7 +599,7 @@ public interface HomeworkPictureDao extends JpaRepository<HomeworkPicture, Strin
     @Query(nativeQuery = true, value = "SELECT count(1) from scon_homework_picture_correct t where homework_id=?1 and type=8 and start_time is not null ")
     int findHomeworkIsCorrect(String homeworkId);
 
-    @Query(nativeQuery = true, value = "update  scon_homework_picture set teacher_id=?2 where homework_id=?1  ")
+    @Query(nativeQuery = true, value = "update  scon_homework_picture set teacher_id=?2,allot_time=?3 where homework_id=?1  ")
     @Modifying
-    void allotPlatHomework(String homeworkId, String teacherId);
+    void allotPlatHomework(String homeworkId, String teacherId, Date now);
 }

+ 1 - 1
src/main/java/com/ssj/dao/sys/homework/dao/impl/HomeworkQueryDaoImpl.java

@@ -338,7 +338,7 @@ public class HomeworkQueryDaoImpl implements HomeworkQueryDao {
         selSQL.append("select t.homework_id,t12.child_name as student_name, t14.`subject`,t14.grade,\n");
         selSQL.append("count(if(t.is_feedback = 1 or t.is_mark in (1,3),true,null)) as correctNums,\n");
         selSQL.append("count(1) as totalNums,\n");
-        selSQL.append("min(t.allot_time) as allot_time,\n");
+        selSQL.append("min(t11.allot_time) as allot_time,\n");
         selSQL.append("min(t11.start_time) as start_time,\n");
         selSQL.append("max(t11.end_time) as end_time,\n");
         selSQL.append("min(t.create_time) as create_time,\n");

+ 1 - 1
src/main/java/com/ssj/dao/weixin/library/dao/impl/LibJoinQueryDaoImpl.java

@@ -1313,7 +1313,7 @@ public class LibJoinQueryDaoImpl implements ILibJoinQueryDao{
 		selSQL.append("(SELECT count(DISTINCT a.homework_id) from scon_homework_picture a join scon_homework_picture_correct b on b.homework_picture_id = a.id where a.teacher_id = t.user_id and a.is_mark in (0,2) and b.type=8  \n" +
 				"and ((b.end_time > ? and a.is_feedback=1) or a.is_feedback=0) ) as wait_nums2, \n");
 		queryParams.add(params.get("beginTime"));
-		selSQL.append("(SELECT ifnull(concat(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,min(a.allot_time),NOW())),''),'00:00:00')   from scon_homework_picture a where a.teacher_id = t.user_id and a.is_mark in (0,2) and a.is_feedback = 0 and  not exists (select 1 from scon_homework_picture_correct x where x.type=8 and x.start_time is not null and a.homework_id = x.homework_id ) ) as wait_max_time, \n");
+		selSQL.append("(SELECT ifnull(concat(SEC_TO_TIME(TIMESTAMPDIFF(SECOND,min(b.allot_time),NOW())),''),'00:00:00')   from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id and b.type=8 where a.teacher_id = t.user_id and a.is_mark in (0,2) and a.is_feedback = 0 and  not exists (select 1 from scon_homework_picture_correct x where x.type=8 and x.start_time is not null and a.homework_id = x.homework_id ) ) as wait_max_time, \n");
 		selSQL.append("t.user_id as teacher_id,t.name as teacher_name, \n");
 		selSQL.append("(select ifnull(concat(SEC_TO_TIME(sum(b.correction_time)),''),'00:00:00') from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id where a.teacher_id = t.user_id and ((a.is_mark in (0,2) and a.is_feedback=1) or a.is_mark in (1,3)) and to_days(b.end_time) =to_days(now())) as today_correct_time, \n");
 		selSQL.append("(select ifnull(concat(SEC_TO_TIME(floor(sum(TIMESTAMPDIFF(SECOND,a.allot_time,b.start_time))/count(1))),''),0) from scon_homework_picture a join scon_homework_picture_correct b on a.id = b.homework_picture_id and b.type=8 where a.teacher_id = t.user_id and b.start_time is not null and (((a.is_feedback=1 or is_mark in (1,3)) and to_days(b.end_time) = to_days(now())) or (a.is_feedback=0 and a.is_mark in (0,2) and to_days(b.start_time) = to_days(now())))) as efficiency, \n");

+ 16 - 1
src/main/java/com/ssj/service/sys/homework/service/impl/HomeworkPictureServiceImpl.java

@@ -212,7 +212,22 @@ public class HomeworkPictureServiceImpl extends BaseServiceImpl<HomeworkPicture,
 
     @Override
     public void allotPlatHomework(String homeworkId, String teacherId) {
-        homeworkPictureDao.allotPlatHomework(homeworkId,teacherId);
+        Date now= new Date();
+        homeworkPictureDao.allotPlatHomework(homeworkId,teacherId,now);
+        List<HomeworkPicture> list = this.findAllByHomeworkId(homeworkId);
+        for(HomeworkPicture homeworkPicture:list){
+            //插入correct表数据
+            HomeworkPictureCorrect    homeworkPictureCorrect = new HomeworkPictureCorrect();
+            homeworkPictureCorrect.setType(8);
+            homeworkPictureCorrect.setCreateTime(new Date());
+            homeworkPictureCorrect.setHomeworkPictureId(homeworkPicture.getId());
+            homeworkPictureCorrect.setHomeworkId(homeworkPicture.getHomeworkId());
+            homeworkPictureCorrect.setStartTime(null);
+            homeworkPictureCorrect.setEndTime(null);
+            homeworkPictureCorrect.setAllotTime(now);
+            homeworkPictureCorrectService.save(homeworkPictureCorrect);
+        }
+
     }
 
     @Override

+ 18 - 0
src/main/java/com/ssj/statistics/dao/ITeacherEnrollmentDao.java

@@ -0,0 +1,18 @@
+package com.ssj.statistics.dao;
+
+import com.ssj.statistics.entity.TeacherEnrollment;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author sh
+ * @className ITeacherEnrollmentDao
+ * @description repository
+ * @date 2021/3/12
+ */
+@Repository
+public interface ITeacherEnrollmentDao extends JpaRepository<TeacherEnrollment,String> {
+    @Query(nativeQuery = true,value = "select * from tb_teacher_enrollment where phone_number=?1 limit 1")
+    TeacherEnrollment findByMobile(String data_1);
+}

+ 56 - 0
src/main/java/com/ssj/statistics/entity/TeacherEnrollment.java

@@ -0,0 +1,56 @@
+package com.ssj.statistics.entity;
+
+import com.ssj.bean.common.framework.core.domain.BaseEntity;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author sh
+ * @className TeacherPay
+ * @description entity
+ * @date 2021/3/2
+ */
+@Table(name = "tb_teacher_enrollment")
+@Entity
+public class TeacherEnrollment extends BaseEntity {
+    //t.phone_number,t.type,t.create_time
+    private String name;
+    private String phoneNumber;
+    private Integer type;
+    private Date createTime;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPhoneNumber() {
+        return phoneNumber;
+    }
+
+    public void setPhoneNumber(String phoneNumber) {
+        this.phoneNumber = phoneNumber;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 21 - 0
src/main/java/com/ssj/statistics/service/ITeacherEnrollment.java

@@ -0,0 +1,21 @@
+package com.ssj.statistics.service;
+
+import com.ssj.framework.core.common.service.BaseService;
+import com.ssj.statistics.entity.TeacherEnrollment;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author sh
+ * @className ITeacherEnrollment
+ * @description interface
+ * @date 2021/3/12
+ */
+public interface ITeacherEnrollment extends BaseService<TeacherEnrollment,String> {
+    /**
+     * 批量导入注册老师
+     * @param datas
+     */
+    void registerTeacherImport(List<Map<String, String>> datas);
+}

+ 51 - 0
src/main/java/com/ssj/statistics/service/impl/TeacherEnrollmentServiceImpl.java

@@ -0,0 +1,51 @@
+package com.ssj.statistics.service.impl;
+
+import com.ssj.framework.core.common.service.BaseServiceImpl;
+import com.ssj.statistics.dao.ITeacherEnrollmentDao;
+import com.ssj.statistics.entity.TeacherEnrollment;
+import com.ssj.statistics.service.ITeacherEnrollment;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.repository.PagingAndSortingRepository;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @author sh
+ * @className TeacherEnrollmentServiceImpl
+ * @description service
+ * @date 2021/3/12
+ */
+@Service
+public class TeacherEnrollmentServiceImpl extends BaseServiceImpl<TeacherEnrollment,String> implements ITeacherEnrollment {
+
+    @Autowired
+    private ITeacherEnrollmentDao dao;
+
+    @Override
+    public PagingAndSortingRepository<TeacherEnrollment, String> getDao() {
+        return dao;
+    }
+
+    @Override
+    public void registerTeacherImport(List<Map<String, String>> datas) {
+        Date now =new Date();
+        for(Map<String, String> map:datas){
+            TeacherEnrollment vo = dao.findByMobile(map.get("data_1"));
+            if(Objects.nonNull(vo)){
+                continue;
+            }
+            vo = new TeacherEnrollment();
+            vo.setName(map.get("data_0"));
+            vo.setPhoneNumber(map.get("data_1"));
+            String type = map.get("data_2");
+            //注册类型(1-社会招聘,2-高校合作,3-远程实习)
+            vo.setType(type.contains("常规兼职")?1:type.contains("高校合作")?2:3);
+            vo.setCreateTime(now);
+            dao.save(vo);
+        }
+    }
+}