Merge remote-tracking branch 'origin/master'
commit
ef69e6cd76
@ -0,0 +1,24 @@
|
||||
package com.op.common.datascope.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 自动设置当前数据源及数据所属的部门
|
||||
*
|
||||
* @ClassName: DataPoolDept
|
||||
* @Description: TODO
|
||||
* @author shichangzhou
|
||||
* @date 2023年4月24日 下午5:47:07
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface PoolDeptAuto {
|
||||
|
||||
// 是否自动设置数据源标识
|
||||
public boolean pool() default true;
|
||||
|
||||
// 是否自动设置部门
|
||||
public boolean dept() default true;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.op.common.datasource.creator;
|
||||
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import com.baomidou.dynamic.datasource.creator.DefaultDataSourceCreator;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 动态创建数据源
|
||||
*
|
||||
* @ClassName: DynamicDatasourceCreator
|
||||
* @Description: TODO
|
||||
* @author shichangzhou
|
||||
* @date 2023年4月20日 下午1:15:09
|
||||
*/
|
||||
@Component
|
||||
public class DynamicDatasourceCreator {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DynamicDatasourceCreator.class);
|
||||
@Resource
|
||||
private DynamicRoutingDataSource dynamicRoutingDataSource;
|
||||
@Resource
|
||||
private DefaultDataSourceCreator defaultDataSourceCreator;
|
||||
|
||||
public DataSource createDynamicDataSource(DataSourceProperty dataSourceProperty) {
|
||||
log.info("Dynamic Datasource init.....");
|
||||
DataSource dataSource = defaultDataSourceCreator.createDataSource(dataSourceProperty);
|
||||
dynamicRoutingDataSource.addDataSource(dataSourceProperty.getPoolName(), dataSource);
|
||||
return dataSource;
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
com.op.common.datasource.creator.DynamicDatasourceCreator
|
@ -0,0 +1,53 @@
|
||||
package com.op.mes.config;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.op.common.core.domain.R;
|
||||
import com.op.common.datasource.creator.DynamicDatasourceCreator;
|
||||
import com.op.system.api.RemoteUserService;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 初始化动态数据源
|
||||
*
|
||||
* @ClassName: DynamicDatasource
|
||||
* @Description: TODO
|
||||
* @author shichangzhou
|
||||
* @date 2023年4月19日 下午1:01:30
|
||||
*/
|
||||
@Component
|
||||
public class DynamicDatasource {
|
||||
|
||||
@Resource
|
||||
private DynamicDatasourceCreator dynamicDatasourceCreator;
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// 加载sf-cloud库的sys_datasource
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(1L);
|
||||
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
|
||||
List<Map<String, String>> dateSources = dateSources0.getData();
|
||||
for (Map<String, String> dateSource : dateSources) {
|
||||
DataSourceProperty sdp = new DataSourceProperty();
|
||||
sdp.setUrl(dateSource.get("url"));
|
||||
sdp.setUsername(dateSource.get("userName"));
|
||||
sdp.setPassword(dateSource.get("password"));
|
||||
sdp.setDriverClassName(dateSource.get("driveClassName"));
|
||||
sdp.setPoolName(dateSource.get("poolName"));// 这是数据源的key
|
||||
sdp.setLazy(false);
|
||||
dynamicDatasourceCreator.createDynamicDataSource(sdp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package com.op.mes.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.op.common.log.annotation.Log;
|
||||
import com.op.common.log.enums.BusinessType;
|
||||
import com.op.common.security.annotation.RequiresPermissions;
|
||||
import com.op.mes.domain.ProRouteLine;
|
||||
import com.op.mes.service.IProRouteLineService;
|
||||
import com.op.common.core.web.controller.BaseController;
|
||||
import com.op.common.core.web.domain.AjaxResult;
|
||||
import com.op.common.core.utils.poi.ExcelUtil;
|
||||
import com.op.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 工艺线体关联Controller
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2023-07-13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pro/routeprodline")
|
||||
public class ProRouteLineController extends BaseController {
|
||||
@Autowired
|
||||
private IProRouteLineService proRouteLineService;
|
||||
|
||||
/**
|
||||
* 查询工艺线体关联列表
|
||||
*/
|
||||
//@RequiresPermissions("system:line:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ProRouteLine proRouteLine) {
|
||||
startPage();
|
||||
List<ProRouteLine> list = proRouteLineService.selectProRouteLineList(proRouteLine);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出工艺线体关联列表
|
||||
*/
|
||||
//@RequiresPermissions("system:line:export")
|
||||
@Log(title = "工艺线体关联", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ProRouteLine proRouteLine) {
|
||||
List<ProRouteLine> list = proRouteLineService.selectProRouteLineList(proRouteLine);
|
||||
ExcelUtil<ProRouteLine> util = new ExcelUtil<ProRouteLine>(ProRouteLine.class);
|
||||
util.exportExcel(response, list, "工艺线体关联数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工艺线体关联详细信息
|
||||
*/
|
||||
//@RequiresPermissions("system:line:query")
|
||||
@GetMapping(value = "/{recordId}")
|
||||
public AjaxResult getInfo(@PathVariable("recordId") String recordId) {
|
||||
return success(proRouteLineService.selectProRouteLineByRecordId(recordId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工艺线体关联
|
||||
*/
|
||||
//@RequiresPermissions("system:line:add")
|
||||
@Log(title = "工艺线体关联", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ProRouteLine proRouteLine) {
|
||||
return toAjax(proRouteLineService.insertProRouteLine(proRouteLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改工艺线体关联
|
||||
*/
|
||||
//@RequiresPermissions("system:line:edit")
|
||||
@Log(title = "工艺线体关联", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ProRouteLine proRouteLine) {
|
||||
return toAjax(proRouteLineService.updateProRouteLine(proRouteLine));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工艺线体关联
|
||||
*/
|
||||
//@RequiresPermissions("system:line:remove")
|
||||
@Log(title = "工艺线体关联", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{recordIds}")
|
||||
public AjaxResult remove(@PathVariable String[] recordIds) {
|
||||
return toAjax(proRouteLineService.deleteProRouteLineByRecordIds(recordIds));
|
||||
}
|
||||
|
||||
/**穿梭框**/
|
||||
@GetMapping("/getList")
|
||||
public ProRouteLine getList(ProRouteLine proRouteLine) {
|
||||
return proRouteLineService.getList(proRouteLine);
|
||||
}
|
||||
}
|
@ -0,0 +1,183 @@
|
||||
package com.op.mes.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.op.common.core.annotation.Excel;
|
||||
import com.op.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工艺线体关联对象 pro_route_line
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2023-07-13
|
||||
*/
|
||||
public class ProRouteLine extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 记录ID */
|
||||
private String recordId;
|
||||
|
||||
/** 工艺路线ID */
|
||||
@Excel(name = "工艺路线ID")
|
||||
private String routeId;
|
||||
|
||||
/** 线体ID */
|
||||
@Excel(name = "线体ID")
|
||||
private String itemId;
|
||||
|
||||
/** 线体编码 */
|
||||
@Excel(name = "线体编码")
|
||||
private String itemCode;
|
||||
|
||||
/** 线体名称 */
|
||||
@Excel(name = "线体名称")
|
||||
private String itemName;
|
||||
|
||||
/** 预留字段1 */
|
||||
@Excel(name = "预留字段1")
|
||||
private String attr1;
|
||||
|
||||
/** 预留字段2 */
|
||||
@Excel(name = "预留字段2")
|
||||
private String attr2;
|
||||
|
||||
/** 预留字段3 */
|
||||
@Excel(name = "预留字段3")
|
||||
private String attr3;
|
||||
|
||||
/** 预留字段4 */
|
||||
@Excel(name = "预留字段4")
|
||||
private String attr4;
|
||||
|
||||
private String key;
|
||||
private String label;
|
||||
private List<ProRouteLine> unSelect;
|
||||
private List<ProRouteLine> selected;
|
||||
private List<String> selectedValues;
|
||||
|
||||
public List<String> getSelectedValues() {
|
||||
return selectedValues;
|
||||
}
|
||||
|
||||
public void setSelectedValues(List<String> selectedValues) {
|
||||
this.selectedValues = selectedValues;
|
||||
}
|
||||
|
||||
public List<ProRouteLine> getUnSelect() {
|
||||
return unSelect;
|
||||
}
|
||||
|
||||
public void setUnSelect(List<ProRouteLine> unSelect) {
|
||||
this.unSelect = unSelect;
|
||||
}
|
||||
|
||||
public List<ProRouteLine> getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(List<ProRouteLine> selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public void setRecordId(String recordId) {
|
||||
this.recordId = recordId;
|
||||
}
|
||||
|
||||
public String getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
public void setRouteId(String routeId) {
|
||||
this.routeId = routeId;
|
||||
}
|
||||
|
||||
public String getRouteId() {
|
||||
return routeId;
|
||||
}
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
public void setItemCode(String itemCode) {
|
||||
this.itemCode = itemCode;
|
||||
}
|
||||
|
||||
public String getItemCode() {
|
||||
return itemCode;
|
||||
}
|
||||
public void setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
public void setAttr1(String attr1) {
|
||||
this.attr1 = attr1;
|
||||
}
|
||||
|
||||
public String getAttr1() {
|
||||
return attr1;
|
||||
}
|
||||
public void setAttr2(String attr2) {
|
||||
this.attr2 = attr2;
|
||||
}
|
||||
|
||||
public String getAttr2() {
|
||||
return attr2;
|
||||
}
|
||||
public void setAttr3(String attr3) {
|
||||
this.attr3 = attr3;
|
||||
}
|
||||
|
||||
public String getAttr3() {
|
||||
return attr3;
|
||||
}
|
||||
public void setAttr4(String attr4) {
|
||||
this.attr4 = attr4;
|
||||
}
|
||||
|
||||
public String getAttr4() {
|
||||
return attr4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("recordId", getRecordId())
|
||||
.append("routeId", getRouteId())
|
||||
.append("itemId", getItemId())
|
||||
.append("itemCode", getItemCode())
|
||||
.append("itemName", getItemName())
|
||||
.append("remark", getRemark())
|
||||
.append("attr1", getAttr1())
|
||||
.append("attr2", getAttr2())
|
||||
.append("attr3", getAttr3())
|
||||
.append("attr4", getAttr4())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.op.mes.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.op.mes.domain.ProRouteLine;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 工艺线体关联Mapper接口
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2023-07-13
|
||||
*/
|
||||
@Mapper
|
||||
public interface ProRouteLineMapper {
|
||||
/**
|
||||
* 查询工艺线体关联
|
||||
*
|
||||
* @param recordId 工艺线体关联主键
|
||||
* @return 工艺线体关联
|
||||
*/
|
||||
public ProRouteLine selectProRouteLineByRecordId(String recordId);
|
||||
|
||||
/**
|
||||
* 查询工艺线体关联列表
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 工艺线体关联集合
|
||||
*/
|
||||
public List<ProRouteLine> selectProRouteLineList(ProRouteLine proRouteLine);
|
||||
|
||||
/**
|
||||
* 新增工艺线体关联
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertProRouteLine(ProRouteLine proRouteLine);
|
||||
|
||||
/**
|
||||
* 修改工艺线体关联
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateProRouteLine(ProRouteLine proRouteLine);
|
||||
|
||||
/**
|
||||
* 删除工艺线体关联
|
||||
*
|
||||
* @param recordId 工艺线体关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProRouteLineByRecordId(String recordId);
|
||||
|
||||
/**
|
||||
* 批量删除工艺线体关联
|
||||
*
|
||||
* @param recordIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProRouteLineByRecordIds(String[] recordIds);
|
||||
|
||||
public List<ProRouteLine> getRouteProdLineListUndo(ProRouteLine proRouteLine);
|
||||
List<ProRouteLine> getRouteProdLineListDo(ProRouteLine proRouteLine);
|
||||
|
||||
void deleteByRouteId(ProRouteLine proRouteLine);
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.op.mes.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.op.mes.domain.ProRouteLine;
|
||||
|
||||
/**
|
||||
* 工艺线体关联Service接口
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2023-07-13
|
||||
*/
|
||||
public interface IProRouteLineService {
|
||||
/**
|
||||
* 查询工艺线体关联
|
||||
*
|
||||
* @param recordId 工艺线体关联主键
|
||||
* @return 工艺线体关联
|
||||
*/
|
||||
public ProRouteLine selectProRouteLineByRecordId(String recordId);
|
||||
|
||||
/**
|
||||
* 查询工艺线体关联列表
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 工艺线体关联集合
|
||||
*/
|
||||
public List<ProRouteLine> selectProRouteLineList(ProRouteLine proRouteLine);
|
||||
|
||||
/**
|
||||
* 新增工艺线体关联
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertProRouteLine(ProRouteLine proRouteLine);
|
||||
|
||||
/**
|
||||
* 修改工艺线体关联
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateProRouteLine(ProRouteLine proRouteLine);
|
||||
|
||||
/**
|
||||
* 批量删除工艺线体关联
|
||||
*
|
||||
* @param recordIds 需要删除的工艺线体关联主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProRouteLineByRecordIds(String[] recordIds);
|
||||
|
||||
/**
|
||||
* 删除工艺线体关联信息
|
||||
*
|
||||
* @param recordId 工艺线体关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteProRouteLineByRecordId(String recordId);
|
||||
|
||||
ProRouteLine getList(ProRouteLine proRouteLine);
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package com.op.mes.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.op.common.core.utils.DateUtils;
|
||||
import com.op.common.core.utils.uuid.IdUtils;
|
||||
import com.op.common.security.utils.SecurityUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.op.mes.mapper.ProRouteLineMapper;
|
||||
import com.op.mes.domain.ProRouteLine;
|
||||
import com.op.mes.service.IProRouteLineService;
|
||||
|
||||
/**
|
||||
* 工艺线体关联Service业务层处理
|
||||
*
|
||||
* @author Open Platform
|
||||
* @date 2023-07-13
|
||||
*/
|
||||
@Service
|
||||
public class ProRouteLineServiceImpl implements IProRouteLineService {
|
||||
@Autowired
|
||||
private ProRouteLineMapper proRouteLineMapper;
|
||||
|
||||
/**
|
||||
* 查询工艺线体关联
|
||||
*
|
||||
* @param recordId 工艺线体关联主键
|
||||
* @return 工艺线体关联
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public ProRouteLine selectProRouteLineByRecordId(String recordId) {
|
||||
return proRouteLineMapper.selectProRouteLineByRecordId(recordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询工艺线体关联列表
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 工艺线体关联
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public List<ProRouteLine> selectProRouteLineList(ProRouteLine proRouteLine) {
|
||||
return proRouteLineMapper.selectProRouteLineList(proRouteLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工艺线体关联
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int insertProRouteLine(ProRouteLine proRouteLine) {
|
||||
Date now = DateUtils.getNowDate();
|
||||
if(StringUtils.isNotBlank(proRouteLine.getRouteId())){
|
||||
//删除之前的关联关系
|
||||
proRouteLineMapper.deleteByRouteId(proRouteLine);
|
||||
}
|
||||
if(proRouteLine.getSelectedValues()!=null){
|
||||
ProRouteLine proRouteLineDto =null;
|
||||
for(String lineCode:proRouteLine.getSelectedValues()){
|
||||
proRouteLineDto = new ProRouteLine();
|
||||
proRouteLineDto.setRecordId(IdUtils.fastSimpleUUID());
|
||||
proRouteLineDto.setCreateTime(now);
|
||||
proRouteLineDto.setCreateBy(SecurityUtils.getUsername());
|
||||
proRouteLineDto.setRouteId(proRouteLine.getRouteId());
|
||||
proRouteLineDto.setItemCode(lineCode);
|
||||
proRouteLineMapper.insertProRouteLine(proRouteLineDto);
|
||||
}
|
||||
}
|
||||
//新增关联关系
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改工艺线体关联
|
||||
*
|
||||
* @param proRouteLine 工艺线体关联
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int updateProRouteLine(ProRouteLine proRouteLine) {
|
||||
proRouteLine.setUpdateTime(DateUtils.getNowDate());
|
||||
return proRouteLineMapper.updateProRouteLine(proRouteLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除工艺线体关联
|
||||
*
|
||||
* @param recordIds 需要删除的工艺线体关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteProRouteLineByRecordIds(String[] recordIds) {
|
||||
return proRouteLineMapper.deleteProRouteLineByRecordIds(recordIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工艺线体关联信息
|
||||
*
|
||||
* @param recordId 工艺线体关联主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public int deleteProRouteLineByRecordId(String recordId) {
|
||||
return proRouteLineMapper.deleteProRouteLineByRecordId(recordId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#header.poolName")
|
||||
public ProRouteLine getList(ProRouteLine proRouteLine) {
|
||||
ProRouteLine dto = new ProRouteLine();
|
||||
List<ProRouteLine> unSelected= proRouteLineMapper.getRouteProdLineListUndo(proRouteLine);
|
||||
dto.setUnSelect(unSelected);
|
||||
List<ProRouteLine> selected= proRouteLineMapper.getRouteProdLineListDo(proRouteLine);
|
||||
dto.setSelected(selected);
|
||||
return dto;
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
<?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.op.mes.mapper.ProRouteLineMapper">
|
||||
|
||||
<resultMap type="ProRouteLine" id="ProRouteLineResult">
|
||||
<result property="recordId" column="record_id" />
|
||||
<result property="routeId" column="route_id" />
|
||||
<result property="itemId" column="item_id" />
|
||||
<result property="itemCode" column="item_code" />
|
||||
<result property="itemName" column="item_name" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="attr1" column="attr1" />
|
||||
<result property="attr2" column="attr2" />
|
||||
<result property="attr3" column="attr3" />
|
||||
<result property="attr4" column="attr4" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProRouteLineVo">
|
||||
select record_id, route_id, item_id, item_code, item_name, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from pro_route_line
|
||||
</sql>
|
||||
|
||||
<select id="selectProRouteLineList" parameterType="ProRouteLine" resultMap="ProRouteLineResult">
|
||||
<include refid="selectProRouteLineVo"/>
|
||||
<where>
|
||||
<if test="routeId != null and routeId != ''"> and route_id = #{routeId}</if>
|
||||
<if test="itemId != null and itemId != ''"> and item_id = #{itemId}</if>
|
||||
<if test="itemCode != null and itemCode != ''"> and item_code = #{itemCode}</if>
|
||||
<if test="itemName != null and itemName != ''"> and item_name like concat('%', #{itemName}, '%')</if>
|
||||
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
|
||||
<if test="attr2 != null and attr2 != ''"> and attr2 = #{attr2}</if>
|
||||
<if test="attr3 != null and attr3 != ''"> and attr3 = #{attr3}</if>
|
||||
<if test="attr4 != null and attr4 != ''"> and attr4 = #{attr4}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectProRouteLineByRecordId" parameterType="String" resultMap="ProRouteLineResult">
|
||||
<include refid="selectProRouteLineVo"/>
|
||||
where record_id = #{recordId}
|
||||
</select>
|
||||
<select id="getRouteProdLineListUndo" resultType="com.op.mes.domain.ProRouteLine">
|
||||
select sf.f_code [key],
|
||||
sf.factory_name label
|
||||
from sys_factory sf
|
||||
where sf.f_type='l' and sf.status = '1' and sf.del_flag = '0'
|
||||
</select>
|
||||
<select id="getRouteProdLineListDo" resultType="com.op.mes.domain.ProRouteLine">
|
||||
select pl.item_code [key],
|
||||
sf.factory_name label
|
||||
from pro_route_line pl
|
||||
left join sys_factory sf on pl.item_code = sf.f_code
|
||||
where pl.route_id = #{routeId}
|
||||
</select>
|
||||
|
||||
<insert id="insertProRouteLine" parameterType="ProRouteLine">
|
||||
insert into pro_route_line
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="recordId != null">record_id,</if>
|
||||
<if test="routeId != null and routeId != ''">route_id,</if>
|
||||
<if test="itemId != null and itemId != ''">item_id,</if>
|
||||
<if test="itemCode != null and itemCode != ''">item_code,</if>
|
||||
<if test="itemName != null and itemName != ''">item_name,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="attr1 != null">attr1,</if>
|
||||
<if test="attr2 != null">attr2,</if>
|
||||
<if test="attr3 != null">attr3,</if>
|
||||
<if test="attr4 != null">attr4,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="recordId != null">#{recordId},</if>
|
||||
<if test="routeId != null and routeId != ''">#{routeId},</if>
|
||||
<if test="itemId != null and itemId != ''">#{itemId},</if>
|
||||
<if test="itemCode != null and itemCode != ''">#{itemCode},</if>
|
||||
<if test="itemName != null and itemName != ''">#{itemName},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="attr1 != null">#{attr1},</if>
|
||||
<if test="attr2 != null">#{attr2},</if>
|
||||
<if test="attr3 != null">#{attr3},</if>
|
||||
<if test="attr4 != null">#{attr4},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateProRouteLine" parameterType="ProRouteLine">
|
||||
update pro_route_line
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="routeId != null and routeId != ''">route_id = #{routeId},</if>
|
||||
<if test="itemId != null and itemId != ''">item_id = #{itemId},</if>
|
||||
<if test="itemCode != null and itemCode != ''">item_code = #{itemCode},</if>
|
||||
<if test="itemName != null and itemName != ''">item_name = #{itemName},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="attr1 != null">attr1 = #{attr1},</if>
|
||||
<if test="attr2 != null">attr2 = #{attr2},</if>
|
||||
<if test="attr3 != null">attr3 = #{attr3},</if>
|
||||
<if test="attr4 != null">attr4 = #{attr4},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where record_id = #{recordId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteProRouteLineByRecordId" parameterType="String">
|
||||
delete from pro_route_line where record_id = #{recordId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteProRouteLineByRecordIds" parameterType="String">
|
||||
delete from pro_route_line where record_id in
|
||||
<foreach item="recordId" collection="array" open="(" separator="," close=")">
|
||||
#{recordId}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteByRouteId">
|
||||
delete from pro_route_line where route_id = #{routeId}
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,199 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="web" name="Web">
|
||||
<configuration>
|
||||
<webroots />
|
||||
</configuration>
|
||||
</facet>
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2021.0.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-alibaba-commons:2021.0.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.nacos:nacos-client:2.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.15" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.13.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.13.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.13.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:20.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient:0.15.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_tracer_otel:0.15.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_tracer_common:0.15.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.prometheus:simpleclient_tracer_otel_agent:0.15.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.30" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.spring:spring-context-support:1.0.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:2021.0.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.36" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-starter-alibaba-sentinel:2021.0.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-transport-simple-http:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-transport-common:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-datasource-extension:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.83_noneautotype" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-annotation-aspectj:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-core:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.9.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-circuitbreaker-sentinel:2021.0.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-reactor-adapter:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-spring-webflux-adapter:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-spring-webmvc-adapter:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-parameter-flow-control:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-cluster-server-default:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-cluster-common-default:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.86.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.csp:sentinel-cluster-client-default:1.8.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.cloud:spring-cloud-alibaba-sentinel-datasource:2021.0.4.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.17.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.17.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.36" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.annotation:jakarta.annotation-api:1.3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.9.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.12" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webmvc:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spi:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-schema:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-core:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.12.20" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.classgraph:classgraph:4.8.83" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.mysql:mysql-connector-j:8.0.31" level="project" />
|
||||
<orderEntry type="module" module-name="op-common-datasource" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.2.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:druid:1.2.16" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.baomidou:dynamic-datasource-spring-boot-starter:3.5.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.7.7" level="project" />
|
||||
<orderEntry type="module" module-name="op-common-datascope" />
|
||||
<orderEntry type="module" module-name="op-common-security" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.3.24" level="project" />
|
||||
<orderEntry type="module" module-name="op-api-system" />
|
||||
<orderEntry type="module" module-name="op-common-core" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-openfeign:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-openfeign-core:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form-spring:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign.form:feign-form:3.8.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-core:11.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.github.openfeign:feign-slf4j:11.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-loadbalancer:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-loadbalancer:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.projectreactor.addons:reactor-extra:3.4.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-cache:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.stoyanr:evictor:1.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba:transmittable-thread-local:2.14.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.4.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.4.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper:5.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.2.5.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.4.3.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.jsonwebtoken:jjwt:0.9.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.xml.bind:jaxb-api:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.activation:javax.activation-api:1.2.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.11.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:SparseBitSet:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.virtuald:curvesapi:1.06" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:4.0.1" level="project" />
|
||||
<orderEntry type="module" module-name="op-common-redis" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.7.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:6.1.10.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.4.26" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.4" level="project" />
|
||||
<orderEntry type="module" module-name="op-common-log" />
|
||||
<orderEntry type="module" module-name="op-common-swagger" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.13.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.70" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.70" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.70" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.3.24" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-annotations:2.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.springfox:springfox-spring-webflux:3.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.6.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.6.2" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-bootstrap:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:3.1.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.11.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.69" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.69" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bouncycastle:bcutil-jdk15on:1.69" level="project" />
|
||||
<orderEntry type="library" name="sapjco3" level="project" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
@ -0,0 +1,47 @@
|
||||
package com.op.system.config;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.op.common.datasource.creator.DynamicDatasourceCreator;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import com.op.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 初始化动态数据源
|
||||
*
|
||||
* @ClassName: DynamicDatasource
|
||||
* @Description: TODO
|
||||
* @author shichangzhou
|
||||
* @date 2023年4月19日 下午1:01:30
|
||||
*/
|
||||
@Component
|
||||
public class DynamicDatasource {
|
||||
|
||||
@Resource
|
||||
private DynamicDatasourceCreator dynamicDatasourceCreator;
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(1L);
|
||||
List<Map<String, String>> dateSources = sysUserService.getPoolNameList(sysUser);
|
||||
for (Map<String, String> dateSource : dateSources) {
|
||||
DataSourceProperty sdp = new DataSourceProperty();
|
||||
sdp.setUrl(dateSource.get("url"));
|
||||
sdp.setUsername(dateSource.get("userName"));
|
||||
sdp.setPassword(dateSource.get("password"));
|
||||
sdp.setDriverClassName(dateSource.get("driveClassName"));
|
||||
sdp.setPoolName(dateSource.get("poolName"));// 这是数据源的key
|
||||
sdp.setLazy(false);
|
||||
dynamicDatasourceCreator.createDynamicDataSource(sdp);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
package com.op.system.controller;
|
||||
|
||||
import com.op.common.core.utils.poi.ExcelUtil;
|
||||
import com.op.common.core.web.controller.BaseController;
|
||||
import com.op.common.core.web.domain.AjaxResult;
|
||||
import com.op.common.core.web.page.TableDataInfo;
|
||||
import com.op.common.log.annotation.Log;
|
||||
import com.op.common.log.enums.BusinessType;
|
||||
import com.op.common.security.annotation.RequiresPermissions;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import com.op.system.domain.SysDatasource;
|
||||
import com.op.system.service.ISysDatasourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工厂数据库Controller
|
||||
*
|
||||
* @author sf
|
||||
* @date 2023-05-18
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/datasource")
|
||||
public class SysDatasourceController extends BaseController {
|
||||
@Autowired
|
||||
private ISysDatasourceService sysDatasourceService;
|
||||
|
||||
/**
|
||||
* 查询工厂数据库列表
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDatasource sysDatasource) {
|
||||
startPage();
|
||||
List<SysDatasource> list = sysDatasourceService.selectSysDatasourceList(sysDatasource);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出工厂数据库列表
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:export")
|
||||
@Log(title = "工厂数据库", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDatasource sysDatasource) {
|
||||
List<SysDatasource> list = sysDatasourceService.selectSysDatasourceList(sysDatasource);
|
||||
ExcelUtil<SysDatasource> util = new ExcelUtil<SysDatasource>(SysDatasource.class);
|
||||
util.exportExcel(response, list, "工厂数据库数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工厂数据库详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") String id) {
|
||||
return success(sysDatasourceService.selectSysDatasourceById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工厂数据库
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:add")
|
||||
@Log(title = "工厂数据库", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysDatasource sysDatasource) {
|
||||
return toAjax(sysDatasourceService.insertSysDatasource(sysDatasource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改工厂数据库
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:edit")
|
||||
@Log(title = "工厂数据库", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysDatasource sysDatasource) {
|
||||
return toAjax(sysDatasourceService.updateSysDatasource(sysDatasource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工厂数据库
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:remove")
|
||||
@Log(title = "工厂数据库", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable String[] ids) {
|
||||
return toAjax(sysDatasourceService.deleteSysDatasourceByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询已分配用户角色列表
|
||||
*/
|
||||
@RequiresPermissions("system:datasource:edit")
|
||||
@GetMapping("/authUser/allocatedList")
|
||||
public TableDataInfo allocatedList(SysDatasource sysDatasource) {
|
||||
startPage();
|
||||
List<SysDatasource> list = sysDatasourceService.selectAllocatedList(sysDatasource);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配用户角色列表
|
||||
*/
|
||||
//@RequiresPermissions("system:role:list")
|
||||
@GetMapping("/authUser/unallocatedList")
|
||||
public TableDataInfo unallocatedList(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = sysDatasourceService.selectUnallocatedList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量选择用户授权
|
||||
*/
|
||||
//@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "数据源管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAll")
|
||||
public AjaxResult selectAuthUserAll(String datasourceId, Long[] userIds) {
|
||||
//sysDatasourceService.checkRoleDataScope(datasourceId);
|
||||
return toAjax(sysDatasourceService.insertAuthUsers(datasourceId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消授权用户
|
||||
*/
|
||||
//@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "数据源管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancel")
|
||||
public AjaxResult cancelAuthUser(@RequestBody SysDatasource sysDatasource) {
|
||||
return toAjax(sysDatasourceService.deleteAuthUser(sysDatasource));
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量取消授权用户
|
||||
*/
|
||||
//@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/cancelAll")
|
||||
public AjaxResult cancelAuthUserAll(String datasourceId, Long[] userIds) {
|
||||
return toAjax(sysDatasourceService.deleteAuthUsers(datasourceId, userIds));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:datasource:add")
|
||||
@Log(title = "激活工厂数据库", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/changeDBStatus/{datasourceId}")
|
||||
public AjaxResult changeDBStatus(@PathVariable("datasourceId") String datasourceId) {
|
||||
SysDatasource sysDatasource = new SysDatasource();
|
||||
sysDatasource.setDatasourceId(datasourceId);
|
||||
return success(sysDatasourceService.changeDBStatus(sysDatasource));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package com.op.system.mapper;
|
||||
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import com.op.system.domain.SysDatasource;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工厂数据库Mapper接口
|
||||
*
|
||||
* @author sf
|
||||
* @date 2023-05-18
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysDatasourceMapper
|
||||
{
|
||||
/**
|
||||
* 查询工厂数据库
|
||||
*
|
||||
* @param id 工厂数据库主键
|
||||
* @return 工厂数据库
|
||||
*/
|
||||
public SysDatasource selectSysDatasourceById(String id);
|
||||
|
||||
/**
|
||||
* 查询工厂数据库列表
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 工厂数据库集合
|
||||
*/
|
||||
public List<SysDatasource> selectSysDatasourceList(SysDatasource sysDatasource);
|
||||
|
||||
/**
|
||||
* 新增工厂数据库
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDatasource(SysDatasource sysDatasource);
|
||||
|
||||
/**
|
||||
* 修改工厂数据库
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDatasource(SysDatasource sysDatasource);
|
||||
|
||||
/**
|
||||
* 删除工厂数据库
|
||||
*
|
||||
* @param id 工厂数据库主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDatasourceById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除工厂数据库
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDatasourceByIds(String[] ids);
|
||||
|
||||
List<SysDatasource> selectAllocatedList(SysDatasource sysDatasource);
|
||||
|
||||
List<SysUser> selectUnallocatedList(SysUser user);
|
||||
|
||||
int batchUserDB(List<SysDatasource> list);
|
||||
|
||||
int deleteUserRoleInfo(SysDatasource sysDatasource);
|
||||
|
||||
int deleteUserRoleInfos(@Param("datasourceId") String datasourceId, @Param("userIds") Long[] userIds);
|
||||
|
||||
List<SysDatasource> selectDBListByDept(SysDatasource qo);
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.op.system.service;
|
||||
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import com.op.system.domain.SysDatasource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工厂数据库Service接口
|
||||
*
|
||||
* @author sf
|
||||
* @date 2023-05-18
|
||||
*/
|
||||
public interface ISysDatasourceService
|
||||
{
|
||||
/**
|
||||
* 查询工厂数据库
|
||||
*
|
||||
* @param id 工厂数据库主键
|
||||
* @return 工厂数据库
|
||||
*/
|
||||
public SysDatasource selectSysDatasourceById(String id);
|
||||
|
||||
/**
|
||||
* 查询工厂数据库列表
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 工厂数据库集合
|
||||
*/
|
||||
public List<SysDatasource> selectSysDatasourceList(SysDatasource sysDatasource);
|
||||
|
||||
/**
|
||||
* 新增工厂数据库
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysDatasource(SysDatasource sysDatasource);
|
||||
|
||||
/**
|
||||
* 修改工厂数据库
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysDatasource(SysDatasource sysDatasource);
|
||||
|
||||
/**
|
||||
* 批量删除工厂数据库
|
||||
*
|
||||
* @param ids 需要删除的工厂数据库主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDatasourceByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除工厂数据库信息
|
||||
*
|
||||
* @param id 工厂数据库主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysDatasourceById(String id);
|
||||
|
||||
List<SysDatasource> selectAllocatedList(SysDatasource sysDatasource);
|
||||
|
||||
List<SysUser> selectUnallocatedList(SysUser user);
|
||||
|
||||
void checkRoleDataScope(String datasourceId);
|
||||
|
||||
int insertAuthUsers(String datasourceId, Long[] userIds);
|
||||
|
||||
int deleteAuthUser(SysDatasource sysDatasource);
|
||||
|
||||
int deleteAuthUsers(String datasourceId, Long[] userIds);
|
||||
|
||||
String changeDBStatus(SysDatasource sysDatasource);
|
||||
}
|
@ -0,0 +1,224 @@
|
||||
package com.op.system.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.op.common.core.utils.DateUtils;
|
||||
import com.op.common.core.utils.StringUtils;
|
||||
import com.op.common.core.utils.uuid.IdUtils;
|
||||
import com.op.common.datasource.creator.DynamicDatasourceCreator;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import com.op.system.domain.SysDatasource;
|
||||
import com.op.system.mapper.SysDatasourceMapper;
|
||||
import com.op.system.service.ISysDatasourceService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 工厂数据库Service业务层处理
|
||||
*
|
||||
* @author sf
|
||||
* @date 2023-05-18
|
||||
*/
|
||||
@Service
|
||||
public class SysDatasourceServiceImpl implements ISysDatasourceService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysDatasourceServiceImpl.class);
|
||||
@Autowired
|
||||
private SysDatasourceMapper sysDatasourceMapper;
|
||||
@Value("${sqlserve.prev}")
|
||||
private String mysqlPrev;
|
||||
@Value("${sqlserve.affter}")
|
||||
private String mysqlAffter;
|
||||
@Value("${sqlserve.poolName.prev}")
|
||||
private String poolNamePrev;
|
||||
@Value("${sqlserve.driver}")
|
||||
private String driver;
|
||||
@Resource
|
||||
private DynamicDatasourceCreator dynamicDatasourceCreator;
|
||||
|
||||
/**
|
||||
* 查询工厂数据库
|
||||
*
|
||||
* @param id 工厂数据库主键
|
||||
* @return 工厂数据库
|
||||
*/
|
||||
@Override
|
||||
public SysDatasource selectSysDatasourceById(String id) {
|
||||
return sysDatasourceMapper.selectSysDatasourceById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询工厂数据库列表
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 工厂数据库
|
||||
*/
|
||||
@Override
|
||||
public List<SysDatasource> selectSysDatasourceList(SysDatasource sysDatasource) {
|
||||
return sysDatasourceMapper.selectSysDatasourceList(sysDatasource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增工厂数据库
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysDatasource(SysDatasource sysDatasource) {
|
||||
sysDatasource.setCreateTime(DateUtils.getNowDate());
|
||||
sysDatasource.setId(IdUtils.randomUUID().replace("-",""));
|
||||
sysDatasource.setDriveClassName(driver);
|
||||
if(StringUtils.isNotEmpty(sysDatasource.getIpPort())){
|
||||
sysDatasource.setUrl(mysqlPrev+sysDatasource.getIpPort().split("/")[0]
|
||||
+mysqlAffter+sysDatasource.getIpPort().split("/")[1]);
|
||||
}
|
||||
if(sysDatasource.getDeptId()!=null){
|
||||
if(StringUtils.isNotEmpty(sysDatasource.getSystemType())){
|
||||
sysDatasource.setPoolName(poolNamePrev+"_"+sysDatasource.getSystemType()+"_"+sysDatasource.getDeptId());
|
||||
}else{
|
||||
sysDatasource.setPoolName(poolNamePrev+"_"+sysDatasource.getDeptId());
|
||||
}
|
||||
}
|
||||
|
||||
return sysDatasourceMapper.insertSysDatasource(sysDatasource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改工厂数据库
|
||||
*
|
||||
* @param sysDatasource 工厂数据库
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysDatasource(SysDatasource sysDatasource) {
|
||||
|
||||
//修改之后status->1 不生效,需要重新测试链接才生效
|
||||
sysDatasource.setStatus("1");
|
||||
sysDatasource.setUpdateTime(DateUtils.getNowDate());
|
||||
return sysDatasourceMapper.updateSysDatasource(sysDatasource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除工厂数据库
|
||||
*
|
||||
* @param ids 需要删除的工厂数据库主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDatasourceByIds(String[] ids) {
|
||||
return sysDatasourceMapper.deleteSysDatasourceByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除工厂数据库信息
|
||||
*
|
||||
* @param id 工厂数据库主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysDatasourceById(String id) {
|
||||
return sysDatasourceMapper.deleteSysDatasourceById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDatasource> selectAllocatedList(SysDatasource sysDatasource) {
|
||||
return sysDatasourceMapper.selectAllocatedList(sysDatasource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||
return sysDatasourceMapper.selectUnallocatedList(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkRoleDataScope(String datasourceId) {
|
||||
// if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
// SysRole role = new SysRole();
|
||||
// role.setRoleId(roleId);
|
||||
// List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role);
|
||||
// if (StringUtils.isEmpty(roles)) {
|
||||
// throw new ServiceException("没有权限访问角色数据!");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertAuthUsers(String datasourceId, Long[] userIds) {
|
||||
// 新增用户与数据源管理
|
||||
List<SysDatasource> list = new ArrayList<SysDatasource>();
|
||||
for (Long userId : userIds) {
|
||||
SysDatasource ur = new SysDatasource();
|
||||
ur.setUserId(userId.toString());
|
||||
ur.setDatasourceId(datasourceId.toString());
|
||||
list.add(ur);
|
||||
}
|
||||
return sysDatasourceMapper.batchUserDB(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAuthUser(SysDatasource sysDatasource) {
|
||||
return sysDatasourceMapper.deleteUserRoleInfo(sysDatasource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteAuthUsers(String datasourceId, Long[] userIds) {
|
||||
return sysDatasourceMapper.deleteUserRoleInfos(datasourceId, userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String changeDBStatus(SysDatasource sd) {
|
||||
|
||||
SysDatasource sysDatasource = sysDatasourceMapper.selectSysDatasourceById(sd.getDatasourceId());
|
||||
|
||||
if(sysDatasource == null){
|
||||
return "数据库链接不存在";
|
||||
}
|
||||
try {
|
||||
Class.forName(sysDatasource.getDriveClassName());
|
||||
Connection conn = DriverManager.getConnection(sysDatasource.getUrl(),
|
||||
sysDatasource.getUserName(),
|
||||
sysDatasource.getPassword());
|
||||
if (conn != null) {
|
||||
if (conn.isClosed()) {
|
||||
log.error("[{}]数据库连接检测异常:[{}]",sysDatasource.getPoolName());
|
||||
return "数据库链接异常,请检查数据库基本信息。";//假如打不开数据库链接则跳过初始化数据库
|
||||
} else {
|
||||
//说明数据库可以正常连接,关闭测试连接
|
||||
conn.close();
|
||||
log.info("[{}]数据库连接检测正常", sysDatasource.getPoolName());
|
||||
}
|
||||
} else {
|
||||
log.error("[{}]数据库连接检测异常:[{}]", sysDatasource.getPoolName());
|
||||
return "数据库链接异常,请检查数据库基本信息。";
|
||||
}
|
||||
|
||||
sysDatasource.setUpdateTime(DateUtils.getNowDate());
|
||||
sysDatasource.setStatus("0");//激活
|
||||
sysDatasourceMapper.updateSysDatasource(sysDatasource);
|
||||
|
||||
DataSourceProperty dataSourceProperty = new DataSourceProperty();
|
||||
dataSourceProperty.setUrl(sysDatasource.getUrl());
|
||||
dataSourceProperty.setUsername(sysDatasource.getUserName());
|
||||
dataSourceProperty.setPassword(sysDatasource.getPassword());
|
||||
dataSourceProperty.setDriverClassName(sysDatasource.getDriveClassName());
|
||||
dataSourceProperty.setPoolName(sysDatasource.getPoolName());// 这是数据源的key
|
||||
dataSourceProperty.setLazy(false);
|
||||
dynamicDatasourceCreator.createDynamicDataSource(dataSourceProperty);
|
||||
|
||||
return "数据库链接测试成功,数据库链接状态正常";
|
||||
}catch (ClassNotFoundException | SQLException classNotFoundException){
|
||||
return "数据库链接异常,请检查数据库基本信息。";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,191 @@
|
||||
<?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.op.system.mapper.SysDatasourceMapper">
|
||||
|
||||
<resultMap type="SysDatasource" id="SysDatasourceResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="url" column="url" />
|
||||
<result property="ipPort" column="ip_port" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="password" column="password" />
|
||||
<result property="driveClassName" column="drive_class_name" />
|
||||
<result property="poolName" column="pool_name" />
|
||||
<result property="parkName" column="park_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="schemaCreated" column="schema_created" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="systemType" column="system_type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysDatasourceVo">
|
||||
select id, url, ip_port, user_name, password, drive_class_name, pool_name, park_name,
|
||||
status, del_flag, create_by, create_time, update_by, update_time, remark,system_type,
|
||||
dept_id, schema_created from sys_datasource
|
||||
</sql>
|
||||
|
||||
<select id="selectSysDatasourceList" parameterType="SysDatasource" resultMap="SysDatasourceResult">
|
||||
select sd.id, sd.url, sd.ip_port, sd.user_name, sd.password, sd.drive_class_name, sd.pool_name, sd.park_name,
|
||||
sd.status, sd.del_flag, sd.create_by, sd.create_time, sd.update_by, sd.update_time, sd.remark,sd.system_type,
|
||||
sd.dept_id,d.dept_name, sd.schema_created from sys_datasource sd
|
||||
left join sys_dept d on sd.dept_id = d.dept_id
|
||||
<where>
|
||||
<if test="url != null and url != ''"> and url = #{url}</if>
|
||||
<if test="ipPort != null and ipPort != ''"> and ip_port like concat('%', #{ipPort}, '%')</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="password != null and password != ''"> and password = #{password}</if>
|
||||
<if test="driveClassName != null and driveClassName != ''"> and drive_class_name like concat('%', #{driveClassName}, '%')</if>
|
||||
<if test="poolName != null and poolName != ''"> and pool_name like concat('%', #{poolName}, '%')</if>
|
||||
<if test="parkName != null and parkName != ''"> and park_name like concat('%', #{parkName}, '%')</if>
|
||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="schemaCreated != null and schemaCreated != ''"> and schema_created = #{schemaCreated}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysDatasourceById" parameterType="String" resultMap="SysDatasourceResult">
|
||||
<include refid="selectSysDatasourceVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectAllocatedList" resultType="com.op.system.domain.SysDatasource">
|
||||
select sd.id,
|
||||
sd.ip_port ipPort,
|
||||
sd.pool_name poolName,
|
||||
sud.user_id userId,
|
||||
su.user_name userName,
|
||||
su.nick_name nickName
|
||||
from sys_datasource sd
|
||||
left join sys_user_datasource sud on sd.id = sud.datasource_id
|
||||
left join sys_user su on su.user_id = sud.user_id
|
||||
where sud.user_id is not null
|
||||
<if test="nickName != null and nickName != ''">
|
||||
AND su.nick_name like concat('%', #{nickName}, '%')
|
||||
</if>
|
||||
<if test="datasourceId != null and datasourceId != ''">
|
||||
AND sd.id = #{datasourceId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectUnallocatedList" resultType="com.op.system.api.domain.SysUser">
|
||||
select distinct u.user_id userId, u.dept_id deptId, u.user_name userName, u.nick_name nickName,
|
||||
u.email, u.phonenumber, u.status, u.create_time createTime
|
||||
from sys_user u
|
||||
left join sys_user_datasource ur on u.user_id = ur.user_id
|
||||
left join sys_datasource r on r.id = ur.datasource_id
|
||||
where u.del_flag = '0' and (r.id != #{datasourceId} or r.id IS NULL)
|
||||
and u.user_id not in (select ur.user_id from sys_user_datasource ur where ur.datasource_id = #{datasourceId})
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectDBListByDept" resultType="com.op.system.domain.SysDatasource">
|
||||
select id
|
||||
from sys_datasource
|
||||
where del_flag = 0 and dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysDatasource" parameterType="SysDatasource">
|
||||
insert into sys_datasource
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="url != null and url != ''">url,</if>
|
||||
<if test="ipPort != null">ip_port,</if>
|
||||
<if test="userName != null and userName != ''">user_name,</if>
|
||||
<if test="password != null and password != ''">password,</if>
|
||||
<if test="driveClassName != null and driveClassName != ''">drive_class_name,</if>
|
||||
<if test="poolName != null and poolName != ''">pool_name,</if>
|
||||
<if test="parkName != null">park_name,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
<if test="schemaCreated != null">schema_created,</if>
|
||||
<if test="systemType != null">system_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="url != null and url != ''">#{url},</if>
|
||||
<if test="ipPort != null">#{ipPort},</if>
|
||||
<if test="userName != null and userName != ''">#{userName},</if>
|
||||
<if test="password != null and password != ''">#{password},</if>
|
||||
<if test="driveClassName != null and driveClassName != ''">#{driveClassName},</if>
|
||||
<if test="poolName != null and poolName != ''">#{poolName},</if>
|
||||
<if test="parkName != null">#{parkName},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
<if test="schemaCreated != null">#{schemaCreated},</if>
|
||||
<if test="systemType != null">#{systemType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="batchUserDB">
|
||||
insert into sys_user_datasource(user_id, datasource_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.userId},#{item.datasourceId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysDatasource" parameterType="SysDatasource">
|
||||
update sys_datasource
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="url != null and url != ''">url = #{url},</if>
|
||||
<if test="ipPort != null">ip_port = #{ipPort},</if>
|
||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||
<if test="password != null and password != ''">password = #{password},</if>
|
||||
<if test="driveClassName != null and driveClassName != ''">drive_class_name = #{driveClassName},</if>
|
||||
<if test="poolName != null and poolName != ''">pool_name = #{poolName},</if>
|
||||
<if test="parkName != null">park_name = #{parkName},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="deptId != null">dept_id = #{deptId},</if>
|
||||
<if test="schemaCreated != null">schema_created = #{schemaCreated},</if>
|
||||
<if test="systemType != null">system_type = #{systemType},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysDatasourceById" parameterType="String">
|
||||
delete from sys_datasource where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysDatasourceByIds" parameterType="String">
|
||||
delete from sys_datasource where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteUserRoleInfo">
|
||||
delete from sys_user_datasource where user_id=#{userId} and datasource_id=#{datasourceId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserRoleInfos">
|
||||
delete from sys_user_datasource where datasource_id=#{datasourceId} and user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
@ -0,0 +1,51 @@
|
||||
package com.op.wms.config;
|
||||
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
||||
import com.op.common.core.domain.R;
|
||||
import com.op.common.datasource.creator.DynamicDatasourceCreator;
|
||||
import com.op.system.api.RemoteUserService;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 初始化动态数据源
|
||||
*
|
||||
* @ClassName: DynamicDatasource
|
||||
* @Description: TODO
|
||||
* @author shichangzhou
|
||||
* @date 2023年4月19日 下午1:01:30
|
||||
*/
|
||||
@Component
|
||||
public class DynamicDatasource {
|
||||
|
||||
@Resource
|
||||
private DynamicDatasourceCreator dynamicDatasourceCreator;
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// 加载sf-cloud库的sys_datasource
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(1L);
|
||||
R<List<Map<String, String>>> dateSources0 = remoteUserService.getPoolNameList(sysUser);
|
||||
List<Map<String, String>> dateSources = dateSources0.getData();
|
||||
for (Map<String, String> dateSource : dateSources) {
|
||||
DataSourceProperty sdp = new DataSourceProperty();
|
||||
sdp.setUrl(dateSource.get("url"));
|
||||
sdp.setUsername(dateSource.get("userName"));
|
||||
sdp.setPassword(dateSource.get("password"));
|
||||
sdp.setDriverClassName(dateSource.get("driveClassName"));
|
||||
sdp.setPoolName(dateSource.get("poolName"));// 这是数据源的key
|
||||
sdp.setLazy(false);
|
||||
dynamicDatasourceCreator.createDynamicDataSource(sdp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package com.op.wms.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
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.PutMapping;
|
||||
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.multipart.MultipartFile;
|
||||
import com.op.common.core.domain.R;
|
||||
import com.op.common.core.utils.StringUtils;
|
||||
import com.op.common.core.utils.poi.ExcelUtil;
|
||||
import com.op.common.core.web.controller.BaseController;
|
||||
import com.op.common.core.web.domain.AjaxResult;
|
||||
import com.op.common.core.web.page.TableDataInfo;
|
||||
import com.op.common.log.annotation.Log;
|
||||
import com.op.common.log.enums.BusinessType;
|
||||
import com.op.common.security.annotation.InnerAuth;
|
||||
import com.op.common.security.annotation.RequiresPermissions;
|
||||
import com.op.common.security.utils.SecurityUtils;
|
||||
import com.op.system.api.domain.SysDept;
|
||||
import com.op.system.api.domain.SysRole;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
import com.op.system.api.model.LoginUser;
|
||||
import com.op.wms.service.ISysUserService;
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @author OP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class SysUserController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@RequiresPermissions("system:user:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysUser user) {
|
||||
startPage();
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
|
||||
@RequiresPermissions("system:user:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysUser user) {
|
||||
List<SysUser> list = userService.selectUserList(user);
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.exportExcel(response, list, "用户数据");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) throws IOException {
|
||||
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
|
||||
util.importTemplateExcel(response, "用户数据");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setCreateBy(SecurityUtils.getUsername());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user) {
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package com.op.wms.domain;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用户和角色关联 sys_user_role
|
||||
*
|
||||
* @author OP
|
||||
*/
|
||||
public class SysUserRole {
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("userId", getUserId())
|
||||
.append("roleId", getRoleId()).toString();
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
package com.op.wms.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
|
||||
/**
|
||||
* 用户表 数据层
|
||||
*
|
||||
* @author OP
|
||||
*/
|
||||
public interface SysUserMapper {
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectAllocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUnallocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetUserPwd(@Param("userName") String userName, @Param("password") String password);
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 批量删除用户信息
|
||||
*
|
||||
* @param userIds 需要删除的用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserByIds(Long[] userIds);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param userName 用户名称
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkUserNameUnique(String userName);
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param phonenumber 手机号码
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkPhoneUnique(String phonenumber);
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 用户邮箱
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
package com.op.wms.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
*
|
||||
* @author OP
|
||||
*/
|
||||
public interface ISysUserService {
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUserList(SysUser user);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectAllocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
public List<SysUser> selectUnallocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public SysUser selectUserById(Long userId);
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkUserNameUnique(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkPhoneUnique(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean checkEmailUnique(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
public void checkUserAllowed(SysUser user);
|
||||
|
||||
/**
|
||||
* 校验用户是否有数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
public void checkUserDataScope(Long userId);
|
||||
|
||||
/**
|
||||
* 新增用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertUser(SysUser user);
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean registerUser(SysUser user);
|
||||
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserStatus(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserProfile(SysUser user);
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean updateUserAvatar(String userName, String avatar);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetPwd(SysUser user);
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public int resetUserPwd(String userName, String password);
|
||||
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
package com.op.wms.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.validation.Validator;
|
||||
|
||||
|
||||
import com.op.wms.mapper.SysUserMapper;
|
||||
import com.op.wms.service.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import com.op.common.core.constant.UserConstants;
|
||||
import com.op.common.core.exception.ServiceException;
|
||||
import com.op.common.core.utils.SpringUtils;
|
||||
import com.op.common.core.utils.StringUtils;
|
||||
import com.op.common.core.utils.bean.BeanValidators;
|
||||
import com.op.common.datascope.annotation.DataScope;
|
||||
import com.op.common.security.utils.SecurityUtils;
|
||||
import com.op.system.api.domain.SysRole;
|
||||
import com.op.system.api.domain.SysUser;
|
||||
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
*
|
||||
* @author OP
|
||||
*/
|
||||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected Validator validator;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUserList(SysUser user) {
|
||||
return userMapper.selectUserList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectAllocatedList(SysUser user) {
|
||||
return userMapper.selectAllocatedList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "d", userAlias = "u")
|
||||
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||
return userMapper.selectUnallocatedList(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserByUserName(String userName) {
|
||||
return userMapper.selectUserByUserName(userName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUser selectUserById(Long userId) {
|
||||
return userMapper.selectUserById(userId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUserNameUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPhoneUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUser user) {
|
||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user) {
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||
throw new ServiceException("不允许操作超级管理员用户");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否有数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||
SysUser user = new SysUser();
|
||||
user.setUserId(userId);
|
||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||
if (StringUtils.isEmpty(users)) {
|
||||
throw new ServiceException("没有权限访问用户数据!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertUser(SysUser user) {
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUser user) {
|
||||
return userMapper.insertUser(user) > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserProfile(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userName, String avatar) {
|
||||
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetPwd(SysUser user) {
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(String userName, String password) {
|
||||
return userMapper.resetUserPwd(userName, password);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue