|
@@ -1,5 +1,6 @@
|
|
|
package org.dromara.risk.service.impl;
|
|
package org.dromara.risk.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -17,6 +18,8 @@ import org.dromara.risk.mapper.RiskPersonnelChangeMapper;
|
|
|
import org.dromara.risk.service.IRiskPersonnelChangeService;
|
|
import org.dromara.risk.service.IRiskPersonnelChangeService;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
@@ -88,12 +91,41 @@ public class RiskPersonnelChangeServiceImpl implements IRiskPersonnelChangeServi
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public int insertByBo(RiskPersonnelChangeBo bo) {
|
|
public int insertByBo(RiskPersonnelChangeBo bo) {
|
|
|
|
|
+ // 变动编号:前端未传时系统自动生成,确保 UNIQUE KEY uk_change_code 不冲突
|
|
|
|
|
+ if (StringUtils.isBlank(bo.getChangeCode())) {
|
|
|
|
|
+ bo.setChangeCode(generateChangeCode());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 变动日期前端不传时取当前日期
|
|
|
|
|
+ if (bo.getChangeDate() == null) {
|
|
|
|
|
+ bo.setChangeDate(new Date());
|
|
|
|
|
+ }
|
|
|
RiskPersonnelChange add = MapstructUtils.convert(bo, RiskPersonnelChange.class);
|
|
RiskPersonnelChange add = MapstructUtils.convert(bo, RiskPersonnelChange.class);
|
|
|
int row = baseMapper.insert(add);
|
|
int row = baseMapper.insert(add);
|
|
|
bo.setId(add.getId());
|
|
bo.setId(add.getId());
|
|
|
return row;
|
|
return row;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成人员变动编号:PC + yyyyMMddHHmmss + 3位随机数
|
|
|
|
|
+ * 冲突自动重试 5 次,极端情况 UUID 兜底
|
|
|
|
|
+ */
|
|
|
|
|
+ private String generateChangeCode() {
|
|
|
|
|
+ String prefix = "PC";
|
|
|
|
|
+ String ts = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
|
|
|
+ java.util.concurrent.ThreadLocalRandom random = java.util.concurrent.ThreadLocalRandom.current();
|
|
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
|
|
+ String suffix = StringUtils.leftPad(
|
|
|
|
|
+ Integer.toString(random.nextInt(1000)), 3, '0');
|
|
|
|
|
+ String code = prefix + ts + suffix;
|
|
|
|
|
+ Long exists = baseMapper.selectCount(Wrappers.<RiskPersonnelChange>lambdaQuery()
|
|
|
|
|
+ .eq(RiskPersonnelChange::getChangeCode, code));
|
|
|
|
|
+ if (exists == null || exists == 0) {
|
|
|
|
|
+ return code;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return prefix + ts + IdUtil.fastSimpleUUID().substring(0, 4).toUpperCase();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 修改人员变动
|
|
* 修改人员变动
|
|
|
*/
|
|
*/
|