Sfoglia il codice sorgente

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 anni fa
parent
commit
58f8691eae

+ 12 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java

@@ -5,8 +5,10 @@ import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
 import com.ym.mec.biz.dal.entity.TeacherSalaryModifyLog;
 import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.TeacherSalaryConfirmStatus;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
+
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
@@ -403,7 +405,7 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @return int
 	 */
 	int updateTeacherSalaryConfirmStatus(@Param("ids") List<Long> ids,
-                                         @Param("confirmStatus") Integer confirmStatus);
+                                         @Param("confirmStatus") TeacherSalaryConfirmStatus confirmStatus);
 
 	/**
 	 * @describe 统计教师指定月份不同团体类型的课酬
@@ -431,4 +433,13 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @param modifyLog
 	 */
     void updateSalary(@Param("modifyLog") TeacherSalaryModifyLog modifyLog);
+
+    /**
+     * @describe 统计指定月份已开启课酬确认的数量
+     * @author Joburgess
+     * @date 2020/4/16
+     * @param month:
+     * @return int
+     */
+    int countOpenConfirmSalarysWithMonth(@Param("month") String month);
 }

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherSalaryComplaintsDao.java

@@ -5,6 +5,8 @@ import com.ym.mec.biz.dal.enums.TeacherSalaryComplaintsStatusEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface TeacherSalaryComplaintsDao extends BaseDAO<Long, TeacherSalaryComplaints> {
 
     /**
@@ -23,4 +25,15 @@ public interface TeacherSalaryComplaintsDao extends BaseDAO<Long, TeacherSalaryC
      * @return
      */
     Object repealComplaints(@Param("salarySettlementMonth") String salarySettlementMonth, @Param("teacherId") Integer teacherId);
+
+    /**
+     * @describe 获取教师指定月份的申诉记录
+     * @author Joburgess
+     * @date 2020/4/16
+     * @param teacherId:
+     * @param month:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.TeacherSalaryComplaints>
+     */
+    List<TeacherSalaryComplaints> findTeacherSalaryComplaintsWithMonth(@Param("teacherId") Integer teacherId,
+                                                                       @Param("month") String month);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseTeacherSalaryStatisticsDto.java

@@ -14,10 +14,20 @@ public class CourseTeacherSalaryStatisticsDto {
 
     private String month;
 
+    private Integer courseTimes;
+
     private BigDecimal totalActualSalary;
 
     private BigDecimal totalReduceSalary;
 
+    public Integer getCourseTimes() {
+        return courseTimes;
+    }
+
+    public void setCourseTimes(Integer courseTimes) {
+        this.courseTimes = courseTimes;
+    }
+
     public String getMonth() {
         return month;
     }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherCourseSalaryDetail4WebDto.java

@@ -24,6 +24,8 @@ public class TeacherCourseSalaryDetail4WebDto {
 
     private Date startClassTime;
 
+    private Date endClassTime;
+
     private String courseName;
 
     private Integer teacherId;
@@ -44,10 +46,28 @@ public class TeacherCourseSalaryDetail4WebDto {
 
     private BigDecimal reduceSalary;
 
+    private BigDecimal finalSalary;
+
     private YesOrNoEnum confirmStatus;
 
     private String memo;
 
+    public BigDecimal getFinalSalary() {
+        return finalSalary;
+    }
+
+    public void setFinalSalary(BigDecimal finalSalary) {
+        this.finalSalary = finalSalary;
+    }
+
+    public Date getEndClassTime() {
+        return endClassTime;
+    }
+
+    public void setEndClassTime(Date endClassTime) {
+        this.endClassTime = endClassTime;
+    }
+
     public Long getId() {
         return id;
     }

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TeacherSalaryConfirmStatus.java

@@ -0,0 +1,32 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/4/16
+ */
+public enum  TeacherSalaryConfirmStatus implements BaseEnum<String, TeacherSalaryConfirmStatus> {
+    UNCONFIRMED("1", "待确认"),
+    CONFIRMED("2", "已确认"),
+    COMPLETED("3", "已完成");
+
+    private String code;
+
+    private String desc;
+
+    private TeacherSalaryConfirmStatus(String code, String desc) {
+        this.code = code;
+        this.desc = desc;
+    }
+
+    @Override
+    public String getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+}

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleTeacherSalaryService.java

@@ -99,6 +99,8 @@ public interface CourseScheduleTeacherSalaryService extends BaseService<Long, Co
      */
     List<Long> querySettlementScheduleId(String courseScheduleIds);
 
+
+
     /**
      * @describe 确定教师指定月份的课酬
      * @author Joburgess
@@ -136,4 +138,22 @@ public interface CourseScheduleTeacherSalaryService extends BaseService<Long, Co
      * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String, Object> findTeacherYearSalarys(Integer teacherId, String year);
+
+    /**
+     * @describe 开启课酬确认
+     * @author Joburgess
+     * @date 2020/4/16
+     * @param month:
+     * @return void
+     */
+    void openSalaryConfirm(String month);
+
+    /**
+     * @describe 关闭课酬确认
+     * @author Joburgess
+     * @date 2020/4/16
+     * @param month:
+     * @return void
+     */
+    void closeSalaryConfirm(String month);
 }

+ 42 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -73,6 +73,8 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     private VipGroupCategoryDao vipGroupCategoryDao;
     @Autowired
     private StudentAttendanceDao studentAttendanceDao;
+    @Autowired
+    private TeacherSalaryComplaintsDao teacherSalaryComplaintsDao;
 
     private static final Logger LOGGER = LoggerFactory
             .getLogger(CourseScheduleTeacherSalaryServiceImpl.class);
@@ -836,7 +838,7 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         if(CollectionUtils.isEmpty(teacherSalaryIds)){
             return;
         }
-        courseScheduleTeacherSalaryDao.updateTeacherSalaryConfirmStatus(teacherSalaryIds,1);
+        courseScheduleTeacherSalaryDao.updateTeacherSalaryConfirmStatus(teacherSalaryIds,TeacherSalaryConfirmStatus.CONFIRMED);
     }
 
     @Override
@@ -851,11 +853,22 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             dataList = courseScheduleTeacherSalaryDao.findIsSettlementCourseSalarys(params);
+            for (TeacherCourseSalaryDetail4WebDto teacherCourseSalaryDetail4WebDto : dataList) {
+                if(Objects.nonNull(teacherCourseSalaryDetail4WebDto.getReduceSalary())){
+                    teacherCourseSalaryDetail4WebDto.setFinalSalary(teacherCourseSalaryDetail4WebDto.getActualSalary().multiply(teacherCourseSalaryDetail4WebDto.getReduceSalary()));
+                }else{
+                    teacherCourseSalaryDetail4WebDto.setFinalSalary(teacherCourseSalaryDetail4WebDto.getActualSalary());
+                }
+            }
         }
         if (count == 0) {
             dataList = new ArrayList<>();
         }
         pageInfo.setRows(dataList);
+        Map<String, Object> result=new HashMap<>();
+        result.put("pageInfo", pageInfo);
+        int i = courseScheduleTeacherSalaryDao.countOpenConfirmSalarysWithMonth(DateUtil.getMonth(DateUtil.addMonths(new Date(), -1)));
+        result.put("isOpenConfirm", i>0?1:0);
         return pageInfo;
     }
 
@@ -867,14 +880,26 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         PageInfo<TeacherCourseSalaryDetail4WebDto> pageInfo = findIsSettlementCourseSalarys(queryInfo4Web);
         Map<String, Object> result=new HashMap<>();
         result.put("pageInfo",pageInfo);
-        Map<String, BigDecimal> groupTypeSalaryMap = new HashMap<>();
+        List<CourseTeacherSalaryStatisticsDto> teacherGroupTypeSalary = new ArrayList<>();
         if(queryInfo4Web.getPage()<=1){
-            List<CourseTeacherSalaryStatisticsDto> teacherGroupTypeSalary = courseScheduleTeacherSalaryDao.getTeacherGroupTypeSalary(queryInfo4Web.getMonth(), queryInfo4Web.getTeacherId());
-            groupTypeSalaryMap = teacherGroupTypeSalary.stream()
-                    .collect(Collectors.toMap(c->c.getGroupType().getCode(),
-                            c -> Objects.isNull(c.getTotalReduceSalary()) ? c.getTotalActualSalary() : c.getTotalActualSalary().subtract(c.getTotalReduceSalary())));
+            teacherGroupTypeSalary = courseScheduleTeacherSalaryDao.getTeacherGroupTypeSalary(queryInfo4Web.getMonth(), queryInfo4Web.getTeacherId());
+        }
+        result.put("stat", teacherGroupTypeSalary);
+        if(!CollectionUtils.isEmpty(pageInfo.getRows())){
+            if(YesOrNoEnum.YES.equals(pageInfo.getRows().get(0).getConfirmStatus())){
+                result.put("confirmStatus",1);
+            }else{
+                result.put("confirmStatus",0);
+            }
+        }else{
+            result.put("confirmStatus",0);
+        }
+        List<TeacherSalaryComplaints> teacherSalaryComplaintsWithMonth = teacherSalaryComplaintsDao.findTeacherSalaryComplaintsWithMonth(queryInfo4Web.getTeacherId(), queryInfo4Web.getMonth());
+        if(CollectionUtils.isEmpty(teacherSalaryComplaintsWithMonth)){
+            result.put("haveComplaints",0);
+        }else{
+            result.put("haveComplaints",1);
         }
-        result.put("stat", groupTypeSalaryMap);
         return result;
     }
 
@@ -896,4 +921,14 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         result.put("totalSalary", totalSalary);
         return result;
     }
+
+    @Override
+    public void openSalaryConfirm(String month) {
+
+    }
+
+    @Override
+    public void closeSalaryConfirm(String month) {
+
+    }
 }

+ 16 - 2
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -449,7 +449,7 @@
 		WHERE course_schedule_id_ = #{modifyLog.courseScheduleId} AND user_id_ = #{modifyLog.teacherId}
 	</update>
 	<update id="updateTeacherSalaryConfirmStatus">
-		UPDATE course_schedule_teacher_salary SET confirm_status_=#{confirmStatus}
+		UPDATE course_schedule_teacher_salary SET confirm_status_=#{confirmStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 		WHERE id_ IN
 		<foreach collection="ids" item="id" open="(" close=")" separator=",">
 			#{id}
@@ -728,6 +728,7 @@
 		<result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 		<result property="courseScheduleId" column="course_schedule_id_" />
 		<result property="startClassTime" column="classes_start_time_" />
+		<result property="endClassTime" column="classes_end_time_" />
 		<result property="courseName" column="course_name_" />
 		<result property="teacherId" column="teacher_id_" />
 		<result property="teacherName" column="teacher_name_" />
@@ -785,7 +786,8 @@
 			cs.id_ course_schedule_id_,
 			cs.group_type_,
 			CONCAT(cs.class_date_, ' ', cs.start_class_time_) classes_start_time_,
-			cs.name_,
+			CONCAT(cs.class_date_, ' ', cs.end_class_time_) classes_end_time_,
+			cs.name_ course_name_,
 			csts.user_id_ teacher_id_,
 			su.real_name_ teacher_name_,
 			t.organ_id_,
@@ -828,6 +830,7 @@
 	<resultMap id="CourseTeacherSalaryStatisticsDto" type="com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto">
 		<result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
 		<result property="month" column="month_"/>
+		<result property="courseTimes" column="course_times_"/>
 		<result property="totalActualSalary" column="total_actual_salary_"/>
 		<result property="totalReduceSalary" column="total_reduce_salary_"/>
 	</resultMap>
@@ -835,6 +838,7 @@
     <select id="getTeacherGroupTypeSalary" resultMap="CourseTeacherSalaryStatisticsDto">
 		SELECT
 			csts.group_type_,
+			COUNT(DISTINCT csts.course_schedule_id_) course_times_,
 			SUM(actual_salary_) total_actual_salary_,
 			SUM(reduce_salary) total_reduce_salary_
 		FROM
@@ -875,4 +879,14 @@
 			AND DATE_FORMAT( cs.class_date_, '%Y-%m' ) = #{month}
 	</select>
 
+	<select id="countOpenConfirmSalarysWithMonth" resultType="int">
+		SELECT
+			COUNT(csts.id_)
+		FROM
+			course_schedule_teacher_salary csts
+			LEFT JOIN course_schedule cs ON cs.id_ = csts.course_schedule_id_
+		WHERE
+			DATE_FORMAT( cs.class_date_, '%Y-%m' ) = #{month}
+			AND csts.settlement_time_ IS NOT NULL AND csts.confirm_status_ IS NOT NULL
+	</select>
 </mapper>

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/TeacherSalaryComplaintsMapper.xml

