zhoulisky 11 months ago
parent
commit
b0ce48368b

File diff suppressed because it is too large
+ 5393 - 0
doc/sql/kd_dev.sql


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

@@ -4,6 +4,7 @@ package org.sky.scientific.pojo.dto;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import org.sky.core.tool.utils.DateUtil;
+import org.sky.scientific.pojo.entity.TechnicianDetailEntity;
 import org.sky.scientific.pojo.entity.TechnicianEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -20,7 +21,7 @@ import java.util.Date;
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
-public class TechnicianDTO extends TechnicianEntity {
+public class TechnicianDTO extends TechnicianDetailEntity {
 	@Serial
 	private static final long serialVersionUID = 1L;
 

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

@@ -0,0 +1,100 @@
+
+package org.sky.scientific.pojo.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.sky.core.mp.base.BaseEntity;
+import org.sky.core.tenant.mp.TenantEntity;
+
+import java.io.Serial;
+import java.time.LocalDate;
+import java.util.Date;
+
+/**
+ * 技术人员花名册 实体类
+ *
+ * @author Kd
+ * @since 2025-06-11
+ */
+@Data
+@TableName("kd_technician_detail")
+@Schema(description = "Technician对象")
+@EqualsAndHashCode(callSuper = true)
+public class TechnicianDetailEntity extends TechnicianEntity {
+
+	@Serial
+	private static final long serialVersionUID = 1L;
+
+
+//	@Schema(description = "姓名")
+//	private String name;
+//
+//	@Schema(description = "工号")
+//	private String number;
+//
+//	@Schema(description = "身份证号码")
+//	private String identityCard;
+
+	private Long technicianId;
+
+	@Schema(description = "性别,1:男,2:女")
+	private Integer gender;
+
+	@Schema(description = "出生日期")
+	private LocalDate birthday;
+
+	@Schema(description = "民族")
+	private String ethnic;
+
+	@Schema(description = "所属二级单位")
+	private String secondaryUnit;
+
+	@Schema(description = "部门/科室/项目部")
+	private String department;
+
+	@Schema(description = "岗位职务")
+	private String post;
+
+	@Schema(description = "岗位所在地")
+	private String postLocation;
+
+	@Schema(description = "用工性质")
+	private String nature;
+
+	@Schema(description = "入职时间")
+	private Date hireDate;
+
+	@Schema(description = "最高学历")
+	private String education;
+
+	@Schema(description = "最高学位")
+	private String degree;
+
+	@Schema(description = "最高学历学校")
+	private String schoolName;
+
+	@Schema(description = "最高学历专业名称")
+	private String major;
+
+	@Schema(description = "职称")
+	private String rank;
+
+	@Schema(description = "执业资格")
+	private String practicingRequirement;
+
+	@Schema(description = "参研情况")
+	private String situation;
+
+	@Schema(description = "人员类型")
+	private String personnelType;
+
+	@Schema(description = "所属年月")
+	private String yearAndMonth;
+
+	@Schema(description = "情况说明")
+	private String remark;
+
+}

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

@@ -1,6 +1,7 @@
 
 package org.sky.scientific.pojo.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import io.swagger.v3.oas.annotations.media.Schema;
@@ -33,109 +34,19 @@ public class TechnicianEntity extends TenantEntity {
 	 * 姓名
 	 */
 	@Schema(description = "姓名")
+	@TableField("name")
 	private String name;
 	/**
 	 * 工号
 	 */
 	@Schema(description = "工号")
+	@TableField("number")
 	private String number;
 	/**
 	 * 身份证号码
 	 */
 	@Schema(description = "身份证号码")
+	@TableField("identity_card")
 	private String identityCard;
-	/**
-	 * 性别,1:男,2:女
-	 */
-	@Schema(description = "性别,1:男,2:女")
-	private Integer gender;
-	/**
-	 * 出生日期
-	 */
-	@Schema(description = "出生日期")
-	private LocalDate birthday;
-	/**
-	 * 民族
-	 */
-	@Schema(description = "民族")
-	private String ethnic;
-	/**
-	 * 所属二级单位
-	 */
-	@Schema(description = "所属二级单位")
-	private String secondaryUnit;
-	/**
-	 * 部门/科室/项目部
-	 */
-	@Schema(description = "部门/科室/项目部")
-	private String department;
-	/**
-	 * 岗位职务
-	 */
-	@Schema(description = "岗位职务")
-	private String post;
-	/**
-	 * 岗位所在地
-	 */
-	@Schema(description = "岗位所在地")
-	private String postLocation;
-	/**
-	 * 用工性质
-	 */
-	@Schema(description = "用工性质")
-	private String nature;
-	/**
-	 * 入职时间
-	 */
-	@Schema(description = "入职时间")
-	private Date hireDate;
-	/**
-	 * 最高学历
-	 */
-	@Schema(description = "最高学历")
-	private String education;
-	/**
-	 * 最高学位
-	 */
-	@Schema(description = "最高学位")
-	private String degree;
-	/**
-	 * 最高学历学校
-	 */
-	@Schema(description = "最高学历学校")
-	private String schoolName;
-	/**
-	 * 最高学历专业名称
-	 */
-	@Schema(description = "最高学历专业名称")
-	private String major;
-	/**
-	 * 职称
-	 */
-	@Schema(description = "职称")
-	private String rank;
-	/**
-	 * 执业资格
-	 */
-	@Schema(description = "执业资格")
-	private String practicingRequirement;
-	/**
-	 * 参研情况
-	 */
-	@Schema(description = "参研情况")
-	private String situation;
-	/**
-	 * 人员类型
-	 */
-	@Schema(description = "人员类型")
-	private String personnelType;
-	/**
-	 * 所属年月
-	 */
-	@Schema(description = "所属年月")
-	private String yearAndMonth;
-
-	@Schema(description = "情况说明")
-	private String remark;
 
 }

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

@@ -16,6 +16,8 @@ import org.sky.core.secure.annotation.IsAdmin;
 import org.sky.core.tool.api.R;
 import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.Func;
+import org.sky.scientific.pojo.dto.SalaryDTO;
+import org.sky.scientific.pojo.dto.TechnicianDTO;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -123,4 +125,11 @@ public class SalaryController extends KdController {
 		ExcelUtil.export(response, "技术人员工资表数据" + DateUtil.time(), "技术人员工资表数据表", list, SalaryExcel.class);
 	}
 
+	@GetMapping("/fetchLastYearData")
+	@ApiOperationSupport(order = 10)
+	@Operation(summary = "读取上年度工资明细", description = "传入选中的年,比如2025")
+	public R<Boolean> fetchLastYearData(SalaryDTO salary) {
+		return R.status(salaryService.fetchLastYearData(salary));
+	}
+
 }

+ 44 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianDetailMapper.java

@@ -0,0 +1,44 @@
+
+package org.sky.scientific.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.sky.core.tenant.annotation.TenantIgnore;
+import org.sky.scientific.excel.TechnicianExcel;
+import org.sky.scientific.pojo.dto.TechnicianDTO;
+import org.sky.scientific.pojo.entity.TechnicianDetailEntity;
+import org.sky.scientific.pojo.entity.TechnicianEntity;
+import org.sky.scientific.pojo.vo.TechnicianVO;
+
+import java.util.List;
+
+/**
+ * 技术人员花名册 Mapper 接口
+ *
+ * @author Kd
+ * @since 2025-06-11
+ */
+public interface TechnicianDetailMapper extends BaseMapper<TechnicianDetailEntity> {
+
+//	/**
+//	 * 自定义分页
+//	 *
+//	 * @param page 分页参数
+//	 * @param technician 查询参数
+//	 * @return List<TechnicianVO>
+//	 */
+	@TenantIgnore
+	List<TechnicianVO> selectTechnicianPage(IPage page, TechnicianDTO technician);
+//
+//	List<TechnicianExcel> exportTechnicianList(@Param("technician") TechnicianDTO technician);
+//
+//
+//	Integer countByDateAndNumberOrIdentityCard(TechnicianEntity technician);
+//
+//	Long countByNumberAndIdentifyCard(String number, String identityCard);
+//
+//	List<TechnicianEntity> selectByYearAndMonth(String yearAndMonth);
+//
+//	Long saveTechnician(TechnicianEntity technician);
+}

+ 156 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianDetailMapper.xml

@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.sky.scientific.mapper.TechnicianDetailMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="technicianResultMap" type="org.sky.scientific.pojo.entity.TechnicianDetailEntity">
+        <result column="id" property="id"/>
+        <result column="tenant_id" property="tenantId"/>
+        <result column="name" property="name"/>
+        <result column="number" property="number"/>
+        <result column="identity_card" property="identityCard"/>
+        <result column="gender" property="gender"/>
+        <result column="birthday" property="birthday"/>
+        <result column="ethnic" property="ethnic"/>
+        <result column="secondary_unit" property="secondaryUnit"/>
+        <result column="department" property="department"/>
+        <result column="post" property="post"/>
+        <result column="post_location" property="postLocation"/>
+        <result column="nature" property="nature"/>
+        <result column="hire_date" property="hireDate"/>
+        <result column="education" property="education"/>
+        <result column="degree" property="degree"/>
+        <result column="school_name" property="schoolName"/>
+        <result column="major" property="major"/>
+        <result column="rank" property="rank"/>
+        <result column="practicing_requirement" property="practicingRequirement"/>
+        <result column="situation" property="situation"/>
+        <result column="personnel_type" property="personnelType"/>
+        <result column="year_and_month" property="yearAndMonth"/>
+        <result column="remark" property="remark"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+    </resultMap>
+
+<!--    <sql id="ba"-->
+
+    <select id="selectTechnicianPage" resultMap="technicianResultMap" parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">
+        select t1.name,t1.number,t1.identity_card,t2.*
+        from kd_technician t1
+        left join kd_technician_detail t2 on t1.id = t2.technician_id
+        <if test="technician.yearAndMonth.length()==4">
+            INNER JOIN
+            (
+            SELECT technician_id,MAX( year_and_month ) AS max_month
+            FROM kd_technician_detail
+            WHERE LEFT ( year_and_month, 4 ) = #{technician.yearAndMonth} AND is_deleted = 0
+            GROUP BY technician_id
+            ) t3
+            ON t1.id = t3.technician_id and t2.year_and_month = t3.max_month
+        </if>
+        where t1.is_deleted = 0
+          <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.identityCard!=null and technician.identityCard!=''">and identity_card like concat(concat('%', #{technician.identityCard}), '%')</if>
+          <if test="technician.secondaryUnit!=null and technician.secondaryUnit!=''">and secondary_unit like concat(concat('%', #{technician.secondaryUnit}), '%')</if>
+          <if test="technician.department!=null and technician.department!=''">and department like concat(concat('%', #{technician.department}), '%')</if>
+          <if test="technician.post!=null and technician.post!=''">and post like concat(concat('%', #{technician.post}), '%')</if>
+          <if test="technician.postLocation!=null and technician.postLocation!=''">and post_location like concat(concat('%', #{technician.postLocation}), '%')</if>
+          <if test="technician.nature!=null and technician.nature!=''">and nature = #{technician.nature}</if>
+          <if test="technician.education!=null and technician.education!=''">and education = #{technician.education}</if>
+          <if test="technician.degree!=null and technician.degree!=''">and degree = #{technician.degree}</if>
+          <if test="technician.rank!=null and technician.rank!=''">and rank = #{technician.rank}</if>
+          <if test="technician.personnelType!=null and technician.personnelType!=''">and personnel_type = #{technician.personnelType}</if>
+          <if test="technician.situation !=null and technician.situation!=''">and situation = #{technician.situation}</if>
+          <if test="technician.practicingRequirement !=null and technician.practicingRequirement!=''">and practicing_requirement like concat(concat('%', #{technician.practicingRequirement}), '%')</if>
+          <if test="technician.hireStartDate!=null and technician.hireEndDate!=''">and hire_Date between #{technician.hireStartDate} and #{technician.hireEndDate}</if>
+          <choose>
+              <when test="technician.yearAndMonth.length()==4">
+                  and LEFT ( year_and_month, 4 ) = #{technician.yearAndMonth}
+              </when>
+              <otherwise>
+                  and LEFT ( year_and_month, 6 ) = #{technician.yearAndMonth}
+              </otherwise>
+          </choose>
+        order by year_and_month asc, t2.id asc
+    </select>
+
+<!--    <select id="exportTechnicianList" resultType="org.sky.scientific.excel.TechnicianExcel" parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">-->
+<!--        select t1.*-->
+<!--        from kd_technician t1-->
+<!--        <if test="technician.yearAndMonth.length()==4">-->
+<!--            INNER JOIN-->
+<!--            (-->
+<!--            SELECT number, identity_card, 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, identity_card-->
+<!--            ) t2-->
+<!--            ON t1.number = t2.number  AND t1.identity_card = t2.identity_card AND t1.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}), '%')</if>-->
+<!--        <if test="technician.number!=null and technician.number!=''">and name like concat(concat('%', #{technician.number}), '%')</if>-->
+<!--        <if test="technician.identityCard!=null and technician.identityCard!=''">and identity_card like concat(concat('%', #{technician.identityCard}), '%')</if>-->
+<!--        <if test="technician.secondaryUnit!=null and technician.secondaryUnit!=''">and secondary_unit like concat(concat('%', #{technician.secondaryUnit}), '%')</if>-->
+<!--        <if test="technician.department!=null and technician.department!=''">and department like concat(concat('%', #{technician.department}), '%')</if>-->
+<!--        <if test="technician.post!=null and technician.post!=''">and post like concat(concat('%', #{technician.post}), '%')</if>-->
+<!--        <if test="technician.postLocation!=null and technician.postLocation!=''">and post_location like concat(concat('%', #{technician.postLocation}), '%')</if>-->
+<!--        <if test="technician.nature!=null and technician.nature!=''">and nature = #{technician.nature}</if>-->
+<!--        <if test="technician.education!=null and technician.education!=''">and education = #{technician.education}</if>-->
+<!--        <if test="technician.degree!=null and technician.degree!=''">and degree = #{technician.degree}</if>-->
+<!--        <if test="technician.rank!=null and technician.rank!=''">and rank = #{technician.rank}</if>-->
+<!--        <if test="technician.personnelType!=null and technician.personnelType!=''">and personnel_type = #{technician.personnelType}</if>-->
+<!--        <if test="technician.situation !=null and technician.situation!=''">and situation = #{technician.situation}</if>-->
+<!--        <if test="technician.practicingRequirement !=null and technician.practicingRequirement!=''">and practicing_requirement like concat(concat('%', #{technician.practicingRequirement}), '%')</if>-->
+<!--        <if test="technician.hireStartDate!=null and technician.hireEndDate!=''">and hire_Date between #{technician.hireStartDate} and #{technician.hireEndDate}</if>-->
+<!--        <choose>-->
+<!--            <when test="technician.yearAndMonth.length()==4">-->
+<!--                and LEFT ( t1.year_and_month, 4 ) = #{technician.yearAndMonth}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and LEFT ( t1.year_and_month, 7 ) = #{technician.yearAndMonth}-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        order by year_and_month asc, id asc-->
+<!--    </select>-->
+
+<!--    <select id="selectByYearAndMonth">-->
+<!--        select * from kd_technician-->
+<!--        where is_deleted = 0 and LEFT(year_and_month,6) = #{yearAndMonth}-->
+
+<!--    </select>-->
+
+<!--    <select id="exportTechnician" resultType="org.sky.scientific.excel.TechnicianExcel">-->
+<!--        SELECT *-->
+<!--        FROM kd_technician ${ew.customSqlSegment}-->
+<!--    </select>-->
+
+<!--    <select id="countByDateAndNumberOrIdentityCard" parameterType="org.sky.scientific.pojo.entity.TechnicianEntity">-->
+<!--        select count(*)-->
+<!--        from kd_technician t-->
+<!--        left join kd_technician_detail d on d.technician_id = t.id-->
+<!--        where d.is_deleted = 0-->
+<!--        <choose>-->
+<!--            <when test="yearAndMonth.length()==4">-->
+<!--                and LEFT(year_and_month,4) = #{yearAndMonth}-->
+<!--            </when>-->
+<!--            <otherwise>-->
+<!--                and LEFT(year_and_month,6) = #{yearAndMonth}-->
+<!--            </otherwise>-->
+<!--        </choose>-->
+<!--        and (number = #{number} or identity_card = #{identityCard})-->
+<!--    </select>-->
+
+<!--    <select id="countByNumberAndIdentifyCard" resultType="java.lang.Long">-->
+<!--        select id-->
+<!--        from kd_technician-->
+<!--        where number = #{number} or identity_card = #{identityCard}-->
+<!--        and is_deleted = 0-->
+<!--    </select>-->
+</mapper>

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

@@ -31,8 +31,11 @@ public interface TechnicianMapper extends BaseMapper<TechnicianEntity> {
 	List<TechnicianExcel> exportTechnicianList(@Param("technician") TechnicianDTO technician);
 
 
-	Integer countByDateAndNumberOrIdentityCard(TechnicianEntity technician);
+//	Integer countByDateAndNumberOrIdentityCard(TechnicianEntity technician);
 
-	List<TechnicianEntity> selectByYearAndMonth(String yearAndMonth);
+//	Long countByNumberAndIdentifyCard(String number, String identityCard);
 
+//	List<TechnicianEntity> selectByYearAndMonth(String yearAndMonth);
+
+//	Long saveTechnician(TechnicianEntity technician);
 }

+ 29 - 21
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/TechnicianMapper.xml

@@ -9,25 +9,25 @@
         <result column="name" property="name"/>
         <result column="number" property="number"/>
         <result column="identity_card" property="identityCard"/>
-        <result column="gender" property="gender"/>
-        <result column="birthday" property="birthday"/>
-        <result column="ethnic" property="ethnic"/>
-        <result column="secondary_unit" property="secondaryUnit"/>
-        <result column="department" property="department"/>
-        <result column="post" property="post"/>
-        <result column="post_location" property="postLocation"/>
-        <result column="nature" property="nature"/>
-        <result column="hire_date" property="hireDate"/>
-        <result column="education" property="education"/>
-        <result column="degree" property="degree"/>
-        <result column="school_name" property="schoolName"/>
-        <result column="major" property="major"/>
-        <result column="rank" property="rank"/>
-        <result column="practicing_requirement" property="practicingRequirement"/>
-        <result column="situation" property="situation"/>
-        <result column="personnel_type" property="personnelType"/>
-        <result column="year_and_month" property="yearAndMonth"/>
-        <result column="remark" property="remark"/>
+<!--        <result column="gender" property="gender"/>-->
+<!--        <result column="birthday" property="birthday"/>-->
+<!--        <result column="ethnic" property="ethnic"/>-->
+<!--        <result column="secondary_unit" property="secondaryUnit"/>-->
+<!--        <result column="department" property="department"/>-->
+<!--        <result column="post" property="post"/>-->
+<!--        <result column="post_location" property="postLocation"/>-->
+<!--        <result column="nature" property="nature"/>-->
+<!--        <result column="hire_date" property="hireDate"/>-->
+<!--        <result column="education" property="education"/>-->
+<!--        <result column="degree" property="degree"/>-->
+<!--        <result column="school_name" property="schoolName"/>-->
+<!--        <result column="major" property="major"/>-->
+<!--        <result column="rank" property="rank"/>-->
+<!--        <result column="practicing_requirement" property="practicingRequirement"/>-->
+<!--        <result column="situation" property="situation"/>-->
+<!--        <result column="personnel_type" property="personnelType"/>-->
+<!--        <result column="year_and_month" property="yearAndMonth"/>-->
+<!--        <result column="remark" property="remark"/>-->
         <result column="create_user" property="createUser"/>
         <result column="create_dept" property="createDept"/>
         <result column="create_time" property="createTime"/>
@@ -38,6 +38,7 @@
     </resultMap>
 
 
+
     <select id="selectTechnicianPage" resultMap="technicianResultMap" parameterType="org.sky.scientific.pojo.dto.TechnicianDTO">
         select t1.*
         from kd_technician t1
@@ -131,8 +132,9 @@
 
     <select id="countByDateAndNumberOrIdentityCard" parameterType="org.sky.scientific.pojo.entity.TechnicianEntity">
         select count(*)
-        from kd_technician
-        where is_deleted = 0
+        from kd_technician t
+        left join kd_technician_detail d on d.technician_id = t.id
+        where d.is_deleted = 0
         <choose>
             <when test="yearAndMonth.length()==4">
                 and LEFT(year_and_month,4) = #{yearAndMonth}
@@ -144,4 +146,10 @@
         and (number = #{number} or identity_card = #{identityCard})
     </select>
 
+    <select id="countByNumberAndIdentifyCard" resultType="java.lang.Long">
+        select id
+        from kd_technician
+        where number = #{number} or identity_card = #{identityCard}
+        and is_deleted = 0
+    </select>
 </mapper>

+ 8 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/ISalaryService.java

@@ -2,6 +2,7 @@
 package org.sky.scientific.service;
 
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import org.sky.scientific.pojo.dto.SalaryDTO;
 import org.sky.scientific.pojo.entity.SalaryEntity;
 import org.sky.scientific.pojo.vo.SalaryVO;
 import org.sky.scientific.excel.SalaryExcel;
@@ -40,4 +41,11 @@ public interface ISalaryService extends BaseService<SalaryEntity> {
 	 * @return
 	 */
 	boolean saveSalary(SalaryEntity salary);
+
+	/**
+	 *读取上年度工资明细
+	 * @param salary
+	 * @return
+	 */
+	boolean fetchLastYearData(SalaryDTO salary);
 }

+ 49 - 35
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/SalaryServiceImpl.java

@@ -10,6 +10,7 @@ import org.sky.core.secure.utils.AuthUtil;
 import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.mapper.TechnicianMapper;
+import org.sky.scientific.pojo.dto.SalaryDTO;
 import org.sky.scientific.pojo.entity.SalaryEntity;
 import org.sky.scientific.pojo.entity.TechnicianEntity;
 import org.sky.scientific.pojo.vo.SalaryVO;
@@ -65,42 +66,55 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 	public boolean saveSalary(SalaryEntity salary) {
 
 		Integer affectNum = 0;
-		if (StringUtil.isBlank(salary.getYearAndMonth())) {
-			salary.setYearAndMonth(DateUtil.format(DateUtil.now(), "yyyy"));
-		}
-		//从技术人员花名册中根据年份和人员信息,查询人员是否存在
-		TechnicianEntity technician = new TechnicianEntity();
-		technician.setYearAndMonth(salary.getYearAndMonth());
-		technician.setNumber(salary.getNumber());
-		technician.setIdentityCard(salary.getIdentityCard());
-		technician.setTenantId(AuthUtil.getTenantId());
-		Integer countWithTechnician = technicianMapper.countByDateAndNumberOrIdentityCard(technician);
-		//不存在则抛出异常
-		if(countWithTechnician == 0){
-			throw new ServiceException("[" + salary.getYearAndMonth() + "]年度内无人员[" + salary.getName() + "、" + salary.getNumber() + "、" + salary.getIdentityCard() + "]");
-		}else {
-			//存在则根据年份和人员信息查询工资是否存在
-			LambdaQueryWrapper<SalaryEntity> wrapper = Wrappers.<SalaryEntity>query().lambda()
-				.eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
-				.eq(SalaryEntity::getNumber, salary.getNumber())
-				.eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
-				.eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
-				.eq(SalaryEntity::getIsDeleted, 0);
-			//存在则覆盖
-			if (baseMapper.selectCount(wrapper) > 0) {
-				LambdaUpdateWrapper<SalaryEntity> updateWrapper = Wrappers.<SalaryEntity>update().lambda()
-					.eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
-					.eq(SalaryEntity::getNumber, salary.getNumber())
-					.eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
-					.eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
-					.eq(SalaryEntity::getIsDeleted, 0);
-				affectNum = baseMapper.update(salary, updateWrapper);
-			}else {
-				//不存在则新增
-				affectNum = baseMapper.insert(salary);
-			}
-		}
+//		if (StringUtil.isBlank(salary.getYearAndMonth())) {
+//			salary.setYearAndMonth(DateUtil.format(DateUtil.now(), "yyyy"));
+//		}
+//		//从技术人员花名册中根据年份和人员信息,查询人员是否存在
+//		TechnicianEntity technician = new TechnicianEntity();
+//		technician.setYearAndMonth(salary.getYearAndMonth());
+//		technician.setNumber(salary.getNumber());
+//		technician.setIdentityCard(salary.getIdentityCard());
+//		technician.setTenantId(AuthUtil.getTenantId());
+//		Integer countWithTechnician = technicianMapper.countByDateAndNumberOrIdentityCard(technician);
+//		//不存在则抛出异常
+//		if(countWithTechnician == 0){
+//			throw new ServiceException("[" + salary.getYearAndMonth() + "]年度内无人员[" + salary.getName() + "、" + salary.getNumber() + "、" + salary.getIdentityCard() + "]");
+//		}else {
+//			//存在则根据年份和人员信息查询工资是否存在
+//			LambdaQueryWrapper<SalaryEntity> wrapper = Wrappers.<SalaryEntity>query().lambda()
+//				.eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
+//				.eq(SalaryEntity::getNumber, salary.getNumber())
+//				.eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
+//				.eq(SalaryEntity::getTenantId, AuthUtil.getTenantId())
+//				.eq(SalaryEntity::getIsDeleted, 0);
+//			//存在则覆盖
+//			if (baseMapper.selectCount(wrapper) > 0) {
+//				//这里需要和客户确定 是覆盖还是忽略(报错)
+//				LambdaUpdateWrapper<SalaryEntity> updateWrapper = Wrappers.<SalaryEntity>update().lambda()
+//					.eq(SalaryEntity::getYearAndMonth, salary.getYearAndMonth())
+//					.eq(SalaryEntity::getNumber, salary.getNumber())
+//					.eq(SalaryEntity::getIdentityCard, salary.getIdentityCard())
+//					.eq(SalaryEntity::getIsDeleted, 0);
+//				affectNum = baseMapper.update(salary, updateWrapper);
+//			}else {
+//				//不存在则新增
+//				affectNum = baseMapper.insert(salary);
+//			}
+//		}
 		return affectNum > 0;
 	}
 
+	@Override
+	public boolean fetchLastYearData(SalaryDTO salary) {
+//		String lastYear = String.valueOf(Integer.parseInt(salary.getYearAndMonth()) - 1);
+//		List<TechnicianEntity> lastMonthList = this.baseMapper.selectByYearAndMonth(lastDate);
+//		//与本月数据对比,去重后保存至数据库
+//		for (TechnicianEntity temp : lastMonthList) {
+//			temp.setYearAndMonth(technician.getYearAndMonth());
+//			temp.setId(null);
+//			saveTechnician(temp);
+//		}
+		return false;
+	}
+
 }

+ 53 - 22
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/TechnicianServiceImpl.java

@@ -1,15 +1,20 @@
 
 package org.sky.scientific.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import jakarta.annotation.Resource;
 import org.sky.core.log.exception.ServiceException;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.excel.TechnicianExcel;
+import org.sky.scientific.mapper.TechnicianDetailMapper;
 import org.sky.scientific.mapper.TechnicianMapper;
 import org.sky.scientific.pojo.dto.TechnicianDTO;
+import org.sky.scientific.pojo.entity.TechnicianDetailEntity;
 import org.sky.scientific.pojo.entity.TechnicianEntity;
 import org.sky.scientific.pojo.vo.TechnicianVO;
 import org.sky.scientific.service.ITechnicianService;
@@ -30,12 +35,15 @@ import java.util.Objects;
 @Service
 public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, TechnicianEntity> implements ITechnicianService {
 
+	@Resource
+	private TechnicianDetailMapper detailMapper;
+
 	@Override
 	public boolean saveTechnician(TechnicianEntity technician) {
 		//检查重复性
-		check(technician);
-		technician.setYearAndMonth(technician.getYearAndMonth());
-		return this.save(technician);
+//		check(technician);
+//		return this.save(technician);
+		return false;
 	}
 
 	@Override
@@ -45,7 +53,7 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 
 	@Override
 	public IPage<TechnicianVO> selectTechnicianPage(IPage<TechnicianVO> page, TechnicianDTO technician) {
-		return page.setRecords(baseMapper.selectTechnicianPage(page, technician));
+		return page.setRecords(detailMapper.selectTechnicianPage(page, technician));
 	}
 
 
@@ -62,11 +70,34 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 	@Override
 	public void importTechnician(List<TechnicianExcel> data, String yearAndMonth) {
 		for (TechnicianExcel excel : data) {
-			TechnicianEntity technician = Objects.requireNonNull(BeanUtil.copyProperties(excel, TechnicianDTO.class));
+			TechnicianDTO technician = Objects.requireNonNull(BeanUtil.copyProperties(excel, TechnicianDTO.class));
 			//转换 性别字典
 			technician.setGender(Integer.valueOf(DictCache.getKey(DictEnum.SEX, excel.getGenderName())));
 			technician.setYearAndMonth(yearAndMonth);
-			this.saveTechnician(technician);
+			//根据 工号和身份证号 查询是否存在,
+			TechnicianEntity dbTechnician = baseMapper.selectOne(Wrappers.<TechnicianEntity>lambdaQuery().eq(TechnicianEntity::getNumber, excel.getNumber()).eq(TechnicianEntity::getIdentityCard, excel.getIdentityCard()).eq(TechnicianEntity::getIsDeleted, 0));
+			if(dbTechnician == null){
+				//新增花名册主表
+				dbTechnician = new TechnicianEntity();
+				dbTechnician.setName(excel.getName());
+				dbTechnician.setNumber(excel.getNumber());
+				dbTechnician.setIdentityCard(excel.getIdentityCard());
+				baseMapper.insert(dbTechnician);
+			}
+
+			//根据年月、工号、身份证号 新增或覆盖
+			LambdaQueryWrapper<TechnicianDetailEntity> eq = Wrappers.<TechnicianDetailEntity>lambdaQuery().
+				eq(TechnicianDetailEntity::getYearAndMonth, technician.getYearAndMonth()).
+				eq(TechnicianEntity::getNumber, technician.getNumber()).
+				eq(TechnicianEntity::getIdentityCard, technician.getIdentityCard());
+			TechnicianDetailEntity detail = detailMapper.selectOne(eq);
+			if(detail == null){
+				//新增
+				detailMapper.insert(technician);
+			}else {
+				//覆盖
+				detailMapper.updateById(technician);
+			}
 		}
 	}
 
@@ -75,25 +106,25 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 	public boolean fetchLastMonthData(TechnicianEntity technician) {
 		//查询上个月的数据
 		//得到上个月的年月
-		String lastDate = DateUtil.format(DateUtil.minusMonths(DateUtil.parse(technician.getYearAndMonth(), "yyyyMM"), 1), "yyyyMM");
-		List<TechnicianEntity> lastMonthList = this.baseMapper.selectByYearAndMonth(lastDate);
-		//与本月数据对比,去重后保存至数据库
-		for (TechnicianEntity temp : lastMonthList) {
-			temp.setYearAndMonth(technician.getYearAndMonth());
-			temp.setId(null);
-			saveTechnician(temp);
-		}
+//		String lastDate = DateUtil.format(DateUtil.minusMonths(DateUtil.parse(technician.getYearAndMonth(), "yyyyMM"), 1), "yyyyMM");
+//		List<TechnicianEntity> lastMonthList = this.baseMapper.selectByYearAndMonth(lastDate);
+//		//与本月数据对比,去重后保存至数据库
+//		for (TechnicianEntity temp : lastMonthList) {
+//			temp.setYearAndMonth(technician.getYearAndMonth());
+//			temp.setId(null);
+//			saveTechnician(temp);
+//		}
 		return true;
 	}
 
 	private void check(TechnicianEntity technician) {
-		if (StringUtil.isBlank(technician.getYearAndMonth())) {
-			technician.setYearAndMonth(DateUtil.format(DateUtil.now(), "yyyyMM"));
-		}
-		//根据 年月 和工号或身份证 查询是否存在,存在则本次导入所有的数据都不成功
-		Integer count = this.baseMapper.countByDateAndNumberOrIdentityCard(technician);
-		if (count > 0) {
-			throw new ServiceException("导入失败,姓名:[" + technician.getName() + "]已存在,请检查数据");
-		}
+//		if (StringUtil.isBlank(technician.getYearAndMonth())) {
+//			technician.setYearAndMonth(DateUtil.format(DateUtil.now(), "yyyyMM"));
+//		}
+//		//根据 年月 和工号或身份证 查询是否存在,存在则本次导入所有的数据都不成功
+//		Integer count = this.baseMapper.countByDateAndNumberOrIdentityCard(technician);
+//		if (count > 0) {
+//			throw new ServiceException("导入失败,姓名:[" + technician.getName() + "]已存在,请检查数据");
+//		}
 	}
 }