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

添加规则编码实现

parent 24cdb527
......@@ -56,6 +56,14 @@ public class IdgeneratorServiceImpl implements IdgeneratorService {
*/
INFO_VERSION_KEY(50L, "getInfoVersion", null),
ATTEND_KEY(50L, "attend", null),
REVIEW_KEY(50L, "review", null),
COMPLAIN_KEY(50L, "complain", null),
GOWORK_KEY(50L, "gowork", null),
EFFECT_KEY(50L, "effect", null),
OTHER_KEY(50L, "other", null),
/** 空,测试用 */
DUMMY(DEFAULT_STEP, "", null),
;
......@@ -125,6 +133,42 @@ public class IdgeneratorServiceImpl implements IdgeneratorService {
}
}
private Long attend() {
synchronized (IdGeneratorKey.ATTEND_KEY) {
return getNextSequenceId(IdGeneratorKey.ATTEND_KEY, null);
}
}
private Long review() {
synchronized (IdGeneratorKey.REVIEW_KEY) {
return getNextSequenceId(IdGeneratorKey.REVIEW_KEY, null);
}
}
private Long complain() {
synchronized (IdGeneratorKey.COMPLAIN_KEY) {
return getNextSequenceId(IdGeneratorKey.COMPLAIN_KEY, null);
}
}
private Long gowork() {
synchronized (IdGeneratorKey.GOWORK_KEY) {
return getNextSequenceId(IdGeneratorKey.GOWORK_KEY, null);
}
}
private Long effect() {
synchronized (IdGeneratorKey.EFFECT_KEY) {
return getNextSequenceId(IdGeneratorKey.EFFECT_KEY, null);
}
}
private Long other() {
synchronized (IdGeneratorKey.OTHER_KEY) {
return getNextSequenceId(IdGeneratorKey.OTHER_KEY, null);
}
}
// *******************************************************************************
/**
......
package com.mortals.xhx.busiz.web;
import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService;
import com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -17,6 +20,9 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/test")
public class TestController {
@Autowired
private IdgeneratorService idgeneratorService;
@GetMapping("webservice")
public String webservice() {
log.info("测试");
......@@ -24,6 +30,16 @@ public class TestController {
return "ok";
}
@GetMapping("idGens")
public String idGens() {
log.info("测试id生成");
String stringId = idgeneratorService.getLongId(IdgeneratorServiceImpl.IdGeneratorKey.EFFECT).toString();
return stringId;
}
public static void main(String[] args) {
......
......@@ -5,8 +5,11 @@ import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService;
import com.mortals.xhx.common.code.CommentTypeEnum;
import com.mortals.xhx.common.code.PerformRulesTypeEnum;
import com.mortals.xhx.common.code.PerformTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
......@@ -16,6 +19,8 @@ import com.mortals.xhx.module.perform.service.PerformRulesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import static com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl.IdGeneratorKey.*;
/**
* PerformRulesService
* 绩效规则信息 service实现
......@@ -26,6 +31,10 @@ import org.springframework.util.ObjectUtils;
@Service("performRulesService")
@Slf4j
public class PerformRulesServiceImpl extends AbstractCRUDCacheServiceImpl<PerformRulesDao, PerformRulesEntity, Long> implements PerformRulesService {
@Autowired
private IdgeneratorService idgeneratorService;
@Override
protected String getExtKey(PerformRulesEntity data) {
return data.getRuleCode();
......@@ -34,8 +43,40 @@ public class PerformRulesServiceImpl extends AbstractCRUDCacheServiceImpl<Perfor
@Override
protected void saveBefore(PerformRulesEntity entity, Context context) throws AppException {
if (ObjectUtils.isEmpty(entity.getRuleCode())) {
String ruleCode = "";
/*
if (PerformRulesTypeEnum.考勤绩效.getValue() == entity.getType()) {
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(ATTEND_KEY);
}
*/
switch (PerformRulesTypeEnum.getByValue(entity.getType())) {
case 考勤绩效:
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(ATTEND_KEY);
break;
case 评价差评绩效:
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(REVIEW_KEY);
break;
case 评价投诉绩效:
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(COMPLAIN_KEY);
break;
case 办件绩效:
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(GOWORK_KEY);
break;
case 效能绩效:
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(EFFECT_KEY);
break;
case 其它绩效:
ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId(OTHER_KEY);
break;
default:
throw new AppException("绩效类型不支持!");
}
//自定义默认规则code
String ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc() + "_" + PinyinUtil.getFirstLetter(ReUtil.replaceAll(entity.getName(), "[^\\u4E00-\\u9FA5]", ""), "");
//PerformTypeEnum
// String ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc() + "_" + PinyinUtil.getFirstLetter(ReUtil.replaceAll(entity.getName(), "[^\\u4E00-\\u9FA5]", ""), "");
//String ruleCode = PerformRulesTypeEnum.getByValue(entity.getType()).getDesc().toUpperCase() + "_" + idgeneratorService.getLongId();
entity.setRuleCode(ruleCode);
}
......
......@@ -32,8 +32,13 @@ GET {{baseUrl}}/sms/set/edit?id={{SmsSet_id}}
Accept: application/json
###id生成
GET {{baseUrl}}/test/idGens
Accept: application/json
###短信设置删除
GET {{baseUrl}}/sms/set/delete?id={{SmsSet_id}}
GET {{baseUrl}}/att/set/delete?id={{SmsSet_id}}
Accept: application/json
......
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