zhouli 10 months ago
parent
commit
770a48c696

+ 1 - 1
kd-service-api/kd-scientific-api/src/main/java/org/sky/scientific/pojo/entity/XmGoodsEntity.java

@@ -34,7 +34,7 @@ public class XmGoodsEntity extends TenantEntity {
 	@Schema(description = "所属年月,如:202505")
 	@Schema(description = "所属年月,如:202505")
 	private String yearAndMonth;
 	private String yearAndMonth;
 
 
-	@Schema(description = "领用日期,如:20250215")
+	@Schema(description = "领用日期,如:2025-02-15")
 	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
 	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
 	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
 	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
 	private Date useDate;
 	private Date useDate;

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
@@ -32,11 +33,13 @@ public class XmLeaseEntity extends TenantEntity {
 	private static final long serialVersionUID = 1L;
 	private static final long serialVersionUID = 1L;
 
 
 	@Schema(description = "所属年月,如:202505")
 	@Schema(description = "所属年月,如:202505")
+	@NotBlank(message = "参数yearAndMonth不能为空")
 	private String yearAndMonth;
 	private String yearAndMonth;
 
 
 	@Schema(description = "租赁日期,如:2025-02-15")
 	@Schema(description = "租赁日期,如:2025-02-15")
 	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
 	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
 	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
 	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
+	@NotNull(message = "请选择租赁日期")
 	private Date leaseDate;
 	private Date leaseDate;
 
 
 	@Schema(description = "研发项目id")
 	@Schema(description = "研发项目id")
@@ -61,9 +64,11 @@ public class XmLeaseEntity extends TenantEntity {
 	private String model;
 	private String model;
 
 
 	@Schema(description = "使用天数或使用量")
 	@Schema(description = "使用天数或使用量")
+	@NotNull(message = "请填写使用天数或使用量")
 	private Integer quantity;
 	private Integer quantity;
 
 
 	@Schema(description = "单价(元)")
 	@Schema(description = "单价(元)")
+	@NotNull(message = "请填写单价")
 	private BigDecimal unitPrice;
 	private BigDecimal unitPrice;
 
 
 	@Schema(description = "总价(不含税)")
 	@Schema(description = "总价(不含税)")

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

@@ -34,10 +34,10 @@
     </select>
     </select>
 
 
     <select id="selectAttendancePage" resultMap="ResultVoMap">
     <select id="selectAttendancePage" resultMap="ResultVoMap">
-        SELECT DISTINCT(r.technician_id), t.name, t.number, t.id_card, t.personnel_type
-        FROM kd_attendance_records r
-        LEFT JOIN kd_technician t ON r.technician_id = t.id
-        WHERE LEFT(r.work_date,6) = #{ew.yearAndMonth}
+        SELECT xt.technician_id, 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
+        WHERE xt.year_and_month = #{ew.yearAndMonth}
         <if test="ew.name != null">
         <if test="ew.name != null">
             and t.name like concat('%',#{ew.name},'%')
             and t.name like concat('%',#{ew.name},'%')
         </if>
         </if>

+ 3 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AttendanceServiceImpl.java

@@ -51,6 +51,9 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 		List<AttendanceVO> list = baseMapper.selectAttendancePage(page, attendance);
 		List<AttendanceVO> list = baseMapper.selectAttendancePage(page, attendance);
 		for (AttendanceVO vo : list) {
 		for (AttendanceVO vo : list) {
 			List<DailyAttendance> dailyAttendanceList = baseMapper.selectDailyAttendanceByTechnicianAndMonth(vo.getTechnicianId(), attendance.getYearAndMonth());
 			List<DailyAttendance> dailyAttendanceList = baseMapper.selectDailyAttendanceByTechnicianAndMonth(vo.getTechnicianId(), attendance.getYearAndMonth());
+			if(CollectionUtil.isEmpty(dailyAttendanceList)){
+				continue;
+			}
 			vo.setMonthlyHours(dailyAttendanceList.stream().mapToDouble(DailyAttendance::getWorkHours).sum());
 			vo.setMonthlyHours(dailyAttendanceList.stream().mapToDouble(DailyAttendance::getWorkHours).sum());
 //			TODO 获取企业填报的考勤时长
 //			TODO 获取企业填报的考勤时长
 			Double workHours = 8.0;
 			Double workHours = 8.0;

+ 18 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/SalaryServiceImpl.java

@@ -214,12 +214,19 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 		if(CollectionUtil.isEmpty(data)){
 		if(CollectionUtil.isEmpty(data)){
 			throw new ServiceException("未能从模板中读取数据,请检查模板格式是否正确");
 			throw new ServiceException("未能从模板中读取数据,请检查模板格式是否正确");
 		}
 		}
+		//导入时人员非本月实际参研人员,提示“某某非本月实际参研人员,请核对数据”
+		//获取本月实际参研人员名单
+		List<XmTechnicianEntity> technicianByYearMonth = xmTechnicianMapper.selectList(Wrappers.<XmTechnicianEntity>lambdaQuery().eq(XmTechnicianEntity::getYearAndMonth, yearAndMonth));
+		if(CollectionUtil.isEmpty(technicianByYearMonth)){
+			throw new ServiceException(yearAndMonth+"实际参研人员名单为空");
+		}
+		List<Long> technicianIds = technicianByYearMonth.stream().map(XmTechnicianEntity::getTechnicianId).toList();
+
 		for (SalaryExcel excel : data) {
 		for (SalaryExcel excel : data) {
 			if(StringUtil.isAllBlank(excel.getNumber(), excel.getIdCard())){
 			if(StringUtil.isAllBlank(excel.getNumber(), excel.getIdCard())){
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工号和身份证不能都为空");
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工号和身份证不能都为空");
 			}
 			}
 			//根据工号或者身份证查询technicianId
 			//根据工号或者身份证查询technicianId
-//			Long technicianId = technicianMapper.selectPrimaryKeyByNumberOrIdentityCard(excel.getNumber(), excel.getIdCard());
 			LambdaQueryWrapper<TechnicianEntity> wrapper = Wrappers.<TechnicianEntity>lambdaQuery()
 			LambdaQueryWrapper<TechnicianEntity> wrapper = Wrappers.<TechnicianEntity>lambdaQuery()
 				.eq(TechnicianEntity::getYearAndMonth, yearAndMonth)
 				.eq(TechnicianEntity::getYearAndMonth, yearAndMonth)
 				.and(t -> t.eq(TechnicianEntity::getNumber, excel.getNumber()).or().eq(TechnicianEntity::getIdCard, excel.getIdCard()));
 				.and(t -> t.eq(TechnicianEntity::getNumber, excel.getNumber()).or().eq(TechnicianEntity::getIdCard, excel.getIdCard()));
@@ -227,12 +234,22 @@ public class SalaryServiceImpl extends BaseServiceImpl<SalaryMapper, SalaryEntit
 			if(dbTechnician == null){
 			if(dbTechnician == null){
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工号和者身份证都不存在");
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工号和者身份证都不存在");
 			}
 			}
+
+			//非本月实际参研人员,提示“某某非本月实际参研人员,请核对数据”
+			if(!technicianIds.contains(dbTechnician.getId())){
+				String tips = StringUtil.isNoneBlank(excel.getNumber())?excel.getNumber()+","+excel.getIdCard():excel.getIdCard();
+				throw new ServiceException("人员["+tips+"]非本月实际参研人员,请核对数据");
+			}
+
 			LambdaQueryWrapper<SalaryEntity> queryWrapper = Wrappers.<SalaryEntity>lambdaQuery()
 			LambdaQueryWrapper<SalaryEntity> queryWrapper = Wrappers.<SalaryEntity>lambdaQuery()
 				.eq(SalaryEntity::getYearAndMonth, yearAndMonth)
 				.eq(SalaryEntity::getYearAndMonth, yearAndMonth)
 				.eq(SalaryEntity::getTechnicianId, dbTechnician.getId());
 				.eq(SalaryEntity::getTechnicianId, dbTechnician.getId());
 			if(baseMapper.selectCount(queryWrapper) > 0){
 			if(baseMapper.selectCount(queryWrapper) > 0){
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工资数据已存在, 导入失败");
 				throw new ServiceException("序号为["+excel.getSerialNumber()+"]的工资数据已存在, 导入失败");
 			}
 			}
+
+
+
 			SalaryEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, SalaryDTO.class));
 			SalaryEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, SalaryDTO.class));
 			entity.setTechnicianId(dbTechnician.getId());
 			entity.setTechnicianId(dbTechnician.getId());
 			entity.setYearAndMonth(yearAndMonth);
 			entity.setYearAndMonth(yearAndMonth);

+ 15 - 0
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmDirectCostServiceImpl.java

@@ -9,6 +9,7 @@ import org.sky.core.log.exception.ServiceException;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.CollectionUtil;
 import org.sky.core.tool.utils.CollectionUtil;
+import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.excel.XmDirectCostExcel;
 import org.sky.scientific.excel.XmDirectCostExcel;
 import org.sky.scientific.mapper.XmDirectCostMapper;
 import org.sky.scientific.mapper.XmDirectCostMapper;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Objects;
 import java.util.Objects;
 
 
@@ -59,6 +61,8 @@ public class XmDirectCostServiceImpl extends BaseServiceImpl<XmDirectCostMapper,
 		}
 		}
 		List<XmDirectCostEntity> insertList = new ArrayList<>();
 		List<XmDirectCostEntity> insertList = new ArrayList<>();
 		for (XmDirectCostExcel excel : data) {
 		for (XmDirectCostExcel excel : data) {
+			judgeDate(excel.getUseDate(), yearAndMonth);
+
 			XmDirectCostEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, XmDirectCostEntity.class));
 			XmDirectCostEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, XmDirectCostEntity.class));
 			if (!StringUtil.isAllBlank(excel.getXmmc(), excel.getXmbh())) {
 			if (!StringUtil.isAllBlank(excel.getXmmc(), excel.getXmbh())) {
 				//根据项目名称或编号查询xmId
 				//根据项目名称或编号查询xmId
@@ -85,7 +89,18 @@ public class XmDirectCostServiceImpl extends BaseServiceImpl<XmDirectCostMapper,
 		if (StringUtil.isBlank(xmDirectCost.getYearAndMonth())) {
 		if (StringUtil.isBlank(xmDirectCost.getYearAndMonth())) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		}
+		judgeDate(xmDirectCost.getUseDate(), xmDirectCost.getYearAndMonth());
 		return this.saveOrUpdate(xmDirectCost);
 		return this.saveOrUpdate(xmDirectCost);
 	}
 	}
 
 
+	private void judgeDate(Date date, String yearAndMonth) {
+		//租赁日期,必须时当月日期
+		if (date != null) {
+			String format = DateUtil.format(date, DateUtil.PATTERN_YYYYMM);
+			boolean equals = StringUtil.equals(format, yearAndMonth);
+			if (!equals) {
+				throw new ServiceException("日期" + format + "必须是" + yearAndMonth + "月的一天");
+			}
+		}
+	}
 }
 }

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

