zhoulisky 10 months ago
parent
commit
0c317a05a8
26 changed files with 259 additions and 158 deletions
  1. BIN
      doc/xls导入模板/表68-长期待摊费用分配表p069基础7.xlsx
  2. 3 3
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/AttendanceDto.java
  3. 3 0
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/XmCqdtfyDTO.java
  4. 3 3
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/AttendanceEntity.java
  5. 3 3
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/SalaryEntity.java
  6. 3 0
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/TechnicianEntity.java
  7. 17 10
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/XmTechnicianEntity.java
  8. 2 2
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/AttendanceVO.java
  9. 2 0
      kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/YsRyrgfyVO.java
  10. 9 0
      kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/AttendanceController.java
  11. 4 2
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AttendanceMapper.java
  12. 25 12
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AttendanceMapper.xml
  13. 2 2
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/SalaryMapper.java
  14. 25 10
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/SalaryMapper.xml
  15. 2 3
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianMapper.java
  16. 19 44
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianMapper.xml
  17. 1 2
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmMapper.xml
  18. 10 2
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianMapper.java
  19. 31 7
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianMapper.xml
  20. 6 4
      kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/YsRyrgfyMapper.xml
  21. 9 0
      kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IAttendanceService.java
  22. 21 9
      kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AttendanceServiceImpl.java
  23. 14 16
      kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/SalaryServiceImpl.java
  24. 35 17
      kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/TechnicianServiceImpl.java
  25. 4 2
      kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmServiceImpl.java
  26. 6 5
      kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/YsRyrgfyServiceImpl.java

BIN
doc/xls导入模板/表68-长期待摊费用分配表p069基础7.xlsx


+ 3 - 3
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/AttendanceDto.java

@@ -12,9 +12,9 @@ import java.util.List;
 @Data
 public class AttendanceDto {
 
-	@Schema(description = "研发人员id")
-	@NotNull(message = "请选择研发人员")
-	private Long technicianId;
+	@Schema(description = "研发人员唯一标识")
+	@NotNull(message = "unicode不能为空")
+	private String unicode;
 
 	@Schema(description = "姓名")
 	private String name;

+ 3 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/dto/XmCqdtfyDTO.java

@@ -49,4 +49,7 @@ public class XmCqdtfyDTO {
 	private BigDecimal yzjeStart;
 	@Schema(description = "月折旧额,max")
 	private BigDecimal yzjeEnd;
+
+	@Schema(description = "所属年月")
+	private String yearAndMonth;
 }

+ 3 - 3
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/AttendanceEntity.java

@@ -28,9 +28,9 @@ public class AttendanceEntity extends TenantEntity {
 	@Serial
 	private static final long serialVersionUID = 1L;
 
-	@Schema(description = "研发人员id")
-	@NotBlank(message = "请选择研发人员")
-	private Long technicianId;
+	@Schema(description = "研发人员唯一标识")
+	@NotBlank(message = "unicode不能为空")
+	private String unicode;
 
 	@Schema(description="考勤时间,yyyyMMdd")
 	@NotNull(message = "请选择考勤时间")

+ 3 - 3
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/SalaryEntity.java

@@ -22,9 +22,9 @@ import java.math.BigDecimal;
 @EqualsAndHashCode(callSuper = true)
 public class SalaryEntity extends TenantEntity {
 
-	@Schema(description = "技术人员ID")
-	@NotNull(message = "参数technicianId缺失或错误")
-	private Long technicianId;
+	@Schema(description = "技术人员唯一标识")
+	@NotNull(message = "参数unicode缺失或错误")
+	private String unicode;
 
 	@Schema(description = "所属年月,如:202505")
 	private String yearAndMonth;

+ 3 - 0
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/TechnicianEntity.java

@@ -50,6 +50,9 @@ public class TechnicianEntity extends TenantEntity {
 	@NotNull
 	private String name;
 
+	@Schema(description = "唯一标识")
+	private String unicode;
+
 	@Schema(description = "工号")
 	private String number;
 

+ 17 - 10
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/XmTechnicianEntity.java

@@ -44,22 +44,21 @@ public class XmTechnicianEntity extends TenantEntity {
 	@TableField(exist = false)
 	private String xmmc;
 
-	@NotNull(message = "请选择科研人员")
-	@Schema(description = "科研人员ID")
-	private Long technicianId;
+	@Schema(description = "人员唯一标识")
+	@NotNull(message = "unicode不能为空")
+	private String unicode;
 
-	@Schema(description = "姓名")
-	@TableField(exist = false)
-	private String name;
-
-	@Schema(description = "工号")
+	@Schema(description = "人员编号")
 	@TableField(exist = false)
 	private String number;
-
-	@Schema(description = "身份证号码")
+	@Schema(description = "身份证号")
 	@TableField(exist = false)
 	private String idCard;
 
+	@Schema(description = "姓名")
+	@TableField(exist = false)
+	private String name;
+
 	@Schema(description = "所属二级单位")
 	@TableField(exist = false)
 	private String secondaryUnit;
@@ -68,6 +67,14 @@ public class XmTechnicianEntity extends TenantEntity {
 	@TableField(exist = false)
 	private String department;
 
+	@Schema(description = "岗位职务")
+	@TableField(exist = false)
+	private String post;
+
+	@Schema(description = "岗位所在地")
+	@TableField(exist = false)
+	private String postLocation;
+
 	@Schema(description = "用工性质")
 	@TableField(exist = false)
 	private String nature;

+ 2 - 2
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/vo/AttendanceVO.java

@@ -8,8 +8,8 @@ import java.util.List;
 @Data
 public class AttendanceVO {
 
-	@Schema(description = "研发人员id")
-	private Long technicianId;
+	@Schema(description = "研发人员唯一标识")
+	private String unicode;
 
 	@Schema(description = "姓名")
 	private String name;

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

@@ -23,4 +23,6 @@ public class YsRyrgfyVO extends YsRyrgfyEntity {
 	@Schema(description = "人员信息")
 	private TechnicianEntity technician;
 
+	private String unicode;
+
 }

+ 9 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/AttendanceController.java

@@ -17,6 +17,8 @@ import org.sky.scientific.service.IAttendanceService;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+
 @RestController
 @AllArgsConstructor
 @RequestMapping("/attendance")
@@ -48,4 +50,11 @@ public class AttendanceController extends KdController {
 		return R.success("操作成功");
 	}
 
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@Operation(summary = "每月考勤信息-清除考勤数据", description  = "多个 unicode、yearAndMonth")
+	public R remove(@RequestBody List<AttendanceDto> attendanceList) {
+		return R.status(service.clearAttendance(attendanceList));
+	}
+
 }

+ 4 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AttendanceMapper.java

@@ -23,11 +23,13 @@ public interface AttendanceMapper extends BaseMapper<AttendanceEntity> {
 
 	int batchUpdate(List<AttendanceEntity> list);
 
-	Long selectPrimaryKeyByTechnicianIdAndWorkDate(@Param("technicianId") Long technicianId, @Param("workDate") String workDate);
+	Long selectPrimaryKeyByUnicodeAndWorkDate(@Param("unicode") String unicode, @Param("workDate") String workDate);
 
 	int batchInsert(List<AttendanceEntity> list);
 
-	List<DailyAttendance> selectDailyAttendanceByTechnicianAndMonth(@Param("technicianId") Long technicianId, @Param("yearAndMonth") String yearAndMonth);
+	List<DailyAttendance> selectDailyAttendanceByUnicodeAndMonth(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
 
 	List<AttendanceVO> selectAttendancePage(IPage<AttendanceVO> page, @Param("ew") AttendanceDto attendance);
+
+	int clearUnicodeAndMonthly(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
 }

+ 25 - 12
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/AttendanceMapper.xml

@@ -5,7 +5,7 @@
     <resultMap id="ResultMap" type="org.sky.scientific.pojo.entity.AttendanceEntity">
         <result column="id" property="id"/>
         <result column="tenant_id" property="tenantId"/>
-        <result column="technician_id" property="technicianId"/>
+        <result column="unicode" property="unicode"/>
         <result column="work_date" property="workDate"/>
         <result column="work_hours" property="workHours"/>
 
@@ -19,24 +19,24 @@
     </resultMap>
 
     <resultMap id="ResultVoMap" type="org.sky.scientific.pojo.vo.AttendanceVO">
-        <result column="technician_id" property="technicianId"/>
+        <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"/>
     </resultMap>
 
-    <select id="selectDailyAttendanceByTechnicianAndMonth" resultType="org.sky.scientific.pojo.vo.DailyAttendance">
+    <select id="selectDailyAttendanceByUnicodeAndMonth" resultType="org.sky.scientific.pojo.vo.DailyAttendance">
         select work_date,work_hours
         from kd_attendance_records
-        where technician_id = #{technicianId} and left(work_date,6) = #{yearAndMonth}
+        where unicode = #{unicode} and left(work_date,6) = #{yearAndMonth}
         order by work_date asc
     </select>
 
     <select id="selectAttendancePage" resultMap="ResultVoMap">
-        SELECT xt.technician_id, t.name, t.number, t.id_card, t.personnel_type
+        SELECT xt.unicode, t.name, t.number, t.id_card, t.personnel_type
         FROM kd_xm_technician xt
-        LEFT JOIN kd_technician t on xt.technician_id = t.id
+        LEFT JOIN kd_technician t on xt.unicode = t.unicode and t.year_and_month = #{ew.yearAndMonth}
         WHERE xt.year_and_month = #{ew.yearAndMonth}
         <if test="ew.name != null">
             and t.name like concat('%',#{ew.name},'%')
@@ -50,6 +50,8 @@
         <if test="ew.personnelType != null">
             and t.personnel_type = #{ew.personnelType}
         </if>
+        group by xt.unicode
+        order by xt.year_and_month desc
     </select>
 
     <update id="batchUpdate" parameterType="java.util.List">
@@ -60,24 +62,35 @@
         </foreach>
     </update>
 
-    <select id="selectPrimaryKeyByTechnicianIdAndWorkDate" resultType="java.lang.Long">
+    <select id="selectPrimaryKeyByUnicodeAndWorkDate" resultType="java.lang.Long">
         select id from kd_attendance_records
-        where technician_id = #{technicianId} and work_date = #{workDate}
+        where unicode = #{unicode} and work_date = #{workDate}
     </select>
 
     <insert id="batchInsert" parameterType="java.util.List">
-        insert into kd_attendance_records(tenant_id,technician_id,work_date,work_hours,create_user,create_dept)
+        insert into kd_attendance_records(tenant_id,unicode,work_date,work_hours,create_user,create_dept)
         VALUES
         <foreach collection="list" item="a" separator=",">
-            (#{a.tenantId},#{a.technicianId},#{a.workDate},#{a.workHours},#{a.createUser},#{a.createDept})
+            (#{a.tenantId},#{a.unicode},#{a.workDate},#{a.workHours},#{a.createUser},#{a.createDept})
         </foreach>
     </insert>
 
-    <select id="selectByYearAndMonth" resultType="org.sky.scientific.pojo.entity.AttendanceEntity" parameterType="java.lang.String">
-        select id,technician_id as technicianId, work_date as workDate, work_hours as workHours
+    <select id="selectByYearAndMonth" resultMap="ResultMap" parameterType="java.lang.String">
+        select id,unicode, work_date, work_hours
         from kd_attendance_records
         where left(work_date,6) = #{yearAndMonth}
     </select>
 
+<!--    <delete id="deleteByUnicodeAndWorkDate">-->
+<!--        delete from kd_attendance_records-->
+<!--        where unicode = #{unicode} and left(work_date,6) = #{workDate}-->
+<!--    </delete>-->
+
+    <update id="clearUnicodeAndMonthly">
+        update kd_attendance_records
+        set work_hours = 0
+        where unicode = #{unicode} and left(work_date,6) = #{yearAndMonth}
+    </update>
+
 
 </mapper>

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

@@ -38,11 +38,11 @@ public interface SalaryMapper extends BaseMapper<SalaryEntity> {
 	List<SalaryExcel> exportSalary(@Param("ew") Wrapper<SalaryEntity> queryWrapper);
 
 	/**
-	 * 物理删除
+	 * 清除工资数据
 	 * @param salary
 	 * @return
 	 */
-	Integer deleteSalary(SalaryEntity salary);
+	int clearSalary(SalaryEntity salary);
 
 	/**
 	 * 修改

+ 25 - 10
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/SalaryMapper.xml

@@ -6,7 +6,7 @@
     <resultMap id="ResultMap" type="org.sky.scientific.pojo.entity.SalaryEntity">
         <result column="id" property="id"/>
         <result column="tenant_id" property="tenantId"/>
-        <result column="technician_id" property="technicianId"/>
+        <result column="unicode" property="unicode"/>
         <result column="year_and_month" property="yearAndMonth"/>
         <result column="average_monthly_salary" property="averageMonthlySalary"/>
         <result column="average_monthly_salary_edit" property="averageMonthlySalaryEdit"/>
@@ -62,12 +62,27 @@
             <if test="pensionInsuranceBc!=null">pension_insurance_bc = #{pensionInsuranceBc}, pension_insurance_bc_edit = 1,</if>
             <if test="medicalInsuranceBc!=null">medical_insurance_bc = #{medicalInsuranceBc}, medical_insurance_bc_edit = 1,</if>
         </trim>
-        where technician_id = #{technicianId} and year_and_month = #{yearAndMonth}
+        where unicode = #{unicode} and year_and_month = #{yearAndMonth}
+    </update>
+
+    <update id="clearSalary" parameterType="org.sky.scientific.pojo.entity.SalaryEntity">
+        update kd_salary set average_monthly_salary = null,
+                             pension_insurance = null,
+                             medical_insurance =null,
+                             unemployment_insurance = null,
+                             injury_insurance = null,
+                             maternity_insurance = null,
+                             provident_fund = null,
+                             bonus =null,
+                             benefit = null,
+                             pension_insurance_bc =null,
+                             medical_insurance_bc = null
+        where unicode = #{unicode} and year_and_month = #{yearAndMonth}
     </update>
 
     <select id="selectSalaryPage" resultMap="ResultVoMap">
         SELECT
-        s.technician_id,
+        s.unicode,
         t.name,
         t.number,
         t.id_card,
@@ -96,7 +111,7 @@
         s.medical_insurance_bc,
         s.medical_insurance_bc_edit
         FROM kd_salary s
-        LEFT JOIN kd_technician t on t.id = s.technician_id
+        LEFT JOIN kd_technician t on t.unicode = s.unicode and t.year_and_month = #{salary.yearAndMonth}
         WHERE s.is_deleted = 0 and s.year_and_month = #{salary.yearAndMonth}
         <if test="salary.name != null">
             and t.name like concat('%',#{salary.name},'%')
@@ -120,17 +135,17 @@
         SELECT * FROM kd_salary ${ew.customSqlSegment}
     </select>
 
-    <delete id="deleteSalary" parameterType="org.sky.scientific.pojo.entity.SalaryEntity">
-        delete from kd_salary
-        where technician_id = #{technicianId} and year_and_month = #{yearAndMonth}
-    </delete>
+<!--    <delete id="deleteSalary" parameterType="org.sky.scientific.pojo.entity.SalaryEntity">-->
+<!--        delete from kd_salary-->
+<!--        where unicode = #{unicode} and year_and_month = #{yearAndMonth}-->
+<!--    </delete>-->
 
     <select id="fetchLastYearData" resultMap="ResultMap">
         SELECT *
         FROM kd_salary
-        WHERE year_and_month = #{lastYear} and technician_id in
+        WHERE year_and_month = #{lastYear} and unicode in
         (
-            SELECT t.id FROM kd_technician t
+            SELECT t.unicode FROM kd_technician t
             WHERE LEFT(t.year_and_month, 4) = #{currentYear}
         )
     </select>

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

@@ -31,10 +31,9 @@ public interface TechnicianMapper extends BaseMapper<TechnicianEntity> {
 
 	List<TechnicianExcel> exportTechnicianList(@Param("technician") TechnicianDTO technician);
 
-	Long selectPrimaryKeyByNumberOrIdentityCard(@Param("number") String number, @Param("idCard") String idCard);
-
-	TechnicianEntity selectByTechnicianIdAndYearAndMonth(@Param("technicianId") Long technicianId, @Param("yearAndMonth") String yearAndMonth);
+	TechnicianEntity selectByUnicodeAndYearAndMonth(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
 
+	String getUnicodeByNumberAndIdentityCard(@Param("number") String number, @Param("idCard") String idCard);
 
 	List<TechnicianVO> selectByYear(@Param("technician") TechnicianDTO technician);
 

+ 19 - 44
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianMapper.xml

@@ -6,6 +6,7 @@
     <resultMap id="technicianResultMap" type="org.sky.scientific.pojo.entity.TechnicianEntity">
         <result column="id" property="id"/>
         <result column="tenant_id" property="tenantId"/>
+        <result column="unicode" property="unicode"/>
         <result column="name" property="name"/>
         <result column="number" property="number"/>
         <result column="id_card" property="idCard"/>
@@ -80,12 +81,12 @@
         <if test="technician.yearAndMonth.length()==4">
             INNER JOIN
             (
-            SELECT number, id_card, MAX( year_and_month ) AS max_month
+            SELECT unicode, MAX( year_and_month ) AS max_month
             FROM kd_technician
             WHERE LEFT ( year_and_month, 4 ) = #{technician.yearAndMonth} AND is_deleted = 0
-            GROUP BY number, id_card
+            GROUP BY unicode
             ) t2
-            ON t1.number = t2.number AND t1.id_card = t2.id_card AND year_and_month = t2.max_month
+            ON t1.unicode= t2.unicode AND year_and_month = t2.max_month
         </if>
         where is_deleted = 0
         <if test="technician.name!=null and technician.name!=''">and name like concat(concat('%', #{technician.name}),
@@ -139,12 +140,12 @@
         from kd_technician t1
         JOIN
         (
-            SELECT number, id_card, MAX(year_and_month) as maxMonth
+            SELECT unicode,MAX(year_and_month) as maxMonth
             from kd_technician
             where left(year_and_month,4) = #{technician.yearAndMonth}
-            GROUP BY number,id_card
-        ) s on t1.year_and_month = s.maxMonth and t1.number = s.number and t1.id_card = s.id_card
-        where t1.is_deleted = 0 and left(t1.year_and_month,4) = #{technician.yearAndMonth}
+            GROUP BY unicode
+        ) s on t1.year_and_month = s.maxMonth and t1.unicode=s.unicode
+        where left(t1.year_and_month,4) = #{technician.yearAndMonth}
         <if test="technician.name!=null and technician.name!=''">and name like concat(concat('%', #{technician.name}),'%')</if>
         <if test="technician.number!=null and technician.number!=''">and name like concat(concat('%',#{technician.number}), '%')</if>
         <if test="technician.idCard!=null and technician.idCard!=''">and id_card like concat(concat('%', #{technician.idCard}), '%')</if>
@@ -163,15 +164,15 @@
     </select>
 
     <select id="selectByDateInterval" resultMap="technicianResultMap" parameterType="java.util.Map">
-        select t1.id, t1.name, t1.number, t1.id_card, year_and_month ,gender, birthday,ethnic,secondary_unit,department,post,post_location,nature,hire_date,education,degree,school_name,major,rank,practicing_requirement,situation,personnel_type
+        select t1.id, t1.unicode, t1.name, t1.number, t1.id_card, year_and_month ,gender, birthday,ethnic,secondary_unit,department,post,post_location,nature,hire_date,education,degree,school_name,major,rank,practicing_requirement,situation,personnel_type
         from kd_technician t1
         JOIN
         (
-            SELECT number, id_card, MAX(year_and_month) as latest_month
+            SELECT unicode, MAX(year_and_month) as latest_month
             from kd_technician
             where year_and_month <![CDATA[>=]]> #{param.startDate} and year_and_month <![CDATA[<=]]> #{param.endDate}
-            GROUP BY number, id_card
-        ) s2 on t1.number = s2.number and t1.id_card = s2.id_card  and t1.year_and_month = s2.latest_month
+            GROUP BY unicode
+        ) s2 on t1.unicode = s2.unicode and t1.year_and_month = s2.latest_month
         where t1.is_deleted = 0
         order by year_and_month asc, t1.id asc
     </select>
@@ -181,42 +182,16 @@
         FROM kd_technician ${ew.customSqlSegment}
     </select>
 
-    <select id="selectPrimaryKeyByNumberOrIdentityCard"
-            resultType="java.lang.Long">
-        select id
-        from kd_technician
-        where is_deleted = 0
-          <if test="number!=null and number!=''">and number = #{number}</if>
-          <if test="idCard!=null and idCard!=''">and id_card = #{idCard}</if>
-    </select>
-
-    <select id="selectByTechnicianIdAndYearAndMonth"
+    <select id="selectByUnicodeAndYearAndMonth"
             resultType="org.sky.scientific.pojo.entity.TechnicianEntity">
         select *
         from kd_technician
-        where is_deleted = 0
-        and number = #{number} and id_card = #{idCard}
-        and year_and_month = #{yearAndMonth}
+        where unicode = #{unicode} and year_and_month = #{yearAndMonth}
     </select>
 
-    <update id="updateTechnicianSnapshot">
-        update kd_technician
-        <trim prefix="set" suffixOverrides=",">
-            <if test="technician.gender == 1 or technician.gender == 2">gender = #{technician.gender},</if>
-            <if test="technician.birthday!=null and technician.ethnic!=''">birthday = #{technician.birthday},</if>
-            <if test="technician.ethnic!=null">ethnic = #{technician.ethnic},</if>
-            <if test="technician.secondaryUnit!=null and technician.secondaryUnit!=''">secondary_unit = #{technician.secondaryUnit},</if>
-            <if test="technician.department!=null and technician.department!=''">department = #{technician.department},</if>
-            <if test="technician.post!=null and technician.post!=''">post = #{technician.post},</if>
-            <if test="technician.postLocation!=null and technician.postLocation!=''">post_location=#{technician.postLocation},</if>
-            <if test="technician.nature!=null and technician.nature!=''">nature = #{technician.nature},</if>
-            <if test="technician.education!=null and technician.education!=''">education = #{technician.education},</if>
-            <if test="technician.degree!=null and technician.degree!=''">degree = #{technician.degree},</if>
-            <if test="technician.rank!=null and technician.rank!=''">rank = #{technician.rank},</if>
-            <if test="technician.personnelType!=null and technician.personnelType!=''">personnel_type = #{technician.personnelType},</if>
-            <if test="technician.situation !=null and technician.situation!=''">situation = #{technician.situation},</if>
-            <if test="technician.practicingRequirement !=null and technician.practicingRequirement!=''">practicing_requirement = #{technician.practicingRequirement},</if>
-        </trim>
-        where number = #{number}  and year_and_month = #{technician.yearAndMonth}
-    </update>
+    <select id="getUnicodeByNumberAndIdentityCard" resultType="java.lang.String">
+        select distinct(unicode)
+        from kd_technician
+        where number = #{number} and id_card = #{idCard}
+    </select>
 </mapper>

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

@@ -43,8 +43,7 @@
             COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMKSSJ' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMKSSJ) AS XMKSSJ,
             COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMJSSJ' AND DATE_FORMAT(bgrz.BGSXSJ,'%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1),XMJSSJ) AS XMJSSJ
         FROM kd_xm xm
-        WHERE xm.is_deleted = 0
-          and DATE_FORMAT(XMKSSJ, '%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth}
+        WHERE DATE_FORMAT(XMKSSJ, '%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth}
     </select>
 
     <select id="exportXm" resultType="org.sky.scientific.excel.XmExcel">

+ 10 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianMapper.java

@@ -35,10 +35,18 @@ public interface XmTechnicianMapper extends BaseMapper<XmTechnicianEntity> {
 	Integer physicalDeleteXmTechnicianMonthlyByIds(List<Long> ids);
 
 	/**
-	 * 项目参研人员汇总表
+	 * 项目参研人员汇总表-按月
 	 * @param page
 	 * @param entity
 	 * @return
 	 */
-	List<XmTechnicianSummary> xmTechnicianSummary(IPage<XmTechnicianSummary> page, @Param("ew") XmTechnicianEntity entity);
+	List<XmTechnicianSummary> xmTechnicianSummaryByMonthly(IPage<XmTechnicianSummary> page, @Param("ew") XmTechnicianEntity entity);
+
+	/**
+	 * 项目参研人员汇总表-按年
+	 * @param page
+	 * @param entity
+	 * @return
+	 */
+	List<XmTechnicianSummary> xmTechnicianSummaryByYear(IPage<XmTechnicianSummary> page, @Param("ew") XmTechnicianEntity entity);
 }

+ 31 - 7
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmTechnicianMapper.xml

@@ -6,10 +6,11 @@
     <resultMap id="ResultMap" type="org.sky.scientific.pojo.entity.XmTechnicianEntity">
         <result column="id" property="id"/>
         <result column="tenant_id" property="tenantId"/>
+        <result column="year_and_month" property="yearAndMonth"/>
         <result column="xm_id" property="xmId"/>
         <result column="XMBH" property="xmbh"/>
         <result column="XMMC" property="xmmc"/>
-        <result column="technician_id" property="technicianId"/>
+        <result column="unicode" property="unicode"/>
         <result column="name" property="name"/>
         <result column="number" property="number"/>
         <result column="id_card" property="idCard"/>
@@ -40,9 +41,9 @@
         SELECT
         xt.id,
         xm.*,
-        t.id as technician_id, t.name, t.number,t.id_card,t.secondary_unit,t.department,t.nature,t.situation,t.personnel_type
+        t.name, t.unicode, t.number,t.id_card,t.secondary_unit,t.department,t.nature,t.situation,t.personnel_type
         FROM kd_xm_technician xt
-        LEFT JOIN kd_technician t on xt.technician_id = t.id
+        LEFT JOIN kd_technician t on xt.unicode = t.unicode and t.year_and_month = #{ew.yearAndMonth}
         LEFT JOIN (
             SELECT temp.id as xm_id, XMBH,
                    COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = temp.id AND bgrz.ZDMC = 'xmmc' AND DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') >= #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1), temp.XMMC ) AS XMMC
@@ -54,36 +55,59 @@
                 #{xm.id}
             </foreach>
         </if>
-        <if test="ew.technicianId!=null and ew.technicianId!=''">and xt.technician_id = #{ew.technicianId}</if>
     </select>
 
     <resultMap id="ResultXmTechnicianSummary" type="org.sky.scientific.pojo.vo.XmTechnicianSummary">
         <result column="XMMC" property="xmmc"/>
         <collection property="technicianList" ofType="org.sky.scientific.pojo.entity.XmTechnicianEntity">
-            <result column="technician_id" property="technicianId"/>
+            <result column="year_and_month" property="yearAndMonth"/>
+            <result column="unicode" property="unicode"/>
             <result column="name" property="name"/>
             <result column="number" property="number"/>
             <result column="id_card" property="idCard"/>
             <result column="secondary_unit" property="secondaryUnit"/>
             <result column="department" property="department"/>
+            <result column="post_location" property="postLocation"/>
+            <result column="post" property="post"/>
             <result column="nature" property="nature"/>
             <result column="situation" property="situation"/>
             <result column="personnel_type" property="personnelType"/>
         </collection>
     </resultMap>
 
-    <select id="xmTechnicianSummary"
+    <select id="xmTechnicianSummaryByMonthly"
             resultMap="ResultXmTechnicianSummary">
         SELECT
         xm.XMMC,
-        m.*
+        t.unicode,t.name, t.number,t.id_card,t.secondary_unit,t.department,t.post,t.post_location,t.nature,t.situation,t.personnel_type,t.year_and_month
         FROM kd_xm_technician m
+        LEFT JOIN kd_technician t on t.unicode = m.unicode and t.year_and_month = #{ew.yearAndMonth}
         LEFT JOIN (
             SELECT temp.id as xm_id, XMBH,
                 COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = temp.id AND bgrz.ZDMC = 'xmmc' AND DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') >= #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1), temp.XMMC ) AS XMMC
             FROM kd_xm temp
         ) xm ON m.xm_id = xm.xm_id
         WHERE m.year_and_month = #{ew.yearAndMonth}
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.XMMC like concat('%',#{ew.xmmc},'%')</if>
         GROUP BY xm.XMMC,m.id
     </select>
+
+
+    <select id="xmTechnicianSummaryByYear"
+            resultMap="ResultXmTechnicianSummary">
+        SELECT
+        xm.XMMC,
+        t.unicode,t.number,t.id_card, t.name,t.secondary_unit,t.department,t.post,t.post_location,t.nature,t.situation,t.personnel_type
+        FROM kd_xm_technician m
+        LEFT JOIN kd_technician t on t.unicode = m.unicode and left(t.year_and_month,4) = #{ew.yearAndMonth}
+        LEFT JOIN (
+        SELECT temp.id as xm_id, XMBH,
+        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = temp.id AND bgrz.ZDMC = 'xmmc' AND
+        DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') >= #{ew.yearAndMonth} ORDER BY bgrz.BGSXSJ DESC LIMIT 1), temp.XMMC ) AS XMMC
+        FROM kd_xm temp
+        ) xm ON m.xm_id = xm.xm_id
+        WHERE LEFT(m.year_and_month,4) = #{ew.yearAndMonth}
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and xm.XMMC like concat('%',#{ew.xmmc},'%')</if>
+        GROUP BY m.xm_id,m.unicode
+    </select>
 </mapper>

+ 6 - 4
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/YsRyrgfyMapper.xml

@@ -3,11 +3,12 @@
 <mapper namespace="org.sky.scientific.mapper.YsRyrgfyMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="ysRyrgfyResultMap" type="org.sky.scientific.pojo.vo.YsRyrgfyVO">
+    <resultMap id="ResultVoMap" type="org.sky.scientific.pojo.vo.YsRyrgfyVO">
         <result column="id" property="id"/>
         <result column="tenant_id" property="tenantId"/>
         <result column="XM_ID" property="xmId"/>
         <result column="technician_id" property="technicianId"/>
+        <result column="unicode" property="unicode"/>
         <result column="ZZSC" property="zzsc"/>
         <result column="PJRGFY" property="pjrgfy"/>
         <result column="create_user" property="createUser"/>
@@ -27,10 +28,11 @@
         </foreach>
     </delete>
 
-    <select id="selectYsRyrgfyPage" resultMap="ysRyrgfyResultMap">
-        select fy.*
+    <select id="selectYsRyrgfyPage" resultMap="ResultVoMap">
+        select fy.*, t.unicode
         from kd_ys_ryrgfy fy
-        where is_deleted = 0
+        left join kd_technician t on fy.technician_id = t.id
+        where fy.is_deleted = 0
         <if test="ysRyrgfy.xmId != null">and fy.XM_ID = #{ysRyrgfy.xmId}</if>
     </select>
 

+ 9 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/IAttendanceService.java

@@ -8,6 +8,8 @@ import org.sky.scientific.pojo.entity.AttendanceEntity;
 import org.sky.scientific.pojo.vo.AttendanceVO;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+
 /**
  * 考勤管理 服务类
  *
@@ -44,4 +46,11 @@ public interface IAttendanceService extends BaseService<AttendanceEntity> {
 	 * @return
 	 */
 	boolean batchSubmit(AttendanceDto attendance);
+
+	/**
+	 * 研发人员考勤表-清除考勤数据
+	 * @param attendanceList
+	 * @return
+	 */
+	boolean clearAttendance(List<AttendanceDto> attendanceList);
 }

+ 21 - 9
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AttendanceServiceImpl.java

@@ -50,7 +50,7 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 		}
 		List<AttendanceVO> list = baseMapper.selectAttendancePage(page, attendance);
 		for (AttendanceVO vo : list) {
-			List<DailyAttendance> dailyAttendanceList = baseMapper.selectDailyAttendanceByTechnicianAndMonth(vo.getTechnicianId(), attendance.getYearAndMonth());
+			List<DailyAttendance> dailyAttendanceList = baseMapper.selectDailyAttendanceByUnicodeAndMonth(vo.getUnicode(), attendance.getYearAndMonth());
 			if(CollectionUtil.isEmpty(dailyAttendanceList)){
 				continue;
 			}
@@ -67,14 +67,14 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 	public boolean submit(AttendanceEntity attendance) {
 		int affectNum = 0;
 		AttendanceEntity one = baseMapper.selectOne(Wrappers.<AttendanceEntity>lambdaQuery().
-			eq(AttendanceEntity::getTechnicianId, attendance.getTechnicianId()).eq(AttendanceEntity::getWorkDate, attendance.getWorkDate()));
+			eq(AttendanceEntity::getUnicode, attendance.getUnicode()).eq(AttendanceEntity::getWorkDate, attendance.getWorkDate()));
 		if (one == null) {
 			//新增
 			affectNum = baseMapper.insert(attendance);
 		} else {
 			//修改
 			LambdaQueryWrapper<AttendanceEntity> updateWrapper = Wrappers.<AttendanceEntity>lambdaQuery()
-				.eq(AttendanceEntity::getTechnicianId, attendance.getTechnicianId())
+				.eq(AttendanceEntity::getUnicode, attendance.getUnicode())
 				.eq(AttendanceEntity::getWorkDate, attendance.getWorkDate());
 			affectNum = baseMapper.update(attendance, updateWrapper);
 		}
@@ -107,18 +107,18 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 		List<AttendanceEntity> dbList = baseMapper.selectByYearAndMonth(yearAndMonth);
 		for (AttendanceMonthlyExcel record : records) {
 			//保存
-			Long technicianId = technicianMapper.selectPrimaryKeyByNumberOrIdentityCard(record.getNumber(), record.getIdCard());
-			if (technicianId == null) {
+			String unicode = technicianMapper.getUnicodeByNumberAndIdentityCard(record.getNumber(), record.getIdCard());
+			if (unicode == null) {
 				throw new ServiceException("序号为[" + record.getSerialNumber() + "]的工号和者身份证都不存在");
 			}
-			List<AttendanceEntity> dataByTechnicianMonthly = dbList.stream().filter(e -> e.getTechnicianId().equals(technicianId)).toList();
+			List<AttendanceEntity> dataByTechnicianMonthly = dbList.stream().filter(e -> e.getUnicode().equals(unicode)).toList();
 			for (DailyAttendance dailyAttendance : record.getDailyAttendances()) {
 
 				List<Long> primaryKeyList = dataByTechnicianMonthly.stream().filter(e -> Objects.equals(e.getWorkDate(), dailyAttendance.getWorkDate())).map(AttendanceEntity::getId).toList();
 				Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
 				AttendanceEntity entity = new AttendanceEntity();
 				if (primaryKey == null) {
-					entity.setTechnicianId(technicianId);
+					entity.setUnicode(unicode);
 					entity.setWorkDate(dailyAttendance.getWorkDate());
 					entity.setWorkHours(dailyAttendance.getWorkHours());
 					entity.setTenantId(SecureUtil.getTenantId());
@@ -156,7 +156,7 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 	@Override
 	public boolean batchSubmit(AttendanceDto attendance) {
 		List<AttendanceEntity> dbList = baseMapper.selectByYearAndMonth(attendance.getYearAndMonth());
-		List<AttendanceEntity> dataByTechnicianMonthly = dbList.stream().filter(e -> e.getTechnicianId().equals(attendance.getTechnicianId())).toList();
+		List<AttendanceEntity> dataByTechnicianMonthly = dbList.stream().filter(e -> e.getUnicode().equals(attendance.getUnicode())).toList();
 
 		//需要新增的,以便后续批量新增
 		List<AttendanceEntity> insertList = new ArrayList<>();
@@ -169,7 +169,7 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 			Long primaryKey = CollectionUtil.isEmpty(primaryKeyList) ? null : primaryKeyList.get(0);
 			AttendanceEntity entity = new AttendanceEntity();
 			if (primaryKey == null) {
-				entity.setTechnicianId(attendance.getTechnicianId());
+				entity.setUnicode(attendance.getUnicode());
 				entity.setWorkDate(dailyAttendance.getWorkDate());
 				entity.setWorkHours(dailyAttendance.getWorkHours());
 				entity.setTenantId(SecureUtil.getTenantId());
@@ -194,4 +194,16 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 		}
 		return true;
 	}
+
+	@Override
+	public boolean clearAttendance(List<AttendanceDto> attendanceList) {
+		if(CollectionUtil.isEmpty(attendanceList)){
+			throw new ServiceException("参数不能为空");
+		}
+		int affectNum = 0;
+		for (AttendanceDto entity : attendanceList) {
+			affectNum += baseMapper.clearUnicodeAndMonthly(entity.getUnicode(), entity.getYearAndMonth());
+		}
+		return affectNum > 0;
+	}
 }

+ 14 - 16
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/SalaryServiceImpl.java

@@ -122,7 +122,7 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 		boolean result = false;
 		//根据number、identityId、yearAndMonth查询工资数据,
 		LambdaQueryWrapper<SalaryEntity> queryWrapper = Wrappers.<SalaryEntity>lambdaQuery()
-			.eq(SalaryEntity::getTechnicianId, salary.getTechnicianId())
+			.eq(SalaryEntity::getUnicode, salary.getUnicode())
 			.eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth());
 		if (baseMapper.selectCount(queryWrapper) == 1) {
 			//存在,则修改
@@ -170,9 +170,9 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 	@Override
 	public boolean clearSalary(List<SalaryEntity> salaryList) {
 		Integer affectNum = 0;
-		//根据number、identityId、yearAndMonth删除工资数据
+		//根据unicode、yearAndMonth工资数据
 		for (SalaryEntity salary : salaryList) {
-			affectNum += baseMapper.deleteSalary(salary);
+			affectNum += baseMapper.clearSalary(salary);
 		}
 		return true;
 	}
@@ -184,20 +184,20 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 		if(CollectionUtil.isEmpty(list)){
 			throw new ServiceException("该月份无实际参研人员");
 		}
-		List<Long> technicianIds = list.stream().map(XmTechnicianEntity::getTechnicianId).toList();
+		List<String> unicodeList = list.stream().map(XmTechnicianEntity::getUnicode).distinct().toList();
 		//yearAndMonth已有工资数据的研发人员
 		List<SalaryEntity> salaryEntities = baseMapper.selectList(Wrappers.<SalaryEntity>lambdaQuery().eq(SalaryEntity::getYearAndMonth, yearAndMonth));
-		List<Long> dbTechnicianIds = null;
+		List<String> dbUnicodeList = null;
 		if(CollectionUtil.isNotEmpty(salaryEntities)){
-			dbTechnicianIds = salaryEntities.stream().map(SalaryEntity::getTechnicianId).toList();
-			List<Long> finalDbTechnicianIds = dbTechnicianIds;
-			technicianIds = technicianIds.stream().filter(n -> !finalDbTechnicianIds.contains(n)).toList();
+			dbUnicodeList = salaryEntities.stream().map(SalaryEntity::getUnicode).toList();
+			List<String> finalDbUnicodeList = dbUnicodeList;
+			unicodeList = unicodeList.stream().filter(n -> !finalDbUnicodeList.contains(n)).toList();
 		}
 
 		List<SalaryEntity> insertList = new ArrayList<>();
-		for (Long technicianId : technicianIds) {
+		for (String unicode : unicodeList) {
 			SalaryEntity salary = new SalaryEntity();
-			salary.setTechnicianId(technicianId);
+			salary.setUnicode(unicode);
 			salary.setYearAndMonth(yearAndMonth);
 			insertList.add(salary);
 		}
@@ -220,7 +220,7 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 		if(CollectionUtil.isEmpty(technicianByYearMonth)){
 			throw new ServiceException(yearAndMonth+"实际参研人员名单为空");
 		}
-		List<Long> technicianIds = technicianByYearMonth.stream().map(XmTechnicianEntity::getTechnicianId).toList();
+		List<String> unicodeList = technicianByYearMonth.stream().map(XmTechnicianEntity::getUnicode).toList();
 
 		for (SalaryExcel excel : data) {
 			if(StringUtil.isAllBlank(excel.getNumber(), excel.getIdCard())){
@@ -236,22 +236,20 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 			}
 
 			//非本月实际参研人员,提示“某某非本月实际参研人员,请核对数据”
-			if(!technicianIds.contains(dbTechnician.getId())){
+			if(!unicodeList.contains(dbTechnician.getUnicode())){
 				String tips = StringUtil.isNoneBlank(excel.getNumber())?excel.getNumber()+","+excel.getIdCard():excel.getIdCard();
 				throw new ServiceException("人员["+tips+"]非本月实际参研人员,请核对数据");
 			}
 
 			LambdaQueryWrapper<SalaryEntity> queryWrapper = Wrappers.<SalaryEntity>lambdaQuery()
 				.eq(SalaryEntity::getYearAndMonth, yearAndMonth)
-				.eq(SalaryEntity::getTechnicianId, dbTechnician.getId());
+				.eq(SalaryEntity::getUnicode, dbTechnician.getUnicode());
 			if(baseMapper.selectCount(queryWrapper) > 0){
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工资数据已存在, 导入失败");
 			}
 
-
-
 			SalaryEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, SalaryDTO.class));
-			entity.setTechnicianId(dbTechnician.getId());
+			entity.setUnicode(dbTechnician.getUnicode());
 			entity.setYearAndMonth(yearAndMonth);
 			this.save(entity);
 		}

+ 35 - 17
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/TechnicianServiceImpl.java

@@ -8,6 +8,8 @@ import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.sky.core.log.exception.ServiceException;
 import org.sky.core.mp.base.BaseServiceImpl;
+import org.sky.core.mp.support.Condition;
+import org.sky.core.mp.support.Query;
 import org.sky.core.secure.utils.SecureUtil;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.CollectionUtil;
@@ -23,19 +25,16 @@ import org.sky.scientific.pojo.dto.XmTechnicianDto;
 import org.sky.scientific.pojo.entity.TechnicianEntity;
 import org.sky.scientific.pojo.entity.XmEntity;
 import org.sky.scientific.pojo.entity.XmTechnicianEntity;
-import org.sky.scientific.pojo.entity.YsRyrgfyEntity;
 import org.sky.scientific.pojo.vo.TechnicianVO;
 import org.sky.scientific.pojo.vo.XmTechnicianSummary;
+import org.sky.scientific.pojo.vo.YsRyrgfyVO;
 import org.sky.scientific.service.ITechnicianService;
 import org.sky.system.cache.DictCache;
 import org.sky.system.pojo.enums.DictEnum;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * 技术人员花名册 服务实现类
@@ -57,13 +56,17 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 	@Override
 	public boolean saveOrUpdateTechnician(TechnicianEntity technician) {
 		if (StringUtil.isBlank(technician.getYearAndMonth())) {
-//			technician.setYearAndMonth(DateUtil.format(DateUtil.now(), DateUtil.PATTERN_YYYYMM));
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		if (StringUtil.isBlank(technician.getNumber()) && StringUtil.isBlank(technician.getIdCard())) {
 			throw new ServiceException("工号和身份证号码不能同时为空");
 		}
 
+		String unicode = baseMapper.getUnicodeByNumberAndIdentityCard(technician.getNumber(), technician.getIdCard());
+		if (unicode == null){
+			unicode = UUID.randomUUID().toString();
+		}
+		technician.setUnicode(unicode);
 		//根据年月和工号或身份证
 		LambdaQueryWrapper<TechnicianEntity> wrapper = Wrappers.<TechnicianEntity>lambdaQuery()
 			.eq(TechnicianEntity::getYearAndMonth, technician.getYearAndMonth())
@@ -161,29 +164,36 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 				.eq(XmTechnicianEntity::getYearAndMonth, DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM));
 			List<XmTechnicianEntity> lastMonthTechnicianList = xmTechnicianMapper.selectList(wrapper);
 			//若无数据,则引入预算表的人员人工费用
-			List<Long> technicianIds = null;
+			List<String> unicodeList = null;
 			if (CollectionUtil.isEmpty(lastMonthTechnicianList)) {
-				List<YsRyrgfyEntity> ysRyrgfyList = ysRyrgfyMapper.selectList(Wrappers.<YsRyrgfyEntity>lambdaQuery().eq(YsRyrgfyEntity::getXmId, xm.getId()));
-				technicianIds = ysRyrgfyList.stream().map(YsRyrgfyEntity::getTechnicianId).toList();
+				Query query = new Query();
+				query.setCurrent(1);
+				query.setSize(Integer.MAX_VALUE);
+
+				YsRyrgfyVO vo = new YsRyrgfyVO();
+				vo.setXmId(xm.getId());
+
+				List<YsRyrgfyVO> ysRyrgfyList = ysRyrgfyMapper.selectYsRyrgfyPage(Condition.getPage(query), vo);
+				unicodeList = ysRyrgfyList.stream().map(YsRyrgfyVO::getUnicode).toList();
 			} else {
-				technicianIds = lastMonthTechnicianList.stream().map(XmTechnicianEntity::getTechnicianId).toList();
+				unicodeList = lastMonthTechnicianList.stream().map(XmTechnicianEntity::getUnicode).toList();
 			}
-			insertXmTechnician(technicianIds, xm.getId(), yearAndMonth);
+			insertXmTechnician(unicodeList, xm.getId(), yearAndMonth);
 		}
 	}
 
-	private void insertXmTechnician(List<Long> technicianIdList, Long xmId, String yearAndMonth) {
-		for (Long technicianId : technicianIdList) {
+	private void insertXmTechnician(List<String> unicodeList, Long xmId, String yearAndMonth) {
+		for (String unicode : unicodeList) {
 			XmTechnicianEntity monthlyEntity = new XmTechnicianEntity();
 			monthlyEntity.setXmId(xmId);
-			monthlyEntity.setTechnicianId(technicianId);
+			monthlyEntity.setUnicode(unicode);
 			monthlyEntity.setYearAndMonth(yearAndMonth);
 			monthlyEntity.setCreateUser(SecureUtil.getUserId());
 			monthlyEntity.setUpdateUser(SecureUtil.getUserId());
 
 			LambdaQueryWrapper<XmTechnicianEntity> queryWrapper = Wrappers.<XmTechnicianEntity>lambdaQuery().
 				eq(XmTechnicianEntity::getYearAndMonth, yearAndMonth).
-				eq(XmTechnicianEntity::getTechnicianId, technicianId).
+				eq(XmTechnicianEntity::getUnicode, unicode).
 				eq(XmTechnicianEntity::getXmId, xmId);
 			if (xmTechnicianMapper.selectCount(queryWrapper) == 0) {
 				xmTechnicianMapper.insert(monthlyEntity);
@@ -206,7 +216,7 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 		entity.setTenantId(SecureUtil.getTenantId());
 		LambdaQueryWrapper<XmTechnicianEntity> wrapper = Wrappers.<XmTechnicianEntity>lambdaQuery().
 			eq(XmTechnicianEntity::getYearAndMonth, entity.getYearAndMonth()).
-			eq(XmTechnicianEntity::getTechnicianId, entity.getTechnicianId()).
+			eq(XmTechnicianEntity::getUnicode, entity.getUnicode()).
 			eq(XmTechnicianEntity::getXmId, entity.getXmId());
 		if (xmTechnicianMapper.selectCount(wrapper) == 0) {
 			affectNum = xmTechnicianMapper.insert(entity);
@@ -257,7 +267,15 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 
 	@Override
 	public IPage<XmTechnicianSummary> xiangmucanyanrenyuanhuizongbiao(IPage<XmTechnicianSummary> page, XmTechnicianEntity entity) {
-		List<XmTechnicianSummary> summary = xmTechnicianMapper.xmTechnicianSummary(page, entity);
+		if (StringUtil.isAllBlank(entity.getYearAndMonth())) {
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		List<XmTechnicianSummary> summary = null;
+		if (entity.getYearAndMonth().length() == 6) {
+			summary = xmTechnicianMapper.xmTechnicianSummaryByMonthly(page, entity);
+		}else {
+			summary = xmTechnicianMapper.xmTechnicianSummaryByYear(page, entity);
+		}
 		return page.setRecords(summary);
 	}
 }

+ 4 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmServiceImpl.java

@@ -89,7 +89,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 
 		if (xm.getXmyszemx() != null) {
 			List<JSONObject> list = JSONObject.parseArray(xm.getXmyszemx(), JSONObject.class);
-			if(CollectionUtil.isNotEmpty(list)){
+			if (CollectionUtil.isNotEmpty(list)) {
 				double total = list.stream().mapToDouble(t -> t.getDouble("amount")).sum();
 				if (total != xm.getXmysze().doubleValue()) {
 					throw new ServiceException("项目预算总额明细不对");
@@ -104,7 +104,9 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
 	public IPage<XmSummary> summaryPage(IPage<XmSummary> page, XmDTO xm) {
 		List<XmSummary> xmList = baseMapper.summaryPage(page, xm);
 		for (XmSummary xmVO : xmList) {
-			xmVO.setXmfzrxm(technicianMapper.selectById(xmVO.getXmfzr()).getName());
+			if (xmVO.getXmfzr() != null) {
+				xmVO.setXmfzrxm(technicianMapper.selectById(xmVO.getXmfzr()).getName());
+			}
 			//立项报告
 			xmVO.setLxbgList(null);
 			//阶段性报告

+ 6 - 5
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/YsRyrgfyServiceImpl.java

@@ -1,20 +1,21 @@
 
 package org.sky.scientific.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.sky.core.log.exception.ServiceException;
+import org.sky.core.mp.base.BaseServiceImpl;
+import org.sky.scientific.excel.YsRyrgfyExcel;
 import org.sky.scientific.mapper.TechnicianMapper;
+import org.sky.scientific.mapper.YsRyrgfyMapper;
 import org.sky.scientific.pojo.entity.TechnicianEntity;
 import org.sky.scientific.pojo.entity.YsRyrgfyEntity;
 import org.sky.scientific.pojo.vo.YsRyrgfyVO;
-import org.sky.scientific.excel.YsRyrgfyExcel;
-import org.sky.scientific.mapper.YsRyrgfyMapper;
 import org.sky.scientific.service.IYsRyrgfyService;
 import org.springframework.stereotype.Service;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.sky.core.mp.base.BaseServiceImpl;
+
 import java.util.List;
 
 /**