|
|
@@ -61,7 +61,8 @@ public class DashboardsService {
|
|
|
*/
|
|
|
public RepEntity setDashboards(String token, DashboardsInfo dashboardsInfo) {
|
|
|
//校验报表编号是否已存在
|
|
|
- validCode(dashboardsInfo.getBdCode(), dashboardsInfo.getId());
|
|
|
+ String code = validCode(dashboardsInfo.getBdCode(), dashboardsInfo.getId());
|
|
|
+ dashboardsInfo.setBdCode(code);
|
|
|
Map<String, String> stringMap = GetTokenDataUtil.getTokenData(token);
|
|
|
int userId = Integer.parseInt(stringMap.get("id"));
|
|
|
String name = stringMap.get("name");
|
|
|
@@ -87,7 +88,8 @@ public class DashboardsService {
|
|
|
*/
|
|
|
public RepEntity updateDashboards(String token, DashboardsInfo dashboardsInfo) {
|
|
|
//校验报表编号是否已存在
|
|
|
- validCode(dashboardsInfo.getBdCode(), dashboardsInfo.getId());
|
|
|
+ String code = validCode(dashboardsInfo.getBdCode(), dashboardsInfo.getId());
|
|
|
+ dashboardsInfo.setBdCode(code);
|
|
|
Map<String, String> stringMap = GetTokenDataUtil.getTokenData(token);
|
|
|
int userId = Integer.parseInt(stringMap.get("id"));
|
|
|
String name = stringMap.get("name");
|
|
|
@@ -130,13 +132,31 @@ public class DashboardsService {
|
|
|
* @param code
|
|
|
* @param id
|
|
|
*/
|
|
|
- private void validCode(String code, int id) {
|
|
|
+ private String validCode(String code, int id) {
|
|
|
if (!StringUtils.isEmpty(code)) {
|
|
|
int count = dashboardsMapper.countBdCodeById(code, id);
|
|
|
if (count > 0) {
|
|
|
throw new MyException("编号" + code + "已存在");
|
|
|
}
|
|
|
+ return code;
|
|
|
+ }else {
|
|
|
+ return generateUUCode(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建报表唯一编号
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String generateUUCode(int id){
|
|
|
+ String UUcode = UUID.randomUUID().toString();
|
|
|
+ UUcode = UUcode.substring(UUcode.lastIndexOf("-") + 1);
|
|
|
+ int count = dashboardsMapper.countBdCodeById(UUcode, id);
|
|
|
+ if (count > 0) {
|
|
|
+ generateUUCode(id);
|
|
|
}
|
|
|
+ return UUcode;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -356,7 +376,7 @@ public class DashboardsService {
|
|
|
dashboards.setCreateBy(userName);
|
|
|
dashboards.setCreateId(userId);
|
|
|
dashboards.setDemo(false);
|
|
|
- dashboards.setBdCode("");
|
|
|
+ dashboards.setBdCode(generateUUCode(0));
|
|
|
dashboardsMapper.setDashboards(dashboards);
|
|
|
String[] ids = String.join(",", idList).split(",");
|
|
|
dashboardsMapper.saveDashboardChartRelation(dashboards.getId(), ids);
|