Browse Source

adfadfadf

zhouli 10 months ago
parent
commit
4f7b10e3e5

+ 2 - 3
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmOtherCostMapper.xml

@@ -33,13 +33,12 @@
 
 
 
 
     <select id="selectXmOtherCostPage" resultMap="ResultMap" parameterType="org.sky.scientific.pojo.dto.XmOtherCostQuery">
     <select id="selectXmOtherCostPage" resultMap="ResultMap" parameterType="org.sky.scientific.pojo.dto.XmOtherCostQuery">
-        select xoc,* , xm.XMBH, xm.XMMC
+        select xoc.* ,xm.XMBH, xm.XMMC
         from kd_xm_other_cost xoc
         from kd_xm_other_cost xoc
         LEFT JOIN
         LEFT JOIN
         (
         (
             SELECT
             SELECT
-                xm.id,
-                COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMBH' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMBH) AS XMBH,
+                xm.id,xm.XMBH,
                 COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMMC' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMMC) AS XMMC
                 COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMMC' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMMC) AS XMMC
             FROM kd_xm xm
             FROM kd_xm xm
             WHERE xm.is_deleted = 0
             WHERE xm.is_deleted = 0

+ 2 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianHoursMapper.xml

@@ -127,13 +127,13 @@
         <if test="ew.name!=null and ew.name!=''">and t.name like concat(concat('%', #{ew.name}), '%')</if>
         <if test="ew.name!=null and ew.name!=''">and t.name like concat(concat('%', #{ew.name}), '%')</if>
         <if test="ew.number!=null and ew.number!=''">and t.number like concat(concat('%', #{ew.number}), '%')</if>
         <if test="ew.number!=null and ew.number!=''">and t.number like concat(concat('%', #{ew.number}), '%')</if>
         <if test="ew.idCard!=null and ew.idCard!=''">and t.id_card like concat(concat('%', #{ew.idCard}), '%')</if>
         <if test="ew.idCard!=null and ew.idCard!=''">and t.id_card like concat(concat('%', #{ew.idCard}), '%')</if>
-        <if test="ew.personnelType!=null and ew.personnelType!=''">and t.personnel_type =#{personnelType})</if>
+        <if test="ew.personnelType!=null and ew.personnelType!=''">and t.personnel_type =#{ew.personnelType})</if>
      </select>
      </select>
 
 
     <select id="selectDailyHoursByUnicodeAndMonth" resultType="org.sky.scientific.pojo.vo.DailyHours">
     <select id="selectDailyHoursByUnicodeAndMonth" resultType="org.sky.scientific.pojo.vo.DailyHours">
         SELECT
         SELECT
             work_date as workDate,SUM(work_hours) as workHours,
             work_date as workDate,SUM(work_hours) as workHours,
-            (SELECT sum(work_hours) FROM kd_attendance_records a WHERE a.unicode = h.unicode and a.work_date = h.work_date ) as attendanceHours
+            ifnull((SELECT sum(work_hours) FROM kd_attendance_records a WHERE a.unicode = h.unicode and a.work_date = h.work_date ),0) as attendanceHours
         FROM kd_xm_technician_hours h
         FROM kd_xm_technician_hours h
         WHERE left(work_date,6)= #{yearAndMonth} and unicode = #{unicode}
         WHERE left(work_date,6)= #{yearAndMonth} and unicode = #{unicode}
         GROUP BY work_date
         GROUP BY work_date

+ 22 - 17
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmTechnicianHoursServiceImpl.java

@@ -321,35 +321,40 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
 
 
 	@Override
 	@Override
 	public IPage<TechnicianHoursMonthlyVO> meiyueyanfagongshifenpeibiao(IPage<TechnicianHoursMonthlyVO> page, TechnicianDTO dto) {
 	public IPage<TechnicianHoursMonthlyVO> meiyueyanfagongshifenpeibiao(IPage<TechnicianHoursMonthlyVO> page, TechnicianDTO dto) {
-		if(StringUtil.isBlank(dto.getYearAndMonth())){
+		if (StringUtil.isBlank(dto.getYearAndMonth())) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		}
 		List<TechnicianHoursMonthlyVO> list = baseMapper.meiyueyanfagongshifenpeibiao(page, dto);
 		List<TechnicianHoursMonthlyVO> list = baseMapper.meiyueyanfagongshifenpeibiao(page, dto);
 		for (TechnicianHoursMonthlyVO vo : list) {
 		for (TechnicianHoursMonthlyVO vo : list) {
 			List<DailyHours> dailyHours = baseMapper.selectDailyHoursByUnicodeAndMonth(dto.getYearAndMonth(), vo.getUnicode());
 			List<DailyHours> dailyHours = baseMapper.selectDailyHoursByUnicodeAndMonth(dto.getYearAndMonth(), vo.getUnicode());
-			if(CollectionUtil.isEmpty(dailyHours)){
-				continue;
-			}
-			for (DailyHours dailyHour : dailyHours) {
-				//设置一天的非研发工时=当天考勤-研发工时
-				dailyHour.setUnworkHours(dailyHour.getAttendanceHours() - dailyHour.getWorkHours());
-			}
 			//总出勤小时
 			//总出勤小时
-			double attendanceTotal = dailyHours.stream().mapToDouble(DailyHours::getAttendanceHours).sum();
-
+			double attendanceTotal = 0;
 			//总研发工时
 			//总研发工时
-			double workTotal = dailyHours.stream().mapToDouble(DailyHours::getWorkHours).sum();
+			double workTotal = 0;
+			if (CollectionUtil.isNotEmpty(dailyHours)) {
+				for (DailyHours dailyHour : dailyHours) {
+					//设置一天的非研发工时=当天考勤-研发工时
+					dailyHour.setUnworkHours(Math.max(dailyHour.getAttendanceHours() - dailyHour.getWorkHours(), 0));
+				}
+				attendanceTotal = dailyHours.stream().mapToDouble(DailyHours::getAttendanceHours).sum();
+				workTotal = dailyHours.stream().mapToDouble(DailyHours::getWorkHours).sum();
+			}
 			vo.setWorkHoursTotal(workTotal);
 			vo.setWorkHoursTotal(workTotal);
-
 			//总非研发工时 = 总出勤 - 总研发
 			//总非研发工时 = 总出勤 - 总研发
-			vo.setUnworkHoursTotal(attendanceTotal - workTotal);
-
+			vo.setUnworkHoursTotal(Math.max(attendanceTotal - workTotal, 0));
 			//研发工时分配率 = 总研发工时/总出勤小时
 			//研发工时分配率 = 总研发工时/总出勤小时
-			vo.setWorkHoursRate(workTotal / attendanceTotal);
+			if (workTotal == 0 || attendanceTotal == 0) {
+				vo.setWorkHoursRate(0.0);
+			} else {
+				vo.setWorkHoursRate(workTotal / attendanceTotal);
+			}
 
 
 			//非研发工时分配率 = 总非研发工时/总出勤小时
 			//非研发工时分配率 = 总非研发工时/总出勤小时
-			vo.setUnworkHoursRate(vo.getUnworkHoursTotal() / attendanceTotal);
-
+			if (vo.getUnworkHoursTotal() == 0 || attendanceTotal == 0) {
+				vo.setUnworkHoursRate(0.0);
+			} else {
+				vo.setUnworkHoursRate(vo.getUnworkHoursTotal() / attendanceTotal);
+			}
 			vo.setDailyHoursList(dailyHours);
 			vo.setDailyHoursList(dailyHours);
 		}
 		}
 		return page.setRecords(list);
 		return page.setRecords(list);