7 changed files with 650 additions and 0 deletions
-
70src/main/java/com/gaotao/modules/sys/controller/SysSceneExceptionRuleController.java
-
47src/main/java/com/gaotao/modules/sys/entity/SysSceneExceptionRuleConditionEntity.java
-
47src/main/java/com/gaotao/modules/sys/entity/SysSceneExceptionRuleEntity.java
-
39src/main/java/com/gaotao/modules/sys/mapper/SysSceneExceptionRuleMapper.java
-
26src/main/java/com/gaotao/modules/sys/service/SysSceneExceptionRuleService.java
-
237src/main/java/com/gaotao/modules/sys/service/impl/SysSceneExceptionRuleServiceImpl.java
-
184src/main/resources/mapper/sys/SysSceneExceptionRuleMapper.xml
@ -0,0 +1,70 @@ |
|||||
|
package com.gaotao.modules.sys.controller; |
||||
|
|
||||
|
import com.gaotao.common.utils.PageUtils; |
||||
|
import com.gaotao.common.utils.R; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleEntity; |
||||
|
import com.gaotao.modules.sys.service.SysSceneExceptionRuleService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
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 java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("sysSceneExceptionRule") |
||||
|
public class SysSceneExceptionRuleController { |
||||
|
|
||||
|
@Autowired |
||||
|
private SysSceneExceptionRuleService sysSceneExceptionRuleService; |
||||
|
|
||||
|
@PostMapping("/searchRule") |
||||
|
public R searchRule(@RequestBody SysSceneExceptionRuleEntity data) { |
||||
|
PageUtils page = sysSceneExceptionRuleService.searchRule(data); |
||||
|
return R.ok().put("page", page); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveRule") |
||||
|
public R saveRule(@RequestBody SysSceneExceptionRuleEntity data) { |
||||
|
sysSceneExceptionRuleService.saveRule(data); |
||||
|
return R.ok().put("ruleCode", data.getRuleCode()); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/updateRule") |
||||
|
public R updateRule(@RequestBody SysSceneExceptionRuleEntity data) { |
||||
|
sysSceneExceptionRuleService.updateRule(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/deleteRule") |
||||
|
public R deleteRule(@RequestBody SysSceneExceptionRuleEntity data) { |
||||
|
sysSceneExceptionRuleService.deleteRule(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/getConditionList") |
||||
|
public R getConditionList(@RequestBody SysSceneExceptionRuleConditionEntity data) { |
||||
|
List<SysSceneExceptionRuleConditionEntity> list = sysSceneExceptionRuleService.getConditionList(data); |
||||
|
return R.ok().put("rows", list); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/saveCondition") |
||||
|
public R saveCondition(@RequestBody SysSceneExceptionRuleConditionEntity data) { |
||||
|
sysSceneExceptionRuleService.saveCondition(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/updateCondition") |
||||
|
public R updateCondition(@RequestBody SysSceneExceptionRuleConditionEntity data) { |
||||
|
sysSceneExceptionRuleService.updateCondition(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/deleteCondition") |
||||
|
public R deleteCondition(@RequestBody SysSceneExceptionRuleConditionEntity data) { |
||||
|
sysSceneExceptionRuleService.deleteCondition(data); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package com.gaotao.modules.sys.entity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.gaotao.common.utils.QueryPage; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.math.BigDecimal; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class SysSceneExceptionRuleConditionEntity extends QueryPage { |
||||
|
|
||||
|
private String site; |
||||
|
private String buNo; |
||||
|
private String ruleCode; |
||||
|
private String conditionNo; |
||||
|
private String parentConditionNo; |
||||
|
private String relationField; |
||||
|
private String compareSymbol; |
||||
|
private BigDecimal conditionParam; |
||||
|
/** |
||||
|
* 强制 / 提示 |
||||
|
*/ |
||||
|
private String forceType; |
||||
|
private String warningLevel; |
||||
|
private String animationEffect; |
||||
|
private String responsibilityDept; |
||||
|
/** |
||||
|
* 异常代码 / 异常单 |
||||
|
*/ |
||||
|
private String triggerEvent; |
||||
|
private String createBy; |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createDate; |
||||
|
private String updateBy; |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date updateDate; |
||||
|
|
||||
|
private List<SysSceneExceptionRuleConditionEntity> children; |
||||
|
private List<SysSceneExceptionRuleConditionEntity> submitList; |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package com.gaotao.modules.sys.entity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.gaotao.common.utils.QueryPage; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
public class SysSceneExceptionRuleEntity extends QueryPage { |
||||
|
|
||||
|
private String site; |
||||
|
private String buNo; |
||||
|
/** |
||||
|
* 前端 BU 选择项,格式:site_buNo |
||||
|
*/ |
||||
|
private String bu; |
||||
|
private String ruleCode; |
||||
|
private String ruleName; |
||||
|
/** |
||||
|
* 应用页面 |
||||
|
*/ |
||||
|
private String applyPage; |
||||
|
/** |
||||
|
* 应用按钮 |
||||
|
*/ |
||||
|
private String applyButton; |
||||
|
/** |
||||
|
* Y: 启用 N: 禁用 |
||||
|
*/ |
||||
|
private String enableFlag; |
||||
|
private String userName; |
||||
|
private String createBy; |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createDate; |
||||
|
private String updateBy; |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date updateDate; |
||||
|
|
||||
|
private List<SysSceneExceptionRuleEntity> submitList; |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
package com.gaotao.modules.sys.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleEntity; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface SysSceneExceptionRuleMapper { |
||||
|
|
||||
|
IPage<SysSceneExceptionRuleEntity> searchRule(Page<SysSceneExceptionRuleEntity> page, |
||||
|
@Param("query") SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void saveRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void updateRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void deleteRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void deleteConditionByRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
List<SysSceneExceptionRuleConditionEntity> getConditionList(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
SysSceneExceptionRuleConditionEntity getCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
Integer countConditionNo(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void saveCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void updateCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void deleteCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void deleteConditionWithChildren(SysSceneExceptionRuleConditionEntity data); |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
package com.gaotao.modules.sys.service; |
||||
|
|
||||
|
import com.gaotao.common.utils.PageUtils; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface SysSceneExceptionRuleService { |
||||
|
|
||||
|
PageUtils searchRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void saveRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void updateRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
void deleteRule(SysSceneExceptionRuleEntity data); |
||||
|
|
||||
|
List<SysSceneExceptionRuleConditionEntity> getConditionList(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void saveCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void updateCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
|
||||
|
void deleteCondition(SysSceneExceptionRuleConditionEntity data); |
||||
|
} |
||||
@ -0,0 +1,237 @@ |
|||||
|
package com.gaotao.modules.sys.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.gaotao.common.utils.PageUtils; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity; |
||||
|
import com.gaotao.modules.sys.entity.SysSceneExceptionRuleEntity; |
||||
|
import com.gaotao.modules.sys.entity.SysUserEntity; |
||||
|
import com.gaotao.modules.sys.mapper.SysSceneExceptionRuleMapper; |
||||
|
import com.gaotao.modules.sys.service.SysSceneExceptionRuleService; |
||||
|
import com.gaotao.modules.trans.dao.TransNoControlMapper; |
||||
|
import com.gaotao.modules.trans.entity.TransNoControl; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.apache.shiro.SecurityUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.LinkedHashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class SysSceneExceptionRuleServiceImpl implements SysSceneExceptionRuleService { |
||||
|
|
||||
|
private static final String TRANS_TYPE = "ExR"; |
||||
|
|
||||
|
@Autowired |
||||
|
private SysSceneExceptionRuleMapper sysSceneExceptionRuleMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private TransNoControlMapper transNoControlMapper; |
||||
|
|
||||
|
@Override |
||||
|
public PageUtils searchRule(SysSceneExceptionRuleEntity data) { |
||||
|
int pageNo = data.getPage() <= 0 ? 1 : data.getPage(); |
||||
|
int pageSize = data.getLimit() <= 0 ? 20 : data.getLimit(); |
||||
|
IPage<SysSceneExceptionRuleEntity> page = sysSceneExceptionRuleMapper.searchRule( |
||||
|
new Page<SysSceneExceptionRuleEntity>(pageNo, pageSize), data); |
||||
|
return new PageUtils(page); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void saveRule(SysSceneExceptionRuleEntity data) { |
||||
|
fillSiteAndBu(data); |
||||
|
if (StringUtils.isBlank(data.getRuleName())) { |
||||
|
throw new RuntimeException("规则名称不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getApplyPage())) { |
||||
|
throw new RuntimeException("应用页面不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getApplyButton())) { |
||||
|
throw new RuntimeException("应用按钮不能为空"); |
||||
|
} |
||||
|
TransNoControl transNo = transNoControlMapper.getTransNo(data.getSite(), TRANS_TYPE, data.getBuNo()); |
||||
|
if (transNo == null || StringUtils.isBlank(transNo.getNewTransNo())) { |
||||
|
throw new RuntimeException("规则编码生成失败,请先在TransNoControl维护trans_type=" + TRANS_TYPE); |
||||
|
} |
||||
|
data.setRuleCode(transNo.getNewTransNo()); |
||||
|
data.setEnableFlag(StringUtils.isBlank(data.getEnableFlag()) ? "Y" : data.getEnableFlag()); |
||||
|
data.setCreateBy(getCurrentUserName()); |
||||
|
data.setUpdateBy(getCurrentUserName()); |
||||
|
sysSceneExceptionRuleMapper.saveRule(data); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void updateRule(SysSceneExceptionRuleEntity data) { |
||||
|
if (StringUtils.isBlank(data.getSite()) || StringUtils.isBlank(data.getBuNo()) || StringUtils.isBlank(data.getRuleCode())) { |
||||
|
throw new RuntimeException("更新失败,规则主键不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getRuleName())) { |
||||
|
throw new RuntimeException("规则名称不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getApplyPage())) { |
||||
|
throw new RuntimeException("应用页面不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getApplyButton())) { |
||||
|
throw new RuntimeException("应用按钮不能为空"); |
||||
|
} |
||||
|
data.setEnableFlag(StringUtils.isBlank(data.getEnableFlag()) ? "Y" : data.getEnableFlag()); |
||||
|
data.setUpdateBy(getCurrentUserName()); |
||||
|
sysSceneExceptionRuleMapper.updateRule(data); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void deleteRule(SysSceneExceptionRuleEntity data) { |
||||
|
List<SysSceneExceptionRuleEntity> deleteList = new ArrayList<>(); |
||||
|
if (data.getSubmitList() != null && !data.getSubmitList().isEmpty()) { |
||||
|
deleteList = data.getSubmitList(); |
||||
|
} else { |
||||
|
deleteList.add(data); |
||||
|
} |
||||
|
for (SysSceneExceptionRuleEntity item : deleteList) { |
||||
|
if (StringUtils.isBlank(item.getSite()) || StringUtils.isBlank(item.getBuNo()) || StringUtils.isBlank(item.getRuleCode())) { |
||||
|
continue; |
||||
|
} |
||||
|
sysSceneExceptionRuleMapper.deleteConditionByRule(item); |
||||
|
sysSceneExceptionRuleMapper.deleteRule(item); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<SysSceneExceptionRuleConditionEntity> getConditionList(SysSceneExceptionRuleConditionEntity data) { |
||||
|
List<SysSceneExceptionRuleConditionEntity> list = sysSceneExceptionRuleMapper.getConditionList(data); |
||||
|
if (list == null || list.isEmpty()) { |
||||
|
return new ArrayList<>(); |
||||
|
} |
||||
|
Map<String, SysSceneExceptionRuleConditionEntity> conditionMap = new LinkedHashMap<>(); |
||||
|
List<SysSceneExceptionRuleConditionEntity> rootList = new ArrayList<>(); |
||||
|
for (SysSceneExceptionRuleConditionEntity item : list) { |
||||
|
item.setChildren(new ArrayList<>()); |
||||
|
conditionMap.put(item.getConditionNo(), item); |
||||
|
} |
||||
|
for (SysSceneExceptionRuleConditionEntity item : list) { |
||||
|
if (StringUtils.isBlank(item.getParentConditionNo())) { |
||||
|
rootList.add(item); |
||||
|
continue; |
||||
|
} |
||||
|
SysSceneExceptionRuleConditionEntity parent = conditionMap.get(item.getParentConditionNo()); |
||||
|
if (parent == null) { |
||||
|
rootList.add(item); |
||||
|
} else { |
||||
|
parent.getChildren().add(item); |
||||
|
} |
||||
|
} |
||||
|
return rootList; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void saveCondition(SysSceneExceptionRuleConditionEntity data) { |
||||
|
checkConditionData(data, true); |
||||
|
data.setCreateBy(getCurrentUserName()); |
||||
|
data.setUpdateBy(getCurrentUserName()); |
||||
|
sysSceneExceptionRuleMapper.saveCondition(data); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void updateCondition(SysSceneExceptionRuleConditionEntity data) { |
||||
|
checkConditionData(data, false); |
||||
|
data.setUpdateBy(getCurrentUserName()); |
||||
|
sysSceneExceptionRuleMapper.updateCondition(data); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void deleteCondition(SysSceneExceptionRuleConditionEntity data) { |
||||
|
List<SysSceneExceptionRuleConditionEntity> deleteList = new ArrayList<>(); |
||||
|
if (data.getSubmitList() != null && !data.getSubmitList().isEmpty()) { |
||||
|
deleteList = data.getSubmitList(); |
||||
|
} else { |
||||
|
deleteList.add(data); |
||||
|
} |
||||
|
for (SysSceneExceptionRuleConditionEntity item : deleteList) { |
||||
|
if (StringUtils.isBlank(item.getSite()) || StringUtils.isBlank(item.getBuNo()) |
||||
|
|| StringUtils.isBlank(item.getRuleCode()) || StringUtils.isBlank(item.getConditionNo())) { |
||||
|
continue; |
||||
|
} |
||||
|
sysSceneExceptionRuleMapper.deleteConditionWithChildren(item); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void checkConditionData(SysSceneExceptionRuleConditionEntity data, boolean checkDuplicate) { |
||||
|
if (StringUtils.isBlank(data.getSite()) || StringUtils.isBlank(data.getBuNo()) || StringUtils.isBlank(data.getRuleCode())) { |
||||
|
throw new RuntimeException("条件主键信息不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getConditionNo())) { |
||||
|
throw new RuntimeException("条件编号不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getRelationField())) { |
||||
|
throw new RuntimeException("关系字段不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getCompareSymbol())) { |
||||
|
throw new RuntimeException("比较符不能为空"); |
||||
|
} |
||||
|
if (data.getConditionParam() == null) { |
||||
|
throw new RuntimeException("条件参数不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getForceType())) { |
||||
|
throw new RuntimeException("是否强制不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getTriggerEvent())) { |
||||
|
throw new RuntimeException("触发异常事件不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(data.getParentConditionNo())) { |
||||
|
if (StringUtils.equals(data.getParentConditionNo(), data.getConditionNo())) { |
||||
|
throw new RuntimeException("父条件不能等于当前条件"); |
||||
|
} |
||||
|
SysSceneExceptionRuleConditionEntity parentQuery = new SysSceneExceptionRuleConditionEntity(); |
||||
|
parentQuery.setSite(data.getSite()); |
||||
|
parentQuery.setBuNo(data.getBuNo()); |
||||
|
parentQuery.setRuleCode(data.getRuleCode()); |
||||
|
parentQuery.setConditionNo(data.getParentConditionNo()); |
||||
|
SysSceneExceptionRuleConditionEntity parent = sysSceneExceptionRuleMapper.getCondition(parentQuery); |
||||
|
if (parent == null) { |
||||
|
throw new RuntimeException("父条件不存在,请刷新后重试"); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(parent.getParentConditionNo())) { |
||||
|
throw new RuntimeException("触发条件仅支持一层树结构"); |
||||
|
} |
||||
|
} |
||||
|
if (checkDuplicate) { |
||||
|
Integer count = sysSceneExceptionRuleMapper.countConditionNo(data); |
||||
|
if (count != null && count > 0) { |
||||
|
throw new RuntimeException("条件编号已存在"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void fillSiteAndBu(SysSceneExceptionRuleEntity data) { |
||||
|
if (StringUtils.isNotBlank(data.getBu()) && data.getBu().contains("_")) { |
||||
|
String[] arr = data.getBu().split("_"); |
||||
|
if (arr.length >= 2) { |
||||
|
data.setSite(arr[0]); |
||||
|
data.setBuNo(arr[1]); |
||||
|
} |
||||
|
} else if (StringUtils.isNotBlank(data.getBu())) { |
||||
|
data.setBuNo(data.getBu()); |
||||
|
} |
||||
|
if (StringUtils.isBlank(data.getSite()) || StringUtils.isBlank(data.getBuNo())) { |
||||
|
throw new RuntimeException("工厂和BU不能为空"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private String getCurrentUserName() { |
||||
|
Object principal = SecurityUtils.getSubject().getPrincipal(); |
||||
|
if (principal instanceof SysUserEntity) { |
||||
|
return ((SysUserEntity) principal).getUsername(); |
||||
|
} |
||||
|
return ""; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,184 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.gaotao.modules.sys.mapper.SysSceneExceptionRuleMapper"> |
||||
|
|
||||
|
<select id="searchRule" resultType="com.gaotao.modules.sys.entity.SysSceneExceptionRuleEntity"> |
||||
|
SELECT |
||||
|
site, |
||||
|
bu_no, |
||||
|
rule_code, |
||||
|
rule_name, |
||||
|
apply_page, |
||||
|
apply_button, |
||||
|
enable_flag, |
||||
|
create_by, |
||||
|
create_date, |
||||
|
update_by, |
||||
|
update_date |
||||
|
FROM sys_scene_exception_rule |
||||
|
<where> |
||||
|
1 = 1 |
||||
|
<if test="query.userName != null and query.userName != ''"> |
||||
|
AND site IN (SELECT site FROM AccessSite WHERE userID = #{query.userName}) |
||||
|
AND bu_no IN (SELECT bu_no FROM AccessBu WHERE username = #{query.userName}) |
||||
|
</if> |
||||
|
<if test="query.site != null and query.site != ''"> |
||||
|
AND site = #{query.site} |
||||
|
</if> |
||||
|
<if test="query.ruleCode != null and query.ruleCode != ''"> |
||||
|
AND rule_code LIKE '%' + #{query.ruleCode} + '%' |
||||
|
</if> |
||||
|
<if test="query.ruleName != null and query.ruleName != ''"> |
||||
|
AND rule_name LIKE '%' + #{query.ruleName} + '%' |
||||
|
</if> |
||||
|
</where> |
||||
|
ORDER BY ISNULL(update_date, create_date) DESC, rule_code DESC |
||||
|
</select> |
||||
|
|
||||
|
<insert id="saveRule"> |
||||
|
INSERT INTO sys_scene_exception_rule |
||||
|
(site, bu_no, rule_code, rule_name, apply_page, apply_button, enable_flag, create_by, create_date, update_by, update_date) |
||||
|
VALUES |
||||
|
(#{site}, #{buNo}, #{ruleCode}, #{ruleName}, #{applyPage}, #{applyButton}, #{enableFlag}, #{createBy}, GETDATE(), #{updateBy}, GETDATE()) |
||||
|
</insert> |
||||
|
|
||||
|
<update id="updateRule"> |
||||
|
UPDATE sys_scene_exception_rule |
||||
|
SET |
||||
|
rule_name = #{ruleName}, |
||||
|
apply_page = #{applyPage}, |
||||
|
apply_button = #{applyButton}, |
||||
|
enable_flag = #{enableFlag}, |
||||
|
update_by = #{updateBy}, |
||||
|
update_date = GETDATE() |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
</update> |
||||
|
|
||||
|
<delete id="deleteRule"> |
||||
|
DELETE FROM sys_scene_exception_rule |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
</delete> |
||||
|
|
||||
|
<delete id="deleteConditionByRule"> |
||||
|
DELETE FROM sys_scene_exception_rule_condition |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
</delete> |
||||
|
|
||||
|
<select id="getConditionList" resultType="com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity"> |
||||
|
SELECT |
||||
|
site, |
||||
|
bu_no, |
||||
|
rule_code, |
||||
|
condition_no, |
||||
|
parent_condition_no, |
||||
|
relation_field, |
||||
|
compare_symbol, |
||||
|
condition_param, |
||||
|
force_type, |
||||
|
warning_level, |
||||
|
animation_effect, |
||||
|
responsibility_dept, |
||||
|
trigger_event, |
||||
|
create_by, |
||||
|
create_date, |
||||
|
update_by, |
||||
|
update_date |
||||
|
FROM sys_scene_exception_rule_condition |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
ORDER BY |
||||
|
CASE WHEN ISNULL(parent_condition_no, '') = '' THEN condition_no ELSE parent_condition_no END, |
||||
|
CASE WHEN ISNULL(parent_condition_no, '') = '' THEN 0 ELSE 1 END, |
||||
|
condition_no |
||||
|
</select> |
||||
|
|
||||
|
<select id="getCondition" resultType="com.gaotao.modules.sys.entity.SysSceneExceptionRuleConditionEntity"> |
||||
|
SELECT |
||||
|
site, |
||||
|
bu_no, |
||||
|
rule_code, |
||||
|
condition_no, |
||||
|
parent_condition_no, |
||||
|
relation_field, |
||||
|
compare_symbol, |
||||
|
condition_param, |
||||
|
force_type, |
||||
|
warning_level, |
||||
|
animation_effect, |
||||
|
responsibility_dept, |
||||
|
trigger_event, |
||||
|
create_by, |
||||
|
create_date, |
||||
|
update_by, |
||||
|
update_date |
||||
|
FROM sys_scene_exception_rule_condition |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
AND condition_no = #{conditionNo} |
||||
|
</select> |
||||
|
|
||||
|
<select id="countConditionNo" resultType="java.lang.Integer"> |
||||
|
SELECT COUNT(1) |
||||
|
FROM sys_scene_exception_rule_condition |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
AND condition_no = #{conditionNo} |
||||
|
</select> |
||||
|
|
||||
|
<insert id="saveCondition"> |
||||
|
INSERT INTO sys_scene_exception_rule_condition |
||||
|
(site, bu_no, rule_code, condition_no, parent_condition_no, relation_field, compare_symbol, |
||||
|
condition_param, force_type, warning_level, animation_effect, responsibility_dept, trigger_event, |
||||
|
create_by, create_date, update_by, update_date) |
||||
|
VALUES |
||||
|
(#{site}, #{buNo}, #{ruleCode}, #{conditionNo}, #{parentConditionNo}, #{relationField}, #{compareSymbol}, |
||||
|
#{conditionParam}, #{forceType}, #{warningLevel}, #{animationEffect}, #{responsibilityDept}, #{triggerEvent}, |
||||
|
#{createBy}, GETDATE(), #{updateBy}, GETDATE()) |
||||
|
</insert> |
||||
|
|
||||
|
<update id="updateCondition"> |
||||
|
UPDATE sys_scene_exception_rule_condition |
||||
|
SET |
||||
|
parent_condition_no = #{parentConditionNo}, |
||||
|
relation_field = #{relationField}, |
||||
|
compare_symbol = #{compareSymbol}, |
||||
|
condition_param = #{conditionParam}, |
||||
|
force_type = #{forceType}, |
||||
|
warning_level = #{warningLevel}, |
||||
|
animation_effect = #{animationEffect}, |
||||
|
responsibility_dept = #{responsibilityDept}, |
||||
|
trigger_event = #{triggerEvent}, |
||||
|
update_by = #{updateBy}, |
||||
|
update_date = GETDATE() |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
AND condition_no = #{conditionNo} |
||||
|
</update> |
||||
|
|
||||
|
<delete id="deleteCondition"> |
||||
|
DELETE FROM sys_scene_exception_rule_condition |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
AND condition_no = #{conditionNo} |
||||
|
</delete> |
||||
|
|
||||
|
<delete id="deleteConditionWithChildren"> |
||||
|
DELETE FROM sys_scene_exception_rule_condition |
||||
|
WHERE site = #{site} |
||||
|
AND bu_no = #{buNo} |
||||
|
AND rule_code = #{ruleCode} |
||||
|
AND (condition_no = #{conditionNo} OR parent_condition_no = #{conditionNo}) |
||||
|
</delete> |
||||
|
</mapper> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue