Commit b90482ad authored by 赵啸非's avatar 赵啸非

添加同步锁再创建请假考勤记录处

parent 5a5d8d40
......@@ -13,10 +13,7 @@ import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
......@@ -66,7 +63,7 @@ public class ResourceController extends BaseCRUDJsonBodyMappingController<Resour
/**
* 资源路径刷新
*/
@PostMapping(value = "refreshUrl")
@GetMapping(value = "refreshUrl")
@UnAuth
public Rest<String> refreshUrl(@RequestParam(name = "packageName", defaultValue = "com.mortals.xhx") String packageName) {
log.info("刷新资源路径,packageName", packageName);
......
......@@ -174,18 +174,6 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
String busiDesc = "外部效能新增";
Rest rest = Rest.ok(busiDesc + "成功!");
try {
/* boolean isMobile = Validator.isMobile(req.getPhone());
if (!isMobile) {
effectErrorSave(req);
rest = Rest.fail("手机号码不正确!");
}*/
/* if (ObjectUtils.isEmpty(req.getPhone())) {
//保存异常数据/
effectErrorSave(req);
rest = Rest.fail("手机号码为空!");
}*/
//如果手机号码为空 将当前记录保存到临时表中,人工手动处理
if (ObjectUtils.isEmpty(req.getRuleCode())) {
//保存异常数据/
effectErrorSave(req);
......@@ -195,10 +183,6 @@ public class ApiWebPerformController extends AbstractBaseController<PerformReq>
if (YesNoEnum.YES.getValue() == rest.getCode()) {
effect(req);
}
//if (ObjectUtils.isEmpty(req.getPhone())) throw new AppException("手机号码不能为空!");
//if (ObjectUtils.isEmpty(req.getRuleCode())) throw new AppException("绩效规则编码不能为空!");
// boolean bool = effect(req);
// if (bool) throw new AppException(busiDesc + "失败!");
} catch (Exception e) {
log.error(busiDesc, e);
return Rest.fail(e.getMessage());
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -22,6 +23,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
@Slf4j
public class ControllerScanUtil {
/**
* 查看类路径
......@@ -276,19 +278,19 @@ public class ControllerScanUtil {
// 添加到classes
classes.add(Class.forName(packageName + '.' + className));
} catch (ClassNotFoundException e) {
e.printStackTrace();
log.error("异常",e);
}
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
log.error("异常",e);
}
}
}
} catch (IOException e) {
e.printStackTrace();
log.error("异常",e);
}
return classes;
......
......@@ -28,6 +28,7 @@ import com.mortals.xhx.module.perform.service.PerformAttendRecordService;
import com.mortals.xhx.module.perform.service.PerformRulesService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.service.StaffService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -54,6 +55,7 @@ import static com.mortals.xhx.common.key.RedisKey.KEY_ATTENDANCE_STAT_CACHE;
* @date 2023-04-07
*/
@Service("attendanceLeaveRecordService")
@Slf4j
public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<AttendanceLeaveRecordDao, AttendanceLeaveRecordEntity, Long> implements AttendanceLeaveRecordService {
@Autowired
......@@ -211,7 +213,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
leaveRecord.setStaffId(item.getCustomerId());
waitSyncLeaveRecords.add(leaveRecord);
log.info("更新记录成功==>"+process);
log.info("更新记录成功==>" + process);
}
} else {
nextToken = DataUtil.converStr2Long(rest.getData().getNextToken(), 0L);
......@@ -220,40 +222,42 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
}
}
private void creatPerformAttend(AttendanceLeaveRecordEntity entity, Context context){
private void creatPerformAttend(AttendanceLeaveRecordEntity entity, Context context) {
try {
if(AppealResultEnum.通过.getValue() == entity.getAuditResult() && LeaveTypeEnum.事假.getValue() == entity.getLeaveType()){
if (AppealResultEnum.通过.getValue() == entity.getAuditResult() && LeaveTypeEnum.事假.getValue() == entity.getLeaveType()) {
//以半天4小时为计算单位进行扣分
int multiple = entity.getDuration()/14400;
if(multiple >0 ) {
PerformAttendRecordEntity recordEntity = conversionLeaveRecord(entity);
recordEntity.setCreateTime(new Date());
recordEntity.setCreateUserId(1l);
recordEntity.setErrorTime(entity.getStartTime());
recordEntity.setScore(recordEntity.getScore().multiply(new BigDecimal(multiple)));
PerformAttendRecordQuery query = new PerformAttendRecordQuery();
query.setStaffId(recordEntity.getStaffId());
query.setRuleId(recordEntity.getRuleId());
query.setErrorTime(recordEntity.getErrorTime());
PerformAttendRecordEntity temp = performAttendRecordService.selectOne(query);
if(temp==null) {
performAttendRecordService.save(recordEntity, context);
int multiple = entity.getDuration() / 14400;
if (multiple > 0) {
synchronized (this) {
PerformAttendRecordEntity recordEntity = conversionLeaveRecord(entity);
recordEntity.setCreateTime(new Date());
recordEntity.setCreateUserId(1l);
recordEntity.setErrorTime(entity.getStartTime());
recordEntity.setScore(recordEntity.getScore().multiply(new BigDecimal(multiple)));
PerformAttendRecordQuery query = new PerformAttendRecordQuery();
query.setStaffId(recordEntity.getStaffId());
query.setRuleId(recordEntity.getRuleId());
query.setErrorTime(recordEntity.getErrorTime());
PerformAttendRecordEntity temp = performAttendRecordService.selectOne(query);
if (ObjectUtils.isEmpty(temp)) {
performAttendRecordService.save(recordEntity, context);
}
}
}
}
}catch (Exception e){
log.error(e.getMessage());
} catch (Exception e) {
log.error("创建假期考勤异常",e.getMessage());
}
}
private PerformAttendRecordEntity conversionLeaveRecord(AttendanceLeaveRecordEntity entity){
private PerformAttendRecordEntity conversionLeaveRecord(AttendanceLeaveRecordEntity entity) {
PerformAttendRecordEntity recordEntity = new PerformAttendRecordEntity();
recordEntity.initAttrValue();
StaffEntity staffEntity = staffService.get(entity.getLeavePersonId());
recordEntity.setStaffId(entity.getLeavePersonId());
recordEntity.setStaffName(entity.getLeavePerson());
if(staffEntity!=null){
if (staffEntity != null) {
recordEntity.setWorkNum(staffEntity.getWorkNum());
}
recordEntity.setDeptId(entity.getDeptId());
......@@ -261,12 +265,12 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
recordEntity.setSalaId(entity.getSalaId());
recordEntity.setSalaName(entity.getSalaName());
AttendanceGroupStaffEntity groupStaffEntity = attendanceGroupStaffService.selectOne(new AttendanceGroupStaffQuery().staffId(entity.getLeavePersonId()));
if(groupStaffEntity!=null){
if (groupStaffEntity != null) {
recordEntity.setAttendanceGroupId(groupStaffEntity.getGroupId());
recordEntity.setAttendanceGroupName(groupStaffEntity.getGroupName());
}
PerformRulesEntity performRulesEntity = performRulesService.selectOne(new PerformRulesQuery().ruleCode("ATTEND1009"));
if(performRulesEntity!=null){
if (performRulesEntity != null) {
recordEntity.setRuleId(performRulesEntity.getId());
recordEntity.setRuleName(performRulesEntity.getName());
recordEntity.setCategoryId(performRulesEntity.getCategoryId());
......@@ -274,7 +278,7 @@ public class AttendanceLeaveRecordServiceImpl extends AbstractCRUDServiceImpl<At
recordEntity.setSubAddType(performRulesEntity.getSubAddType());
recordEntity.setScore(performRulesEntity.getScore());
recordEntity.setRemark(performRulesEntity.getContent());
}else {
} else {
throw new AppException("没有查询到请假扣分规则:ATTEND1009");
}
recordEntity.setSubMethod(SubMethodEnum.系统自动.getValue());
......
......@@ -3,6 +3,10 @@
"baseUrl": "http://127.0.0.1:17500/attendance"
},
"test": {
"baseUrl": "http://192.168.0.98:11039/attendance",
"baseLogin": "http://192.168.0.98:11078/base"
},
"test-remote": {
"baseUrl": "http://8.136.255.30:11039/attendance",
"baseLogin": "http://192.168.0.98:11078/base"
},
......
......@@ -160,4 +160,9 @@ Content-Type: application/json
"createTimeStart": "2024-03-27 00:00:00",
"createTimeEnd": "2024-03-27 23:59:59",
"deviceId": 4
}
\ No newline at end of file
}
###controoler 测试
POST {{baseUrl}}/resource/refreshUrl?packageName=com.mortals.xhx.module
Accept: application/json
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment