Browse Source

444444444444

zhouli 7 months ago
parent
commit
ab02d7f9cc

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

@@ -56,7 +56,7 @@ public class AttendanceController extends KdController {
 
 	@SneakyThrows
 	@PostMapping("export")
-	@ApiOperationSupport(order = 3)
+	@ApiOperationSupport(order = 5)
 	@Operation(summary = "每月考勤信息-导出")
 	public void exportAttendance(@RequestBody AttendanceDto dto, HttpServletResponse response) {
 		List<AttendanceVO> list = service.selectAttendancePage(dto, Condition.getPage(new Query().setCurrent(1).setSize(Integer.MAX_VALUE))).getRecords();
@@ -70,8 +70,8 @@ public class AttendanceController extends KdController {
 
 	@PostMapping("/remove")
 	@ApiOperationSupport(order = 7)
-	@Operation(summary = "每月考勤信息-清除考勤数据", description = "多个 unicode、yearAndMonth")
-	public R remove(@RequestBody List<AttendanceDto> attendanceList) {
+	@Operation(summary = "每月考勤信息-清除考勤数据", description = "多个unicode、yearAndMonth")
+	public R clearAttendance(@RequestBody List<AttendanceDto> attendanceList) {
 		return R.status(service.clearAttendance(attendanceList));
 	}
 

+ 2 - 2
kd-service/kd-scientific/src/main/java/org/sky/scientific/controller/TechnicianController.java

@@ -74,14 +74,14 @@ public class TechnicianController extends KdController {
 	@ApiOperationSupport(order = 4)
 	@Operation(summary = "新增", description = "传入technician")
 	public R save(@Valid @RequestBody TechnicianDTO technician) {
-		return R.status(technicianService.saveOrUpdateTechnician(technician));
+		return R.status(technicianService.insertTechnician(technician));
 	}
 
 	@PostMapping("/update")
 	@ApiOperationSupport(order = 5)
 	@Operation(summary = "修改", description = "传入technician")
 	public R update(@Valid @RequestBody TechnicianEntity technician) {
-		return R.status(technicianService.updateById(technician));
+		return R.status(technicianService.updateTechnician(technician));
 	}
 
 	@PostMapping("/remove")

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

@@ -33,5 +33,7 @@ public interface AttendanceMapper extends BaseMapper<AttendanceEntity> {
 
 	int clearUnicodeAndMonthly(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
 
+	int deleteByUnicodeAndMonthly(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
+
 	Long countByUnicodeAndMonth(@Param("unicode") String unicode, @Param("yearAndMonth") String yearAndMonth);
 }

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

@@ -94,5 +94,9 @@
         where unicode = #{unicode} and left(work_date,6) = #{yearAndMonth}
     </update>
 
+    <delete id="deleteByUnicodeAndMonthly">
+        delete from kd_attendance_records where unicode = #{unicode} and left(work_date,6) = #{yearAndMonth}
+    </delete>
+
 
 </mapper>

+ 8 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/ITechnicianService.java

@@ -29,7 +29,14 @@ public interface ITechnicianService extends BaseService<TechnicianEntity> {
 	 * @param technician
 	 * @return
 	 */
-	boolean saveOrUpdateTechnician(TechnicianEntity technician);
+	boolean insertTechnician(TechnicianEntity technician);
+
+	/**
+	 * 修改
+	 * @param technician
+	 * @return
+	 */
+	boolean updateTechnician(TechnicianEntity technician);
 
 	/**
 	 * 自定义分页

+ 2 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/AttendanceServiceImpl.java

@@ -341,8 +341,9 @@ public class AttendanceServiceImpl extends BaseServiceImpl<AttendanceMapper, Att
 		}
 		int affectNum = 0;
 		for (AttendanceDto entity : attendanceList) {
-			affectNum += baseMapper.clearUnicodeAndMonthly(entity.getUnicode(), entity.getYearAndMonth());
+			affectNum += baseMapper.deleteByUnicodeAndMonthly(entity.getUnicode(), entity.getYearAndMonth());
 		}
 		return affectNum >= 0;
 	}
+
 }

+ 59 - 10
kd-service/kd-scientific/src/main/java/org/sky/scientific/service/impl/TechnicianServiceImpl.java

@@ -69,7 +69,7 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 	private final XmBgrzMapper xmBgrzMapper;
 
 	@Override
-	public boolean saveOrUpdateTechnician(TechnicianEntity technician) {
+	public boolean insertTechnician(TechnicianEntity technician) {
 		if (StringUtil.isBlank(technician.getYearAndMonth())) {
 			throw new ServiceException("参数yearAndMonth不能为空");
 		}
@@ -78,17 +78,66 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 		}
 
 		String unicode = baseMapper.getUnicodeByNumberAndIdentityCard(technician.getNumber(), technician.getIdCard());
-		if (unicode == null) {
-			unicode = generateUnicode();
+		if (Func.notNull(unicode)) {
+			throw new ServiceException("工号或身份证已存在");
+		}
+//		if (unicode == null) {
+//			unicode = generateUnicode();
+//		}
+		technician.setUnicode(generateUnicode());
+
+//		if (Func.isNull(technician.getId())) {
+		//新增
+		return this.save(technician);
+//		} else {
+//			//修改technician.getYearAndMonth()及之后月份的数据
+//			LambdaQueryWrapper<TechnicianEntity> updateWrapper = Wrappers.<TechnicianEntity>lambdaQuery().eq(TechnicianEntity::getUnicode, technician.getUnicode()).ge(TechnicianEntity::getYearAndMonth, technician.getYearAndMonth());
+//			technician.setId(null);
+//			technician.setTenantId(null);
+//			technician.setUnicode(null);
+//			technician.setYearAndMonth(null);
+//			technician.setCreateTime(null);
+//			technician.setCreateUser(null);
+//			technician.setCreateDept(null);
+//			return this.update(technician, updateWrapper);
+//		}
+	}
+
+	@Override
+	public boolean updateTechnician(TechnicianEntity technician) {
+		if (StringUtil.isBlank(technician.getYearAndMonth())) {
+			throw new ServiceException("参数yearAndMonth不能为空");
+		}
+		if (StringUtil.isBlank(technician.getNumber()) && StringUtil.isBlank(technician.getIdCard())) {
+			throw new ServiceException("工号和身份证号码不能同时为空");
 		}
-		technician.setUnicode(unicode);
 
-		if (Func.isNull(technician.getId())) {
-			//新增
-			return this.save(technician);
-		} else {
-			return this.updateById(technician);
+		if(Func.isBlank(technician.getUnicode())){
+			throw new ServiceException("参数unicode不能为空");
 		}
+
+//		String unicode = baseMapper.getUnicodeByNumberAndIdentityCard(technician.getNumber(), technician.getIdCard());
+//
+//		if (unicode == null) {
+//			unicode = generateUnicode();
+//		}
+//		technician.setUnicode(unicode);
+
+//		if (Func.isNull(technician.getId())) {
+//			//新增
+//			return this.save(technician);
+//		} else {
+			//修改technician.getYearAndMonth()及之后月份的数据
+			LambdaQueryWrapper<TechnicianEntity> updateWrapper = Wrappers.<TechnicianEntity>lambdaQuery().eq(TechnicianEntity::getUnicode, technician.getUnicode()).ge(TechnicianEntity::getYearAndMonth, technician.getYearAndMonth());
+			technician.setId(null);
+			technician.setTenantId(null);
+			technician.setUnicode(null);
+			technician.setYearAndMonth(null);
+			technician.setCreateTime(null);
+			technician.setCreateUser(null);
+			technician.setCreateDept(null);
+			return this.update(technician, updateWrapper);
+//		}
 	}
 
 	@Override
@@ -261,7 +310,7 @@ public class TechnicianServiceImpl extends BaseServiceImpl<TechnicianMapper, Tec
 			//删除人员花名册时需判断数据是否被引入
 			//项目负责人
 			Long xmBgCount = xmBgrzMapper.selectCount(Wrappers.<XmBgrzEntity>lambdaQuery().eq(XmBgrzEntity::getZdmc, "XMFZR").eq(XmBgrzEntity::getBgqdz, dbTechnician.getId()).or().eq(XmBgrzEntity::getBghdz, dbTechnician.getId()));
-			if(xmMapper.selectCount(Wrappers.<XmEntity>lambdaQuery().eq(XmEntity::getXmfzr, technician.getId())) > 0 || xmBgCount > 0){
+			if (xmMapper.selectCount(Wrappers.<XmEntity>lambdaQuery().eq(XmEntity::getXmfzr, technician.getId())) > 0 || xmBgCount > 0) {
 				throw new ServiceException("删除失败,[" + dbTechnician.getName() + "]是项目负责人");
 			}