@@ -121,4 +121,9 @@
 		AND tsc.status_ = #{statusEnum,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} LIMIT 1
 	</select>
 
+	<select id="findTeacherSalaryComplaintsWithMonth" resultMap="TeacherSalaryComplaints">
+		SELECT * FROM teacher_salary_complaints tsc
+		WHERE tsc.teacher_id_ = #{teacherId} AND tsc.salary_settlement_month_ = #{month}
+	</select>
+
 </mapper>

+ 16 - 0
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleTeacherSalaryController.java

@@ -74,4 +74,20 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
         }
         return succeed(courseScheduleTeacherSalaryService.findIsSettlementCourseSalarys(queryInfo));
     }
+
+    @ApiOperation(value = "开启课酬确认")
+    @GetMapping("/openSalaryConfirm")
+    @PreAuthorize("@pcs.hasPermissions('courseScheduleTeacherSalary/openSalaryConfirm')")
+    public HttpResponseResult openSalaryConfirm(String month){
+        courseScheduleTeacherSalaryService.openSalaryConfirm(month);
+        return succeed();
+    }
+
+    @ApiOperation(value = "关闭课酬确认")
+    @GetMapping("/closeSalaryConfirm")
+    @PreAuthorize("@pcs.hasPermissions('courseScheduleTeacherSalary/closeSalaryConfirm')")
+    public HttpResponseResult closeSalaryConfirm(String month){
+        courseScheduleTeacherSalaryService.closeSalaryConfirm(month);
+        return succeed();
+    }
 }

+ 55 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -1152,4 +1152,59 @@ public class ExportController extends BaseController {
             }
         }
     }
+
+    @ApiOperation(value = "课外训练-教学导出")
+    @GetMapping("export/isSettlementCourseSalarys")
+    @PreAuthorize("@pcs.hasPermissions('export/isSettlementCourseSalarys')")
+    public void isSettlementCourseSalarys(CourseSalaryQueryInfo4Web queryInfo, HttpServletResponse response) throws IOException {
+        queryInfo.setRows(999999999);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        if (!sysUser.getIsSuperAdmin()) {
+            Employee employee = employeeDao.get(sysUser.getId());
+            if (org.apache.commons.lang3.StringUtils.isEmpty(queryInfo.getOrganIdList())) {
+                queryInfo.setOrganIdList(employee.getOrganIdList());
+            } else if (org.apache.commons.lang3.StringUtils.isEmpty(employee.getOrganIdList())) {
+                throw new BizException("用户所在分部异常");
+            } else {
+                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+                if (!list.containsAll(Arrays.asList(queryInfo.getOrganIdList().split(",")))) {
+                    throw new BizException("非法请求");
+                }
+            }
+        }
+        List<TeacherCourseSalaryDetail4WebDto> rows = courseScheduleTeacherSalaryService.findIsSettlementCourseSalarys(queryInfo).getRows();
+        if (CollectionUtils.isEmpty(rows)) {
+            response.setStatus(500);
+            response.setContentType("Content-Type: application/json;charset=UTF-8");
+            response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
+            response.flushBuffer();
+            return;
+        }
+        OutputStream ouputStream = null;
+        try {
+            HSSFWorkbook workbook = POIUtil.exportExcel(
+                    new String[]{"分部", "课程组类型", "课程编号", "时间", "课程名称", "老师编号", "老师姓名", "签到时间", "签退时间", "应发课酬",
+                                 "课酬扣款", "结算课酬", "结算课酬", "状态", "备注"},
+                    new String[]{"organName", "groupType", "courseScheduleId", "startClassTime", "courseName", "teacherId", "teacherName",
+                                "signInTime", "signOutTime", "actualSalary", "reduceSalary", "finalSalary", "confirmStatus", "memo"}, rows);
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
+            ouputStream = response.getOutputStream();
+            workbook.write(ouputStream);
+            ouputStream.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ouputStream != null) {
+                try {
+                    ouputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }