Browse Source

每月研发工时分配表

zhouli 10 months ago
parent
commit
6873f3e56a

+ 1 - 1
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/XmWwxmCostQuery.java

@@ -18,6 +18,6 @@ public class XmWwxmCostQuery {
 	@Schema(description = "技术合同登记类型")
 	private String JSHTDJLX;
 
-	@Schema(description = "STFLX")
+	@Schema(description = "受托方类型")
 	private String STFLX;
 }

+ 18 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/DailyHours.java

@@ -0,0 +1,18 @@
+package org.sky.scientific.pojo.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class DailyHours {
+
+	@Schema(description = "日期")
+	private String workDate;
+	@Schema(description = "研发时长")
+	private Double workHours;
+	@Schema(description = "考勤时长")
+	private Double attendanceHours;
+	@Schema(description = "非研发时长")
+	private Double unworkHours;
+
+}

+ 50 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/TechnicianHoursMonthlyVO.java

@@ -0,0 +1,50 @@
+package org.sky.scientific.pojo.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 每月研发工时分配
+ */
+@Data
+public class TechnicianHoursMonthlyVO implements Serializable {
+
+
+	@Schema(description = "唯一标识")
+	private String unicode;
+
+	@Schema(description = "姓名")
+	@NotNull
+	private String name;
+
+	@Schema(description = "工号")
+	private String number;
+
+	@Schema(description = "身份证号码")
+	private String idCard;
+
+	@Schema(description = "科研人员类别")
+	private String personnelType;
+
+	@Schema(description = "明细")
+	private List<DailyHours> dailyHoursList;
+
+	@Schema(description="研发工时合计")
+ 	private Double workHoursTotal;
+
+	@Schema(description = "非研发工时合计")
+	private Double unworkHoursTotal;
+
+	@Schema(description="研发工时分配率")
+	private Double workHoursRate;
+
+	@Schema(description = "非研发工时分配率")
+	private Double unworkHoursRate;
+
+
+
+}

+ 0 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/XmCostDetailsController.java

@@ -58,7 +58,6 @@ public class XmCostDetailsController extends KdController {
 	}
 
 
-
 	@PostMapping("/remove")
 	@ApiOperationSupport(order = 7)
 	@Operation(summary = "删除", description  = "传入ids")

+ 8 - 6
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/XmTechnicianHoursController.java

@@ -12,6 +12,8 @@ import org.sky.core.boot.ctrl.KdController;
 import org.sky.core.mp.support.Condition;
 import org.sky.core.mp.support.Query;
 import org.sky.core.tool.api.R;
+import org.sky.scientific.pojo.dto.TechnicianDTO;
+import org.sky.scientific.pojo.vo.TechnicianHoursMonthlyVO;
 import org.sky.scientific.pojo.vo.XmTechnicianHoursVO;
 import org.sky.scientific.service.IXmTechnicianHoursService;
 import org.springframework.web.bind.annotation.*;
@@ -76,11 +78,11 @@ public class XmTechnicianHoursController extends KdController {
 		return R.data(service.selectListForPrint(dto));
 	}
 
-//	@GetMapping("/list/print/export")
-//	@ApiOperationSupport(order = 20)
-//	@Operation(summary = "每月研发工时分配表")
-//	public R<IPage<>> selectTechnicianHoursSummary(){
-//		return
-//	}
+	@GetMapping("/myyfgsfpb")
+	@ApiOperationSupport(order = 20)
+	@Operation(summary = "每月研发工时分配表")
+	public R<IPage<TechnicianHoursMonthlyVO>> meiyueyanfagongshifenpeibiao(TechnicianDTO dto, Query query){
+		return R.data(service.meiyueyanfagongshifenpeibiao(Condition.getPage(query), dto));
+	}
 
 }

+ 19 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianHoursMapper.java

@@ -5,8 +5,11 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.sky.scientific.pojo.dto.TechnicianDTO;
 import org.sky.scientific.pojo.entity.XmTechnicianHours;
 import org.sky.scientific.pojo.vo.DailyAttendance;
+import org.sky.scientific.pojo.vo.DailyHours;
+import org.sky.scientific.pojo.vo.TechnicianHoursMonthlyVO;
 import org.sky.scientific.pojo.vo.XmTechnicianHoursVO;
 
 import java.util.List;
@@ -42,4 +45,20 @@ public interface XmTechnicianHoursMapper extends BaseMapper<XmTechnicianHours> {
 	 * @return
 	 */
 	List<DailyAttendance> selectHoursListByUnicodeAndYear(@Param("unicode") String unicode, @Param("year") String year);
+
+	/**
+	 * 每月研发工时分配表
+	 * @param page
+	 * @param dto
+	 * @return
+	 */
+    List<TechnicianHoursMonthlyVO> meiyueyanfagongshifenpeibiao(@Param("page") IPage<TechnicianHoursMonthlyVO> page, @Param("ew") TechnicianDTO dto);
+
+	/**
+	 * 查询考勤、研发工时
+	 * @param yearAndMonth 月份
+	 * @param unicode 人员
+	 * @return
+	 */
+	List<DailyHours> selectDailyHoursByUnicodeAndMonth(@Param("yearAndMonth") String yearAndMonth, @Param("unicode") String unicode);
 }

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

@@ -105,6 +105,39 @@
         GROUP BY LEFT(work_date, 6)
     </select>
 
+    <resultMap id="TechnicianHoursMonthlyVOMap" type="org.sky.scientific.pojo.vo.TechnicianHoursMonthlyVO">
+        <result column="unicode" property="unicode"/>
+        <result column="name" property="name"/>
+        <result column="number" property="number"/>
+        <result column="id_card" property="idCard"/>
+        <result column="personnel_type" property="personnelType"/>
+        <result column="unicode" property="unicode"/>
+<!--        <collection property="dailyHoursList" ofType="org.sky.scientific.pojo.vo.DailyHours">-->
+<!--            <result column="work_date" property="workDate"/>-->
+<!--            <result column="work_hours" property="workHours"/>-->
+<!--            <result column="attendance_hours" property="attendanceHours"/>-->
+<!--        </collection>-->
+    </resultMap>
+    <select id="meiyueyanfagongshifenpeibiao" resultMap="TechnicianHoursMonthlyVOMap" parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">
+        SELECT
+            DISTINCT xt.unicode, name, number, id_card, personnel_type
+        FROM kd_xm_technician xt
+        LEFT JOIN  kd_technician t on t.unicode = xt.unicode and t.year_and_month=#{ew.yearAndMonth}
+        WHERE xt.year_and_month = #{ew.yearAndMonth}
+        <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.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>
+     </select>
+
+    <select id="selectDailyHoursByUnicodeAndMonth" resultType="org.sky.scientific.pojo.vo.DailyHours">
+        SELECT
+            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
+        FROM kd_xm_technician_hours h
+        WHERE left(work_date,6)= #{yearAndMonth} and unicode = #{unicode}
+        GROUP BY work_date
+    </select>
     <delete id="clear">
         DELETE FROM kd_xm_technician_hours
         WHERE left(work_date,6) = #{yearAndMonth} and xm_id = #{xmId} and unicode = #{unicode}

+ 8 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmWwxmCostMapper.xml

@@ -47,6 +47,10 @@
         ) xm on xm.id = m.xm_id
         where
             xa.year_and_month = #{ew.yearAndMonth}
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.xmmc like concat('%',#{ew.xmmc},'%')</if>
+        <if test="ew.SFWCJSHTDJ!=null and ew.SFWCJSHTDJ!=''">and m.SFWCJSHTDJ like concat('%',#{ew.SFWCJSHTDJ},'%')</if>
+        <if test="ew.JSHTDJLX!=null and ew.JSHTDJLX!=''">and m.JSHTDJLX like concat('%',#{ew.JSHTDJLX},'%')</if>
+        <if test="ew.STFLX!=null and ew.STFLX!=''">and x.STFLX like concat('%',#{ew.STFLX},'%')</if>
     </select>
 
     <select id="selectPageByYear" resultMap="ResultVoMap">
@@ -64,6 +68,10 @@
         ) xm on xm.id = m.xm_id
         where
             left(xa.year_and_month,4) = #{ew.yearAndMonth}
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.xmmc like concat('%',#{ew.xmmc},'%')</if>
+        <if test="ew.SFWCJSHTDJ!=null and ew.SFWCJSHTDJ!=''">and m.SFWCJSHTDJ like concat('%',#{ew.SFWCJSHTDJ},'%')</if>
+        <if test="ew.JSHTDJLX!=null and ew.JSHTDJLX!=''">and m.JSHTDJLX like concat('%',#{ew.JSHTDJLX},'%')</if>
+        <if test="ew.STFLX!=null and ew.STFLX!=''">and x.STFLX like concat('%',#{ew.STFLX},'%')</if>
     </select>
 
     <delete id="physicalDeleteByIds">

+ 10 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IXmTechnicianHoursService.java

@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import jakarta.servlet.http.HttpServletResponse;
 import org.sky.core.mp.base.BaseService;
+import org.sky.scientific.pojo.dto.TechnicianDTO;
 import org.sky.scientific.pojo.entity.XmTechnicianHours;
+import org.sky.scientific.pojo.vo.TechnicianHoursMonthlyVO;
 import org.sky.scientific.pojo.vo.XmTechnicianHoursVO;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -56,4 +58,12 @@ public interface IXmTechnicianHoursService extends BaseService<XmTechnicianHours
 	 * @return
 	 */
 	List<JSONObject> selectListForPrint(XmTechnicianHoursVO dto);
+
+	/**
+	 * 研发费用统计-人员人工费用-每月研发工时分配表
+	 * @param page
+	 * @param dto
+	 * @return
+	 */
+    IPage<TechnicianHoursMonthlyVO> meiyueyanfagongshifenpeibiao(IPage<TechnicianHoursMonthlyVO> page, TechnicianDTO dto);
 }

+ 40 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmTechnicianHoursServiceImpl.java

@@ -18,8 +18,11 @@ import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.excel.XmTechnicianHoursExcel;
 import org.sky.scientific.excel.XmTechnicianHoursListener;
 import org.sky.scientific.mapper.*;
+import org.sky.scientific.pojo.dto.TechnicianDTO;
 import org.sky.scientific.pojo.entity.XmTechnicianHours;
 import org.sky.scientific.pojo.vo.DailyAttendance;
+import org.sky.scientific.pojo.vo.DailyHours;
+import org.sky.scientific.pojo.vo.TechnicianHoursMonthlyVO;
 import org.sky.scientific.pojo.vo.XmTechnicianHoursVO;
 import org.sky.scientific.service.IXmTechnicianHoursService;
 import org.springframework.stereotype.Service;
@@ -147,7 +150,7 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
 
 				if (hoursTotal - usedHours < dailyAttendance.getWorkHours()) {
 					//当 考勤时长 - 当天以用工时 < 新的工时 ,则提示“考勤时长不足”
-					throw new ServiceException("[序号"+record.getSerialNumber()+",日期"+dailyAttendance.getWorkDate()+"工时"+dailyAttendance.getWorkHours()+"]的考勤时长不足,出勤总时长" + hoursTotal + ",已用" + usedHours + ",可用"+(hoursTotal-usedHours)+",请核对数据");
+					throw new ServiceException("[序号" + record.getSerialNumber() + ",日期" + dailyAttendance.getWorkDate() + "工时" + dailyAttendance.getWorkHours() + "]的考勤时长不足,出勤总时长" + hoursTotal + ",已用" + usedHours + ",可用" + (hoursTotal - usedHours) + ",请核对数据");
 				}
 
 				double doubleValue = usedHoursByUnicodeAndDate.getDoubleValue(key) + dailyAttendance.getWorkHours();
@@ -315,4 +318,40 @@ public class XmTechnicianHoursServiceImpl extends BaseServiceImpl<XmTechnicianHo
 	public List<JSONObject> selectListForPrint(XmTechnicianHoursVO dto) {
 		return baseMapper.selectListForPrint(dto);
 	}
+
+	@Override
+	public IPage<TechnicianHoursMonthlyVO> meiyueyanfagongshifenpeibiao(IPage<TechnicianHoursMonthlyVO> page, TechnicianDTO dto) {
+		if(StringUtil.isBlank(dto.getYearAndMonth())){
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		List<TechnicianHoursMonthlyVO> list = baseMapper.meiyueyanfagongshifenpeibiao(page, dto);
+		for (TechnicianHoursMonthlyVO vo : list) {
+			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 workTotal = dailyHours.stream().mapToDouble(DailyHours::getWorkHours).sum();
+			vo.setWorkHoursTotal(workTotal);
+
+			//总非研发工时 = 总出勤 - 总研发
+			vo.setUnworkHoursTotal(attendanceTotal - workTotal);
+
+			//研发工时分配率 = 总研发工时/总出勤小时
+			vo.setWorkHoursRate(workTotal / attendanceTotal);
+
+			//非研发工时分配率 = 总非研发工时/总出勤小时
+			vo.setUnworkHoursRate(vo.getUnworkHoursTotal() / attendanceTotal);
+
+			vo.setDailyHoursList(dailyHours);
+		}
+		return page.setRecords(list);
+	}
 }

BIN
kd-service/kd-scientific/src/main/resources/export-template/技术人员花名册.xls