@@ -9,6 +9,7 @@ import org.sky.core.log.exception.ServiceException;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.CollectionUtil;
 import org.sky.core.tool.utils.CollectionUtil;
+import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.excel.XmGoodsExcel;
 import org.sky.scientific.excel.XmGoodsExcel;
 import org.sky.scientific.mapper.XmGoodsMapper;
 import org.sky.scientific.mapper.XmGoodsMapper;
@@ -91,6 +92,13 @@ public class XmGoodsServiceImpl extends BaseServiceImpl<XmGoodsMapper, XmGoodsEn
 		if (StringUtil.isBlank(xmGoods.getYearAndMonth())) {
 		if (StringUtil.isBlank(xmGoods.getYearAndMonth())) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		}
+		//领用日期,必须时当月日期
+		if(xmGoods.getUseDate() != null){
+			boolean equals = StringUtil.equals(DateUtil.format(xmGoods.getUseDate(), DateUtil.PATTERN_YYYYMM), xmGoods.getYearAndMonth());
+			if (!equals) {
+				throw new ServiceException("领取日期必须是"+xmGoods.getYearAndMonth()+"月的一天");
+			}
+		}
 		return this.saveOrUpdate(xmGoods);
 		return this.saveOrUpdate(xmGoods);
 	}
 	}
 
 

+ 19 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/XmLeaseServiceImpl.java

@@ -9,6 +9,7 @@ import org.sky.core.log.exception.ServiceException;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.mp.base.BaseServiceImpl;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.BeanUtil;
 import org.sky.core.tool.utils.CollectionUtil;
 import org.sky.core.tool.utils.CollectionUtil;
+import org.sky.core.tool.utils.DateUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.core.tool.utils.StringUtil;
 import org.sky.scientific.excel.XmLeaseExcel;
 import org.sky.scientific.excel.XmLeaseExcel;
 import org.sky.scientific.mapper.XmLeaseMapper;
 import org.sky.scientific.mapper.XmLeaseMapper;
@@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.Objects;
 import java.util.Objects;
 
 
@@ -60,6 +62,10 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
 		List<XmLeaseEntity> insertList = new ArrayList<>();
 		List<XmLeaseEntity> insertList = new ArrayList<>();
 		for (XmLeaseExcel excel : data) {
 		for (XmLeaseExcel excel : data) {
 			XmLeaseEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, XmLeaseEntity.class));
 			XmLeaseEntity entity = Objects.requireNonNull(BeanUtil.copyProperties(excel, XmLeaseEntity.class));
+
+			//租赁日期,必须时当月日期
+			judgeLeaseDate(excel.getLeaseDate(), yearAndMonth);
+
 			if (!StringUtil.isAllBlank(excel.getXmmc(), excel.getXmbh())) {
 			if (!StringUtil.isAllBlank(excel.getXmmc(), excel.getXmbh())) {
 				//根据项目名称或编号查询xmId
 				//根据项目名称或编号查询xmId
 				Long xmId = xmMapper.getXmIdByXmmcOrXmbh(yearAndMonth, excel.getXmmc(), excel.getXmbh());
 				Long xmId = xmMapper.getXmIdByXmmcOrXmbh(yearAndMonth, excel.getXmmc(), excel.getXmbh());
@@ -67,8 +73,8 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
 					throw new ServiceException("研发项目[" + (StringUtil.isNotBlank(excel.getXmmc()) ? excel.getXmmc() + "," : "") + (StringUtil.isNotBlank(excel.getXmbh()) ? excel.getXmbh() : "") + "]不存在,请检查模板数据");
 					throw new ServiceException("研发项目[" + (StringUtil.isNotBlank(excel.getXmmc()) ? excel.getXmmc() + "," : "") + (StringUtil.isNotBlank(excel.getXmbh()) ? excel.getXmbh() : "") + "]不存在,请检查模板数据");
 				}
 				}
 				entity.setXmId(xmId);
 				entity.setXmId(xmId);
-
 			}
 			}
+
 			entity.setYearAndMonth(yearAndMonth);
 			entity.setYearAndMonth(yearAndMonth);
 			insertList.add(entity);
 			insertList.add(entity);
 		}
 		}
@@ -85,7 +91,19 @@ public class XmLeaseServiceImpl extends BaseServiceImpl<XmLeaseMapper, XmLeaseEn
 		if (StringUtil.isBlank(xmLease.getYearAndMonth())) {
 		if (StringUtil.isBlank(xmLease.getYearAndMonth())) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
 		}
+		judgeLeaseDate(xmLease.getLeaseDate(), xmLease.getYearAndMonth());
 		return this.saveOrUpdate(xmLease);
 		return this.saveOrUpdate(xmLease);
 	}
 	}
 
 
+	private void judgeLeaseDate(Date date, String yearAndMonth) {
+		//租赁日期,必须时当月日期
+		if (date != null) {
+			String format = DateUtil.format(date, DateUtil.PATTERN_YYYYMM);
+			boolean equals = StringUtil.equals(format, yearAndMonth);
+			if (!equals) {
+				throw new ServiceException("租赁日期" + format + "必须是" + yearAndMonth + "月的一天");
+			}
+		}
+	}
+
 }
 }