mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
新增-智能分线相关接口
This commit is contained in:
+3
-3
@@ -6,7 +6,7 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.module.system.api.setting.dto.PackageConfigDTO;
|
||||
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
|
||||
import com.cf.imes.module.system.dal.mysql.setting.SettingMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.setting.PackageConfigMapper;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SettingApiImpl implements SettingApi{
|
||||
|
||||
|
||||
@Resource
|
||||
private SettingMapper settingMapper;
|
||||
private PackageConfigMapper packageConfigMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -30,7 +30,7 @@ public class SettingApiImpl implements SettingApi{
|
||||
|
||||
LoginUser loginUser = getLoginUser();
|
||||
assert loginUser != null;
|
||||
PackageConfigDO packageConfigDO = settingMapper.selectSetting(type, loginUser.getId(), loginUser.getOrganId());
|
||||
PackageConfigDO packageConfigDO = packageConfigMapper.selectSetting(type, loginUser.getId(), loginUser.getOrganId());
|
||||
|
||||
if(packageConfigDO == null){
|
||||
throw exception(CURRENTLY_NO_CONFIGURATION_AVAILABLE,type == 1 ? UserSettingTypeEnum.PREPACKAGED.getName(): UserSettingTypeEnum.PACKAGED.getName());
|
||||
|
||||
+15
-5
@@ -2,8 +2,11 @@ package com.cf.imes.module.system.controller.admin.setting;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.setting.vo.PackageConfigReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigRespVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.service.setting.SettingService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@@ -16,7 +19,7 @@ import javax.annotation.Resource;
|
||||
|
||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 系统配置")
|
||||
@Tag(name = "管理后台 - 系统打包配置")
|
||||
@RestController
|
||||
@RequestMapping("/system/setting")
|
||||
@Validated
|
||||
@@ -29,7 +32,7 @@ public class SettingController {
|
||||
|
||||
|
||||
@PutMapping("/insert")
|
||||
@Operation(summary = "新增系统配置")
|
||||
@Operation(summary = "新增打包系统配置")
|
||||
//@PreAuthorize("@ss.hasPermission('system:data-source:query')")
|
||||
public CommonResult<Long> insertSetting( @RequestBody PackageConfigReqVO reqVO ) {
|
||||
|
||||
@@ -41,7 +44,7 @@ public class SettingController {
|
||||
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "更新系统配置")
|
||||
@Operation(summary = "更新打包系统配置")
|
||||
//@PreAuthorize("@ss.hasPermission('system:data-source:query')")
|
||||
public CommonResult<Long> updateSetting( @RequestBody PackageConfigReqVO reqVO ) {
|
||||
|
||||
@@ -52,15 +55,22 @@ public class SettingController {
|
||||
|
||||
|
||||
@GetMapping("/select")
|
||||
@Operation(summary = "查看当前用户的配置信息")
|
||||
@Operation(summary = "查看当前用户的打包配置信息")
|
||||
@Parameter(name = "type", description = "配置类型", required = true)
|
||||
public CommonResult<PackageConfigDO> selectSetting(@RequestParam("type") Integer type ) {
|
||||
|
||||
return success(settingService.selectSetting(type));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/selectDefault")
|
||||
@Operation(summary = "获取默认的智能分线配置")
|
||||
public CommonResult<ConfigRespVO> selectDefaultBranching() {
|
||||
SystemConfigDO systemConfigDO = settingService.selectDefaultBranching();
|
||||
return success(BeanUtils.toBean(systemConfigDO, ConfigRespVO.class));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+12
-10
@@ -3,22 +3,14 @@ package com.cf.imes.module.system.controller.admin.systemconfig;
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.*;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.service.config.SystemConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
@@ -70,4 +62,14 @@ public class SystemConfigController {
|
||||
systemConfigService.modifySystemConfig(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("")
|
||||
@Operation(summary = "删除系统配置")
|
||||
@PreAuthorize("@ss.hasPermission('system:base-setting:setting')")
|
||||
public CommonResult<Boolean> deleteSystemConfig(@Valid @RequestBody ConfigDeleteReqVO reqVO) {
|
||||
systemConfigService.deleteSystemConfig(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.system.controller.admin.systemconfig.vo;
|
||||
|
||||
|
||||
import com.cf.imes.module.system.validation.config.SystemConfigTypeEnumValid;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 基础配置删除 Request VO")
|
||||
@Data
|
||||
public class ConfigDeleteReqVO {
|
||||
|
||||
@Schema(description = "基础配置编号", example = "1")
|
||||
@NotNull(message = "系统配置编号不能为空")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Schema(description = "配置类型:1 自定义板编号,2 智能分线,3 高级筛选'", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "配置类型不能为空")
|
||||
@SystemConfigTypeEnumValid
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class ConfigSaveReqVO {
|
||||
@Size(max = 64, message = "基础配置名称长度不能超过 64 个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "配置类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@Schema(description = "配置类型:1 自定义板编号,2 智能分线,3 高级筛选'", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "配置类型不能为空")
|
||||
@SystemConfigTypeEnumValid
|
||||
private Integer type;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class ConfigUpdateStatusReqVO {
|
||||
@NotNull(message = "系统配置编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举(0启用1禁用) ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface SettingMapper extends BaseMapperX<PackageConfigDO> {
|
||||
public interface PackageConfigMapper extends BaseMapperX<PackageConfigDO> {
|
||||
|
||||
|
||||
|
||||
+25
@@ -1,13 +1,17 @@
|
||||
package com.cf.imes.module.system.dal.mysql.systemconfig;
|
||||
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统配置 Mapper
|
||||
*
|
||||
@@ -31,4 +35,25 @@ public interface SystemConfigMapper extends BaseMapperX<SystemConfigDO> {
|
||||
.select(SystemConfigDO::getId, SystemConfigDO::getName, SystemConfigDO::getStatus, SystemConfigDO::getType)
|
||||
.orderByAsc(SystemConfigDO::getId));
|
||||
}
|
||||
|
||||
|
||||
default SystemConfigDO selectDefaultBranching() {
|
||||
return selectOne(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
.eqIfPresent(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getDeleted,false)
|
||||
.eq(SystemConfigDO::getType, SystemConfigTypeEnum.INTELLIGENT_BRANCH.getType())
|
||||
.eq(SystemConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
default List<SystemConfigDO> selectSystemConfigList(Integer type,Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
.eqIfPresent(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getDeleted,false)
|
||||
.eq(SystemConfigDO::getType, type)
|
||||
.eqIfPresent(SystemConfigDO::getStatus,status));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.service.config;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
@@ -49,4 +50,7 @@ public interface SystemConfigService {
|
||||
* @return
|
||||
*/
|
||||
SystemConfigCopyDO getOrgCustomPlateNoConfig();
|
||||
|
||||
void deleteSystemConfig(ConfigDeleteReqVO reqVO);
|
||||
|
||||
}
|
||||
|
||||
+13
@@ -8,6 +8,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
@@ -72,6 +73,8 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
systemConfigDO = validateSystemConfigExists(id);
|
||||
// 覆盖配置
|
||||
systemConfigDO.setSetting(reqVO.getSetting());
|
||||
// 覆盖名称
|
||||
systemConfigDO.setName(reqVO.getName());
|
||||
// 更新
|
||||
systemConfigMapper.updateById(systemConfigDO);
|
||||
} else {
|
||||
@@ -113,6 +116,16 @@ public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteSystemConfig(ConfigDeleteReqVO reqVO) {
|
||||
validateSystemConfigExists(reqVO.getId());
|
||||
// 根据配置类型选择对应的service
|
||||
AbstractSystemConfigServiceHandler configService = configServiceFactory.getConfigServiceHandler(reqVO.getType());
|
||||
configService.deleteConfig(reqVO);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验基础配置是否存在
|
||||
*
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
||||
import com.cf.imes.module.system.service.config.factory.service.impl.CustomPlateNoServiceHandler;
|
||||
import com.cf.imes.module.system.service.config.factory.service.impl.DefaultSystemConfigServiceHandler;
|
||||
import com.cf.imes.module.system.service.config.factory.service.impl.IntellectBranchingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -34,7 +35,7 @@ public class SystemConfigServiceFactory {
|
||||
case CUSTOM_PLATE_NO:
|
||||
return applicationContext.getBean(CustomPlateNoServiceHandler.class);
|
||||
case INTELLIGENT_BRANCH:
|
||||
// todo 智能分线
|
||||
return applicationContext.getBean(IntellectBranchingService.class);
|
||||
case ADVANCED_SCREEN:
|
||||
// todo 高级筛选
|
||||
default:
|
||||
|
||||
+11
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.service.config.factory.service;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
@@ -52,4 +53,14 @@ public abstract class AbstractSystemConfigServiceHandler {
|
||||
* @param reqVO
|
||||
*/
|
||||
public abstract void afterUpdateStatus(SystemConfigDO systemConfigDO, ConfigUpdateStatusReqVO reqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 删除系统配置操作
|
||||
*
|
||||
* @param reqVO
|
||||
*/
|
||||
public abstract void deleteConfig(ConfigDeleteReqVO reqVO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -11,6 +11,7 @@ import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
@@ -234,4 +235,9 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
|
||||
log.info("[CustomPlateNoGenerateService][afterUpdateStatus]key:{}缓存删除结果:{}", redisKey, delete);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConfig(ConfigDeleteReqVO reqVO) {
|
||||
// TODO document why this method is empty
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.config.factory.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
@@ -59,4 +60,9 @@ public class DefaultSystemConfigServiceHandler extends AbstractSystemConfigServi
|
||||
public void afterUpdateStatus(SystemConfigDO systemConfigDO, ConfigUpdateStatusReqVO reqVO) {
|
||||
// todo afterUpdateStatus
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteConfig(ConfigDeleteReqVO reqVO) {
|
||||
// TODO document why this method is empty
|
||||
}
|
||||
}
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.cf.imes.module.system.service.config.factory.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.exception.ServiceException;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigServiceHandler;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author 智能分线生成服务
|
||||
*/
|
||||
@Service("intellectBranchingService")
|
||||
public class IntellectBranchingService extends AbstractSystemConfigServiceHandler {
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<SystemConfigDO> selectPage(ConfigPageReqVO pageReqVO) {
|
||||
|
||||
List<SystemConfigDO> systemConfigDOS = systemConfigMapper.selectSystemConfigList(pageReqVO.getType(),null);
|
||||
|
||||
if (systemConfigDOS.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
|
||||
PageResult<SystemConfigDO> pageResult = new PageResult<>();
|
||||
|
||||
pageResult.setList(systemConfigDOS);
|
||||
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkValid(String setting) {
|
||||
|
||||
JSONArray jsonArray = JSON.parseArray(setting);
|
||||
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
|
||||
checkMachineId(jsonObject.getString("machineId"));
|
||||
checkMachineName(jsonObject.getString("machineName"));
|
||||
checkMachineConfig(jsonObject.get("machineConfig"));
|
||||
}
|
||||
|
||||
if(jsonArray.size() < 2){
|
||||
throw new ServiceException(BRANCHING_SETTING_COUNT_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void beforeSaveConfig(ConfigSaveReqVO reqVO) {
|
||||
|
||||
// todo beforeSaveConfig
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void afterSaveConfig(SystemConfigDO systemConfigDO, ConfigSaveReqVO reqVO) {
|
||||
|
||||
List<SystemConfigDO> systemConfigDOS = systemConfigMapper.selectSystemConfigList(reqVO.getType(), CommonStatusEnum.ENABLE.getStatus());
|
||||
|
||||
if(systemConfigDOS.size() > 1){
|
||||
systemConfigMapper.update(new LambdaUpdateWrapper<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getId,systemConfigDO.getId())
|
||||
.set(SystemConfigDO::getStatus, CommonStatusEnum.DISABLE.getStatus()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterUpdateStatus(SystemConfigDO systemConfigDO, ConfigUpdateStatusReqVO reqVO) {
|
||||
|
||||
systemConfigMapper.update(new LambdaUpdateWrapper<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.eq(SystemConfigDO::getDeleted,false)
|
||||
.notIn(SystemConfigDO::getId,reqVO.getId())
|
||||
.eq(SystemConfigDO::getType, systemConfigDO.getType())
|
||||
.set(SystemConfigDO::getStatus, CommonStatusEnum.DISABLE.getStatus()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteConfig(ConfigDeleteReqVO reqVO) {
|
||||
|
||||
systemConfigMapper.deleteById(reqVO.getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验 机台ID
|
||||
*
|
||||
*/
|
||||
private void checkMachineId(String machineId) {
|
||||
if (StringUtils.isBlank(machineId)) {
|
||||
throw new ServiceException(BRANCHING_SETTING_RULE_SAVE_CHECK_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验 机台名称
|
||||
*
|
||||
*/
|
||||
private void checkMachineName(String machineName) {
|
||||
if (StringUtils.isBlank(machineName)) {
|
||||
throw new ServiceException(BRANCHING_SETTING_RULE_SAVE_CHECK_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验 机台分流条件
|
||||
*
|
||||
*/
|
||||
private void checkMachineConfig(Object machineConfig) {
|
||||
if (ObjectUtil.isEmpty(machineConfig)) {
|
||||
throw new ServiceException(BRANCHING_SETTING_SAVE_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -114,7 +114,6 @@ public class MachineTemplateServiceImpl implements MachineTemplateService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateCuttingTemplate(CuttingTemplateSaveReqVO reqVO) {
|
||||
|
||||
// todo 测试时的判断,测试完毕后删除
|
||||
MachineBrandDO machineBrandDO = machineBrandMapper.selectById(reqVO.getNowBrandId());
|
||||
if (machineBrandDO == null) {
|
||||
throw exception(THE_CURRENT_BRAND);
|
||||
|
||||
+3
-1
@@ -3,7 +3,7 @@ package com.cf.imes.module.system.service.setting;
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.setting.vo.PackageConfigReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
|
||||
public interface SettingService {
|
||||
|
||||
@@ -14,4 +14,6 @@ public interface SettingService {
|
||||
Long updateSetting(PackageConfigReqVO reqVO);
|
||||
|
||||
PackageConfigDO selectSetting(Integer type);
|
||||
|
||||
SystemConfigDO selectDefaultBranching();
|
||||
}
|
||||
|
||||
+24
-10
@@ -2,11 +2,14 @@ package com.cf.imes.module.system.service.setting;
|
||||
|
||||
|
||||
import com.cf.imes.framework.common.enums.UserSettingTypeEnum;
|
||||
import com.cf.imes.framework.common.util.Assert.AssertUtils;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
import com.cf.imes.module.system.controller.admin.setting.vo.PackageConfigReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
|
||||
import com.cf.imes.module.system.dal.mysql.setting.SettingMapper;
|
||||
import com.cf.imes.module.system.dal.dataobject.systemconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.dal.mysql.setting.PackageConfigMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.systemconfig.SystemConfigMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -15,7 +18,7 @@ import javax.annotation.Resource;
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.json.JsonUtils.unzipString;
|
||||
import static com.cf.imes.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.CURRENTLY_NO_CONFIGURATION_AVAILABLE;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -24,15 +27,17 @@ public class SettingServiceImpl implements SettingService{
|
||||
|
||||
|
||||
@Resource
|
||||
private SettingMapper settingMapper;
|
||||
private PackageConfigMapper packageConfigMapper;
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
@Override
|
||||
public Long insertSetting(PackageConfigReqVO reqVO) {
|
||||
|
||||
LoginUser loginUser = getLoginUser();
|
||||
|
||||
settingMapper.deleteSetting(reqVO.getType(),loginUser.getId(),loginUser.getOrganId());
|
||||
packageConfigMapper.deleteSetting(reqVO.getType(),loginUser.getId(),loginUser.getOrganId());
|
||||
|
||||
PackageConfigDO packageConfigDO = PackageConfigDO.builder()
|
||||
.userId(loginUser.getId())
|
||||
@@ -41,7 +46,7 @@ public class SettingServiceImpl implements SettingService{
|
||||
.type(reqVO.getType())
|
||||
.build();
|
||||
|
||||
settingMapper.insert(packageConfigDO);
|
||||
packageConfigMapper.insert(packageConfigDO);
|
||||
|
||||
|
||||
return packageConfigDO.getId();
|
||||
@@ -54,14 +59,14 @@ public class SettingServiceImpl implements SettingService{
|
||||
|
||||
LoginUser loginUser = getLoginUser();
|
||||
// 更新
|
||||
PackageConfigDO packageConfigDO = settingMapper.selectSetting(reqVO.getType(), loginUser.getId(), loginUser.getOrganId());
|
||||
PackageConfigDO packageConfigDO = packageConfigMapper.selectSetting(reqVO.getType(), loginUser.getId(), loginUser.getOrganId());
|
||||
if (packageConfigDO == null) {
|
||||
throw exception(CURRENTLY_NO_CONFIGURATION_AVAILABLE,reqVO.getType() == 1 ? UserSettingTypeEnum.PREPACKAGED.getName(): UserSettingTypeEnum.PACKAGED.getName());
|
||||
}
|
||||
if(reqVO.getSetting() != null) {
|
||||
packageConfigDO.setSetting(JsonUtils.zipString(reqVO.getSetting().toJSONString()));
|
||||
}
|
||||
settingMapper.updateById(packageConfigDO);
|
||||
packageConfigMapper.updateById(packageConfigDO);
|
||||
|
||||
return packageConfigDO.getId();
|
||||
}
|
||||
@@ -74,18 +79,27 @@ public class SettingServiceImpl implements SettingService{
|
||||
LoginUser loginUser = getLoginUser();
|
||||
|
||||
assert loginUser != null;
|
||||
PackageConfigDO packageConfigDO = settingMapper.selectSetting(type, loginUser.getId(), loginUser.getOrganId());
|
||||
PackageConfigDO packageConfigDO = packageConfigMapper.selectSetting(type, loginUser.getId(), loginUser.getOrganId());
|
||||
|
||||
if (packageConfigDO == null) {
|
||||
throw exception(CURRENTLY_NO_CONFIGURATION_AVAILABLE,type == 1 ? UserSettingTypeEnum.PREPACKAGED.getName(): UserSettingTypeEnum.PACKAGED.getName());
|
||||
}
|
||||
|
||||
|
||||
packageConfigDO.setSetting(unzipString(packageConfigDO.getSetting()));
|
||||
|
||||
|
||||
return packageConfigDO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SystemConfigDO selectDefaultBranching() {
|
||||
|
||||
SystemConfigDO systemConfigDO = systemConfigMapper.selectDefaultBranching();
|
||||
|
||||
AssertUtils.notEmpty(systemConfigDO,BRANCHING_DEFAULT_SETTING_ERROR);
|
||||
|
||||
return systemConfigDO;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user