去掉id next
This commit is contained in:
parent
1a49cce3da
commit
e208e55147
|
|
@ -1,53 +1,53 @@
|
||||||
package com.bonus.common.core.utils.id;
|
//package com.bonus.common.core.utils.id;
|
||||||
|
//
|
||||||
import com.google.common.base.Preconditions;
|
//import com.google.common.base.Preconditions;
|
||||||
import java.time.LocalDateTime;
|
//import java.time.LocalDateTime;
|
||||||
import java.time.ZoneId;
|
//import java.time.ZoneId;
|
||||||
|
//
|
||||||
public class Id {
|
//public class Id {
|
||||||
private static final long EPOCH = LocalDateTime.of(2021, 12, 29, 9, 2).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
// private static final long EPOCH = LocalDateTime.of(2021, 12, 29, 9, 2).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||||
private static final long SEQUENCE_BITS = 12L;
|
// private static final long SEQUENCE_BITS = 12L;
|
||||||
private static final long WORKER_ID_BITS = 10L;
|
// private static final long WORKER_ID_BITS = 10L;
|
||||||
static final long WORKER_ID_MAX_VALUE = 1024L;
|
// static final long WORKER_ID_MAX_VALUE = 1024L;
|
||||||
private static final long SEQUENCE_MASK = 4095L;
|
// private static final long SEQUENCE_MASK = 4095L;
|
||||||
private static final long WORKER_ID_LEFT_SHIFT_BITS = 12L;
|
// private static final long WORKER_ID_LEFT_SHIFT_BITS = 12L;
|
||||||
private static final long TIMESTAMP_LEFT_SHIFT_BITS = 22L;
|
// private static final long TIMESTAMP_LEFT_SHIFT_BITS = 22L;
|
||||||
static Long WORKER_ID;
|
// static Long WORKER_ID;
|
||||||
private static long SEQUENCE;
|
// private static long SEQUENCE;
|
||||||
private static long LAST_TIME;
|
// private static long LAST_TIME;
|
||||||
|
//
|
||||||
public Id(Long workerId) {
|
// public Id(Long workerId) {
|
||||||
WORKER_ID = workerId;
|
// WORKER_ID = workerId;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static long next() {
|
// public static long next() {
|
||||||
return nextKey();
|
// return nextKey();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public static String nextString() {
|
// public static String nextString() {
|
||||||
return String.valueOf(next());
|
// return String.valueOf(next());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static synchronized long nextKey() {
|
// private static synchronized long nextKey() {
|
||||||
long currentMillis = System.currentTimeMillis();
|
// long currentMillis = System.currentTimeMillis();
|
||||||
Preconditions.checkState(LAST_TIME <= currentMillis, "Clock is moving backwards, last time is %d milliseconds, current time is %d milliseconds", LAST_TIME, currentMillis);
|
// Preconditions.checkState(LAST_TIME <= currentMillis, "Clock is moving backwards, last time is %d milliseconds, current time is %d milliseconds", LAST_TIME, currentMillis);
|
||||||
if (LAST_TIME == currentMillis) {
|
// if (LAST_TIME == currentMillis) {
|
||||||
if (0L == (SEQUENCE = SEQUENCE + 1L & 4095L)) {
|
// if (0L == (SEQUENCE = SEQUENCE + 1L & 4095L)) {
|
||||||
currentMillis = waitUntilNextTime(currentMillis);
|
// currentMillis = waitUntilNextTime(currentMillis);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
SEQUENCE = 0L;
|
// SEQUENCE = 0L;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
LAST_TIME = currentMillis;
|
// LAST_TIME = currentMillis;
|
||||||
return currentMillis - EPOCH << 22 | WORKER_ID << 12 | SEQUENCE;
|
// return currentMillis - EPOCH << 22 | WORKER_ID << 12 | SEQUENCE;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private static long waitUntilNextTime(final long lastTime) {
|
// private static long waitUntilNextTime(final long lastTime) {
|
||||||
long time;
|
// long time;
|
||||||
for(time = System.currentTimeMillis(); time <= lastTime; time = System.currentTimeMillis()) {
|
// for(time = System.currentTimeMillis(); time <= lastTime; time = System.currentTimeMillis()) {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return time;
|
// return time;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,123 @@
|
||||||
package com.bonus.common.core.utils.id;
|
//package com.bonus.common.core.utils.id;
|
||||||
|
//
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
//import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import org.apache.commons.io.FileUtils;
|
//import org.apache.commons.io.FileUtils;
|
||||||
import org.slf4j.Logger;
|
//import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
//import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
//import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
//import org.springframework.util.CollectionUtils;
|
||||||
|
//
|
||||||
import java.io.File;
|
//import java.io.File;
|
||||||
import java.io.IOException;
|
//import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
//import java.io.RandomAccessFile;
|
||||||
import java.nio.channels.FileChannel;
|
//import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.FileLock;
|
//import java.nio.channels.FileLock;
|
||||||
import java.nio.charset.StandardCharsets;
|
//import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collection;
|
//import java.util.Collection;
|
||||||
import java.util.UUID;
|
//import java.util.UUID;
|
||||||
|
//
|
||||||
@Component
|
//@Component
|
||||||
@ConditionalOnClass({StringRedisTemplate.class})
|
//@ConditionalOnClass({StringRedisTemplate.class})
|
||||||
@EnableConfigurationProperties({IdProperties.class})
|
//@EnableConfigurationProperties({IdProperties.class})
|
||||||
@ConditionalOnProperty(
|
//@ConditionalOnProperty(
|
||||||
prefix = "id",
|
// prefix = "id",
|
||||||
name = {"enabled"},
|
// name = {"enabled"},
|
||||||
havingValue = "true",
|
// havingValue = "true",
|
||||||
matchIfMissing = true
|
// matchIfMissing = true
|
||||||
)
|
//)
|
||||||
public class IdWorkConfiguration {
|
//public class IdWorkConfiguration {
|
||||||
private static final Logger log = LoggerFactory.getLogger(IdWorkConfiguration.class);
|
// private static final Logger log = LoggerFactory.getLogger(IdWorkConfiguration.class);
|
||||||
private final IdProperties idProperties;
|
// private final IdProperties idProperties;
|
||||||
|
//
|
||||||
public IdWorkConfiguration(StringRedisTemplate redisTemplate, IdProperties idProperties) throws IOException {
|
// public IdWorkConfiguration(StringRedisTemplate redisTemplate, IdProperties idProperties) throws IOException {
|
||||||
this.idProperties = idProperties;
|
// this.idProperties = idProperties;
|
||||||
Long workerId = this.getLocalWorkId();
|
// Long workerId = this.getLocalWorkId();
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
while(workerId == null) {
|
// while(workerId == null) {
|
||||||
Long newWorkId = redisTemplate.opsForValue().increment(idProperties.getKey(), 1L);
|
// Long newWorkId = redisTemplate.opsForValue().increment(idProperties.getKey(), 1L);
|
||||||
this.saveLocalWorkId(String.valueOf(newWorkId));
|
// this.saveLocalWorkId(String.valueOf(newWorkId));
|
||||||
workerId = this.getLocalWorkId();
|
// workerId = this.getLocalWorkId();
|
||||||
}
|
// }
|
||||||
} catch (Throwable var5) {
|
// } catch (Throwable var5) {
|
||||||
log.error("获取workID失败", var5);
|
// log.error("获取workID失败", var5);
|
||||||
throw var5;
|
// throw var5;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (workerId > 1024L) {
|
// if (workerId > 1024L) {
|
||||||
throw new RuntimeException("超过最大启动实例");
|
// throw new RuntimeException("超过最大启动实例");
|
||||||
} else {
|
// } else {
|
||||||
Id.WORKER_ID = workerId;
|
// Id.WORKER_ID = workerId;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void saveLocalWorkId(String workId) throws IOException {
|
// private void saveLocalWorkId(String workId) throws IOException {
|
||||||
File workIdHome = this.getWorkIdHome();
|
// File workIdHome = this.getWorkIdHome();
|
||||||
String var10002 = String.valueOf(workIdHome.getAbsoluteFile());
|
// String var10002 = String.valueOf(workIdHome.getAbsoluteFile());
|
||||||
FileUtils.writeStringToFile(new File(var10002 + "/" + String.valueOf(UUID.randomUUID()) + ".lock"), workId, StandardCharsets.UTF_8);
|
// FileUtils.writeStringToFile(new File(var10002 + "/" + String.valueOf(UUID.randomUUID()) + ".lock"), workId, StandardCharsets.UTF_8);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private File getWorkIdHome() {
|
// private File getWorkIdHome() {
|
||||||
String workHome = this.idProperties.getWorkspace();
|
// String workHome = this.idProperties.getWorkspace();
|
||||||
if (CharSequenceUtil.isBlank(workHome)) {
|
// if (CharSequenceUtil.isBlank(workHome)) {
|
||||||
workHome = FileUtils.getUserDirectoryPath() + "/.workId/";
|
// workHome = FileUtils.getUserDirectoryPath() + "/.workId/";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String var10002 = CharSequenceUtil.removeSuffix(workHome, "/");
|
// String var10002 = CharSequenceUtil.removeSuffix(workHome, "/");
|
||||||
return new File(var10002 + "/" + this.idProperties.getKey());
|
// return new File(var10002 + "/" + this.idProperties.getKey());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private Long getLocalWorkId() throws IOException {
|
// private Long getLocalWorkId() throws IOException {
|
||||||
File workIdHome = this.getWorkIdHome();
|
// File workIdHome = this.getWorkIdHome();
|
||||||
if (!workIdHome.exists()) {
|
// if (!workIdHome.exists()) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Collection<File> files = FileUtils.listFiles(workIdHome, new String[]{"lock"}, false);
|
// Collection<File> files = FileUtils.listFiles(workIdHome, new String[]{"lock"}, false);
|
||||||
if (CollectionUtils.isEmpty(files)) {
|
// if (CollectionUtils.isEmpty(files)) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
for (File file : files) {
|
// for (File file : files) {
|
||||||
FileChannel channel = null;
|
// FileChannel channel = null;
|
||||||
FileLock fileLock = null;
|
// FileLock fileLock = null;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
|
// RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
|
||||||
channel = randomAccessFile.getChannel();
|
// channel = randomAccessFile.getChannel();
|
||||||
fileLock = channel.tryLock();
|
// fileLock = channel.tryLock();
|
||||||
|
//
|
||||||
if (fileLock != null) { // 成功获取文件锁
|
// if (fileLock != null) { // 成功获取文件锁
|
||||||
Long workId = Long.valueOf(randomAccessFile.readLine());
|
// Long workId = Long.valueOf(randomAccessFile.readLine());
|
||||||
releaseResourcesOnShutdown(channel);
|
// releaseResourcesOnShutdown(channel);
|
||||||
return workId;
|
// return workId;
|
||||||
}
|
// }
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Error accessing workId file", e);
|
// log.error("Error accessing workId file", e);
|
||||||
} finally {
|
// } finally {
|
||||||
if (fileLock == null && channel != null) {
|
// if (fileLock == null && channel != null) {
|
||||||
try {
|
// try {
|
||||||
channel.close();
|
// channel.close();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Failed to close file channel", e);
|
// log.error("Failed to close file channel", e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private void releaseResourcesOnShutdown(FileChannel channel) {
|
// private void releaseResourcesOnShutdown(FileChannel channel) {
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
// Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
try {
|
// try {
|
||||||
channel.close();
|
// channel.close();
|
||||||
} catch (IOException e) {
|
// } catch (IOException e) {
|
||||||
log.error("Release WorkId file lock error", e);
|
// log.error("Release WorkId file lock error", e);
|
||||||
}
|
// }
|
||||||
}));
|
// }));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.bonus.system.config;
|
//package com.bonus.system.config;
|
||||||
|
//
|
||||||
import com.bonus.common.core.utils.id.IdWorkConfiguration;
|
//import com.bonus.common.core.utils.id.IdWorkConfiguration;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
//import org.springframework.context.annotation.Import;
|
||||||
|
//
|
||||||
@Configuration
|
//@Configuration
|
||||||
@Import({IdWorkConfiguration.class})
|
//@Import({IdWorkConfiguration.class})
|
||||||
public class CommonConfiguration {
|
//public class CommonConfiguration {
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,112 +1,112 @@
|
||||||
package com.bonus.system.controller;
|
//package com.bonus.system.controller;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
import com.bonus.common.log.enums.OperaType;
|
//import com.bonus.common.log.enums.OperaType;
|
||||||
import io.swagger.annotations.Api;
|
//import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
//import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
//import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
//import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.bonus.common.log.annotation.SysLog;
|
//import com.bonus.common.log.annotation.SysLog;
|
||||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
//import com.bonus.common.security.annotation.RequiresPermissions;
|
||||||
import com.bonus.system.domain.AllocArea;
|
//import com.bonus.system.domain.AllocArea;
|
||||||
import com.bonus.system.service.IAllocAreaService;
|
//import com.bonus.system.service.IAllocAreaService;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
//import com.bonus.common.core.web.controller.BaseController;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
//import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
//import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.page.TableDataInfo;
|
//import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 区域Controller
|
// * 区域Controller
|
||||||
*
|
// *
|
||||||
* @author xsheng
|
// * @author xsheng
|
||||||
* @date 2025-02-18
|
// * @date 2025-02-18
|
||||||
*/
|
// */
|
||||||
@Api(tags = "区域接口")
|
//@Api(tags = "区域接口")
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/alloc_area")
|
//@RequestMapping("/alloc_area")
|
||||||
public class AllocAreaController extends BaseController {
|
//public class AllocAreaController extends BaseController {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private IAllocAreaService sysAllocAreaService;
|
// private IAllocAreaService sysAllocAreaService;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 查询区域列表
|
// * 查询区域列表
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "查询区域列表")
|
// @ApiOperation(value = "查询区域列表")
|
||||||
@RequiresPermissions("system:area:list")
|
// @RequiresPermissions("system:area:list")
|
||||||
@GetMapping("/list")
|
// @GetMapping("/list")
|
||||||
public TableDataInfo list(AllocArea sysAllocArea) {
|
// public TableDataInfo list(AllocArea sysAllocArea) {
|
||||||
startPage();
|
// startPage();
|
||||||
List<AllocArea> list = sysAllocAreaService.selectAllocAreaList(sysAllocArea);
|
// List<AllocArea> list = sysAllocAreaService.selectAllocAreaList(sysAllocArea);
|
||||||
return getDataTable(list);
|
// return getDataTable(list);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 导出区域列表
|
// * 导出区域列表
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "导出区域列表")
|
// @ApiOperation(value = "导出区域列表")
|
||||||
@RequiresPermissions("system:area:export")
|
// @RequiresPermissions("system:area:export")
|
||||||
@SysLog(title = "区域", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出区域")
|
// @SysLog(title = "区域", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出区域")
|
||||||
@PostMapping("/export")
|
// @PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, AllocArea sysAllocArea) {
|
// public void export(HttpServletResponse response, AllocArea sysAllocArea) {
|
||||||
List<AllocArea> list = sysAllocAreaService.selectAllocAreaList(sysAllocArea);
|
// List<AllocArea> list = sysAllocAreaService.selectAllocAreaList(sysAllocArea);
|
||||||
ExcelUtil<AllocArea> util = new ExcelUtil<AllocArea>(AllocArea.class);
|
// ExcelUtil<AllocArea> util = new ExcelUtil<AllocArea>(AllocArea.class);
|
||||||
util.exportExcel(response, list, "区域数据");
|
// util.exportExcel(response, list, "区域数据");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 获取区域详细信息
|
// * 获取区域详细信息
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "获取区域详细信息")
|
// @ApiOperation(value = "获取区域详细信息")
|
||||||
@RequiresPermissions("system:area:query")
|
// @RequiresPermissions("system:area:query")
|
||||||
@GetMapping(value = "/{areaId}")
|
// @GetMapping(value = "/{areaId}")
|
||||||
public AjaxResult getInfo(@PathVariable("areaId") Long areaId) {
|
// public AjaxResult getInfo(@PathVariable("areaId") Long areaId) {
|
||||||
return success(sysAllocAreaService.selectAllocAreaByAreaId(areaId));
|
// return success(sysAllocAreaService.selectAllocAreaByAreaId(areaId));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 新增区域
|
// * 新增区域
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "新增区域")
|
// @ApiOperation(value = "新增区域")
|
||||||
@RequiresPermissions("system:area:add")
|
// @RequiresPermissions("system:area:add")
|
||||||
@SysLog(title = "区域", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增区域")
|
// @SysLog(title = "区域", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增区域")
|
||||||
@PostMapping
|
// @PostMapping
|
||||||
public AjaxResult add(@RequestBody AllocArea sysAllocArea) {
|
// public AjaxResult add(@RequestBody AllocArea sysAllocArea) {
|
||||||
try {
|
// try {
|
||||||
return toAjax(sysAllocAreaService.insertAllocArea(sysAllocArea));
|
// return toAjax(sysAllocAreaService.insertAllocArea(sysAllocArea));
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return error("系统错误, " + e.getMessage());
|
// return error("系统错误, " + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 修改区域
|
// * 修改区域
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "修改区域")
|
// @ApiOperation(value = "修改区域")
|
||||||
@RequiresPermissions("system:area:edit")
|
// @RequiresPermissions("system:area:edit")
|
||||||
@SysLog(title = "区域", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改区域")
|
// @SysLog(title = "区域", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改区域")
|
||||||
@PostMapping("/edit")
|
// @PostMapping("/edit")
|
||||||
public AjaxResult edit(@RequestBody AllocArea sysAllocArea) {
|
// public AjaxResult edit(@RequestBody AllocArea sysAllocArea) {
|
||||||
try {
|
// try {
|
||||||
return toAjax(sysAllocAreaService.updateAllocArea(sysAllocArea));
|
// return toAjax(sysAllocAreaService.updateAllocArea(sysAllocArea));
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return error("系统错误, " + e.getMessage());
|
// return error("系统错误, " + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 删除区域
|
// * 删除区域
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "删除区域")
|
// @ApiOperation(value = "删除区域")
|
||||||
@RequiresPermissions("system:area:remove")
|
// @RequiresPermissions("system:area:remove")
|
||||||
@SysLog(title = "区域", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除区域")
|
// @SysLog(title = "区域", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除区域")
|
||||||
@PostMapping("/del/{areaIds}")
|
// @PostMapping("/del/{areaIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] areaIds) {
|
// public AjaxResult remove(@PathVariable Long[] areaIds) {
|
||||||
return toAjax(sysAllocAreaService.deleteAllocAreaByAreaIds(areaIds));
|
// return toAjax(sysAllocAreaService.deleteAllocAreaByAreaIds(areaIds));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,60 @@
|
||||||
package com.bonus.system.service;
|
//package com.bonus.system.service;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import com.bonus.system.domain.AllocArea;
|
//import com.bonus.system.domain.AllocArea;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 区域Service接口
|
// * 区域Service接口
|
||||||
*
|
// *
|
||||||
* @author xsheng
|
// * @author xsheng
|
||||||
* @date 2025-02-18
|
// * @date 2025-02-18
|
||||||
*/
|
// */
|
||||||
public interface IAllocAreaService {
|
//public interface IAllocAreaService {
|
||||||
/**
|
// /**
|
||||||
* 查询区域
|
// * 查询区域
|
||||||
*
|
// *
|
||||||
* @param areaId 区域主键
|
// * @param areaId 区域主键
|
||||||
* @return 区域
|
// * @return 区域
|
||||||
*/
|
// */
|
||||||
public AllocArea selectAllocAreaByAreaId(Long areaId);
|
// public AllocArea selectAllocAreaByAreaId(Long areaId);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 查询区域列表
|
// * 查询区域列表
|
||||||
*
|
// *
|
||||||
* @param sysAllocArea 区域
|
// * @param sysAllocArea 区域
|
||||||
* @return 区域集合
|
// * @return 区域集合
|
||||||
*/
|
// */
|
||||||
public List<AllocArea> selectAllocAreaList(AllocArea sysAllocArea);
|
// public List<AllocArea> selectAllocAreaList(AllocArea sysAllocArea);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 新增区域
|
// * 新增区域
|
||||||
*
|
// *
|
||||||
* @param sysAllocArea 区域
|
// * @param sysAllocArea 区域
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
public int insertAllocArea(AllocArea sysAllocArea);
|
// public int insertAllocArea(AllocArea sysAllocArea);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 修改区域
|
// * 修改区域
|
||||||
*
|
// *
|
||||||
* @param sysAllocArea 区域
|
// * @param sysAllocArea 区域
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
public int updateAllocArea(AllocArea sysAllocArea);
|
// public int updateAllocArea(AllocArea sysAllocArea);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 批量删除区域
|
// * 批量删除区域
|
||||||
*
|
// *
|
||||||
* @param areaIds 需要删除的区域主键集合
|
// * @param areaIds 需要删除的区域主键集合
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
public int deleteAllocAreaByAreaIds(Long[] areaIds);
|
// public int deleteAllocAreaByAreaIds(Long[] areaIds);
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 删除区域信息
|
// * 删除区域信息
|
||||||
*
|
// *
|
||||||
* @param areaId 区域主键
|
// * @param areaId 区域主键
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
public int deleteAllocAreaByAreaId(Long areaId);
|
// public int deleteAllocAreaByAreaId(Long areaId);
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,109 +1,109 @@
|
||||||
package com.bonus.system.service.impl;
|
//package com.bonus.system.service.impl;
|
||||||
|
//
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
//import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
//import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.utils.id.Id;
|
//import com.bonus.common.core.utils.id.Id;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
//import org.springframework.stereotype.Service;
|
||||||
import com.bonus.system.mapper.AllocAreaMapper;
|
//import com.bonus.system.mapper.AllocAreaMapper;
|
||||||
import com.bonus.system.domain.AllocArea;
|
//import com.bonus.system.domain.AllocArea;
|
||||||
import com.bonus.system.service.IAllocAreaService;
|
//import com.bonus.system.service.IAllocAreaService;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 区域Service业务层处理
|
// * 区域Service业务层处理
|
||||||
*
|
// *
|
||||||
* @author xsheng
|
// * @author xsheng
|
||||||
* @date 2025-02-18
|
// * @date 2025-02-18
|
||||||
*/
|
// */
|
||||||
@Service
|
//@Service
|
||||||
public class AllocAreaServiceImpl implements IAllocAreaService {
|
//public class AllocAreaServiceImpl implements IAllocAreaService {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AllocAreaMapper allocAreaMapper;
|
// private AllocAreaMapper allocAreaMapper;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 查询区域
|
// * 查询区域
|
||||||
*
|
// *
|
||||||
* @param areaId 区域主键
|
// * @param areaId 区域主键
|
||||||
* @return 区域
|
// * @return 区域
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public AllocArea selectAllocAreaByAreaId(Long areaId) {
|
// public AllocArea selectAllocAreaByAreaId(Long areaId) {
|
||||||
return allocAreaMapper.selectAllocAreaByAreaId(areaId);
|
// return allocAreaMapper.selectAllocAreaByAreaId(areaId);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 查询区域列表
|
// * 查询区域列表
|
||||||
*
|
// *
|
||||||
* @param sysAllocArea 区域
|
// * @param sysAllocArea 区域
|
||||||
* @return 区域
|
// * @return 区域
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public List<AllocArea> selectAllocAreaList(AllocArea sysAllocArea) {
|
// public List<AllocArea> selectAllocAreaList(AllocArea sysAllocArea) {
|
||||||
return allocAreaMapper.selectAllocAreaList(sysAllocArea);
|
// return allocAreaMapper.selectAllocAreaList(sysAllocArea);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 新增区域
|
// * 新增区域
|
||||||
*
|
// *
|
||||||
* @param allocArea 区域
|
// * @param allocArea 区域
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public int insertAllocArea(AllocArea allocArea) {
|
// public int insertAllocArea(AllocArea allocArea) {
|
||||||
allocArea.setCreateTime(DateUtils.getNowDate());
|
// allocArea.setCreateTime(DateUtils.getNowDate());
|
||||||
try {
|
// try {
|
||||||
//增加根公司的处理
|
// //增加根公司的处理
|
||||||
if (allocArea.getParentId() == null) {
|
// if (allocArea.getParentId() == null) {
|
||||||
allocArea.setParentId(0L);
|
// allocArea.setParentId(0L);
|
||||||
allocArea.setAncestors("0");
|
// allocArea.setAncestors("0");
|
||||||
allocArea.setStatus("0");//默认启用
|
// allocArea.setStatus("0");//默认启用
|
||||||
} else {
|
// } else {
|
||||||
AllocArea info = allocAreaMapper.selectAllocAreaByAreaId(allocArea.getParentId());
|
// AllocArea info = allocAreaMapper.selectAllocAreaByAreaId(allocArea.getParentId());
|
||||||
allocArea.setAncestors(info.getAncestors() + "," + allocArea.getParentId());
|
// allocArea.setAncestors(info.getAncestors() + "," + allocArea.getParentId());
|
||||||
}
|
// }
|
||||||
allocArea.setAreaId(Id.next());
|
// allocArea.setAreaId(Id.next());
|
||||||
return allocAreaMapper.insertAllocArea(allocArea);
|
// return allocAreaMapper.insertAllocArea(allocArea);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
throw new ServiceException("新增区域错误" + e.getMessage());
|
// throw new ServiceException("新增区域错误" + e.getMessage());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 修改区域
|
// * 修改区域
|
||||||
*
|
// *
|
||||||
* @param sysAllocArea 区域
|
// * @param sysAllocArea 区域
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public int updateAllocArea(AllocArea sysAllocArea) {
|
// public int updateAllocArea(AllocArea sysAllocArea) {
|
||||||
sysAllocArea.setUpdateTime(DateUtils.getNowDate());
|
// sysAllocArea.setUpdateTime(DateUtils.getNowDate());
|
||||||
try {
|
// try {
|
||||||
return allocAreaMapper.updateAllocArea(sysAllocArea);
|
// return allocAreaMapper.updateAllocArea(sysAllocArea);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
throw new ServiceException("错误信息描述");
|
// throw new ServiceException("错误信息描述");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 批量删除区域
|
// * 批量删除区域
|
||||||
*
|
// *
|
||||||
* @param areaIds 需要删除的区域主键
|
// * @param areaIds 需要删除的区域主键
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public int deleteAllocAreaByAreaIds(Long[] areaIds) {
|
// public int deleteAllocAreaByAreaIds(Long[] areaIds) {
|
||||||
return allocAreaMapper.deleteAllocAreaByAreaIds(areaIds);
|
// return allocAreaMapper.deleteAllocAreaByAreaIds(areaIds);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 删除区域信息
|
// * 删除区域信息
|
||||||
*
|
// *
|
||||||
* @param areaId 区域主键
|
// * @param areaId 区域主键
|
||||||
* @return 结果
|
// * @return 结果
|
||||||
*/
|
// */
|
||||||
@Override
|
// @Override
|
||||||
public int deleteAllocAreaByAreaId(Long areaId) {
|
// public int deleteAllocAreaByAreaId(Long areaId) {
|
||||||
return allocAreaMapper.deleteAllocAreaByAreaId(areaId);
|
// return allocAreaMapper.deleteAllocAreaByAreaId(areaId);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.core.utils.id.Id;
|
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
import com.bonus.config.SystemConfig;
|
import com.bonus.config.SystemConfig;
|
||||||
import com.bonus.system.api.domain.*;
|
import com.bonus.system.api.domain.*;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import com.bonus.common.core.utils.SpringUtils;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.core.utils.bean.BeanValidators;
|
import com.bonus.common.core.utils.bean.BeanValidators;
|
||||||
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||||
import com.bonus.common.core.utils.id.Id;
|
|
||||||
import com.bonus.common.core.utils.sms.SmsUtils;
|
import com.bonus.common.core.utils.sms.SmsUtils;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
|
@ -360,9 +359,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int insertUser(SysUser user) {
|
public int insertUser(SysUser user) {
|
||||||
user.setCustId(Id.next());
|
|
||||||
// 新增用户信息
|
// 新增用户信息
|
||||||
int rows = userMapper.insertUser(user);
|
int rows = userMapper.insertUser(user);
|
||||||
|
user.setCustId(user.getUserId());
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
insertUserPost(user);
|
insertUserPost(user);
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
|
|
@ -378,8 +377,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean registerUser(SysUser user) {
|
public boolean registerUser(SysUser user) {
|
||||||
user.setCustId(Id.next());
|
int count = userMapper.insertUser(user);
|
||||||
return userMapper.insertUser(user) > 0;
|
user.setCustId(user.getUserId());
|
||||||
|
return count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -585,7 +585,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
String password = configService.selectConfigByKey("sys.user.initPassword");
|
||||||
user.setPassword(SecurityUtils.encryptPassword(password));
|
user.setPassword(SecurityUtils.encryptPassword(password));
|
||||||
user.setCreateBy(operName);
|
user.setCreateBy(operName);
|
||||||
user.setCustId(Id.next());
|
user.setCustId(user.getUserId());
|
||||||
userMapper.insertUser(user);
|
userMapper.insertUser(user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue