计量中心项目

This commit is contained in:
2022-07-25 11:09:12 +08:00
parent 5911f42537
commit c8bb34e6cb
2143 changed files with 306192 additions and 0 deletions

View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.yxt</groupId>
<artifactId>yxt-parent</artifactId>
<version>0.0.1</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jlzx-single-system-biz</artifactId>
<groupId>com.yxt.jlzx</groupId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>com.yxt.jlzx</groupId>
<artifactId>jlzx-single-system-api</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.yxt.jlzx</groupId>
<artifactId>jlzx-single-jlcyry-api</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.yxt</groupId>
<artifactId>yxt-common-base</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- <dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
</dependency>-->
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- word模板动态生成word poi-tl -->
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>com.yxt.jlzx</groupId>
<artifactId>jlzx-single-oa-api</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.10</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.yxt.workflow</groupId>
<artifactId>yxt-single-workflow-api</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
<!--2021.09.27-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.29</version>
</dependency>
<!--2021.10.04-->
<dependency>
<groupId>com.jacob</groupId>
<artifactId>jacob</artifactId>
<version>1.18</version>
</dependency>
<dependency>
<groupId>com.yxt.jlzx</groupId>
<artifactId>jlzx-single-cxjl-api</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*Mapper.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

View File

@@ -0,0 +1,24 @@
package com.yxt.jlzx.system;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @author dimengzhe
* @date 2020/9/11 14:44
* @description
*/
@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = {
"com.yxt.common.base.config",
"com.yxt.jlzx.system"
})
@EnableFeignClients(basePackages = {"com.yxt.jlzx.jlcyry","com.yxt.jlzx.oa","com.yxt.jlzx.cxjl"})
public class SystemApplication {
public static void main(String[] args) {
SpringApplication.run(SystemApplication.class, args);
}
}

View File

@@ -0,0 +1,64 @@
package com.yxt.jlzx.system.biz.app;
import com.yxt.common.base.config.component.FileUploadComponent;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.app.VersionVo;
import io.swagger.annotations.Api;
import net.dongliu.apk.parser.ApkFile;
import net.dongliu.apk.parser.bean.ApkMeta;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
/**
* @author dimengzhe
* @date 2021/1/5 11:18
* @description
*/
@Controller
@RequestMapping("/apkTest")
@Api(tags = "app获取版本信息工具类")
public class ApkUtil {
@Autowired
private FileUploadComponent fileUploadComponent;
public ResultBean<VersionVo> apkParser(MultipartFile multipartFile) {
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
if (!prefix.equals(".apk")) {
return new ResultBean<VersionVo>().fail().setMsg("请上传apk文件");
}
Map<String, Object> map = new HashMap<>();
VersionVo versionVo = new VersionVo();
try {
// 上传后的文件含完整路径
String url = "apk/"+System.currentTimeMillis() + ".apk";
String path = fileUploadComponent.getUploadPath() + url;
File excelFile = new File(path);
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), excelFile);
ApkFile apkFile = new ApkFile(excelFile);
ApkMeta apkMeta = apkFile.getApkMeta();
versionVo.setAppName(apkMeta.getLabel());
versionVo.setUpdateUrl(fileUploadComponent.getUrlPrefix() + url);
versionVo.setVersionCode(Integer.parseInt(apkMeta.getVersionCode().toString()));
versionVo.setVersionName(apkMeta.getVersionName());
// map.put("size", (double) (excelFile.length() * 100 / 1024 / 1024) / 100 + " MB");
} catch (Exception e) {
e.printStackTrace();
}
return new ResultBean<VersionVo>().success().setData(versionVo);
}
}

View File

@@ -0,0 +1,102 @@
package com.yxt.jlzx.system.biz.app;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.app.*;
import io.swagger.annotations.Api;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
/**
* @author dimengzhe
* @date 2020/12/30 9:11
* @description
*/
@Controller
@RequestMapping("v1/appVersion")
@Api(tags = "app版本管理-主框架")
public class AppVersionApiImpl implements AppVersionApi {
@Autowired
private AppVersionService appVersionService;
@Autowired
private ApkUtil apkUtil;
@Override
public ResultBean<AppVersionVo> update() {
AppVersionVo appVersionVo = appVersionService.selectNewAppVersion();
if (appVersionVo == null) {
appVersionVo = new AppVersionVo();
appVersionVo.setAppName("");
appVersionVo.setIconUrl("");
appVersionVo.setUpdateUrl("");
appVersionVo.setVersionCode(0);
appVersionVo.setVersionName("");
}
return new ResultBean<AppVersionVo>().success().setData(appVersionVo);
}
public ResultBean save2(AppVersionDto appVersionDto) {
AppVersion appVersion = new AppVersion();
appVersionDto.fillEntity(appVersion);
//查询目前数据库中的最新版本
AppVersionVo appVersionVo = appVersionService.selectNewAppVersion();
if (appVersionVo != null) {
int versionCode = appVersion.getVersionCode();
if (versionCode < appVersionVo.getVersionCode()) {
return ResultBean.fireFail().setMsg("上传的版本不能小于所存在的最新版本号");
} else {
boolean isSave = appVersionService.save(appVersion);
if (!isSave) {
return ResultBean.fireFail().setMsg("更新失败");
}
}
} else {
boolean isSave = appVersionService.save(appVersion);
if (!isSave) {
return ResultBean.fireFail().setMsg("更新失败");
}
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
@Override
public ResultBean save(MultipartFile multipartFile, String upgradeInfo, String iconUrl) {
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
if (!prefix.equals(".apk")) {
return new ResultBean<VersionVo>().fail().setMsg("请上传apk文件");
}
VersionVo versionVo = apkUtil.apkParser(multipartFile).getData();
AppVersionDto appVersionDto = new AppVersionDto();
appVersionDto.setAppName(versionVo.getAppName());
appVersionDto.setIconUrl(iconUrl);
appVersionDto.setUpdateUrl(versionVo.getUpdateUrl());
appVersionDto.setVersionName(versionVo.getVersionName());
appVersionDto.setUpgradeInfo(upgradeInfo);
appVersionDto.setVersionCode(versionVo.getVersionCode());
appVersionDto.setAppSid("147694bb-c765-4426-8f67-d19a66585f30");
ResultBean resultBean = save2(appVersionDto);
if (!resultBean.getSuccess()) {
return ResultBean.fireFail().setMsg(resultBean.getMsg());
}
return ResultBean.fireSuccess().setMsg(resultBean.getMsg());
}
@Override
public ResultBean<Map<String, Object>> selectNewAppVersion() {
// TODO Auto-generated method stub
AppVersionVo appVersionVo = appVersionService.selectNewAppVersion();
Map<String, Object> map = new HashMap<String, Object>();
map.put("appVersionVo", appVersionVo);
map.put("linkPhone", "0311-88606625");
return new ResultBean<Map<String, Object>>().success().setData(map);
}
}

View File

@@ -0,0 +1,18 @@
package com.yxt.jlzx.system.biz.app;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.jlzx.system.api.app.AppVersion;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.user.User;
import org.apache.ibatis.annotations.Mapper;
/**
* @author dimengzhe
* @date 2020/12/31 9:39
* @description
*/
@Mapper
public interface AppVersionMapper extends BaseMapper<AppVersion> {
public AppVersionVo selectNewAppVersion();
}

View File

@@ -0,0 +1,12 @@
<?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.yxt.jlzx.system.biz.app.AppVersionMapper">
<select id="selectNewAppVersion" resultType="com.yxt.jlzx.system.api.app.AppVersionVo">
SELECT appName, versionCode, versionName, updateUrl, upgradeInfo, iconUrl
FROM app_version
ORDER BY versionCode DESC
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
package com.yxt.jlzx.system.biz.app;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.app.AppVersion;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import org.springframework.stereotype.Service;
/**
* @author dimengzhe
* @date 2020/12/31 9:35
* @description
*/
@Service
public class AppVersionService extends MybatisBaseService<AppVersionMapper, AppVersion> {
public AppVersionVo selectNewAppVersion(){
return baseMapper.selectNewAppVersion();
}
}

View File

@@ -0,0 +1,146 @@
package com.yxt.jlzx.system.biz.applydateset;
import io.swagger.annotations.Api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSet;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetApi;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetDto;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetQuery;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetVo;
import com.yxt.jlzx.system.api.role.Role;
import com.yxt.jlzx.system.api.role.RoleApi;
import com.yxt.jlzx.system.api.role.RoleDto;
import com.yxt.jlzx.system.api.role.RoleQuery;
import com.yxt.jlzx.system.api.role.RoleVo;
/**
* @author yxt_hwj
* @date 2020/9/29 13:30
* @description 角色信息
*/
@Controller
@RequestMapping("v1/applyDateSets")
@Api(tags = "申报日期设置")
public class ApplyDateSetApiImpl implements ApplyDateSetApi {
@Autowired
private ApplyDateSetService applyDateSetService;
/**
* 保存
*
* @param roleDto 角色dto对象
* @return ResultBean
*/
@Override
public ResultBean save(ApplyDateSetDto applyDateSetDto) {
ApplyDateSet applyDateSet = new ApplyDateSet();
applyDateSetDto.fillEntity(applyDateSet);
if (!applyDateSetService.save(applyDateSet))
return ResultBean.fireFail().setMsg("保存失败");
return ResultBean.fireSuccess().setData(applyDateSet.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值.
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean update(ApplyDateSetDto applyDateSetDto, String sid) throws Exception {
ApplyDateSet applyDateSet = applyDateSetService.fetchBySid(sid);
if (null == applyDateSet)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == applyDateSetService.updateBySid(applyDateSetDto.toMap(), sid))
return ResultBean.fireFail().setMsg("更新失败");
return ResultBean.fireSuccess().setMsg("更新成功");
}
/**
* 删除
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
ApplyDateSet applyDateSet = applyDateSetService.fetchBySid(sid);
if (null == applyDateSet)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == applyDateSetService.deleteBySid(sid))
return ResultBean.fireFail().setMsg("删除失败");
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 修改页面初始化数据
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean<ApplyDateSetVo> getVo(String sid) {
ApplyDateSet applyDateSet = applyDateSetService.fetchBySid(sid);
if (null == applyDateSet)
return new ResultBean().fail().setData(null);
ApplyDateSetVo applyDateSetVo = new ApplyDateSetVo();
applyDateSetVo.setSid(applyDateSet.getSid());
applyDateSetVo.setStartDate(applyDateSet.getStartDate());
applyDateSetVo.setEndDate(applyDateSet.getEndDate());
return new ResultBean().success().setData(applyDateSetVo);
}
@Override
public ResultBean<PagerVo<ApplyDateSetVo>> pageList(@Valid PagerQuery<ApplyDateSetQuery> pagerQuery) {
ResultBean<PagerVo<ApplyDateSetVo>> rb = ResultBean.fireFail();
IPage<ApplyDateSetVo> page = applyDateSetService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<ApplyDateSetVo> pv_result = PagerUtil.pageToVo(page, null);
return rb.success().setData(pv_result);
}
@Override
public ResultBean<List<ApplyDateSetVo>> list(@Valid ApplyDateSetQuery query) {
// TODO Auto-generated method stub
List<ApplyDateSetVo> list=applyDateSetService.lists();
return new ResultBean<List<ApplyDateSetVo>>().setData(list).fireSuccess();
}
@Override
public List<ApplyDateSetVo> lists() {
// TODO Auto-generated method stub
return applyDateSetService.lists();
}
}

View File

@@ -0,0 +1,29 @@
package com.yxt.jlzx.system.biz.applydateset;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSet;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetVo;
/**
* @author yxt_mtl
* @date 2020/9/29 13:45
* @description
*/
@Mapper
public interface ApplyDateSetMapper extends BaseMapper<ApplyDateSet> {
//分页列表
IPage<ApplyDateSetVo> pageList(IPage<ApplyDateSetVo> page, @Param(Constants.WRAPPER) Wrapper<ApplyDateSetVo> qw);
List<ApplyDateSetVo> lists();
}

View File

@@ -0,0 +1,13 @@
<?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.yxt.jlzx.system.biz.applydateset.ApplyDateSetMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.applydateset.ApplyDateSetVo">
SELECT sid, startDate,endDate
FROM apply_date_set ${ew.customSqlSegment}
</select>
<select id="lists" resultType="com.yxt.jlzx.system.api.applydateset.ApplyDateSetVo">
SELECT sid, startDate,endDate
FROM apply_date_set
</select>
</mapper>

View File

@@ -0,0 +1,58 @@
package com.yxt.jlzx.system.biz.applydateset;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSet;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetQuery;
import com.yxt.jlzx.system.api.applydateset.ApplyDateSetVo;
import com.yxt.jlzx.system.api.dictcommon.DictCommonVo;
import com.yxt.jlzx.system.biz.dictcommon.DictCommonService;
/**
* @author yxt_mtl
* @date 2020/9/29 13:40
* @description
*/
@Service
public class ApplyDateSetService extends MybatisBaseService<ApplyDateSetMapper, ApplyDateSet> {
@Autowired
private DictCommonService dictCommonService;
// 分页列表
public IPage<ApplyDateSetVo> pageList(PagerQuery<ApplyDateSetQuery> pagerQuery) {
// mybits所用的分页对对象
IPage<ApplyDateSetVo> page = PagerUtil.queryToPage(pagerQuery);
// mybits所用的查询条件封装类
QueryWrapper<ApplyDateSetVo> qw = buildQueryWrapper(pagerQuery.getParams());
List<ApplyDateSetVo> records = page.getRecords();
return baseMapper.pageList(page, qw);
}
/**
* 解析和组装查询条件封装在qw中
*
* @param pagerQuery
* @return
*/
private QueryWrapper<ApplyDateSetVo> buildQueryWrapper(ApplyDateSetQuery query) {
QueryWrapper<ApplyDateSetVo> qw = new QueryWrapper<>();
qw.orderByDesc("createTime");
return qw;
}
public List<ApplyDateSetVo> lists() {
// mybits所用的分页对对象
return baseMapper.lists();
}
}

View File

@@ -0,0 +1,205 @@
package com.yxt.jlzx.system.biz.appsubset;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.app.VersionVo;
import com.yxt.jlzx.system.api.appsubset.*;
import com.yxt.jlzx.system.biz.app.ApkUtil;
import com.yxt.jlzx.system.biz.source.SourceService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import java.util.UUID;
/**
* @author dimengzhe
* @date 2021/1/4 15:31
* @description
*/
@Controller
@RequestMapping("v1/appSubsetVersion")
@Api(tags = "app主框架首页-一级应用")
public class AppSubsetVersionApiImpl implements AppSubsetVersionApi {
@Autowired
private AppSubsetVersionService appSubsetVersionService;
@Autowired
private ApkUtil apkUtil;
@Autowired
private SourceService sourceService;
@Override
public ResultBean<List<AppSubsetVersionVo>> selectVersionList() {
//主框架sid
String linkSid = "147694bb-c765-4426-8f67-d19a66585f31";
List<AppSubsetVersionVo> appSubsetVersionVoList = appSubsetVersionService.selectVersionList(linkSid);
return new ResultBean<List<AppSubsetVersionVo>>().success().setData(appSubsetVersionVoList);
}
@Override
public ResultBean save(AppSubsetVersionDto appSubsetVersionDto) {
if (appSubsetVersionDto.getType().equals("2")) {
if (StringUtils.isBlank(appSubsetVersionDto.getModulePluginName()) || appSubsetVersionDto.getModulePluginName().equals("null")) {
return ResultBean.fireFail().setMsg("插件名称不能为空");
}
}
if (appSubsetVersionDto.getType().equals("2") || appSubsetVersionDto.getType().equals("3")) {
if (appSubsetVersionDto.getMultipartFile() == null) {
return ResultBean.fireFail().setMsg("请上传文件");
} else {
// 获取文件名
String fileName = appSubsetVersionDto.getMultipartFile().getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
if (!prefix.equals(".apk")) {
return ResultBean.fireFail().setMsg("请上传apk文件");
}
}
}
AppSubsetVersionOneDto appSubsetVersionOneDto = new AppSubsetVersionOneDto();
if (appSubsetVersionDto.getType().equals("2")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetVersionDto.getMultipartFile()).getData();
appSubsetVersionOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetVersionOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetVersionOneDto.setVersionName(versionVo.getVersionName());
appSubsetVersionOneDto.setModulePluginName(appSubsetVersionDto.getModulePluginName());
} else if (appSubsetVersionDto.getType().equals("3")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetVersionDto.getMultipartFile()).getData();
appSubsetVersionOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetVersionOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetVersionOneDto.setVersionName(versionVo.getVersionName());
appSubsetVersionOneDto.setModulePluginName("");
} else {
appSubsetVersionOneDto.setVersionCode(0);
appSubsetVersionOneDto.setUpdateUrl("");
appSubsetVersionOneDto.setVersionName("");
appSubsetVersionOneDto.setModulePluginName("");
}
appSubsetVersionOneDto.setAppName(appSubsetVersionDto.getAppName());
appSubsetVersionOneDto.setIconUrl(appSubsetVersionDto.getIconUrl());
appSubsetVersionOneDto.setUpgradeInfo(appSubsetVersionDto.getUpgradeInfo());
appSubsetVersionOneDto.setType(appSubsetVersionDto.getType());
appSubsetVersionOneDto.setSortNo(appSubsetVersionDto.getSortNo());
appSubsetVersionOneDto.setSourceAction(appSubsetVersionDto.getSourceAction());
appSubsetVersionOneDto.setSourcePackage(appSubsetVersionDto.getSourcePackage());
appSubsetVersionOneDto.setAppSid(UUID.randomUUID().toString());
appSubsetVersionOneDto.setLinkSid(appSubsetVersionDto.getLinkSid());
ResultBean resultBean = save2(appSubsetVersionOneDto);
if (!resultBean.getSuccess()) {
return ResultBean.fireFail().setMsg(resultBean.getMsg());
}
return ResultBean.fireSuccess().setMsg(resultBean.getMsg());
}
@Override
public ResultBean update(AppSubsetVersionDto appSubsetVersionDto) {
if (appSubsetVersionDto.getType().equals("2")) {
if (StringUtils.isBlank(appSubsetVersionDto.getModulePluginName()) || appSubsetVersionDto.getModulePluginName().equals("null")) {
return ResultBean.fireFail().setMsg("插件名称不能为空");
}
}
if (appSubsetVersionDto.getType().equals("2") || appSubsetVersionDto.getType().equals("3")) {
if (appSubsetVersionDto.getMultipartFile() == null) {
return ResultBean.fireFail().setMsg("请上传文件");
} else {
// 获取文件名
String fileName = appSubsetVersionDto.getMultipartFile().getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
if (!prefix.equals(".apk")) {
return ResultBean.fireFail().setMsg("请上传apk文件");
}
}
}
if (StringUtils.isBlank(appSubsetVersionDto.getAppSid()) || appSubsetVersionDto.getAppSid().equals("null")) {
return ResultBean.fireFail().setMsg("appSid不能为空");
}
AppSubsetVersionOneDto appSubsetVersionOneDto = new AppSubsetVersionOneDto();
if (appSubsetVersionDto.getType().equals("2")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetVersionDto.getMultipartFile()).getData();
appSubsetVersionOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetVersionOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetVersionOneDto.setVersionName(versionVo.getVersionName());
appSubsetVersionOneDto.setModulePluginName(appSubsetVersionDto.getModulePluginName());
} else if (appSubsetVersionDto.getType().equals("3")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetVersionDto.getMultipartFile()).getData();
appSubsetVersionOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetVersionOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetVersionOneDto.setVersionName(versionVo.getVersionName());
appSubsetVersionOneDto.setModulePluginName("");
} else {
appSubsetVersionOneDto.setVersionCode(0);
appSubsetVersionOneDto.setUpdateUrl("");
appSubsetVersionOneDto.setVersionName("");
appSubsetVersionOneDto.setModulePluginName("");
}
appSubsetVersionOneDto.setAppName(appSubsetVersionDto.getAppName());
appSubsetVersionOneDto.setIconUrl(appSubsetVersionDto.getIconUrl());
appSubsetVersionOneDto.setUpgradeInfo(appSubsetVersionDto.getUpgradeInfo());
appSubsetVersionOneDto.setType(appSubsetVersionDto.getType());
appSubsetVersionOneDto.setSourceAction(appSubsetVersionDto.getSourceAction());
appSubsetVersionOneDto.setSourcePackage(appSubsetVersionDto.getSourcePackage());
appSubsetVersionOneDto.setAppSid(appSubsetVersionDto.getAppSid());
appSubsetVersionOneDto.setLinkSid(appSubsetVersionDto.getLinkSid());
appSubsetVersionOneDto.setSortNo(appSubsetVersionDto.getSortNo());
ResultBean resultBean = update2(appSubsetVersionOneDto);
if (!resultBean.getSuccess()) {
return ResultBean.fireFail().setMsg(resultBean.getMsg());
}
return ResultBean.fireSuccess().setMsg(resultBean.getMsg());
}
public ResultBean save2(AppSubsetVersionOneDto appSubsetVersionOneDto) {
AppSubsetVersion appSubsetVersion = new AppSubsetVersion();
appSubsetVersionOneDto.fillEntity(appSubsetVersion);
boolean isSave = appSubsetVersionService.save(appSubsetVersion);
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
} else {
// Source source = new Source();
// source.setSourceAction(appSubsetVersionOneDto.getSourceAction());
// source.setSourceName(appSubsetVersionOneDto.getAppName());
// source.setSourcePackage(appSubsetVersionOneDto.getSourcePackage());
// source.setVer(appSubsetVersionOneDto.getVersionCode());
// source.setSourceType(appSubsetVersionOneDto.getType());
// source.setModulePluginName(appSubsetVersionOneDto.getModulePluginName());
// sourceService.save(source);
}
return ResultBean.fireSuccess().setMsg("保存成功");
}
public ResultBean update2(AppSubsetVersionOneDto appSubsetVersionOneDto) {
AppSubsetVersion appSubsetVersion = new AppSubsetVersion();
appSubsetVersionOneDto.fillEntity(appSubsetVersion);
//查询目前数据库中的最新版本
AppVersionVo appVersionVo = appSubsetVersionService.selectByAppSid(appSubsetVersionOneDto.getAppSid());
if (appVersionVo != null) {
int versionCode = appSubsetVersion.getVersionCode();
if (appSubsetVersionOneDto.getType().equals("2") || appSubsetVersionOneDto.getType().equals("3")) {
if (versionCode <= appVersionVo.getVersionCode()) {
return ResultBean.fireFail().setMsg("上传的版本不能小于所存在的最新版本号");
}
}
boolean isSave = appSubsetVersionService.save(appSubsetVersion);
if (!isSave) {
return ResultBean.fireFail().setMsg("更新失败");
}
} else {
boolean isSave = appSubsetVersionService.save(appSubsetVersion);
if (!isSave) {
return ResultBean.fireFail().setMsg("更新失败");
}
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
}

View File

@@ -0,0 +1,23 @@
package com.yxt.jlzx.system.biz.appsubset;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersion;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersionVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author dimengzhe
* @date 2021/1/4 16:47
* @description
*/
@Mapper
public interface AppSubsetVersionMapper extends BaseMapper<AppSubsetVersion> {
public List<AppSubsetVersionVo> selectVersionList(String linkSid);
public AppVersionVo selectByAppSid(String appSid);
}

View File

@@ -0,0 +1,36 @@
<?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.yxt.jlzx.system.biz.appsubset.AppSubsetVersionMapper">
<select id="selectVersionList" resultType="com.yxt.jlzx.system.api.appsubset.AppSubsetVersionVo">
SELECT asv.sortNo,
asv.appName,
asv.appSid,
asv.versionCode,
asv.iconUrl,
asv.versionName,
asv.updateUrl,
asv.updateUrl,
asv.upgradeInfo,
asv.type,
asv.modulePluginName,
asv.sourcePackage,
asv.sourceAction,
asv.`id`
FROM app_subset_version asv
WHERE linkSid = #{linkSid}
AND id IN (SELECT MAX(id) FROM app_subset_version GROUP BY appSid)
ORDER BY sortNo ASC
</select>
<select id="selectByAppSid" resultType="com.yxt.jlzx.system.api.app.AppVersionVo">
SELECT versionCode
FROM app_subset_version
WHERE appSid = #{appSid}
ORDER BY createTime DESC
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,26 @@
package com.yxt.jlzx.system.biz.appsubset;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersion;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersionVo;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author dimengzhe
* @date 2021/1/4 16:46
* @description
*/
@Service
public class AppSubsetVersionService extends MybatisBaseService<AppSubsetVersionMapper, AppSubsetVersion> {
public List<AppSubsetVersionVo> selectVersionList(String linkSid) {
return baseMapper.selectVersionList(linkSid);
}
public AppVersionVo selectByAppSid(String appSid) {
return baseMapper.selectByAppSid(appSid);
}
}

View File

@@ -0,0 +1,197 @@
package com.yxt.jlzx.system.biz.appsubset2;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.app.VersionVo;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersion;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersionOneDto;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersionVo;
import com.yxt.jlzx.system.api.appsubset2.*;
import com.yxt.jlzx.system.biz.app.ApkUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import java.util.UUID;
/**
* @author dimengzhe
* @date 2021/1/9 14:04
* @description
*/
@Controller
@RequestMapping("v1/appSubsets")
@Api(tags = "app管理-更新二级应用")
public class AppSubsetApiImpl implements AppSubsetApi {
@Autowired
private AppSubsetService appSubsetService;
@Autowired
private ApkUtil apkUtil;
@Override
public ResultBean<List<AppSubsetVo>> selectVersionList(String linkSid) {
List<AppSubsetVo> appSubsetVoList = appSubsetService.selectVersionList(linkSid);
return new ResultBean<List<AppSubsetVo>>().success().setData(appSubsetVoList);
}
@Override
public ResultBean save(AppSubsetDto appSubsetDto) {
if (appSubsetDto.getType().equals("2")) {
if (StringUtils.isBlank(appSubsetDto.getModulePluginName()) || appSubsetDto.getModulePluginName().equals("null")) {
return ResultBean.fireFail().setMsg("插件名称不能为空");
}
}
if (appSubsetDto.getType().equals("2") || appSubsetDto.getType().equals("3")) {
if (appSubsetDto.getMultipartFile() == null) {
return ResultBean.fireFail().setMsg("请上传文件");
} else {
// 获取文件名
String fileName = appSubsetDto.getMultipartFile().getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
if (!prefix.equals(".apk")) {
return ResultBean.fireFail().setMsg("请上传apk文件");
}
}
}
AppSubsetOneDto appSubsetOneDto = new AppSubsetOneDto();
if (appSubsetDto.getType().equals("2")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetDto.getMultipartFile()).getData();
appSubsetOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetOneDto.setVersionName(versionVo.getVersionName());
appSubsetOneDto.setModulePluginName(appSubsetDto.getModulePluginName());
} else if (appSubsetDto.getType().equals("3")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetDto.getMultipartFile()).getData();
appSubsetOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetOneDto.setVersionName(versionVo.getVersionName());
appSubsetOneDto.setModulePluginName("");
} else {
appSubsetOneDto.setVersionCode(0);
appSubsetOneDto.setUpdateUrl("");
appSubsetOneDto.setVersionName("");
appSubsetOneDto.setModulePluginName("");
}
appSubsetOneDto.setAppName(appSubsetDto.getAppName());
appSubsetOneDto.setIconUrl(appSubsetDto.getIconUrl());
appSubsetOneDto.setUpgradeInfo(appSubsetDto.getUpgradeInfo());
appSubsetOneDto.setType(appSubsetDto.getType());
appSubsetOneDto.setSortNo(appSubsetDto.getSortNo());
appSubsetOneDto.setSourceAction(appSubsetDto.getSourceAction());
appSubsetOneDto.setSourcePackage(appSubsetDto.getSourcePackage());
appSubsetOneDto.setAppSid(UUID.randomUUID().toString());
appSubsetOneDto.setLinkSid(appSubsetDto.getLinkSid());
ResultBean resultBean = save2(appSubsetOneDto);
if (!resultBean.getSuccess()) {
return ResultBean.fireFail().setMsg(resultBean.getMsg());
}
return ResultBean.fireSuccess().setMsg(resultBean.getMsg());
}
@Override
public ResultBean update(AppSubsetDto appSubsetDto) {
if (StringUtils.isBlank(appSubsetDto.getAppSid()) || appSubsetDto.getAppSid().equals("null")) {
return ResultBean.fireFail().setMsg("appSid不能为空");
}
if (appSubsetDto.getType().equals("2")) {
if (StringUtils.isBlank(appSubsetDto.getModulePluginName()) || appSubsetDto.getModulePluginName().equals("null")) {
return ResultBean.fireFail().setMsg("插件名称不能为空");
}
}
if (appSubsetDto.getType().equals("2") || appSubsetDto.getType().equals("3")) {
if (appSubsetDto.getMultipartFile() == null) {
return ResultBean.fireFail().setMsg("请上传文件");
} else {
// 获取文件名
String fileName = appSubsetDto.getMultipartFile().getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
if (!prefix.equals(".apk")) {
return ResultBean.fireFail().setMsg("请上传apk文件");
}
}
}
AppSubsetOneDto appSubsetOneDto = new AppSubsetOneDto();
if (appSubsetDto.getType().equals("2")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetDto.getMultipartFile()).getData();
appSubsetOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetOneDto.setVersionName(versionVo.getVersionName());
appSubsetOneDto.setModulePluginName(appSubsetDto.getModulePluginName());
} else if (appSubsetDto.getType().equals("3")) {
VersionVo versionVo = apkUtil.apkParser(appSubsetDto.getMultipartFile()).getData();
appSubsetOneDto.setVersionCode(versionVo.getVersionCode());
appSubsetOneDto.setUpdateUrl(versionVo.getUpdateUrl());
appSubsetOneDto.setVersionName(versionVo.getVersionName());
appSubsetOneDto.setModulePluginName("");
} else {
appSubsetOneDto.setVersionCode(0);
appSubsetOneDto.setUpdateUrl("");
appSubsetOneDto.setVersionName("");
appSubsetOneDto.setModulePluginName("");
}
appSubsetOneDto.setAppName(appSubsetDto.getAppName());
appSubsetOneDto.setIconUrl(appSubsetDto.getIconUrl());
appSubsetOneDto.setUpgradeInfo(appSubsetDto.getUpgradeInfo());
appSubsetOneDto.setType(appSubsetDto.getType());
appSubsetOneDto.setSourceAction(appSubsetDto.getSourceAction());
appSubsetOneDto.setSourcePackage(appSubsetDto.getSourcePackage());
appSubsetOneDto.setAppSid(appSubsetDto.getAppSid());
appSubsetOneDto.setLinkSid(appSubsetDto.getLinkSid());
appSubsetOneDto.setSortNo(appSubsetDto.getSortNo());
ResultBean resultBean = update2(appSubsetOneDto);
if (!resultBean.getSuccess()) {
return ResultBean.fireFail().setMsg(resultBean.getMsg());
}
return ResultBean.fireSuccess().setMsg(resultBean.getMsg());
}
public ResultBean save2(AppSubsetOneDto appSubsetOneDto) {
AppSubset appSubset = new AppSubset();
appSubsetOneDto.fillEntity(appSubset);
boolean isSave = appSubsetService.save(appSubset);
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
} else {
}
return ResultBean.fireSuccess().setMsg("保存成功");
}
public ResultBean update2(AppSubsetOneDto appSubsetOneDto) {
AppSubset appSubset = new AppSubset();
appSubsetOneDto.fillEntity(appSubset);
//查询目前数据库中的最新版本
AppVersionVo appVersionVo = appSubsetService.selectByAppSid(appSubsetOneDto.getAppSid());
if (appVersionVo != null) {
int versionCode = appSubset.getVersionCode();
if (appSubsetOneDto.getType().equals("2") || appSubsetOneDto.getType().equals("3")) {
if (versionCode <= appVersionVo.getVersionCode()) {
return ResultBean.fireFail().setMsg("上传的版本不能小于所存在的最新版本号");
}
}
boolean isSave = appSubsetService.save(appSubset);
if (!isSave) {
return ResultBean.fireFail().setMsg("更新失败");
}
} else {
boolean isSave = appSubsetService.save(appSubset);
if (!isSave) {
return ResultBean.fireFail().setMsg("更新失败");
}
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
}

View File

@@ -0,0 +1,24 @@
package com.yxt.jlzx.system.biz.appsubset2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersion;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersionVo;
import com.yxt.jlzx.system.api.appsubset2.AppSubset;
import com.yxt.jlzx.system.api.appsubset2.AppSubsetVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author dimengzhe
* @date 2021/1/9 14:19
* @description
*/
@Mapper
public interface AppSubsetMapper extends BaseMapper<AppSubset> {
public List<AppSubsetVo> selectVersionList(String linkSid);
public AppVersionVo selectByAppSid(String appSid);
}

View File

@@ -0,0 +1,36 @@
<?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.yxt.jlzx.system.biz.appsubset2.AppSubsetMapper">
<select id="selectVersionList" resultType="com.yxt.jlzx.system.api.appsubset2.AppSubsetVo">
SELECT asv.sortNo,
asv.appName,
asv.appSid,
asv.versionCode,
asv.iconUrl,
asv.versionName,
asv.updateUrl,
asv.updateUrl,
asv.upgradeInfo,
asv.type,
asv.modulePluginName,
asv.sourcePackage,
asv.sourceAction,
asv.id
FROM app_subset asv
WHERE linkSid = #{linkSid}
AND id IN (SELECT MAX(id) FROM app_subset GROUP BY appSid)
ORDER BY sortNo ASC
</select>
<select id="selectByAppSid" resultType="com.yxt.jlzx.system.api.app.AppVersionVo">
SELECT versionCode
FROM app_subset
WHERE appSid = #{appSid}
ORDER BY createTime DESC
LIMIT 1
</select>
</mapper>

View File

@@ -0,0 +1,29 @@
package com.yxt.jlzx.system.biz.appsubset2;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.jlzx.system.api.app.AppVersionVo;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersion;
import com.yxt.jlzx.system.api.appsubset.AppSubsetVersionVo;
import com.yxt.jlzx.system.api.appsubset2.AppSubset;
import com.yxt.jlzx.system.api.appsubset2.AppSubsetVo;
import com.yxt.jlzx.system.biz.appsubset.AppSubsetVersionMapper;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author dimengzhe
* @date 2021/1/9 14:10
* @description
*/
@Service
public class AppSubsetService extends MybatisBaseService<AppSubsetMapper, AppSubset> {
public List<AppSubsetVo> selectVersionList(String linkSid) {
return baseMapper.selectVersionList(linkSid);
}
public AppVersionVo selectByAppSid(String appSid) {
return baseMapper.selectByAppSid(appSid);
}
}

View File

@@ -0,0 +1,31 @@
package com.yxt.jlzx.system.biz.banner;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.banner.BannerApi;
import com.yxt.jlzx.system.api.banner.BannerVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/11/13 9:35
* @description
*/
@Controller
@RequestMapping("v1/banners")
@Api(tags = "广告")
public class BannerApiImpl implements BannerApi {
@Autowired
private BannerService bannerService;
@Override
public ResultBean<List<BannerVo>> selectBannerList() {
List<BannerVo> bannerVoList = bannerService.selectBannerList();
return new ResultBean<List<BannerVo>>().success().setData(bannerVoList);
}
}

View File

@@ -0,0 +1,19 @@
package com.yxt.jlzx.system.biz.banner;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.jlzx.system.api.banner.Banner;
import com.yxt.jlzx.system.api.banner.BannerVo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/11/13 9:38
* @description
*/
@Mapper
public interface BannerMapper extends BaseMapper<Banner> {
public List<BannerVo> bannerVoList();
}

View File

@@ -0,0 +1,10 @@
<?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.yxt.jlzx.system.biz.banner.BannerMapper">
<select id="bannerVoList" resultType="com.yxt.jlzx.system.api.banner.BannerVo">
SELECT url, picUrl pic, sid
FROM banner
</select>
</mapper>

View File

@@ -0,0 +1,21 @@
package com.yxt.jlzx.system.biz.banner;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.jlzx.system.api.banner.Banner;
import com.yxt.jlzx.system.api.banner.BannerVo;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/11/13 9:37
* @description
*/
@Service
public class BannerService extends MybatisBaseService<BannerMapper, Banner> {
public List<BannerVo> selectBannerList() {
return baseMapper.bannerVoList();
}
}

View File

@@ -0,0 +1,135 @@
package com.yxt.jlzx.system.biz.cahtmlsignature;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.cahtmlsignature.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yxt_mtl
* @date 2020/9/29 13:30
* @description 角色信息
*/
@Controller
@RequestMapping("v1/cahtmlsignatures")
@Api(tags = "电子签章")
public class CahtmlsignatureApiImpl implements CahtmlsignatureApi {
@Autowired
private CahtmlsignatureService cahtmlsignatureService;
/**
* 角色分页列表
*
* @param pagerQuery 查询条件
* @return 角色分页列表
*/
@Override
public ResultBean<PagerVo<CahtmlsignatureVo>> pageList(PagerQuery<CahtmlsignatureQuery> pagerQuery) {
ResultBean<PagerVo<CahtmlsignatureVo>> rb = ResultBean.fireFail();
IPage<CahtmlsignatureVo> page = cahtmlsignatureService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<CahtmlsignatureVo> pv_result = PagerUtil.pageToVo(page, null);
return rb.success().setData(pv_result);
}
/**
* 保存
*
* @param cahtmlsignatureDto 角色dto对象
* @return ResultBean
*/
@Override
public ResultBean save(CahtmlsignatureDto cahtmlsignatureDto) {
Cahtmlsignature cahtmlsignature = new Cahtmlsignature();
cahtmlsignatureDto.fillEntity(cahtmlsignature);
if (!cahtmlsignatureService.save(cahtmlsignature))
return ResultBean.fireFail().setMsg("保存失败");
return ResultBean.fireSuccess().setData(cahtmlsignature.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值.
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean update(CahtmlsignatureDto cahtmlsignatureDto, String sid) throws Exception {
Cahtmlsignature cahtmlsignature = cahtmlsignatureService.fetchBySid(sid);
if (null == cahtmlsignature)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == cahtmlsignatureService.updateBySid(cahtmlsignatureDto.toMap(), sid))
return ResultBean.fireFail().setMsg("更新失败");
return ResultBean.fireSuccess().setMsg("更新成功");
}
/**
* 删除
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
Cahtmlsignature cahtmlsignature = cahtmlsignatureService.fetchBySid(sid);
if (null == cahtmlsignature)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == cahtmlsignatureService.deleteBySid(sid))
return ResultBean.fireFail().setMsg("删除失败");
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 修改页面初始化数据
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean<CahtmlsignatureVo> getVo(String sid) {
Cahtmlsignature cahtmlsignature = cahtmlsignatureService.fetchBySid(sid);
if (null == cahtmlsignature)
return new ResultBean().fail().setData(null);
CahtmlsignatureVo cahtmlsignatureVo = new CahtmlsignatureVo();
cahtmlsignatureVo.fromEntity(cahtmlsignature);
return new ResultBean().success().setData(cahtmlsignatureVo);
}
@Override
public ResultBean<List<CahtmlsignatureVo>> list(@Valid CahtmlsignatureQuery query) {
List<CahtmlsignatureVo> list = cahtmlsignatureService.list(query);
return new ResultBean().success().setData(list);
}
@Override
public ResultBean<Cahtmlsignature> selectBySignSid(String signatureSid) {
Cahtmlsignature cahtmlsignature = cahtmlsignatureService.selectBySignSid(signatureSid);
if (cahtmlsignature == null) {
Cahtmlsignature cahtmlsignature1 = new Cahtmlsignature();
return new ResultBean<Cahtmlsignature>().fail().setData(cahtmlsignature1);
}
return new ResultBean<Cahtmlsignature>().success().setData(cahtmlsignature);
}
}

View File

@@ -0,0 +1,34 @@
package com.yxt.jlzx.system.biz.cahtmlsignature;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.cahtmlsignature.Cahtmlsignature;
import com.yxt.jlzx.system.api.cahtmlsignature.CahtmlsignatureQuery;
import com.yxt.jlzx.system.api.cahtmlsignature.CahtmlsignatureVo;
/**
* @author yxt_mtl
* @date 2020/9/29 13:45
* @description
*/
@Mapper
public interface CahtmlsignatureMapper extends BaseMapper<Cahtmlsignature> {
//分页列表
IPage<CahtmlsignatureVo> pageList(IPage<CahtmlsignatureQuery> page, @Param(Constants.WRAPPER) Wrapper<CahtmlsignatureVo> qw);
public int updateIsEnable(@Param("sid") String sid, @Param("isEnable") Integer isEnable);
List<CahtmlsignatureVo> list(@Param(Constants.WRAPPER) Wrapper<CahtmlsignatureVo> qw);
public Cahtmlsignature selectBySignSid(String sid);
}

View File

@@ -0,0 +1,19 @@
<?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.yxt.jlzx.system.biz.cahtmlsignature.CahtmlsignatureMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.cahtmlsignature.CahtmlsignatureVo">
SELECT sid, signatureSid, signature, documentSid
FROM cahtmlsignature ${ew.customSqlSegment}
</select>
<select id="list" resultType="com.yxt.jlzx.system.api.cahtmlsignature.CahtmlsignatureVo">
SELECT sid, signatureSid, signature, documentSid, sealPic
FROM cahtmlsignature ${ew.customSqlSegment}
</select>
<select id="selectBySignSid" resultType="com.yxt.jlzx.system.api.cahtmlsignature.Cahtmlsignature">
SELECT *
FROM cahtmlsignature
WHERE signatureSid = #{sid}
</select>
</mapper>

View File

@@ -0,0 +1,67 @@
package com.yxt.jlzx.system.biz.cahtmlsignature;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.cahtmlsignature.Cahtmlsignature;
import com.yxt.jlzx.system.api.cahtmlsignature.CahtmlsignatureQuery;
import com.yxt.jlzx.system.api.cahtmlsignature.CahtmlsignatureVo;
import java.util.List;
import javax.validation.Valid;
import org.springframework.stereotype.Service;
/**
* @author yxt_mtl
* @date 2020/9/29 13:40
* @description
*/
@Service
public class CahtmlsignatureService extends MybatisBaseService<CahtmlsignatureMapper, Cahtmlsignature> {
// 分页列表
public IPage<CahtmlsignatureVo> pageList(PagerQuery<CahtmlsignatureQuery> pagerQuery) {
// mybits所用的分页对对象
IPage<CahtmlsignatureQuery> page = PagerUtil.queryToPage(pagerQuery);
// mybits所用的查询条件封装类
QueryWrapper<CahtmlsignatureVo> qw = buildQueryWrapper(pagerQuery.getParams());
return baseMapper.pageList(page, qw);
}
/**
* 解析和组装查询条件封装在qw中
*
* @param pagerQuery
* @return
*/
private QueryWrapper<CahtmlsignatureVo> buildQueryWrapper(CahtmlsignatureQuery pagerQuery) {
QueryWrapper<CahtmlsignatureVo> qw = new QueryWrapper<>();
if (pagerQuery != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery.getDocumentSid()))
qw.eq("documentSid", pagerQuery.getDocumentSid());
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery.getSignatureSid()))
qw.eq("signatureSid", pagerQuery.getSignatureSid());
qw.orderByDesc("createTime");
}
return qw;
}
public List<CahtmlsignatureVo> list(@Valid CahtmlsignatureQuery query) {
QueryWrapper<CahtmlsignatureVo> qw = buildQueryWrapper(query);
return baseMapper.list(qw);
}
public Cahtmlsignature selectBySignSid(String sid) {
return baseMapper.selectBySignSid(sid);
}
}

View File

@@ -0,0 +1,151 @@
package com.yxt.jlzx.system.biz.captcha;
import com.alibaba.fastjson.JSON;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.yxt.common.base.config.RedisUtil;
import com.yxt.common.base.config.captcha.CaptchaBaseParam;
import com.yxt.common.base.config.captcha.CaptchaType;
import com.yxt.common.base.config.captcha.ImageUtils;
import com.yxt.common.base.config.captcha.factory.CaptchaFactory;
import com.yxt.common.base.config.captcha.factory.ICaptchaFactory;
import com.yxt.common.base.config.captcha.factory.impl.AbstractCaptcha;
import com.yxt.common.base.utils.AjaxResult;
import com.yxt.common.base.utils.Base64;
import com.yxt.common.base.utils.VerifyCodeUtils;
import com.yxt.common.core.vo.CaptchaBaseVO;
import com.yxt.jlzx.system.api.captcha.BlendCodeApi;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
/**
* @author dimengzhe
* @date 2020/9/11 16:50
* @description 登录时字母验证码
*/
@Controller
@RequestMapping("/api")
@Api(tags = "验证码接口")
@ApiSort(30)
public class BlendCodeController implements BlendCodeApi {
@Autowired
private DefaultKaptcha captchaProducer;
@Autowired
private RedisUtil redisUtil;
@Autowired
private ImageUtils imageUtils;
/**
* 超时时间3min
*/
private static int captchaExpires = 2 * 60;
@Override
public void defaultBlendCode(HttpServletResponse httpServletResponse) throws Exception {
byte[] captchaOutputStream = null;
ByteArrayOutputStream imgOutputStream = new ByteArrayOutputStream();
String uuid = UUID.randomUUID().toString();
try {
//生产验证码字符串
//String verifyCode = captchaProducer.createText();
String verifyCode = VerifyCodeUtils.generateVerifyCode(4);
redisUtil.set(uuid, verifyCode);
redisUtil.expire(uuid, captchaExpires);
//BufferedImage challenge = captchaProducer.createImage(verifyCode);
int w = 111, h = 36;
VerifyCodeUtils.outputImage(w, h, imgOutputStream, verifyCode);
// ImageIO.write(challenge, "jpg", imgOutputStream);
} catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
captchaOutputStream = imgOutputStream.toByteArray();
httpServletResponse.setHeader("Cache-Control", "no-store");
httpServletResponse.setHeader("Pragma", "no-cache");
httpServletResponse.setHeader("uuid", uuid);
httpServletResponse.setDateHeader("Expires", 0);
httpServletResponse.setContentType("image/jpeg");
ServletOutputStream responseOutputStream = httpServletResponse.getOutputStream();
responseOutputStream.write(captchaOutputStream);
responseOutputStream.flush();
responseOutputStream.close();
}
@Override
public AjaxResult blockPuzzle(HttpServletResponse httpServletResponse) throws Exception {
String uuid = UUID.randomUUID().toString();
ICaptchaFactory captchaFactory = new CaptchaFactory();
AbstractCaptcha captcha = captchaFactory.getInstance(CaptchaType.BLOCK_PUZZLE);
CaptchaBaseParam captchaBaseParam = new CaptchaBaseParam();
captchaBaseParam.setUrlOrPath(imageUtils.getBlockPuzzleBgPath());
captcha.setJigsawUrlOrPath(imageUtils.getBlockPuzzleJigsawPath());
CaptchaBaseVO dataVO = captcha.create(captchaBaseParam);
AjaxResult ajaxResult = new AjaxResult();
ajaxResult.put("dataVo", dataVO);
Map map = JSON.parseObject(JSON.toJSONString(dataVO), Map.class);
String point = map.get("point").toString();
HashMap hashMap = JSON.parseObject(point, HashMap.class);
redisUtil.set(uuid, hashMap.get("x").toString());
redisUtil.expire(uuid, captchaExpires);
ajaxResult.put("uuid", uuid);
return ajaxResult;
}
@Override
public AjaxResult getCaptcha(HttpServletResponse httpServletResponse) {
ByteArrayOutputStream imgOutputStream = new ByteArrayOutputStream();
String uuid = UUID.randomUUID().toString();
//生产验证码字符串
//String verifyCode = captchaProducer.createText();
String verifyCode = VerifyCodeUtils.generateVerifyCode(4);
redisUtil.set(uuid, verifyCode);
redisUtil.expire(uuid, captchaExpires);
//BufferedImage challenge = captchaProducer.createImage(verifyCode);
int w = 111, h = 36;
try {
VerifyCodeUtils.outputImage(w, h, imgOutputStream, verifyCode);
//ImageIO.write(challenge, "jpg", imgOutputStream);
} catch (IOException e) {
return AjaxResult.error(e.getMessage());
}
AjaxResult ajaxResult = AjaxResult.success();
ajaxResult.put("uuid", uuid);
ajaxResult.put("img", Base64.encode(imgOutputStream.toByteArray()));
return ajaxResult;
}
@Override
public AjaxResult clickWord(HttpServletResponse httpServletResponse) {
String uuid = UUID.randomUUID().toString();
ICaptchaFactory captchaFactory = new CaptchaFactory();
AbstractCaptcha captcha = captchaFactory.getInstance(CaptchaType.CLICK_WORD);
CaptchaBaseParam captchaBaseParam = new CaptchaBaseParam();
captchaBaseParam.setUrlOrPath(imageUtils.getClickWordBgPath());
captcha.setFontColorRandom(false);
CaptchaBaseVO dataVO = captcha.create(captchaBaseParam);
AjaxResult ajaxResult = AjaxResult.success();
ajaxResult.put("dataVO", dataVO);
Map map = JSON.parseObject(JSON.toJSONString(dataVO), Map.class);
String wordList = map.get("wordList").toString();
String pointList = map.get("pointList").toString();
// List<String> lis = Arrays.asList(wordList.split(""));
// redisUtil.set(uuid, lis.get(0) + lis.get(1) + lis.get(2));
redisUtil.set(uuid, pointList);
redisUtil.expire(uuid, captchaExpires);
ajaxResult.put("uuid", uuid);
return ajaxResult;
}
}

View File

@@ -0,0 +1,235 @@
package com.yxt.jlzx.system.biz.department;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.yxt.common.base.config.component.FileUploadComponent;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.QRCodeUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.department.*;
import com.yxt.jlzx.system.api.index.IndexDeptUser;
import com.yxt.jlzx.system.api.index.IndexDeptUserOne;
import com.yxt.jlzx.system.biz.index.IndexService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.Valid;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author dimengzhe
* @date 2020/10/11 11:36
* @description 内部机构
*/
@Controller
@RequestMapping("v1/departments")
@Api(tags = "内部机构接口")
@ApiSort(60)
public class DepartmentApiImpl implements DepartmentApi {
@Autowired
private DepartmentService departmentService;
@Autowired
private FileUploadComponent fileUploadComponent;
@Autowired
private IndexService indexService;
@Override
public ResultBean<List<DepartmentListVo>> list(@Valid DepartmentQuery departmentQuery) {
return null;
}
@Override
public ResultBean<PagerVo<DepartmentListVo>> pageList(PagerQuery<DepartmentQuery> pagerQuery) {
ResultBean<PagerVo<DepartmentListVo>> rb = ResultBean.fireFail();
if (StringUtils.isBlank(pagerQuery.getParams().getOrganizationSid())) {
return rb.fail().setMsg("机构sid不能为空");
} else if (StringUtils.isBlank(pagerQuery.getParams().getPsid())) {
return rb.fail().setMsg("父级sid不能为空");
}
PagerVo<DepartmentListVo> pv = new PagerVo<>();
IPage<DepartmentListVo> p2 = departmentService.pageList(pagerQuery);
PagerVo<DepartmentListVo> pv1 = PagerUtil.pageToVo(p2, pv);
return rb.success().setData(pv1);
}
@Override
public ResultBean save(@Valid DepartmentDto departmentDto) {
Department department = new Department();
departmentDto.fillEntity(department);
if (!departmentService.save(department)) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setData("保存成功");
}
/**
* 部门修改
*
* @param departmentDto departmentDto对象
* @param s 部门sid
* @return 修改是否成功
* @throws Exception
*/
@Override
public ResultBean update(@Valid DepartmentDto departmentDto, String s) throws Exception {
Department department = departmentService.fetchBySid(s);
if (null == department) {
return ResultBean.fireFail().setMsg("该部门不存在");
}
if (0 == departmentService.updateBySid(departmentDto.toMap(), s)) {
return ResultBean.fireFail();
}
departmentService.updateQrCodePath(s, "");
return ResultBean.fireSuccess().setMsg("修改成功");
}
/**
* 删除内部机构部门
*
* @param s 部门sid
* @return 删除是否成功
*/
@Override
public ResultBean delete(String s) {
Department department = departmentService.fetchBySid(s);
if (null == department) {
return ResultBean.fireFail().setMsg("该部门不存在");
}
int i = departmentService.selectBySid(s);
if (i > 0) {
return ResultBean.fireFail().setMsg("该部门存在下级,请删除下级后再操作");
}
int ii = departmentService.deleteBySid(s);
if (ii == 0) {
return ResultBean.fireFail().setMsg("删除失败");
}
return ResultBean.fireSuccess().setMsg("删除成功");
}
@Override
public ResultBean<DepartmentListVo> getVo(String s) {
ResultBean<DepartmentListVo> resultBean = ResultBean.fireFail();
Department department = departmentService.fetchBySid(s);
DepartmentListVo vo = new DepartmentListVo();
vo.fromEntity(department);
return resultBean.success().setData(vo);
}
/**
* 内部机构树形列表
*
* @param organizationSid 机构sid
* @return 内部机构的树形列表
*/
@Override
public ResultBean<List<DepartmentVo>> departmentTreeList(String orgSid) {
String deptUsetList = indexService.deptUsetList(orgSid);
JSONObject jsonObject1 = JSONObject.parseObject(deptUsetList);
Map<String, Object> map = JSONObject.parseObject(jsonObject1.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> listData = ConstantUtils.getListData(map, "data");
Map<String, Object> dataMap=listData.get(0);
// 将 Map 转换为 实体类
IndexDeptUser indexDeptUser= JSON.parseObject(JSON.toJSONString(dataMap), IndexDeptUser.class);
List<DepartmentVo> voList = new ArrayList<>();
DepartmentVo departmentVo = new DepartmentVo();
departmentVo.setOrganizationName(indexDeptUser.getName());
departmentVo.setOrganizationSid(indexDeptUser.getOwnerId());
List<DepartmentVoList> voList1 = new ArrayList<>();
if(indexDeptUser!=null) {
List<IndexDeptUserOne> children = indexDeptUser.getChildren();
for (IndexDeptUserOne indexDeptUser1 : children){
DepartmentVoList departmentVoList = new DepartmentVoList();
String name = indexDeptUser1.getName();
String sid = indexDeptUser1.getOwnerId();
String pSid = indexDeptUser1.getPsid();
departmentVoList.setName(name);
departmentVoList.setSid(indexDeptUser1.getId().toString());
voList1.add(departmentVoList);
}
}
departmentVo.setOrgDepartmentVoList(voList1);
voList.add(departmentVo);
// List<DepartmentVo> departmentVo = departmentService.departmentTreeList(orgSid);
// if (departmentVo == null) {
// return new ResultBean<List<DepartmentVo>>().fail().setMsg("该人员无单位");
// }
return new ResultBean<List<DepartmentVo>>().success().setData(voList);
}
/**
* 内部机构tree树修改
*
* @param sid 部门sid
* @param name 部门名称
* @return 修改是否成功
*/
@Override
public ResultBean departmentTreeUpdate(String sid, String name, int sortNo) {
Department department = departmentService.fetchBySid(sid);
if (null == department) {
return ResultBean.fireFail().setMsg("该部门不存在");
}
if (0 == departmentService.updateName(sid, name, sortNo)) {
return ResultBean.fireFail().setMsg("修改失败");
}
return ResultBean.fireSuccess().setMsg("修改成功");
}
@Override
public ResultBean<QrCodeVo> getQrCode(String sid) {
Department department = departmentService.fetchBySid(sid);
if (department == null) {
return new ResultBean<QrCodeVo>().fail().setMsg("部门不存在");
}
if (StringUtils.isBlank(department.getQrFilePath())) {
File file = new File(fileUploadComponent.getUploadPath() + "qrCode");
QRCodeUtil.createCodeToFile(department.getOrganizationSid() + "#" + department.getId() + "#" + "q", file, department.getName() + department.getId() + ".png");
//将该二维码地址放进部门表中的二维码图片地址中
String path = fileUploadComponent.getUrlPrefix() + "qrCode/" + department.getName() + department.getId() + ".png";
departmentService.updateQrCodePath(sid, path);
}
QrCodeVo qrCodeVo = departmentService.getQrCodeVo(sid);
return new ResultBean<QrCodeVo>().success().setData(qrCodeVo);
}
@Override
public ResultBean<List<DepartmentOrgListVo>> departmentOrgList(String organizationSid) {
List<DepartmentOrgListVo> departmentOrgListVoList = departmentService.departmentOrgList(organizationSid);
return new ResultBean<List<DepartmentOrgListVo>>().success().setData(departmentOrgListVoList);
}
@Override
public ResultBean<QrCodeVo> queryByStaffSid(String staffSid) {
QrCodeVo qrCodeVo = departmentService.queryByStaffSid(staffSid);
if (qrCodeVo == null) {
qrCodeVo = new QrCodeVo();
return new ResultBean<QrCodeVo>().fail().setData(qrCodeVo);
} else {
return new ResultBean<QrCodeVo>().success().setData(qrCodeVo);
}
}
@Override
public ResultBean<Department> selectId(Integer id) {
Department department = departmentService.fetchById(id);
return new ResultBean<Department>().success().setData(department);
}
}

View File

@@ -0,0 +1,57 @@
package com.yxt.jlzx.system.biz.department;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.department.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/10/11 14:57
* @description
*/
@Mapper
public interface DepartmentMapper extends BaseMapper<Department> {
/**
* 内部机构tree树形列表
*
* @param organizationSid 机构sid
* @return 内部机构tree树形列表
*/
public List<DepartmentVo> departmentTreeList(String organizationSid);
/**
* 根据sid更新名称
*
* @param sid 部门sid
* @param name 部门名称
* @return
*/
public int updateName(@Param("sid") String sid, @Param("name") String name,@Param("sortNo") int sortNo);
/**
* 根据sid查询部门是否存在下级
*
* @param sid 部门sid
* @return
*/
public int selectBySid(String sid);
public IPage<DepartmentListVo> pageList(IPage<?> page, @Param(Constants.WRAPPER) Wrapper<DepartmentListVo> qw);
public int updateQrCodePath(@Param("sid") String sid, @Param("path") String path);
public QrCodeVo getQrCodeVo(@Param("sid") String sid);
public List<DepartmentOrgListVo> departmentOrgList(String organizationSid);
public QrCodeVo queryByStaffSid(String staffSid);
public int selectByPsid(String pSid);
}

View File

@@ -0,0 +1,107 @@
<?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.yxt.jlzx.system.biz.department.DepartmentMapper">
<resultMap id="departmentTreeListMap" type="com.yxt.jlzx.system.api.department.DepartmentVo">
<result column="organizationSid" jdbcType="VARCHAR" property="organizationSid"/>
<result column="organizationName" jdbcType="VARCHAR" property="organizationName"/>
<result column="gisInfo" jdbcType="VARCHAR" property="gisInfo"/>
<result column="orgAddress" jdbcType="VARCHAR" property="orgAddress"/>
<collection property="orgDepartmentVoList" ofType="DepartmentVoList"
select="departmentVoLists" column="organizationSid">
</collection>
</resultMap>
<select id="departmentVoLists" resultType="com.yxt.jlzx.system.api.department.DepartmentVoList"
resultMap="orgDepartmentVoListMap">
SELECT d.sid, d.name, d.sortNo, d.dlxx, d.address
FROM department d
WHERE d.organizationSid = #{organizationSid}
AND d.pSid = '0'
ORDER BY d.sortNo ASC
</select>
<resultMap id="orgDepartmentVoListMap" type="com.yxt.jlzx.system.api.department.OrgDepartmentVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="sid" jdbcType="VARCHAR" property="sid"/>
<result column="pSid" jdbcType="VARCHAR" property="psid"/>
<result column="dlxx" jdbcType="VARCHAR" property="dlxx"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<collection property="orgDepartmentVoList" ofType="OrgDepartmentVo"
select="orgDepartmentVoList" column="sid">
</collection>
</resultMap>
<select id="orgDepartmentVoList" resultType="com.yxt.jlzx.system.api.department.OrgDepartmentVo"
resultMap="orgDepartmentVoListMap">
SELECT d.sid, d.pSid, d.name,d.dlxx,d.address
FROM department d
LEFT JOIN department d1 ON d.pSid = d1.sid
WHERE d.pSid = #{sid}
ORDER BY d.sortNo ASC
</select>
<select id="departmentTreeList" resultType="com.yxt.jlzx.system.api.department.DepartmentVo"
resultMap="departmentTreeListMap">
SELECT o.sid organizationSid, o.name organizationName, o.gisInfo, o.orgAddress
FROM organization o
WHERE o.sid = #{organizationSid}
</select>
<update id="updateName">
UPDATE department
SET name = #{name},
sortNo=#{sortNo}
WHERE sid = #{sid}
</update>
<select id="selectBySid" resultType="java.lang.Integer">
SELECT COUNT(d.id)
FROM department d
WHERE d.pSid = #{sid}
</select>
<select id="pageList" resultType="com.yxt.jlzx.system.api.department.DepartmentListVo">
SELECT d.sid,
d.pSid,
d.name,
d.contactMan,
d.mobile,
d.address,
d.dlxx,
d.sortNo
FROM department d
${ew.customSqlSegment}
</select>
<update id="updateQrCodePath">
UPDATE jlzx_system.department
SET qrFilePath = #{path}
WHERE sid = #{sid}
</update>
<select id="getQrCodeVo" resultType="com.yxt.jlzx.system.api.department.QrCodeVo">
SELECT d.name departmentName, d.organizationSid, d.qrFilePath, d.address, o.name organizationName, d.sid
FROM jlzx_system.department d
LEFT JOIN jlzx_system.organization o ON o.sid = d.organizationSid
WHERE d.sid = #{sid}
ORDER BY d.sortNo ASC
</select>
<select id="departmentOrgList" resultType="com.yxt.jlzx.system.api.department.DepartmentOrgListVo">
SELECT d.name departmentName, d.sid departmentSid
FROM department d
WHERE d.pSid = 0
AND d.organizationSid = #{organizationSid}
ORDER BY d.sortNo ASC
</select>
<select id="queryByStaffSid" resultType="com.yxt.jlzx.system.api.department.QrCodeVo">
SELECT d.name departmentName, d.sid
FROM jlzx_system.department d
WHERE d.sid = (SELECT departmentSid FROM department_staff WHERE staffSid = #{staffSid} LIMIT 1)
</select>
<select id="selectByPsid" resultType="java.lang.Integer">
SELECT count(*)
FROM department
WHERE pSid = #{pSid}
</select>
</mapper>

View File

@@ -0,0 +1,83 @@
package com.yxt.jlzx.system.biz.department;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.department.*;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/10/11 14:56
* @description
*/
@Service
public class DepartmentService extends MybatisBaseService<DepartmentMapper, Department> {
public List<DepartmentVo> departmentTreeList(String organizationSid) {
return baseMapper.departmentTreeList(organizationSid);
}
public int updateName(String sid, String name,int sortNo) {
return baseMapper.updateName(sid, name,sortNo);
}
public int selectBySid(String sid) {
return baseMapper.selectBySid(sid);
}
/**
* 分页列表
*
* @param pagerQuery 查询条件
* @return
*/
public IPage<DepartmentListVo> pageList(PagerQuery<DepartmentQuery> pagerQuery) {
IPage<DepartmentQuery> page = PagerUtil.queryToPage(pagerQuery);
DepartmentQuery params = pagerQuery.getParams();
QueryWrapper<DepartmentListVo> qw = new QueryWrapper<>();
if (params != null) {
String name = params.getName();
if (StringUtils.isNotBlank(name)) {
qw.like("d.name", name);
}
String organizationSid = params.getOrganizationSid();
if (StringUtils.isNotBlank(organizationSid)) {
qw.eq("d.organizationSid", organizationSid);
}
String pSid = params.getPsid();
if (StringUtils.isNotBlank(pSid)) {
qw.eq("d.pSid", pSid);
}
}
qw.orderByAsc("d.sortNo");
return baseMapper.pageList(page, qw);
}
public int updateQrCodePath(String sid, String path) {
return baseMapper.updateQrCodePath(sid, path);
}
public QrCodeVo getQrCodeVo(String sid) {
return baseMapper.getQrCodeVo(sid);
}
public List<DepartmentOrgListVo> departmentOrgList(String organizationSid) {
return baseMapper.departmentOrgList(organizationSid);
}
public QrCodeVo queryByStaffSid(String staffSid) {
// TODO Auto-generated method stub
return baseMapper.queryByStaffSid(staffSid);
}
public int selectByPsid(String pSid) {
return baseMapper.selectByPsid(pSid);
}
}

View File

@@ -0,0 +1,481 @@
package com.yxt.jlzx.system.biz.departmentstaff;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.yxt.common.base.config.RedisUtil;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.department.Department;
import com.yxt.jlzx.system.api.department.DepartmentFourVo;
import com.yxt.jlzx.system.api.department.DepartmentOneVo;
import com.yxt.jlzx.system.api.department.DepartmentOrgListVo;
import com.yxt.jlzx.system.api.department.DepartmentThreeVo;
import com.yxt.jlzx.system.api.department.DepartmentTwoVo;
import com.yxt.jlzx.system.api.departmentstaff.*;
import com.yxt.jlzx.system.api.index.IndexDeptUser;
import com.yxt.jlzx.system.api.index.IndexDeptUserOne;
import com.yxt.jlzx.system.api.index.IndexDetailsOrg;
import com.yxt.jlzx.system.api.index.IndexUserListVo;
import com.yxt.jlzx.system.api.index.IndexUserListVo2;
import com.yxt.jlzx.system.api.index.IndexUtils;
import com.yxt.jlzx.system.api.index.UserBaseInfo;
import com.yxt.jlzx.system.api.organization.Organization;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionApi;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionQuery3;
import com.yxt.jlzx.system.api.user.User;
import com.yxt.jlzx.system.api.user.UserInfoVo;
import com.yxt.jlzx.system.api.user.UserStaffOneVo;
import com.yxt.jlzx.system.biz.department.DepartmentService;
import com.yxt.jlzx.system.biz.index.IndexApiImpl;
import com.yxt.jlzx.system.biz.organization.OrganizationService;
import com.yxt.jlzx.system.biz.sysfunction.SysFunctionService;
import com.yxt.jlzx.system.biz.user.UserService;
import io.swagger.annotations.Api;
import net.sf.jsqlparser.expression.StringValue;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
/**
* @author dimengzhe
* @date 2020/10/15 22:28
* @description
*/
@Controller
@RequestMapping("v1/departmentStaffs")
@Api(tags = "部门与人员")
@ApiSort(70)
public class DepartmentStaffApiImpl implements DepartmentStaffApi {
@Autowired
private DepartmentStaffService departmentStaffService;
@Autowired
private DepartmentService departmentService;
@Autowired
private HttpServletRequest httpServletRequest;
@Autowired
private RedisUtil redisUtil;
@Autowired
private UserService userService;
@Autowired
private OrganizationService organizationService;
@Autowired
private OrgRoleFunctionApi orgRoleFunctionApi;
@Autowired
private SysFunctionService sysFunctionService;
@Autowired
private IndexApiImpl indexApiImpl;
// @Autowired
// private UserApi userApi;
// @Autowired
// private OrganizationApi organizationApi;
@Override
public ResultBean setUpDepartment(DepartmentStaffDto departmentStaffDto) {
String staffSid = departmentStaffDto.getStaffSid();
String departmentSid = departmentStaffDto.getDepartmentSid();
//查询该部门是否有下级
int count = departmentService.selectByPsid(departmentSid);
if (count > 0) {
return ResultBean.fireFail().setMsg("请选择最后一级部门绑定");
}
//查询是否已经在该机构的该部门
//DepartmentStaff departmentStaff = departmentStaffService.selectByOne(staffSid, departmentSid);
DepartmentStaff departmentStaffTwo = departmentStaffService.selectByTwo(staffSid);
if (departmentStaffTwo == null) {
DepartmentStaff departmentStaffOne = new DepartmentStaff();
departmentStaffDto.fillEntity(departmentStaffOne);
if (!departmentStaffService.save(departmentStaffOne)) {
return ResultBean.fireFail().setMsg("保存失败");
}
} else {
if (0 == departmentStaffService.updateBySid(departmentStaffDto.toMap(), departmentStaffTwo.getSid())) {
return ResultBean.fireFail();
}
}
return ResultBean.fireSuccess().setMsg("设置成功");
}
/**
* 分页列表
*
* @param pagerQuery
* @return
*/
@Override
public ResultBean<PagerVo<DepartmentStaffVo>> pagerVoList(PagerQuery<DepartmentStaffQuery> pagerQuery) {
ResultBean<PagerVo<DepartmentStaffVo>> rb = ResultBean.fireFail();
PagerVo<DepartmentStaffVo> pv = new PagerVo<>();
IPage<DepartmentStaffVo> p2 = departmentStaffService.pagerVoList(pagerQuery);
PagerVo<DepartmentStaffVo> pv1 = PagerUtil.pageToVo(p2, pv);
return rb.success().setData(pv1);
}
@Override
public ResultBean<List<DepartmentStaffVo>> appList(DepartmentStaffQuery departmentStaffQuery) {
ResultBean<List<DepartmentStaffVo>> rb = ResultBean.fireFail();
List<DepartmentStaffVo> p2 = departmentStaffService.appList(departmentStaffQuery);
return rb.success().setData(p2);
}
//2021.10.30 根据部门查询该部门下的人员
@Override
public ResultBean<List<DepartmentStaffQuery>> selectBydep(String depSid) {
if (depSid == null || depSid.length() <= 0) {
return new ResultBean<List<DepartmentStaffQuery>>().fail().setMessage("请选择部门!");
}
List<DepartmentStaffQuery> depAndStaffinfoList = departmentStaffService.selectBydep(depSid); //查询该部门下的人员信息
return new ResultBean<List<DepartmentStaffQuery>>().success().setData(depAndStaffinfoList);
}
//查询当前登录人单位下的部门
@Override
public ResultBean<DeptOrgVo> selectOrgDept() {
String token = httpServletRequest.getHeader("token");
String userName = redisUtil.get(token);
User user = userService.selectByUserName(userName);
; //获取当前用户的信息
Organization organization = organizationService.fetchBySid(user.getOrganizationSid()); //获取到当前用户所属单位
// user.setOrganizationSid("7a9cbedd-4859-4c34-90ce-d32b7eb3f22f");
List<DepartmentOrgListVo> departmentOrgList = departmentService.departmentOrgList(user.getOrganizationSid()); //查询公司下得部门
DeptOrgVo deptOrgVo = new DeptOrgVo();
deptOrgVo.setOrgName(organization.getName());
deptOrgVo.setOrgSid(organization.getSid());
List<Department> departments = new ArrayList<>();
for (int i = 0; i < departmentOrgList.size(); i++) {
Department department = new Department();
department.setName(departmentOrgList.get(i).getDepartmentName());
department.setSid(departmentOrgList.get(i).getDepartmentSid());
departments.add(department);
}
deptOrgVo.setDepartmentList(departments);
return new ResultBean<DeptOrgVo>().success().setData(deptOrgVo);
}
/* @Override
public ResultBean<List<DeptStaffInfoVo>> selectDeptStaff(String functionfunid,String organizationSid) {
//判断功能的Sid是否空
if (functionfunid == null || functionfunid.length() <= 0) {
return new ResultBean<List<DeptStaffInfoVo>>().fail().setMessage("请赋权此功能");
}
//===============添加对接
String result = null;
// 请求接口地址
String url = IndexUtils.userListUrl;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("right", functionfunid);
// ToDo:最后需要修改为计量中心的单位sid
// params.put("organizationId", "cbb4d35dfde35e2f8fa5c4ed5765c3cf");
// params.put("organizationId", "43ed06dc950993115f0f608a4fbce93e");
params.put("organizationId", organizationSid);
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
try {
result = ConstantUtils.net2(url, params, "GET", ticket);
} catch (Exception e) {
e.printStackTrace();
}
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> dataList = ConstantUtils.getListData(map, "data");
List list = new ArrayList<>();
for (int i = 0; i < dataList.size(); i++) {
StaffInfoVo staffInfoVo = new StaffInfoVo();
Map<String, Object> dataMap = dataList.get(i);
String name = ConstantUtils.getString(dataMap, "name", "");
String id = ConstantUtils.getString(dataMap, "id", "");
staffInfoVo.setStatffname(name);
staffInfoVo.setStatffSid(id);
list.add(staffInfoVo);
}
DeptStaffInfoVo deptStaffInfoVo = new DeptStaffInfoVo();
deptStaffInfoVo.setStaffInfoVoList(list);
List list1 = new ArrayList();
list1.add(deptStaffInfoVo);
//=============添加对接
return new ResultBean<List<DeptStaffInfoVo>>().success().setData(list1);
}
*/
@Override
public ResultBean<List<DeptStaffInfoVo>> selectDeptStaff(String functionfunid, String organizationSid) {
//判断功能的Sid是否空
if (functionfunid == null || functionfunid.length() <= 0) {
return new ResultBean<List<DeptStaffInfoVo>>().fail().setMessage("请赋权此功能");
}
//===============添加对接
String result = null;
// 请求接口地址
String url = IndexUtils.userListUrl;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("right", functionfunid);
// ToDo:最后需要修改为计量中心的单位sid
params.put("organizationId", organizationSid);
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
try {
result = ConstantUtils.net2(url, params, "GET", ticket);
} catch (Exception e) {
e.printStackTrace();
}
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> dataList = ConstantUtils.getListData(map, "data");
List list = new ArrayList<>();
List<StaffInfoVo> listName = new ArrayList();
for (int i = 0; i < dataList.size(); i++) {
Map<String, Object> dataMap = dataList.get(i);
String id = ConstantUtils.getString(dataMap, "id", "");
list.add(id);
StaffInfoVo staffInfoVo = new StaffInfoVo();
String name = ConstantUtils.getString(dataMap, "name", "");
Integer departmentId = ConstantUtils.getInteger(dataMap, "departmentId");
staffInfoVo.setStatffname(name);
staffInfoVo.setStatffSid(id);
staffInfoVo.setId(id);
listName.add(staffInfoVo);
}
List<DeptStaffInfoVo> deptList = new ArrayList();
List<DepartmentOneVo> departmentOneVoList = departmentStaffService.departmentStaffListOne2(organizationSid);
if (departmentOneVoList.size() != 0) {
for (int i = 0; i < departmentOneVoList.size(); i++) {
List<DepartmentTwoVo> departmentTwoVoList = departmentOneVoList.get(i).getDepartmentTwoVoList();
if (departmentTwoVoList.size() != 0) {
for (int z = 0; z < departmentTwoVoList.size(); z++) {
String deptName = departmentTwoVoList.get(z).getName();
String deptSid = departmentTwoVoList.get(z).getSid();
DeptStaffInfoVo deptStaffInfoVo = new DeptStaffInfoVo();
deptStaffInfoVo.setDeptSid(deptSid);
deptStaffInfoVo.setDeptName(deptName);
List<DepartmentThreeVo> departmentThreeVoList = departmentTwoVoList.get(z).getDepartmentThreeVoList();
if (departmentThreeVoList.size() != 0) {
for (int y = 0; y < departmentThreeVoList.size(); y++) {
List<DepartmentFourVo> departmentFourVoList = departmentTwoVoList.get(y).getDepartmentFourVoList();
if (departmentFourVoList.size() != 0) {
List<StaffInfoVo> staffInfoVoList = new ArrayList<>();
for (int j = 0; j < departmentFourVoList.size(); j++) {
String userSid = departmentFourVoList.get(j).getUserSid();
if (!list.contains(userSid)) {
continue;
} else {
StaffInfoVo staffInfoVo = new StaffInfoVo();
for (int k = 0; k < listName.size(); k++) {
StaffInfoVo staffInfoVo1 = listName.get(k);
if (userSid.contains(staffInfoVo1.getId())) {
staffInfoVo.setStatffSid(staffInfoVo1.getStatffSid());
staffInfoVo.setStatffname(staffInfoVo1.getStatffname());
staffInfoVoList.add(staffInfoVo);
} else {
continue;
}
}
deptStaffInfoVo.setStaffInfoVoList(staffInfoVoList);
}
}
} else {
continue;
}
}
} else {
List<DepartmentFourVo> departmentFourVoList = departmentTwoVoList.get(z).getDepartmentFourVoList();
if (departmentFourVoList.size() != 0) {
List<StaffInfoVo> staffInfoVoList = new ArrayList<>();
for (int j = 0; j < departmentFourVoList.size(); j++) {
String userSid = departmentFourVoList.get(j).getUserSid();
if (!list.contains(userSid)) {
continue;
} else {
StaffInfoVo staffInfoVo = new StaffInfoVo();
for (int k = 0; k < listName.size(); k++) {
StaffInfoVo staffInfoVo1 = listName.get(k);
if (userSid.contains(staffInfoVo1.getId())) {
staffInfoVo.setStatffSid(staffInfoVo1.getStatffSid());
staffInfoVo.setStatffname(staffInfoVo1.getStatffname());
staffInfoVoList.add(staffInfoVo);
} else {
continue;
}
}
deptStaffInfoVo.setStaffInfoVoList(staffInfoVoList);
// deptList.add(deptStaffInfoVo);
}
}
} else {
continue;
}
}
if (deptStaffInfoVo.getStaffInfoVoList() != null) {
deptList.add(deptStaffInfoVo);
}
}
} else {
DeptStaffInfoVo deptStaffInfoVo = new DeptStaffInfoVo();
deptStaffInfoVo.setDeptSid(departmentOneVoList.get(i).getOrganizationSid());
deptStaffInfoVo.setDeptName(departmentOneVoList.get(i).getOrganizationName());
deptStaffInfoVo.setStaffInfoVoList(listName);
deptList.add(deptStaffInfoVo);
}
if (deptList.size() == 0) {
DeptStaffInfoVo deptStaffInfoVo = new DeptStaffInfoVo();
deptStaffInfoVo.setDeptSid(departmentOneVoList.get(i).getOrganizationSid());
deptStaffInfoVo.setDeptName(departmentOneVoList.get(i).getOrganizationName());
deptStaffInfoVo.setStaffInfoVoList(listName);
deptList.add(deptStaffInfoVo);
}
}
}
return new ResultBean<List<DeptStaffInfoVo>>().success().setData(deptList);
}
public ResultBean<List<DepartmentOneVo>> departmentStaffListOne1(String organizationSid) {
List<DepartmentOneVo> departmentVo = departmentStaffService.departmentStaffListOne(organizationSid);
return new ResultBean<List<DepartmentOneVo>>().success().setData(departmentVo);
}
@Override
public ResultBean<List<DepartmentOneVo>> departmentStaffListOne(String organizationSid) {
List<DepartmentOneVo> list = new ArrayList<DepartmentOneVo>();
DepartmentOneVo v = new DepartmentOneVo();
String deptUsetList = indexApiImpl.deptUsetList(organizationSid);
JSONObject jsonObject1 = JSONObject.parseObject(deptUsetList);
Map<String, Object> map = JSONObject.parseObject(jsonObject1.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> listData = ConstantUtils.getListData(map, "data");
Map<String, Object> dataMap = listData.get(0);
// 将 Map 转换为 实体类
IndexDeptUser indexDeptUser = JSON.parseObject(JSON.toJSONString(dataMap), IndexDeptUser.class);
if (indexDeptUser != null) {
v.setOrganizationName(indexDeptUser.getName());
v.setOrganizationSid(indexDeptUser.getOwnerId());
List<DepartmentTwoVo> departmentTwoVoList = new ArrayList<DepartmentTwoVo>();
List<IndexDeptUserOne> children = indexDeptUser.getChildren();
if (children != null) {
for (int i = 0; i < children.size(); i++) {
IndexDeptUserOne indexDeptUserOne = children.get(i);
List<IndexUserListVo2> indexUserListVo2List = indexDeptUserOne.getUserList();
DepartmentTwoVo vo = new DepartmentTwoVo();
List<DepartmentThreeVo> departmentThreeVoList = new ArrayList<DepartmentThreeVo>();
List<DepartmentFourVo> departmentFourVoList = new ArrayList<DepartmentFourVo>();
if (indexDeptUserOne.getChildren() != null) {
departmentStaffService.lists(indexDeptUserOne, departmentFourVoList);
} else {
if (indexUserListVo2List == null || indexUserListVo2List.size() == 0) {
continue;
}
}
vo.setSid(indexDeptUserOne.getOwnerId());
vo.setName(indexDeptUserOne.getName());
if (indexUserListVo2List != null) {
for (IndexUserListVo2 furvo : indexUserListVo2List) {
DepartmentFourVo vvo = new DepartmentFourVo();
vvo.setName(furvo.getName());
vvo.setUserSid(furvo.getId());
departmentFourVoList.add(vvo);
}
}
vo.setDepartmentThreeVoList(departmentThreeVoList);
vo.setDepartmentFourVoList(departmentFourVoList);
vo.setId(indexDeptUserOne.getId());
departmentTwoVoList.add(vo);
}
}
v.setDepartmentTwoVoList(departmentTwoVoList);
list.add(v);
}
return new ResultBean<List<DepartmentOneVo>>().setData(list).success();
}
@Override
public ResultBean<List<DepartmentStaffOneVo>> departmentStaffListTwo(String organizationSid) {
if (StringUtils.isBlank(organizationSid)) {
return new ResultBean<List<DepartmentStaffOneVo>>().fail().setMessage("尚无单位人员暂无该功能权限!");
}
List<DepartmentStaffOneVo> departmentStaffOneVoList = departmentStaffService.departmentStaffListTwo(organizationSid);
return new ResultBean<List<DepartmentStaffOneVo>>().success().setData(departmentStaffOneVoList);
}
@Override
public ResultBean<List<DepartmentStaffOneVo>> departmentStaffListTwo() {
return new ResultBean<List<DepartmentStaffOneVo>>().fail().setMsg("尚无单位人员暂无该功能权限!");
}
@Override
public ResultBean<DepartmentStaff> selectByStaffSid(String staffSid) {
DepartmentStaff departmentStaff = departmentStaffService.selectByStaffSid(staffSid);
return new ResultBean<DepartmentStaff>().success().setData(departmentStaff);
}
@Override
public ResultBean deleteByStaffSid(String staffSid) {
// TODO Auto-generated method stub
departmentStaffService.deleteByStaffSid(staffSid);
return new ResultBean().success().setMsg("删除成功");
}
@Override
public ResultBean updateSortBySid(String sid, String sortNo) {
int i = departmentStaffService.updateSortBySid(sid, Integer.parseInt(sortNo));
if (i == 0) {
return ResultBean.fireFail().setMsg("修改失败");
}
return ResultBean.fireSuccess().setMsg("修改成功");
}
}

View File

@@ -0,0 +1,50 @@
package com.yxt.jlzx.system.biz.departmentstaff;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.department.DepartmentOneVo;
import com.yxt.jlzx.system.api.departmentstaff.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/10/15 22:31
* @description
*/
@Mapper
public interface DepartmentStaffMapper extends BaseMapper<DepartmentStaff> {
public DepartmentStaff selectByOne(@Param("staffSid") String staffSid, @Param("departmentSid") String departmentSid);
public DepartmentStaff selectByTwo(@Param("staffSid") String staffSid);
public IPage<DepartmentStaffVo> pagerVoList(
IPage<?> page, @Param(Constants.WRAPPER) Wrapper<DepartmentStaffVo> qw);
public List<DepartmentOneVo> departmentStaffListOne(String organizationSid);
public List<DepartmentStaffOneVo> departmentStaffListTwo(String organizationSid);
public DepartmentStaff selectByStaffSid(String staffSid);
public void deleteByStaffSid(String staffSid);
public int updateSortBySid(@Param("sid") String sid, @Param("sortNo") int sortNo);
public List<DepartmentStaffVo> appList( @Param(Constants.WRAPPER) Wrapper<DepartmentStaffVo> qw);
//2021.10.30查询该部门下的人员
List<DepartmentStaffQuery> selectBydep(@Param("depSid") String depSid);
//2021.11.11
List<DeptStaffInfoVo> selectByStaffSid1(@Param(Constants.WRAPPER) QueryWrapper<DeptStaffInfoVo> qw);
//2021.11.11
List<StaffInfoVo> selectBydep1(@Param("deptSid") String deptSid);
}

View File

@@ -0,0 +1,156 @@
<?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.yxt.jlzx.system.biz.departmentstaff.DepartmentStaffMapper">
<select id="selectByOne" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaff">
SELECT *
FROM department_staff
WHERE staffSid = #{staffSid}
AND departmentSid = #{departmentSid}
</select>
<select id="selectByTwo" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaff">
SELECT *
FROM department_staff
WHERE staffSid = #{staffSid}
</select>
<select id="pagerVoList" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaffVo">
SELECT o.sid, si.name, si.telephone telephone, si.mobile, d.name departmentName,df.sortNo,df.sid departmentStaffSid,so.nowTechtitle
FROM jlzx_system.department_staff df
LEFT JOIN jlzx_base.staffinfo si ON si.sid = df.staffSid
LEFT JOIN jlzx_system.department d ON df.departmentSid = d.sid
LEFT JOIN jlzx_base.staff_org so ON so.staffSid = si.sid AND so.orgSid = d.organizationSid
LEFT JOIN jlzx_system.organization o ON o.sid = d.organizationSid
${ew.customSqlSegment}
</select>
<select id="appList" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaffVo">
SELECT o.sid, si.name, si.telephone telephone, si.mobile, d.name departmentName,df.sortNo,df.sid departmentStaffSid
FROM jlzx_system.department_staff df
LEFT JOIN jlzx_base.staffinfo si ON si.sid = df.staffSid
LEFT JOIN jlzx_system.department d ON df.departmentSid = d.sid
LEFT JOIN jlzx_base.staff_org so ON so.staffSid = si.sid AND so.orgSid = d.organizationSid
LEFT JOIN jlzx_system.organization o ON o.sid = d.organizationSid
${ew.customSqlSegment}
</select>
<select id="departmentStaffListOne" resultType="com.yxt.jlzx.system.api.department.DepartmentOneVo"
resultMap="departmentStaffListOneMap">
SELECT o.sid organizationSid, o.name organizationName
FROM organization o
WHERE o.sid = #{organizationSid}
</select>
<resultMap id="departmentStaffListOneMap" type="com.yxt.jlzx.system.api.department.DepartmentOneVo">
<result column="organizationSid" jdbcType="VARCHAR" property="organizationSid"/>
<result column="organizationName" jdbcType="VARCHAR" property="organizationName"/>
<collection property="departmentTwoVoList" ofType="DepartmentTwoVo"
select="departmentTwoVoList" column="organizationSid">
</collection>
</resultMap>
<select id="departmentTwoVoList" resultType="com.yxt.jlzx.system.api.department.DepartmentTwoVo"
resultMap="departmentTwoVoListMap">
SELECT d.sid, d.name
FROM department d
WHERE d.organizationSid = #{organizationSid}
AND d.pSid = '0' order by d.sortNo
</select>
<resultMap id="departmentTwoVoListMap" type="com.yxt.jlzx.system.api.department.DepartmentThreeVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="sid" jdbcType="VARCHAR" property="sid"/>
<result column="pSid" jdbcType="VARCHAR" property="psid"/>
<collection property="departmentThreeVoList" ofType="DepartmentThreeVo"
select="departmentThreeVoList" column="sid">
</collection>
<collection property="departmentFourVoList" ofType="DepartmentFourVo"
select="departmentFourVoList" column="sid">
</collection>
</resultMap>
<select id="departmentThreeVoList" resultType="com.yxt.jlzx.system.api.department.DepartmentThreeVo"
resultMap="departmentTwoVoListMap">
SELECT d.sid, d.pSid, d.name
FROM department d
LEFT JOIN department d1 ON d.pSid = d1.sid
WHERE d.pSid = #{sid} order by d.sortNo
</select>
<select id="departmentFourVoList" resultType="com.yxt.jlzx.system.api.department.DepartmentFourVo">
SELECT si.name, u.sid userSid
FROM department_staff ds
LEFT JOIN jlzx_base.staffinfo si ON si.sid = ds.staffSid
LEFT JOIN user u ON u.staffSid = si.sid
WHERE ds.departmentSid = #{sid}
AND u.isAdmin = 2 order by ds.sortNo
</select>
<select id="departmentStaffListTwo" resultMap="departmentStaffListTwoMap">
SELECT d.name departmentName, d.sid departmentSid
FROM department d
WHERE d.organizationSid = #{organizationSid} order by d.sortNo
</select>
<resultMap id="departmentStaffListTwoMap" type="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaffOneVo">
<result column="departmentName" jdbcType="VARCHAR" property="departmentName"/>
<result column="departmentSid" jdbcType="VARCHAR" property="departmentSid"/>
<collection property="departmentStaffTwoVoList" ofType="DepartmentStaffTwoVo"
select="departmentStaffTwoVoList" column="departmentSid">
</collection>
</resultMap>
<select id="departmentStaffTwoVoList" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaffTwoVo">
SELECT si.name, u.sid userSid, si.mobile
FROM department_staff ds
LEFT JOIN jlzx_base.staffinfo si ON si.sid = ds.staffSid
LEFT JOIN user u ON u.staffSid = si.sid
WHERE ds.departmentSid = #{departmentSid}
AND ds.staffSid IS NOT NULL
AND u.isAdmin = 2 order by ds.sortNo
</select>
<select id="selectByStaffSid" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaff">
SELECT *
FROM department_staff
WHERE staffSid = #{staffSid}
</select>
<select id="selectBydep" resultType="com.yxt.jlzx.system.api.departmentstaff.DepartmentStaffQuery">
SELECT dep.departmentSid as Sid,
d.`name` as departmentName,
s.`name` as name
FROM department_staff dep
INNER JOIN jlzx_base.staffinfo s
on dep.staffSid = s.sid
INNER JOIN department d
on dep.departmentSid = d.sid
where dep.departmentSid = #{depSid}
</select>
<select id="selectByStaffSid1" resultType="com.yxt.jlzx.system.api.departmentstaff.DeptStaffInfoVo">
select d.name as deptName,d.Sid as deptSid
from department d
inner join
department_staff dep
on d.Sid = dep.departmentSid
${ew.customSqlSegment}
</select>
<select id="selectBydep1" resultType="com.yxt.jlzx.system.api.departmentstaff.StaffInfoVo">
select s.name as statffname,u.sid as statffSid
from jlzx_system.department_staff dep
inner join jlzx_base.staffinfo s on dep.staffSid = s.Sid
INNER JOIN jlzx_system.user u on s.Sid = u.staffSid
where dep.departmentSid = #{deptSid}
</select>
<delete id="deleteByStaffSid">
DELETE
FROM department_staff
WHERE staffSid = #{staffSid}
</delete>
<update id="updateSortBySid">
UPDATE department_staff
SET sortNo = #{sortNo}
WHERE sid = #{sid}
</update>
</mapper>

View File

@@ -0,0 +1,254 @@
package com.yxt.jlzx.system.biz.departmentstaff;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.department.DepartmentFourVo;
import com.yxt.jlzx.system.api.department.DepartmentOneVo;
import com.yxt.jlzx.system.api.department.DepartmentThreeVo;
import com.yxt.jlzx.system.api.department.DepartmentTwoVo;
import com.yxt.jlzx.system.api.departmentstaff.*;
import com.yxt.jlzx.system.api.dictcommon.DictCommonVo;
import com.yxt.jlzx.system.api.index.IndexDeptUser;
import com.yxt.jlzx.system.api.index.IndexDeptUserOne;
import com.yxt.jlzx.system.api.index.IndexUserListVo2;
import com.yxt.jlzx.system.api.index.IndexUtils;
import com.yxt.jlzx.system.biz.dictcommon.DictCommonService;
import com.yxt.jlzx.system.biz.index.IndexApiImpl;
import com.yxt.jlzx.system.biz.index.IndexService;
import com.yxt.jlzx.system.biz.orgtype.OrgTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author dimengzhe
* @date 2020/10/15 22:31
* @description
*/
@Service
public class DepartmentStaffService extends MybatisBaseService<DepartmentStaffMapper, DepartmentStaff> {
@Autowired
private DictCommonService dictCommonService;
@Autowired
private OrgTypeService orgTypeService;
public DepartmentStaff selectByOne(String staffSid, String departmentSid) {
return baseMapper.selectByOne(staffSid, departmentSid);
}
@Autowired
private IndexService indexService;
public DepartmentStaff selectByTwo(String staffSid) {
return baseMapper.selectByTwo(staffSid);
}
public IPage<DepartmentStaffVo> pagerVoList(PagerQuery<DepartmentStaffQuery> pagerQuery) {
IPage<DepartmentStaffQuery> page = PagerUtil.queryToPage(pagerQuery);
DepartmentStaffQuery params = pagerQuery.getParams();
QueryWrapper<DepartmentStaffVo> qw = new QueryWrapper<>();
if (params != null) {
if (StringUtils.isNotBlank(params.getOrganizationSid())) {
qw.eq("o.sid", params.getOrganizationSid());
} else {
qw.eq("o.sid", "");
List<String> list = new ArrayList<>();
IPage<DepartmentStaffVo> departmentStaffVoIPage = baseMapper.pagerVoList(page, qw);
for (int i = 0; i < departmentStaffVoIPage.getSize(); i++) {
list = orgTypeService.findTypeKeysByOrgSid(departmentStaffVoIPage.getRecords().get(i).getSid());
if (list.contains("0002")) {
DictCommonVo v = dictCommonService.selectBykey(departmentStaffVoIPage.getRecords().get(i).getNowTechtitle(), "xrzw");
departmentStaffVoIPage.getRecords().get(i).setNowTechtitle(v.getDictValue());
} else {
DictCommonVo v = dictCommonService.selectBykey(departmentStaffVoIPage.getRecords().get(i).getNowTechtitle(), "xrzg");
departmentStaffVoIPage.getRecords().get(i).setNowTechtitle(v.getDictValue());
}
}
// return baseMapper.pagerVoList(page, qw);
return departmentStaffVoIPage;
}
String sid = params.getSid();
if (StringUtils.isNotBlank(sid)) {
qw.eq("df.departmentSid", sid);
}
String name = params.getName();
if (StringUtils.isNotBlank(name)) {
qw.like("si.name", name);
}
String departmentName = params.getDepartmentName();
if (StringUtils.isNotBlank(departmentName)) {
qw.like("d.name", departmentName);
}
qw.orderByAsc("d.sortNo");
qw.orderByAsc("df.sortNo");
}
return baseMapper.pagerVoList(page, qw);
}
public List<DepartmentOneVo> departmentStaffListOne(String organizationSid) {
return baseMapper.departmentStaffListOne(organizationSid);
}
public List<DepartmentOneVo> departmentStaffListOne1(String organizationSid) {
return baseMapper.departmentStaffListOne(organizationSid);
}
public List<DepartmentStaffOneVo> departmentStaffListTwo(String organizationSid) {
return baseMapper.departmentStaffListTwo(organizationSid);
}
public DepartmentStaff selectByStaffSid(String staffSid) {
return baseMapper.selectByStaffSid(staffSid);
}
public void deleteByStaffSid(String staffSid) {
// TODO Auto-generated method stub
baseMapper.deleteByStaffSid(staffSid);
}
public int updateSortBySid(String sid, int sortNo) {
return baseMapper.updateSortBySid(sid, sortNo);
}
public List<DepartmentStaffVo> appList(DepartmentStaffQuery params) {
// TODO Auto-generated method stub
QueryWrapper<DepartmentStaffVo> qw = new QueryWrapper<>();
if (params != null) {
if (StringUtils.isNotBlank(params.getOrganizationSid())) {
qw.eq("o.sid", params.getOrganizationSid());
} else {
qw.eq("o.sid", "");
}
String name = params.getName();
if (StringUtils.isNotBlank(name)) {
qw.like("si.name", name).or().like("si.mobile", name);
}
qw.orderByAsc("d.sortNo");
qw.orderByAsc("df.sortNo");
List<DepartmentStaffVo> departmentStaffVoList = baseMapper.appList(qw);
return departmentStaffVoList;
}
return null;
}
//2021.10.30查询该部门下的人员
public List<DepartmentStaffQuery> selectBydep(String depSid) {
return baseMapper.selectBydep(depSid);
}
//2021.11.11查询人员所属的部门
public List<DeptStaffInfoVo> selectByStaffSid1(List<String> list) {
QueryWrapper<DeptStaffInfoVo> qw = new QueryWrapper<>();
if(list.size()>0){
qw.in("dep.staffSid",list);
qw.groupBy("d.sid");
}
return baseMapper.selectByStaffSid1(qw);
}
//2021.11.11根据部门查询所属的人员
public List<StaffInfoVo> selectBydep1(String deptSid) {
List<StaffInfoVo> list = baseMapper.selectBydep1(deptSid);
return list;
}
public List<DepartmentFourVo> lists(IndexDeptUserOne one,List<DepartmentFourVo> departmentFourVoList){
for (int j = 0; j < one.getChildren().size(); j++) {
DepartmentThreeVo vo1=new DepartmentThreeVo();
IndexDeptUserOne indexDeptUserOne1 = one.getChildren().get(j);
if(indexDeptUserOne1.getChildren()!=null) {
departmentFourVoList= lists(indexDeptUserOne1,departmentFourVoList);
}
List<IndexUserListVo2> indexUserListVo2List1 = indexDeptUserOne1.getUserList();
if(indexUserListVo2List1!=null) {
for(IndexUserListVo2 furvo: indexUserListVo2List1) {
DepartmentFourVo vvo=new DepartmentFourVo();
vvo.setName(furvo.getName());
vvo.setUserSid(furvo.getId());
departmentFourVoList.add(vvo);
}
}
}
return departmentFourVoList;
}
public List<DepartmentOneVo> departmentStaffListOne2(String organizationSid) {
List<DepartmentOneVo> list=new ArrayList<DepartmentOneVo>();
DepartmentOneVo v=new DepartmentOneVo();
String deptUsetList = indexService.deptUsetList(organizationSid);
JSONObject jsonObject1 = JSONObject.parseObject(deptUsetList);
Map<String, Object> map = JSONObject.parseObject(jsonObject1.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> listData = ConstantUtils.getListData(map, "data");
Map<String, Object> dataMap=listData.get(0);
// 将 Map 转换为 实体类
IndexDeptUser indexDeptUser= JSON.parseObject(JSON.toJSONString(dataMap), IndexDeptUser.class);
if(indexDeptUser!=null) {
v.setOrganizationName(indexDeptUser.getName());
v.setOrganizationSid(indexDeptUser.getOwnerId());
List<DepartmentTwoVo> departmentTwoVoList=new ArrayList<DepartmentTwoVo>();
List<IndexDeptUserOne> children = indexDeptUser.getChildren();
if(children!=null) {
for (int i = 0; i < children.size(); i++) {
IndexDeptUserOne indexDeptUserOne = children.get(i);
List<IndexUserListVo2> indexUserListVo2List = indexDeptUserOne.getUserList();
DepartmentTwoVo vo=new DepartmentTwoVo();
List<DepartmentThreeVo> departmentThreeVoList=new ArrayList<DepartmentThreeVo>();
List<DepartmentFourVo> departmentFourVoList=new ArrayList<DepartmentFourVo>();
if(indexDeptUserOne.getChildren()!=null) {
lists(indexDeptUserOne,departmentFourVoList);
}else {
if(indexUserListVo2List==null||indexUserListVo2List.size()==0) {
continue;
}
}
vo.setSid(indexDeptUserOne.getOwnerId());
vo.setName(indexDeptUserOne.getName());
if(indexUserListVo2List!=null) {
for(IndexUserListVo2 furvo: indexUserListVo2List) {
DepartmentFourVo vvo=new DepartmentFourVo();
vvo.setName(furvo.getName());
vvo.setUserSid(furvo.getId());
departmentFourVoList.add(vvo);
}
}
vo.setDepartmentThreeVoList(departmentThreeVoList);
vo.setDepartmentFourVoList(departmentFourVoList);
departmentTwoVoList.add(vo);
}
}
v.setDepartmentTwoVoList(departmentTwoVoList);
list.add(v);
}
return list;
}
}

View File

@@ -0,0 +1,698 @@
package com.yxt.jlzx.system.biz.dictcommon;
import cn.hutool.core.lang.Dict;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.dictcommon.*;
import io.swagger.annotations.Api;
import org.apache.poi.hpsf.Array;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
/**
* @author dongjianzhao
* @ClassName: DictCommonApiImpl
* @Description:数据字典管理
* @date 2020年10月3日
*/
@Controller
@RequestMapping("/dictCommon")
@Api(tags = "数据字典管理")
public class DictCommonApiImpl implements DictCommonApi {
@Autowired
private DictCommonService dictCommonService;
@Autowired
private DictTypeService dictTypeService;
/**
* 数据字典分页列表
*
* @param pagerQuery 查询条件
* @return 数据字典分页列表
*/
@Override
public ResultBean<PagerVo<DictCommonVo>> pageList(PagerQuery<DictCommonQuery> pagerQuery) {
// PagerVo<DictCommonVo> pagerVo = dictCommonService.page(pagerQuery);
// ResultBean<PagerVo<DictCommonVo>> objectResultBean = ResultBean.fireSuccess();
// return objectResultBean.setData(pagerVo);
ResultBean<PagerVo<DictCommonVo>> rb = ResultBean.fireFail();
PagerVo<DictCommonVo> pv = new PagerVo<>();
IPage<DictCommonVo> p2 = dictCommonService.pageList(pagerQuery);
PagerVo<DictCommonVo> pv1 = PagerUtil.pageToVo(p2, pv);
return rb.success().setData(pv1);
}
/**
* 保存
*
* @param dictCommonDto 数据字典dto对象
* @return ResultBean
*/
@Override
public ResultBean<String> save(DictCommonDto dictCommonDto) {
DictCommon dictCommon = dictCommonDto.toEntity();
Map<String, Object> map_dictType_params = new HashMap<String, Object>();
map_dictType_params.put("dictTypeCode", dictCommon.getDictType());
List<DictType> map_dictType_list = dictTypeService.listByMap(map_dictType_params);
if (map_dictType_list.size() > 0) {
Map<String, Object> map_dictcommon_params = new HashMap<String, Object>();
map_dictcommon_params.put("dictType", dictCommon.getDictType());
map_dictcommon_params.put("dictKey", dictCommon.getDictKey());
map_dictcommon_params.put("dictValue", dictCommon.getDictValue());
List<DictCommon> list = dictCommonService.repeatCheck(map_dictcommon_params);
if (list.size() > 0) {
return new ResultBean<String>().fail().setMsg("数据字典名称已存在!");
}
dictCommon.setSidPath(dictCommon.getSid());
dictCommon.setParentSid(null);
if (!dictCommonService.save(dictCommon)) {
return new ResultBean<String>().fail().setMsg("保存失败");
}
} else {
return new ResultBean<String>().fail().setMsg("保存失败,数据字典分类不存在!");
}
return new ResultBean<String>().success().setData(dictCommon.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值. 通过 @PathVariable
* 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean<DictCommonVo> update(DictCommonDto dictCommonDto, String sid) throws Exception {
Map<String, Object> map_dictType_params = new HashMap<String, Object>();
map_dictType_params.put("dictTypeCode", dictCommonDto.getDictType());
List<DictType> map_dictType_list = dictTypeService.listByMap(map_dictType_params);
if (map_dictType_list.size() > 0) {
DictCommon dictCommon = dictCommonService.fetchBySid(sid);
dictCommonDto.setSidPath(dictCommon.getSidPath());
dictCommonDto.setParentSid(dictCommon.getParentSid());
if (null == dictCommon) {
return new ResultBean<DictCommonVo>().fail().setMsg("该数据字典不存在");
}
if (0 == dictCommonService.updateBySid(dictCommonDto.toMap(dictCommon), sid)) {
return new ResultBean<DictCommonVo>().fail().setMsg("更新失败");
}
} else {
return new ResultBean<DictCommonVo>().fail().setMsg("保存失败,数据字典分类不存在!");
}
return new ResultBean<DictCommonVo>().success().setMsg("更新成功");
}
/**
* 删除
*
* @param sid 数据字典sid
* @return ResultBean
*/
@Override
public ResultBean<DictCommonVo> delete(String sid) {
if (0 == dictCommonService.deleteBySid(sid)) {
return new ResultBean<DictCommonVo>().fail().setMsg("删除失败");
}
return new ResultBean<DictCommonVo>().success().setMsg("删除成功");
}
/**
* 修改页面初始化数据
*
* @param sid 数据字典sid
* @return ResultBean
*/
@Override
public ResultBean<DictCommonVo> initUpdate(String sid) {
DictCommon dictcommon = dictCommonService.fetchBySid(sid);
if (null == dictcommon) {
return new ResultBean<DictCommonVo>().fail().setData(null);
}
DictCommonVo dictcommonVo = new DictCommonVo();
dictcommonVo.setSid(dictcommon.getSid());
dictcommonVo.setDictKey(dictcommon.getDictKey());
dictcommonVo.setDictType(dictcommon.getDictType());
dictcommonVo.setDictValue(dictcommon.getDictValue());
dictcommonVo.setParentSid(dictcommon.getParentSid());
dictcommonVo.setSidPath(dictcommon.getSidPath());
return new ResultBean<DictCommonVo>().success().setData(dictcommonVo);
}
/**
* 查询机构的单位类别
*
* @return dictType为dwlb的数据
*/
@Override
public ResultBean getDwType() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getDwType();
return ResultBean.fireSuccess().setData(dictCommonVoList);
}
/**
* 查询机构的人员类别
*
* @return
*/
@Override
public ResultBean getRylb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getRylb();
return ResultBean.fireSuccess().setData(dictCommonVoList);
}
@Override
public ResultBean getYcsy() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getYcsy();
return ResultBean.fireSuccess().setData(dictCommonVoList);
}
/**
* 获取单位级别
*
* @return
*/
@Override
public ResultBean<List<DictCommonListVo>> getDwJb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getDwJb();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getZblb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getZblb();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getHylb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getHylb();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean<List<DictCommonListVo>> getZzylb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getZzylb();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getJglb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getJglb();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getJgsx() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getJgsx();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getJgcclx() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getJgcclx();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getTsjbly() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getTsjbly();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getXzcfwflx() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getXzcfwflx();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getXzcfrdyj() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getXzcfrdyj();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getXzcfyj() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getXzcfyj();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getTsjbcljg() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getTsjbcljg();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getTsjblb() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getTsjblb();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean getCndwsqzt() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getCndwsqzt();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
/**
* 初始化获取数据字典部分字段
*
* @return
*/
@Override
public ResultBean<DictCommonInitVo> dictCommonInit() {
DictCommonInitVo dictCommonInitVo = dictCommonService.dictCommonInit();
return new ResultBean<DictCommonInitVo>().success().setData(dictCommonInitVo);
}
/**
* 获取印章类型
*
* @return
*/
@Override
public ResultBean<List<Map<String, Object>>> dictCommonOaSeal() {
List dictCommonOaSealVo = dictCommonService.dictCommonOaSeal();
return new ResultBean<List<Map<String, Object>>>().success().setData(dictCommonOaSealVo);
}
/**
* oa项目项目管理新建项目初始化
*
* @return
*/
@Override
public ResultBean<DictCommonProjectVo> dictCommonProjectInit() {
DictCommonProjectVo dictCommonProjectVo = dictCommonService.dictCommonProjectInit();
return new ResultBean<DictCommonProjectVo>().success().setData(dictCommonProjectVo);
}
/**
* 人员教育信息页面下拉框初始化
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonEducation() {
List<DictCommonListVo> xllist = dictCommonService.dictSelect("xl");//学历
List<DictCommonListVo> xwlist = dictCommonService.dictSelect("xw");//学位
List<DictCommonListVo> xzlist = dictCommonService.dictSelect("xz");//学制
List<DictCommonListVo> xlbslist = dictCommonService.dictSelect("xlbs");//学历标识
List<DictCommonListVo> xxlxlist = dictCommonService.dictSelect("xxlx");//学习类型
List<DictCommonListVo> xxxslist = dictCommonService.dictSelect("xxxs");//学习形式
List<DictCommonListVo> bkzymlslist = dictCommonService.dictSelect("bkzy");//本科专业门类
Map<String, Object> map = new HashMap<String, Object>();
map.put("xllist", xllist);
map.put("xwlist", xwlist);
map.put("xzlist", xzlist);
map.put("xlbslist", xlbslist);
map.put("xxlxlist", xxlxlist);
map.put("xxxslist", xxxslist);
map.put("bkzymlslist", bkzymlslist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
/**
* 从事计量技术工作经历下拉框
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonWorkExperienceJl() {
List<DictCommonListVo> cszylist = dictCommonService.dictSelect("cszy");//从事专业
List<DictCommonListVo> zwlist = dictCommonService.dictSelect("jlgw");//职务
Map<String, Object> map = new HashMap<String, Object>();
map.put("zslblist", cszylist);
map.put("djlist", zwlist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
/**
* 人员从业资格情况下拉框
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonCertificate() {
List<DictCommonListVo> zslblist = dictCommonService.dictSelect("zslb");//证书类别
List<DictCommonListVo> djlist = dictCommonService.dictSelect("zcjlszg");//等级
List<DictCommonListVo> zyxmlist = dictCommonService.dictSelect("cszy");//专业项目
Map<String, Object> map = new HashMap<String, Object>();
map.put("zslblist", zslblist);
map.put("djlist", djlist);
map.put("zyxmlist", zyxmlist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
/**
* 参加业务培训经历
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonTrain() {
List<DictCommonListVo> pxlxlist = dictCommonService.dictSelect("pxlx");//培训类型
List<DictCommonListVo> pxxslist = dictCommonService.dictSelect("pxxs");//培训形式
List<DictCommonListVo> khdclist = dictCommonService.dictSelect("khdc");//考核等次
Map<String, Object> map = new HashMap<String, Object>();
map.put("pxlxlist", pxlxlist);
map.put("pxxslist", pxxslist);
map.put("khdclist", khdclist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
/**
* 专业技术资格情况
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonProfessionalQualification() {
//List<DictCommonListVo> zyjsxlList=dictCommonService.dictSelect("zyjsxl");//专业技术系列
//List<DictCommonListVo> zymcList=dictCommonService.dictSelect("zymc");//专业名称
List<DictCommonListVo> zgmcList = dictCommonService.dictSelect("xrzg");//技术资格
Map<String, Object> map = new HashMap<String, Object>();
//map.put("zyjsxlList", zyjsxlList);
//map.put("zymcList", zymcList);
map.put("zgmcList", zgmcList);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
/**
* 专家任职情况
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonExpertPostInfo() {
List<DictCommonListVo> rzjgList = dictCommonService.dictSelect("rzjg");//任职机构
List<DictCommonListVo> zjzwList = dictCommonService.dictSelect("zjzw");//专业类别
Map<String, Object> map = new HashMap<String, Object>();
map.put("rzjgList", rzjgList);
map.put("zjzwList", zjzwList);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
/**
* 专业技术工作经历
*
* @return
*/
@Override
public ResultBean<Map<String, Object>> dictCommonProfessionalwork() {
List<DictCommonListVo> xmjbList = dictCommonService.dictSelect("xmjb");//项目级别
List<DictCommonListVo> gzxmList = dictCommonService.dictSelect("gzxm");//工作名称、工作项目
List<DictCommonListVo> cyxsList = dictCommonService.dictSelect("cyqk");//参与情况
List<DictCommonListVo> wcqkList = dictCommonService.dictSelect("wcqk");//完成情况
Map<String, Object> map = new HashMap<String, Object>();
map.put("xmjbList", xmjbList);
map.put("gzxmList", gzxmList);
map.put("cyxsList", cyxsList);
map.put("wcqkList", wcqkList);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<Map<String, Object>> dictCommonProfessionalAchievement() {
List<DictCommonListVo> cglxlist = dictCommonService.dictSelect("zllx");//专利类型
List<DictCommonListVo> cgdjlist = dictCommonService.dictSelect("cgdj");//成果等级
List<DictCommonListVo> cyxsList = dictCommonService.dictSelect("cyqk");//参与方式
List<DictCommonListVo> wcqkList = dictCommonService.dictSelect("wcqk");//完成情况
Map<String, Object> map = new HashMap<String, Object>();
map.put("cglxlist", cglxlist);
map.put("cgdjlist", cgdjlist);
map.put("cyxsList", cyxsList);
map.put("wcqkList", wcqkList);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<Map<String, Object>> dictCommonScience() {
Map<String, Object> map = new HashMap<String, Object>();
List<DictCommonListVo> zyfslist = dictCommonService.dictSelect("zyfs");//著译方式
List<DictCommonListVo> zylblist = dictCommonService.dictSelect("zylb1");//著译类别
List<DictCommonListVo> zypmlist = dictCommonService.dictSelect("zypm");//著译排名
map.put("zyfslist", zyfslist);
map.put("zylblist", zylblist);
map.put("zypmlist", zypmlist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<Map<String, Object>> dictCommonReport() {
Map<String, Object> map = new HashMap<String, Object>();
List<DictCommonListVo> zyfslist = dictCommonService.dictSelect("zyfs");//著译方式
List<DictCommonListVo> zylblist = dictCommonService.dictSelect("zylb2");//著译类别
List<DictCommonListVo> zypmlist = dictCommonService.dictSelect("zypm");//著译排名
map.put("zyfslist", zyfslist);
map.put("zylblist", zylblist);
map.put("zypmlist", zypmlist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<Map<String, Object>> dictCommonRewardInfo() {
List<DictCommonListVo> jlmclist = dictCommonService.dictSelect("jlqk1");//奖励情况
List<DictCommonListVo> syjbList = dictCommonService.dictSelect("syjb");//授予级别
List<DictCommonListVo> jlpmList = dictCommonService.dictSelect("jlpm");//奖励排名
List<DictCommonListVo> jldcList = dictCommonService.dictSelect("jldc");//奖励等次
Map<String, Object> map = new HashMap<String, Object>();
map.put("jlmclist", jlmclist);
map.put("syjbList", syjbList);
map.put("jlpmList", jlpmList);
map.put("jldcList", jldcList);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<List<DictCommonListVo>> selectByParentSid(String sid) {
List<DictCommonListVo> list = dictCommonService.selectByParentSid(sid);
//2021.10.07
if (list.size() == 0) {
//没有再数据库中字典中添加,只是单独赋值一个 无 的下拉选
DictCommonListVo dict = new DictCommonListVo();
dict.setDictKey("rzjgzymc01");
dict.setDictType("zylb01");
dict.setSid("123");
dict.setDictValue("");
list.add(dict);
}
return new ResultBean<List<DictCommonListVo>>().success().setData(list);
}
@Override
public ResultBean<List<DictCommonListVo>> likeDict(String value) {
List<DictCommonListVo> list = dictCommonService.likeDict(value);
return new ResultBean<List<DictCommonListVo>>().success().setData(list);
}
/**
* 查询学历
*
* @return
*/
@Override
public ResultBean getXl() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getXl();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
/**
* 查询政治面貌
*
* @return
*/
@Override
public ResultBean getZzmm() {
List<DictCommonListVo> dictCommonVoList = dictCommonService.getZzmm();
return new ResultBean<List<DictCommonListVo>>().success().setData(dictCommonVoList);
}
@Override
public ResultBean<Map<String, Object>> dictCommonProject() {
List<DictCommonListVo> zylblist = dictCommonService.dictSelect("zylbOA");//专业类别
List<DictCommonListVo> xmlblist = dictCommonService.dictSelect("xmlbOA");//项目类别
Map<String, Object> map = new HashMap<String, Object>();
map.put("zylblist", zylblist);
map.put("xmlblist", xmlblist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<Map<String, Object>> dictCommonContract() {
List<DictCommonListVo> htlblist = dictCommonService.dictSelect("contract");//合同类别
Map<String, Object> map = new HashMap<String, Object>();
map.put("htlblist", htlblist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<DictCommonVo> selectBykey(String key, String type) {
// TODO Auto-generated method stub
DictCommonVo v = dictCommonService.selectBykey(key, type);
if (v == null) {
return new ResultBean<DictCommonVo>().success().setData(new DictCommonVo());
}
return new ResultBean<DictCommonVo>().success().setData(v);
}
@Override
public ResultBean<Map<String, Object>> dictCommonSeal() {
List<DictCommonListVo> yylblist = dictCommonService.dictSelect("sealType");//用印类别
Map<String, Object> map = new HashMap<String, Object>();
map.put("yylblist", yylblist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<List<DictCommon>> getCodeByName(String name) {
QueryWrapper<DictCommon> wrapper = new QueryWrapper<>();
wrapper.eq("dictValue", name);
List<DictCommon> list = dictCommonService.list(wrapper);
return new ResultBean<List<DictCommon>>().success().setData(list);
}
@Override
public ResultBean<Map<String, Object>> dictCommonGoodsform() {
List<DictCommonListVo> wplylist = dictCommonService.dictSelect("wplx");//用印类别
Map<String, Object> map = new HashMap<String, Object>();
map.put("wplylist", wplylist);
return new ResultBean<Map<String, Object>>().success().setData(map);
}
@Override
public ResultBean<List<DictCommonListVo>> getDictsByTypeCode(String typeCode) {
List<DictCommonListVo> list = dictCommonService.dictSelect(typeCode);
if (list == null) {
list = new ArrayList<DictCommonListVo>();
return new ResultBean<List<DictCommonListVo>>().success().setData(list);
}
return new ResultBean<List<DictCommonListVo>>().success().setData(list);
}
@Override
public ResultBean<List<DictCommonListVo>> likeZymc(String likeStr) {
List<DictCommonListVo> bkzymlslist = dictCommonService.likeZymc("bkzy", likeStr);//本科专业门类
return new ResultBean<List<DictCommonListVo>>().success().setData(bkzymlslist);
}
@Override
public ResultBean<String> saveIndustry(DictCommonHylbDto dto) {
ResultBean<String> rb = ResultBean.fireFail();
String sid = dto.getSid();
String type = "hylb";
if (StringUtils.isBlank(sid)) {
DictCommon dictCommon1 = dictCommonService.selectByValue(type, dto.getDictValue());
if (dictCommon1 != null) {
return rb.setMsg("该行业类别已存在");
}
DictCommon dictCommon = new DictCommon();
dictCommon.setDictType(type);
dictCommon.setSidPath(dictCommon.getSid());
dictCommon.setDictValue(dto.getDictValue());
//查询key
String key = dictCommonService.selectKeyByType(type);
dictCommon.setDictKey(addOne(key));
boolean isSave = dictCommonService.save(dictCommon);
if (!isSave) {
return rb.setMsg("添加失败");
}
} else {
//查询是否有该类别
DictCommon dictCommon = dictCommonService.selectByValue1(type, dto.getDictValue(), sid);
if (dictCommon != null) {
return rb.setMsg("该行业类别已存在");
}
int count = dictCommonService.updateValue(sid, dto.getDictValue());
if (count == 0) {
return rb.setMsg("修改失败");
}
}
return rb.success().setMsg("操作成功");
}
@Override
public ResultBean<List<DictCommonHylbVo>> hylbList() {
ResultBean<List<DictCommonHylbVo>> rb = ResultBean.fireFail();
String type = "hylb";
List<DictCommonHylbVo> voList = dictCommonService.hylbList(type);
return rb.success().setData(voList);
}
@Override
public ResultBean deleteHylb(String sid) {
ResultBean rb = ResultBean.fireFail();
DictCommon dictCommon = dictCommonService.fetchBySid(sid);
if (dictCommon == null) {
return rb.setMsg("该行业类别不存在");
}
int i = dictCommonService.deleteBySid(sid);
if (i == 0) {
return rb.setMsg("删除失败");
}
return rb.success().setMsg("删除成功");
}
@Override
public ResultBean<String> initHylb(String sid) {
ResultBean<String> rb = ResultBean.fireFail();
DictCommon dictCommon = dictCommonService.fetchBySid(sid);
if (dictCommon == null) {
return rb.setMsg("该数据不存在");
}
String value = dictCommon.getDictValue();
return rb.success().setData(value);
}
/**
* 字符串+1方法该方法将其结尾的整数+1,适用于任何以整数结尾的字符串,不限格式,不限分隔符。
*
* @param testStr 要+1的字符串
* @return +1后的字符串
* @throws NumberFormatException
*/
public static String addOne(String testStr) {
//根据不是数字的字符拆分字符串
String[] strs = testStr.split("[^0-9]");
//取出最后一组数字
String numStr = strs[strs.length - 1];
//如果最后一组没有数字(也就是不以数字结尾)抛NumberFormatException异常
if (numStr != null && numStr.length() > 0) {
//取出字符串的长度
int n = numStr.length();
//将该数字加一
int num = Integer.parseInt(numStr) + 1;
String added = String.valueOf(num);
n = Math.min(n, added.length());
//拼接字符串
return testStr.subSequence(0, testStr.length() - n) + added;
} else {
throw new NumberFormatException();
}
}
}

View File

@@ -0,0 +1,129 @@
package com.yxt.jlzx.system.biz.dictcommon;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.dictcommon.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author dongjianzhao
* @ClassName: DictCommonMapper
* @Description: TODO(这里用一句话描述这个类的作用)
* @date 2020年10月3日
*/
@Mapper
public interface DictCommonMapper extends BaseMapper<DictCommon> {
public IPage<DictCommonVo> pageList(
IPage<?> page, @Param(Constants.WRAPPER) Wrapper<DictCommonVo> qw);
/**
* 查询单位类别
*
* @return dictType为dwlb的数据
*/
public List<DictCommonListVo> getDwType();
/**
* 查询机构的人员类别
*
* @return
*/
public List<DictCommonListVo> getRylb();
/**
* 查询用车事由下拉框
*
* @return
*/
public List<DictCommonListVo> getYcsy();
/**
* 获取单位级别
*
* @return
*/
public List<DictCommonListVo> getDwJb();
public List<DictCommonListVo> getZblb();
/**
* 获取行业类别
*
* @return
*/
public List<DictCommonListVo> getHylb();
public List<DictCommonListVo> getXl();
public List<DictCommonListVo> getZzmm();
public List<DictCommonListVo> getZzylb();
public List<DictCommonListVo> getJglb();
public List<DictCommonListVo> getJgsx();
public List<DictCommonListVo> getJgcclx();
public List<DictCommonListVo> getTsjbly();
public List<DictCommonListVo> getXzcfwflx();
public List<DictCommonListVo> getXzcfrdyj();
public List<DictCommonListVo> getXzcfyj();
public List<DictCommonListVo> getTsjbcljg();
public List<DictCommonListVo> getTsjblb();
public List<DictCommonListVo> getCndwsqzt();
public List<DictCommonListVo> dictSelect(@Param("dictType") String dictType);
public List<DictCommonListVo> selectByParentSid(@Param("sid") String sid);
/**
* 人员编辑页面初始化
*
* @return
*/
public DictCommonInitVo dictCommonInit();
public List<Map<String, Object>> dictCommonOaSeal();
/**
* oa项目项目新建初始化
*
* @return
*/
public DictCommonProjectVo dictCommonProjectInit();
public List<DictCommonListVo> likeDict(String value);
public DictCommonVo selectBykey(@Param("key") String key, @Param("type") String sid);
public List<DictCommonListVo> likeZymc(@Param("type") String type, @Param("likeStr") String likeStr);
String selectKeyByType(String type);
DictCommon selectByValue(@Param("type") String type, @Param("value") String dictValue);
DictCommon selectByValue1(@Param("type") String type, @Param("value") String dictValue, @Param("sid") String sid);
int updateValue(@Param("sid") String sid, @Param("dictValue") String dictValue);
List<DictCommonHylbVo> hylbList(String type);
}

View File

@@ -0,0 +1,426 @@
<?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.yxt.jlzx.system.biz.dictcommon.DictCommonMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonVo">
SELECT dc.dictValue, dc.dictType, dc.dictKey, dc.sid
FROM jlzx_system.dict_common dc
${ew.customSqlSegment}
</select>
<resultMap id="commonMap" type="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
<result column="dictKey" jdbcType="VARCHAR" property="dictKey"/>
<result column="dictType" jdbcType="VARCHAR" property="dictType"/>
<result column="dictValue" jdbcType="VARCHAR" property="dictValue"/>
</resultMap>
<resultMap id="dictCommonInitMap" type="com.yxt.jlzx.system.api.dictcommon.DictCommonInitVo">
<collection property="nationalList" ofType="DictCommonListVo"
select="nationalList" column="dictTypeMinZu">
</collection>
<collection property="poliCodeList" ofType="DictCommonListVo"
select="poliCodeList" column="dictTypeZzmm">
</collection>
<collection property="sexList" ofType="DictCommonListVo"
select="sexList" column="dictTypeSex">
</collection>
<collection property="staffIdentityList" ofType="DictCommonListVo"
select="staffIdentityList" column="dictTypeRysf">
</collection>
<collection property="awardsList" ofType="DictCommonListVo"
select="awardsList" column="dictTypeJlqk">
</collection>
<collection property="workList" ofType="DictCommonListVo"
select="workList" column="dictTypeXcsgz">
</collection>
<collection property="educationList" ofType="DictCommonListVo"
select="educationList" column="dictTypeXl">
</collection>
<collection property="degreeList" ofType="DictCommonListVo"
select="degreeList" column="dictTypeXw">
</collection>
<collection property="jrdwxsList" ofType="DictCommonListVo"
select="jrdwxsList" column="dictTypeJrbdwxs">
</collection>
<collection property="xjshuzczgList" ofType="DictCommonListVo"
select="xjshuzczgList" column="dictTypezyjszgmc">
</collection>
</resultMap>
<resultMap id="dictCommonProjectInitMap" type="com.yxt.jlzx.system.api.dictcommon.DictCommonProjectVo">
<collection property="projectTypeList" ofType="DictCommonListVo"
select="projectTypeList" column="xmlbType">
</collection>
<collection property="professionalTypeList" ofType="DictCommonListVo"
select="professionalTypeList" column="xmzylbType">
</collection>
<collection property="participateWayList" ofType="DictCommonListVo"
select="participateWayList" column="cyfsType">
</collection>
</resultMap>
<select id="projectTypeList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{xmlbType}
</select>
<select id="jrdwxsList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeJrbdwxs}
</select>
<select id="xjshuzczgList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypezyjszgmc}
</select>
<select id="professionalTypeList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{xmzylbType}
</select>
<select id="participateWayList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{cyfsType}
</select>
<select id="nationalList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeMinZu}
</select>
<select id="poliCodeList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeZzmm}
</select>
<select id="sexList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeSex}
</select>
<select id="educationList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey, dc.dictValue, dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeXl}
</select>
<select id="degreeList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey, dc.dictValue, dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeXw}
</select>
<select id="staffIdentityList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeRysf}
</select>
<select id="awardsList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeJlqk}
</select>
<select id="workList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dc.dictKey,
dc.dictValue,
dc.dictType
FROM dict_common dc
WHERE dictType = #{dictTypeXcsgz}
</select>
<select id="getDwType" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'dwlb'
</select>
<select id="getRylb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'rylb'
</select>
<select id="getYcsy" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'ycsyOA'
</select>
<select id="getDwJb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'dwjb'
</select>
<select id="getZblb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'zblb'
</select>
<select id="getHylb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'hylb'
</select>
<select id="getXl" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'xl'
</select>
<select id="getZzmm" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'zzmm'
</select>
<select id="getZzylb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'zzylb'
</select>
<select id="getJglb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'jglb'
</select>
<select id="getJgsx" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'jgsx'
</select>
<select id="getJgcclx" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'jgcclx'
</select>
<select id="getTsjbly" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'tsjbly'
</select>
<select id="getXzcfwflx" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'xzcfwflx'
</select>
<select id="getXzcfrdyj" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'xzcfrdyj'
</select>
<select id="getXzcfyj" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'xzcfyj'
</select>
<select id="getTsjbcljg" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'tsjbcljg'
</select>
<select id="getTsjblb" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'tsjblb'
</select>
<select id="getCndwsqzt" resultMap="commonMap">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'cndwsqzt'
and dictKey in (1, 2, 3, 4)
</select>
<select id="dictSelect" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT *
FROM dict_common
WHERE dictType = #{dictType}
</select>
<select id="selectByParentSid" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dictKey,
dictType,
dictValue,
sid
FROM dict_common
WHERE parentSid = #{sid}
</select>
<select id="dictCommonInit" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonInitVo"
resultMap="dictCommonInitMap">
SELECT 'minzu' dictTypeMinZu,
'sex' dictTypeSex,
'zzmm' dictTypeZzmm,
'xl' dictTypeXl,
'rysf' dictTypeRysf,
'jlqk1' dictTypeJlqk,
'xw' dictTypeXw,
'xcsgz1' dictTypeXcsgz,
'jrbdwxs1' dictTypeJrbdwxs,
'zyjszgmc' dictTypezyjszgmc
FROM dict_common
LIMIT 1
</select>
<select id="dictCommonOaSeal" resultType="java.util.Map">
SELECT dictType, dictKey, dictValue
FROM dict_common
WHERE dictType = 'sealType'
</select>
<select id="dictCommonProjectInit" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonProjectVo"
resultMap="dictCommonProjectInitMap">
SELECT 'xmlb' xmlbType,
'xmzylb' xmzylbType,
'cyqk' cyfsType
FROM dict_common
LIMIT 1
</select>
<select id="likeDict" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = 'bkzy'
AND dictValue LIKE concat("%", #{value}, "%")
</select>
<select id="selectBykey" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonVo">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = #{type}
AND dictkey = #{key}
</select>
<select id="likeZymc" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dictKey,
dictType,
dictValue
FROM dict_common
WHERE dictType = #{type}
AND dictValue LIKE concat("%", #{likeStr}, "%")
</select>
<select id="selectKeyByType" resultType="java.lang.String">
select dictKey
from dict_common
where dictType = #{type}
order by dictKey desc
limit 1
</select>
<select id="selectByValue" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommon">
select *
from dict_common
where dictType = #{type}
and dictValue = #{value}
</select>
<select id="selectByValue1" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommon">
select *
from dict_common
where dictType = #{type}
and dictValue = #{value}
and sid &lt;&gt; #{sid}
</select>
<update id="updateValue">
update dict_common
set dictValue = #{dictValue}
where sid = #{sid}
</update>
<select id="hylbList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonHylbVo">
select sid, dictKey, dictType, dictValue
from dict_common
where dictType = #{type}
</select>
</mapper>

View File

@@ -0,0 +1,243 @@
package com.yxt.jlzx.system.biz.dictcommon;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.dictcommon.*;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author dongjianzhao
* @ClassName: DictCommonService
* @Description: TODO(这里用一句话描述这个类的作用)
* @date 2020年10月3日
*/
@Service
public class DictCommonService extends MybatisBaseService<DictCommonMapper, DictCommon> {
public IPage<DictCommonVo> pageList(PagerQuery<DictCommonQuery> pagerQuery) {
IPage<DictCommonQuery> page = PagerUtil.queryToPage(pagerQuery);
DictCommonQuery params = pagerQuery.getParams();
QueryWrapper<DictCommonVo> qw = new QueryWrapper<>();
if (params != null) {
String dictKey = params.getDictKey();
String dictType = params.getDictType();
String dictValue = params.getDictValue();
if (StringUtils.isNotBlank(dictType)) {
qw.eq("dc.dictType", dictType);
}
if (StringUtils.isNotBlank(dictValue)) {
qw.like("dc.dictValue", dictValue);
}
if (StringUtils.isNotBlank(dictKey)) {
qw.like("dc.dictKey", dictKey);
}
}
qw.orderByDesc("dc.createTime");
return baseMapper.pageList(page, qw);
}
/**
* @param @param map
* @param @return 参数
* @return List<DictCommon> 返回类型
* @throws
* @Title: repeatCheck
* @Description: 重复验证码
*/
public List<DictCommon> repeatCheck(Map<String, Object> map) {
List<DictCommon> list = baseMapper.selectByMap(map);
return list;
}
/**
* 查询单位类别
*
* @return dictType为dwlb的数据
*/
public List<DictCommonListVo> getDwType() {
return baseMapper.getDwType();
}
/**
* 查询机构的人员类别
*
* @return
*/
public List<DictCommonListVo> getRylb() {
return baseMapper.getRylb();
}
/**
* 查询用车事由
*
* @return
*/
public List<DictCommonListVo> getYcsy() {
return baseMapper.getYcsy();
}
/**
* 获取单位级别
*
* @return
*/
public List<DictCommonListVo> getDwJb() {
return baseMapper.getDwJb();
}
public List<DictCommonListVo> getZblb() {
return baseMapper.getZblb();
}
/**
* 获取行业类别下拉框
*
* @return
*/
public List<DictCommonListVo> getHylb() {
return baseMapper.getHylb();
}
public List<DictCommonListVo> getXl() {
return baseMapper.getXl();
}
public List<DictCommonListVo> getZzmm() {
return baseMapper.getZzmm();
}
public List<DictCommonListVo> getZzylb() {
return baseMapper.getZzylb();
}
public List<DictCommonListVo> getJglb() {
return baseMapper.getJglb();
}
public List<DictCommonListVo> getJgsx() {
return baseMapper.getJgsx();
}
public List<DictCommonListVo> getJgcclx() {
return baseMapper.getJgcclx();
}
public List<DictCommonListVo> getTsjbly() {
return baseMapper.getTsjbly();
}
public List<DictCommonListVo> getXzcfwflx() {
return baseMapper.getXzcfwflx();
}
public List<DictCommonListVo> getXzcfrdyj() {
return baseMapper.getXzcfrdyj();
}
public List<DictCommonListVo> getXzcfyj() {
return baseMapper.getXzcfyj();
}
public List<DictCommonListVo> getTsjbcljg() {
return baseMapper.getTsjbcljg();
}
public List<DictCommonListVo> getTsjblb() {
return baseMapper.getTsjblb();
}
public List<DictCommonListVo> getCndwsqzt() {
return baseMapper.getCndwsqzt();
}
public List<DictCommonListVo> dictSelect(String dictType) {
// TODO Auto-generated method stub
return baseMapper.dictSelect(dictType);
}
public List<DictCommonListVo> selectByParentSid(String sid) {
// TODO Auto-generated method stub
return baseMapper.selectByParentSid(sid);
}
/**
* 人员编辑初始化
*
* @return
*/
public DictCommonInitVo dictCommonInit() {
return baseMapper.dictCommonInit();
}
/**
* 获取印章类型
*
* @return
*/
public List<Map<String, Object>> dictCommonOaSeal() {
return baseMapper.dictCommonOaSeal();
}
/**
* oa项目项目新建初始化
*
* @return
*/
public DictCommonProjectVo dictCommonProjectInit() {
return baseMapper.dictCommonProjectInit();
}
public List<DictCommonListVo> likeDict(String value) {
// TODO Auto-generated method stub
return baseMapper.likeDict(value);
}
public DictCommonVo selectBykey(String key, String type) {
return baseMapper.selectBykey(key, type);
}
public List<DictCommonListVo> likeZymc(String type, String likeStr) {
// TODO Auto-generated method stub
return baseMapper.likeZymc(type, likeStr);
}
public String selectKeyByType(String type) {
return baseMapper.selectKeyByType(type);
}
public DictCommon selectByValue(String type, String dictValue) {
return baseMapper.selectByValue(type, dictValue);
}
public DictCommon selectByValue1(String type, String dictValue, String sid) {
return baseMapper.selectByValue1(type, dictValue, sid);
}
public int updateValue(String sid, String dictValue) {
return baseMapper.updateValue(sid, dictValue);
}
public List<DictCommonHylbVo> hylbList(String type) {
return baseMapper.hylbList(type);
}
}

View File

@@ -0,0 +1,98 @@
package com.yxt.jlzx.system.biz.dictcommon;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.dictcommon.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author dongjianzhao
* @ClassName: DictTypeApiImpl
* @Description:数据字典类型管理
* @date 2020年10月3日
*/
@Controller
@RequestMapping("dicttype")
@Api(tags = "数据字典类型管理")
public class DictTypeApiImpl implements DictTypeApi {
@Autowired
private DictTypeService dictTypeService;
@Override
public ResultBean<PagerVo<DictTypeVo>> pageList(PagerQuery<DictTypeQuery> pagerQuery) {
// PagerVo<DictTypeVo> pagerVo = dictTypeService.page(pagerQuery);
// ResultBean<PagerVo<DictTypeVo>> objectResultBean = ResultBean.fireSuccess();
// return objectResultBean.setData(pagerVo);
ResultBean<PagerVo<DictTypeVo>> rb = ResultBean.fireFail();
PagerVo<DictTypeVo> pv = new PagerVo<>();
IPage<DictTypeVo> p2 = dictTypeService.pageList(pagerQuery);
PagerVo<DictTypeVo> pv1 = PagerUtil.pageToVo(p2, pv);
return rb.success().setData(pv1);
}
@Override
public ResultBean save(@Valid DictTypeDto dictTypeDto) {
DictType dictType = dictTypeDto.toEntity();
Map<String, Object> map = new HashMap<String, Object>();
map.put("dictTypeCode", dictType.getDictTypeCode());
map.put("dictTypeName", dictType.getDictTypeName());
List<DictType> list = dictTypeService.listByMap(map);
if (list.size() > 0) {
return ResultBean.fireFail().setMsg("数据字典分类名称已存在!");
}
if (!dictTypeService.save(dictType)) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setData(dictType.getSid());
}
@Override
public ResultBean update(@Valid DictTypeDto dictTypeDto, String sid) throws Exception {
DictType dictType = dictTypeService.fetchBySid(sid);
if (null == dictType) {
return ResultBean.fireFail().setMsg("该数据字典类型不存在");
}
if (0 == dictTypeService.updateBySid(dictTypeDto.toMap(dictType), sid)) {
return ResultBean.fireFail().setMsg("更新失败");
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
@Override
public ResultBean delete(String sid) {
if (0 == dictTypeService.deleteBySid(sid)) {
return ResultBean.fireFail().setMsg("删除失败");
}
return ResultBean.fireSuccess().setMsg("删除成功");
}
@Override
public ResultBean<DictTypeVo> initUpdate(String sid) {
DictType dictType = dictTypeService.fetchBySid(sid);
if (null == dictType) {
return new ResultBean<DictTypeVo>().fail().setData(null);
}
DictTypeVo dictTypeVo = new DictTypeVo();
dictTypeVo.setSid(dictType.getSid());
dictTypeVo.setDictTypeCode(dictType.getDictTypeCode());
dictTypeVo.setDictTypeName(dictType.getDictTypeName());
return new ResultBean<DictTypeVo>().success().setData(dictTypeVo);
}
}

View File

@@ -0,0 +1,26 @@
package com.yxt.jlzx.system.biz.dictcommon;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.dictcommon.DictType;
import com.yxt.jlzx.system.api.dictcommon.DictTypeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @ClassName: DictTypeMapper
* @Description: TODO(这里用一句话描述这个类的作用)
* @author dongjianzhao
* @date 2020年10月3日
*
*/
@Mapper
public interface DictTypeMapper extends BaseMapper<DictType>{
public IPage<DictTypeVo> pageList(
IPage<?> page, @Param(Constants.WRAPPER) Wrapper<DictTypeVo> qw);
}

View File

@@ -0,0 +1,10 @@
<?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.yxt.jlzx.system.biz.dictcommon.DictTypeMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.dictcommon.DictTypeVo">
SELECT dt.dictTypeCode, dt.dictTypeName, dt.sid, dt.remarks
FROM jlzx_system.dict_type dt
${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,43 @@
package com.yxt.jlzx.system.biz.dictcommon;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.dictcommon.DictType;
import com.yxt.jlzx.system.api.dictcommon.DictTypeQuery;
import com.yxt.jlzx.system.api.dictcommon.DictTypeVo;
import org.springframework.stereotype.Service;
/**
* @author dongjianzhao
* @ClassName: DictTypeService
* @Description:
* @date 2020年10月3日
*/
@Service
public class DictTypeService extends MybatisBaseService<DictTypeMapper, DictType> {
public IPage<DictTypeVo> pageList(PagerQuery<DictTypeQuery> pagerQuery) {
IPage<DictTypeQuery> page = PagerUtil.queryToPage(pagerQuery);
DictTypeQuery params = pagerQuery.getParams();
QueryWrapper<DictTypeVo> qw = new QueryWrapper<>();
if (params != null) {
String dictTypeCode = params.getDictTypeCode();
if (StringUtils.isNotBlank(dictTypeCode)) {
qw.like("dt.dictTypeCode", dictTypeCode);
}
String dictTypeName = params.getDictTypeName();
if (StringUtils.isNotBlank(dictTypeName)) {
qw.like("dt.dictTypeName", dictTypeName);
}
}
qw.orderByDesc("dt.createTime");
return baseMapper.pageList(page, qw);
}
}

View File

@@ -0,0 +1,176 @@
package com.yxt.jlzx.system.biz.exportoexcel;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
//2021.10.30
public class exportToExcel {
// @Resource
// OnLineConfig onLineConfig;
/**
*
* @param sheetTitle 页签名
* @param title 表头
* @param list 导出数据
* @return
*/
public String export(String sheetTitle, String[] title, List<Object> list, HttpServletResponse response) {
HSSFWorkbook wb = new HSSFWorkbook();//创建excel表
HSSFSheet sheet = wb.createSheet(sheetTitle);
sheet.setDefaultColumnWidth(40);//设置默认行宽
sheet.createFreezePane(0,2,0,2); //不动行
CellRangeAddress c = CellRangeAddress.valueOf("A2:J2"); //设置筛选框
sheet.setAutoFilter(c);
//表头样式(加粗,水平居中,垂直居中)
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
//设置边框样式
// cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
// cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
// cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
// cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
HSSFFont fontStyle = wb.createFont();
// fontStyle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
fontStyle.setFontHeightInPoints((short) 12);//设置字体大小
cellStyle.setFont(fontStyle);
//标题样式(加粗,垂直居中)
HSSFCellStyle cellStyle2 = wb.createCellStyle();
cellStyle2.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle2.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
cellStyle2.setFont(fontStyle);
//设置边框样式
// cellStyle2.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
// cellStyle2.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
// cellStyle2.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
// cellStyle2.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
//字段样式(垂直居中)
HSSFCellStyle cellStyle3 = wb.createCellStyle();
cellStyle3.setAlignment(HorizontalAlignment.CENTER);//水平居中
cellStyle3.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
cellStyle3.setFont(fontStyle); //字体大小
cellStyle3.setWrapText(false); //自动换行
//设置边框样式
// cellStyle3.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
// cellStyle3.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
// cellStyle3.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
// cellStyle3.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
//创建表头
HSSFRow row = sheet.createRow(0);
row.setHeightInPoints(30);//行高
HSSFCell cell = row.createCell(0);
cell.setCellValue(sheetTitle); //2021.09.17 去掉表头
cell.setCellStyle(cellStyle);
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, (title.length - 1)));
//创建标题
HSSFRow rowTitle = sheet.createRow(1);
rowTitle.setHeightInPoints(30);
HSSFCell hc;
for (int i = 0; i < title.length; i++) {
hc = rowTitle.createCell(i);
hc.setCellValue(title[i]);
hc.setCellStyle(cellStyle2);
}
byte result[] = null;
ByteArrayOutputStream out = null;
FileOutputStream output = null;
String createdate = null;
try {
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
//创建表格数据
Field[] fields;
int i = 2;
for (Object obj : list) {
fields = obj.getClass().getDeclaredFields();
HSSFRow rowBody = sheet.createRow(i);
rowBody.setHeightInPoints(50); //100
int j = 0;
for (Field f : fields) {
f.setAccessible(true);
Object va = f.get(obj);
if (null == va) {
va = "";
}
hc = rowBody.createCell(j);
hc.setCellValue(va.toString());
hc.setCellStyle(cellStyle3);
j++;
}
i++;
}
Date date = new Date();
// 设置要获取到什么样的时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmSS");
// 获取String类型的时间
createdate = sdf.format(date);
//创建一个文件夹 2021.09.17,保存路径先固定,后期在修改 ;//onLineConfig.getShengTingFile()
// String downloadDircopy = "C:\\Users\\Administrator\\Desktop\\" + File.separator + createdate + "_" + sheetTitle + File.separator;
// File downloadFilePath1 = new File(downloadDircopy);
// if (downloadFilePath1.exists() == false){
// // 如果该目录不存在,则创建之
// downloadFilePath1.mkdirs();
// }
// output = new FileOutputStream(downloadDircopy + sheetTitle+".xls");
// wb.write(output);
// output.flush();
try{
buildExcelDocument(sheetTitle+".xls", wb, response);
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception ex) {
// Logger.getLogger(ExportExcel.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
if (null != output) {
output.close();
}
} catch (IOException ex) {
// Logger.getLogger(ExportExcel.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
wb.close();
} catch (IOException ex) {
// Logger.getLogger(ExportExcel.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
// return "images" + File.separator + createdate;
return "导出成功";
}
//浏览器下载excel 2021.10.31
private void buildExcelDocument(String filename, HSSFWorkbook workbook, HttpServletResponse response) throws IOException {
// response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "utf-8"));
OutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
outputStream.close();
}
}

View File

@@ -0,0 +1,183 @@
package com.yxt.jlzx.system.biz.filenumrule;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.filenumrule.Filenumrule;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleApi;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleDto;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleDto2;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleOneVo;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleQuery;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleVo;
import com.yxt.jlzx.system.api.filenumruleauthorize.Filenumruleauthorize;
import com.yxt.jlzx.system.api.filenumruleauthorize.Filenumruleauthorize1Vo;
import com.yxt.jlzx.system.api.filenumruleauthorize.FilenumruleauthorizeVo;
import com.yxt.jlzx.system.biz.filenumruleauthorize.FilenumruleauthorizeService;
import io.swagger.annotations.Api;
/**
* @author dimengzhe
* @date 2020/11/13 9:35
* @description
*/
@Controller
@RequestMapping("v1/filenumrules")
@Api(tags = "编号规则管理")
public class FilenumruleApiImpl implements FilenumruleApi {
@Autowired
private FilenumruleService filenumruleService;
@Autowired
private FilenumruleauthorizeService filenumruleauthorizeService;
@Override
public ResultBean<List<FilenumruleVo>> list(@Valid FilenumruleQuery query) {
ResultBean<List<FilenumruleVo>> resultBean=ResultBean.fireFail();
List<FilenumruleVo> list=filenumruleService.list(query);
if(null==list)
return resultBean;
return resultBean.success().setData(list);
}
@Override
public ResultBean<PagerVo<FilenumruleVo>> pageList(@Valid PagerQuery<FilenumruleQuery> pagerQuery) {
ResultBean<PagerVo<FilenumruleVo>> rb = ResultBean.fireFail();
IPage<FilenumruleVo> page = filenumruleService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<FilenumruleVo> pv_result = PagerUtil.pageToVo(page, null);
return rb.success().setData(pv_result);
}
@Override
public ResultBean save(@Valid FilenumruleDto dto) {
Filenumrule filenumrule=new Filenumrule();
List<String> processSid = dto.getProcessSids();
FilenumruleDto2 dto2=new FilenumruleDto2();
dto2.setRuleName(dto.getRuleName());
FilenumruleVo filenumrule1=filenumruleService.selectByRuleName(dto2);
if(filenumrule1!=null) {
filenumrule.setSid(filenumrule1.getSid());
return ResultBean.fireFail().setMsg("保存失败,该名称已存在");
}
if(processSid==null||processSid.size()==0) {
return ResultBean.fireSuccess().setMsg("保存失败");
}else {
for (int i = 0; i < processSid.size(); i++) {
int j=filenumruleauthorizeService.countByProcessSidruleSid(filenumrule.getSid(),processSid.get(i));
if(j==0) {
Filenumruleauthorize filenumruleauthorize = new Filenumruleauthorize();
filenumruleauthorize.setRuleSid(filenumrule.getSid());
filenumruleauthorize.setProcessSid(processSid.get(i));
filenumruleauthorizeService.save(filenumruleauthorize);
}
}
}
dto.fillEntity(filenumrule);
boolean isSave =true;
if(filenumrule1==null) {
isSave=filenumruleService.save(filenumrule);
}
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setData(filenumrule.getSid()).setMsg("保存成功");
}
@Override
public ResultBean update(@Valid FilenumruleDto dto, String sid) throws Exception {
Filenumrule filenumrule=filenumruleService.fetchBySid(sid);
if(null==filenumrule)
return ResultBean.fireFail().setMsg("该记录不存在");
FilenumruleDto2 dto2=new FilenumruleDto2();
dto2.setRuleName(dto.getRuleName());
dto2.setSid(sid);
FilenumruleVo filenumrule1=filenumruleService.selectByRuleName(dto2);
if(filenumrule1!=null) {
filenumrule.setSid(filenumrule1.getSid());
return ResultBean.fireFail().setMsg("保存失败,该名称已存在");
}
if(0==filenumruleService.updateBySid(dto.toMap(), sid))
return ResultBean.fireFail();
filenumruleauthorizeService.deleteByRuleSid(sid);
List<String> processSids = dto.getProcessSids();
if(processSids!=null&&processSids.size()>0) {
for(int i=0;i<processSids.size();i++){
Filenumruleauthorize filenumruleauthorize = new Filenumruleauthorize();
filenumruleauthorize.setRuleSid(sid);
filenumruleauthorize.setProcessSid(processSids.get(i));
filenumruleauthorizeService.save(filenumruleauthorize);
}
}
return ResultBean.fireSuccess().setData(sid);
}
@Override
public ResultBean delete(String sid) {
Filenumrule t=filenumruleService.fetchBySid(sid);
if(null==t)
return ResultBean.fireFail().setMsg("该记录不存在");
if(0==filenumruleService.deleteBySid(sid))
return ResultBean.fireFail();
filenumruleauthorizeService.deleteByRuleSid(sid);
return ResultBean.fireSuccess();
}
@Override
public ResultBean<FilenumruleVo> getVo(String sid) {
ResultBean<FilenumruleVo> resultBean=ResultBean.fireFail();
Filenumrule t=filenumruleService.fetchBySid(sid);
if(null==t)
return resultBean;
FilenumruleVo vo=new FilenumruleVo();
vo.fromEntity(t);
List<String> selectFilenumruleauthorizeList = filenumruleauthorizeService.selectFilenumruleauthorizeList(sid);
vo.setProcessSids(selectFilenumruleauthorizeList);
return resultBean.success().setData(vo);
}
@Override
public ResultBean<List<FilenumruleOneVo>> getVoByProcessSid(String processSid) {
ResultBean<List<FilenumruleOneVo>> resultBean=ResultBean.fireFail();
List<FilenumruleOneVo> t=filenumruleService.getVoByProcessSid(processSid);
if(t==null) {
t=new ArrayList<FilenumruleOneVo>();
}
return resultBean.success().setData(t);
}
@Override
public ResultBean isRepeat(@Valid FilenumruleDto2 dto) {
// TODO Auto-generated method stub
FilenumruleVo filenumrule=filenumruleService.selectByRuleName(dto);
if(filenumrule!=null) {
return ResultBean.fireFail().setMsg("该名称已存在");
}else {
return ResultBean.fireSuccess().setMsg("该名称可以使用");
}
}
}

View File

@@ -0,0 +1,31 @@
package com.yxt.jlzx.system.biz.filenumrule;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.filenumrule.Filenumrule;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleOneVo;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleQuery;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleVo;
/**
* @author dimengzhe
* @date 2020/11/13 9:38
* @description
*/
@Mapper
public interface FilenumruleMapper extends BaseMapper<Filenumrule> {
//分页列表
IPage<FilenumruleVo> pageList(IPage<FilenumruleQuery> page,@Param(Constants.WRAPPER) Wrapper<FilenumruleVo> qw);
List<FilenumruleVo> list(@Param(Constants.WRAPPER) QueryWrapper<FilenumruleVo> qw);
int countBySid(String sid);
FilenumruleVo selectByRuleName(@Param(Constants.WRAPPER) QueryWrapper<FilenumruleVo> qw);
List<FilenumruleOneVo> getVoByProcessSid(String processSid);
}

View File

@@ -0,0 +1,29 @@
<?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.yxt.jlzx.system.biz.filenumrule.FilenumruleMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.filenumrule.FilenumruleVo">
select sid, ruleName, ruleType, fromDetpt, startNumber
from filenumrule ${ew.customSqlSegment}
</select>
<select id="list" resultType="com.yxt.jlzx.system.api.filenumrule.FilenumruleVo">
select sid, ruleName, ruleType, fromDetpt, startNumber
from filenumrule ${ew.customSqlSegment}
</select>
<select id="selectByRuleName" resultType="com.yxt.jlzx.system.api.filenumrule.FilenumruleVo">
select *
from filenumrule ${ew.customSqlSegment}
</select>
<select id="countBySid" resultType="java.lang.Integer">
SELECT count(id)
FROM filenumrule
where sid = #{sid}
</select>
<select id="getVoByProcessSid" resultType="com.yxt.jlzx.system.api.filenumrule.FilenumruleOneVo">
SELECT *
FROM filenumrule
where sid in (SELECT ruleSid FROM filenumruleauthorize where processSid = #{processSid})
</select>
</mapper>

View File

@@ -0,0 +1,106 @@
package com.yxt.jlzx.system.biz.filenumrule;
import java.util.List;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.filenumrule.Filenumrule;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleDto2;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleOneVo;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleQuery;
import com.yxt.jlzx.system.api.filenumrule.FilenumruleVo;
/**
* @author dimengzhe
* @date 2020/11/13 9:37
* @description
*/
@Service
public class FilenumruleService extends MybatisBaseService<FilenumruleMapper, Filenumrule> {
// 分页列表
public IPage<FilenumruleVo> pageList(PagerQuery<FilenumruleQuery> pagerQuery) {
// mybits所用的分页对对象
IPage<FilenumruleQuery> page = PagerUtil.queryToPage(pagerQuery);
// mybits所用的查询条件封装类
QueryWrapper<FilenumruleVo> qw = buildQueryWrapper(pagerQuery.getParams());
return baseMapper.pageList(page, qw);
}
// 不分页列表
public List<FilenumruleVo> list(FilenumruleQuery pagerQuery) {
// mybits所用的查询条件封装类
QueryWrapper<FilenumruleVo> qw = buildQueryWrapper(pagerQuery);
return baseMapper.list(qw);
}
/**
* 解析和组装查询条件封装在qw中,虚方法,需要在子类中定义具体实现
* @param pagerQuery
* @return
*/
private QueryWrapper<FilenumruleVo> buildQueryWrapper(FilenumruleQuery pagerQuery)
{
QueryWrapper<FilenumruleVo> qw = new QueryWrapper<FilenumruleVo>();
if (pagerQuery != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery.getRuleName()))
qw.like("ruleName", pagerQuery.getRuleName());
if(org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery.getRuleType()))
qw.eq("ruleType", pagerQuery.getRuleType());
qw.orderByDesc("createTime");
}
return qw;
}
public int countBySid(String sid) {
// TODO Auto-generated method stub
return baseMapper.countBySid(sid);
}
public FilenumruleVo selectByRuleName(FilenumruleDto2 dto) {
// TODO Auto-generated method stub
if(dto!=null) {
String ruleName=dto.getRuleName();
String sid=dto.getSid();
QueryWrapper<FilenumruleVo> qw = buildQueryWrapper1(dto);
return baseMapper.selectByRuleName(qw);
}else {
return null;
}
}
private QueryWrapper<FilenumruleVo> buildQueryWrapper1(FilenumruleDto2 dto) {
QueryWrapper<FilenumruleVo> qw = new QueryWrapper<FilenumruleVo>();
if (dto != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(dto.getRuleName()))
qw.eq("ruleName", dto.getRuleName().trim());
if(org.apache.commons.lang3.StringUtils.isNotBlank(dto.getSid()))
qw.ne("sid", dto.getSid());
qw.orderByDesc("createTime");
}
return qw;
}
public List<FilenumruleOneVo> getVoByProcessSid(String processSid) {
// TODO Auto-generated method stub
return baseMapper.getVoByProcessSid(processSid) ;
}
}

View File

@@ -0,0 +1,25 @@
package com.yxt.jlzx.system.biz.filenumruleauthorize;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.jlzx.system.api.filenumruleauthorize.Filenumruleauthorize;
import com.yxt.jlzx.system.api.filenumruleauthorize.FilenumruleauthorizeVo;
/**
* @author dimengzhe
* @date 2020/11/13 9:38
* @description
*/
@Mapper
public interface FilenumruleauthorizeMapper extends BaseMapper<Filenumruleauthorize> {
public void deleteByRuleSid(String ruleSid);
public List<String> selectFilenumruleauthorizeList(String ruleSid);
public int countByProcessSidruleSid(@Param("ruleSid") String ruleSid,@Param("processSid") String processSid);
}

View File

@@ -0,0 +1,17 @@
<?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.yxt.jlzx.system.biz.filenumruleauthorize.FilenumruleauthorizeMapper">
<select id="selectFilenumruleauthorizeList" resultType="java.lang.String">
SELECT processSid FROM filenumruleauthorize where ruleSid=#{ruleSid}
</select>
<delete id="deleteByRuleSid">
delete from filenumruleauthorize where ruleSid=#{ruleSid}
</delete>
<select id="countByProcessSidruleSid" resultType="java.lang.Integer">
SELECT count(id) FROM filenumruleauthorize where ruleSid=#{ruleSid} and processSid=#{processSid}
</select>
</mapper>

View File

@@ -0,0 +1,46 @@
package com.yxt.jlzx.system.biz.filenumruleauthorize;
import java.util.List;
import org.springframework.stereotype.Service;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.jlzx.system.api.filenumruleauthorize.Filenumruleauthorize;
import com.yxt.jlzx.system.api.filenumruleauthorize.FilenumruleauthorizeVo;
/**
* @author dimengzhe
* @date 2020/11/13 9:37
* @description
*/
@Service
public class FilenumruleauthorizeService extends MybatisBaseService<FilenumruleauthorizeMapper, Filenumruleauthorize> {
public List<String> selectFilenumruleauthorizeList(String ruleSid) {
return baseMapper.selectFilenumruleauthorizeList(ruleSid);
}
public void deleteByRuleSid(String ruleSid) {
baseMapper.deleteByRuleSid(ruleSid);
}
public int countByProcessSidruleSid(String ruleSid, String processSid) {
// TODO Auto-generated method stub
return baseMapper.countByProcessSidruleSid(ruleSid,processSid);
}
//
// private QueryWrapper<FilenumruleauthorizeVo> buildQueryWrapper(FilenumruleQuery filenumruleQuery)
// {
// QueryWrapper<FilenumruleauthorizeVo> qw = new QueryWrapper<FilenumruleauthorizeVo>();
// if (filenumruleQuery != null) {
// if (org.apache.commons.lang3.StringUtils.isNotBlank(filenumruleQuery.getRuleSid()))
// qw.eq("ruleSid", filenumruleQuery.getRuleSid());
// }
//
// return qw;
//
// }
}

View File

@@ -0,0 +1,120 @@
package com.yxt.jlzx.system.biz.holiday;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.holiday.*;
import com.yxt.jlzx.system.api.role.Role;
import com.yxt.jlzx.system.api.role.RoleVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yxt_mtl
* @date 2020/9/29 13:30
* @description 角色信息
*/
@Controller
@RequestMapping("v1/holidays")
@Api(tags = "节假日")
public class HolidayApiImpl implements HolidayApi {
@Autowired
private HolidayService holidayService;
/**
*
* @param pagerQuery 查询条件
* @return
*/
@Override
public ResultBean<PagerVo<HolidayVo>> pageList(PagerQuery<HolidayQuery> pagerQuery) {
ResultBean<PagerVo<HolidayVo>> rb = ResultBean.fireFail();
return rb.setMsg("该接口暂未使用");
}
/**
* 保存
*
* @param holidayDto dto对象
* @return ResultBean
*/
@Override
public ResultBean save(HolidayDto holidayDto) {
Holiday holiday = new Holiday();
holidayDto.fillEntity(holiday);
if (!holidayService.save(holiday))
return ResultBean.fireFail().setMsg("保存失败");
return ResultBean.fireSuccess().setData(holiday.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值.
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean update(HolidayDto holidayDto, String sid) throws Exception {
Holiday holiday = holidayService.fetchBySid(sid);
if (null == holiday)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == holidayService.updateBySid(holidayDto.toMap(), sid))
return ResultBean.fireFail().setMsg("更新失败");
return ResultBean.fireSuccess().setMsg("更新成功");
}
/**
* 删除
*
* @param sid 节假日sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
ResultBean rb = ResultBean.fireFail();
return rb.setMsg("该接口暂未使用");
}
/**
* 修改页面初始化数据
*
* @param sid
* @return ResultBean
*/
@Override
public ResultBean<HolidayVo> getVo(String sid) {
Holiday holiday = holidayService.fetchBySid(sid);
if (null == holiday)
return new ResultBean<HolidayVo>().fail().setData(null);
HolidayVo vo = new HolidayVo();
vo.fromEntity(holiday);
return new ResultBean<HolidayVo>().success().setData(vo);
}
@Override
public ResultBean<List<HolidayVo>> list(HolidayQuery query) {
ResultBean<List<HolidayVo>> rb = ResultBean.fireFail();
return rb.setMsg("该接口暂未使用");
}
}

View File

@@ -0,0 +1,27 @@
package com.yxt.jlzx.system.biz.holiday;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.holiday.Holiday;
import com.yxt.jlzx.system.api.holiday.HolidayQuery;
import com.yxt.jlzx.system.api.holiday.HolidayVo;
/**
* @author yxt_mtl
* @date 2020/9/29 13:45
* @description
*/
@Mapper
public interface HolidayMapper extends BaseMapper<Holiday> {
//分页列表
IPage<HolidayVo> pageList(IPage<HolidayQuery> page, @Param(Constants.WRAPPER) Wrapper<HolidayVo> qw);
public int updateIsEnable(@Param("sid") String sid, @Param("isEnable") Integer isEnable);
}

View File

@@ -0,0 +1,11 @@
<?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.yxt.jlzx.system.biz.holiday.HolidayMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.holiday.HolidayVo">
SELECT sid, holiday, workday
FROM holiday ${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,206 @@
package com.yxt.jlzx.system.biz.holiday;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import org.springframework.stereotype.Service;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.jlzx.system.api.holiday.Holiday;
@Service
public class HolidayService extends MybatisBaseService<HolidayMapper, Holiday> {
public String getUseTime(Date startDate, Date endDate) {
// 初始化 法定节假日
String holidays = "";
// 初始化 上班的周六日
String workdays = "";
// 起止时间格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sdf.format(startDate).replace(" ", "T");
String str2 = sdf.format(endDate).replace(" ", "T");
LocalDateTime start = LocalDateTime.parse(str);
LocalDateTime end = LocalDateTime.parse(str2);
/*
* if (end.isBefore(start)) { String di="止日小于起日"; return di; }
*/
int middleDays = 0;
// 如果开始时间和结束时间是同一天
LocalDateTime tempEnd = LocalDateTime.parse(start.toLocalDate()
.toString() + "T" + end.toLocalTime().toString());
if (start.toLocalDate().until(end.toLocalDate()).getDays() > 0) {
tempEnd = LocalDateTime.parse(start.toLocalDate().plusDays(1)
.toString()
+ "T" + end.toLocalTime().toString());
LocalDate tempDate = start.toLocalDate();
// 循环每一天,计算上班的天数
while (!tempDate.isAfter(end.toLocalDate().minusDays(2))) {
tempDate = tempDate.plusDays(1);
// 周六日上班或者不是节假日则添加
if (workdays.contains(tempDate.toString())
|| (tempDate.getDayOfWeek().getValue() != 6
&& tempDate.getDayOfWeek().getValue() != 7 && !holidays
.contains(tempDate.toString()))) {
middleDays++;
}
}
}
long minutes = 0;
// 是同一天并且是节假日则返回0
if (start.toLocalDate().until(end.toLocalDate()).getDays() == 0) {
if (!workdays.contains(start.toString())
&& (start.getDayOfWeek().getValue() == 6
|| start.getDayOfWeek().getValue() == 7 || holidays
.contains(start.toString())))
minutes = 0;
} else {
// 2.如果开始时间是节假日,则直接置成第二天的上班时间
if (!workdays.contains(start.toString())
&& (start.getDayOfWeek().getValue() == 6
|| start.getDayOfWeek().getValue() == 7 || holidays
.contains(start.toString())))
start = LocalDateTime.parse(start.toLocalDate().plusDays(1)
.toString()
+ "T" + "00:00:00");
// 3.如果结束时间是节假日,则直接置成当前的上班时间
if (!workdays.contains(tempEnd.toString())
&& (tempEnd.getDayOfWeek().getValue() == 6
|| tempEnd.getDayOfWeek().getValue() == 7 || holidays
.contains(tempEnd.toString())))
tempEnd = LocalDateTime.parse(tempEnd.toLocalDate().toString()
+ "T" + "00:00:00");
changeWorkTime(start);
changeWorkTime(tempEnd);
minutes = start.until(tempEnd, ChronoUnit.MINUTES);
}
// 计算天 时 分
long day = minutes / 60 / 24 + middleDays;
long hours = minutes / 60 % 24;
long min = minutes % 60;
return day + "" + hours + "小时" + min + "";
}
/**
* 转换时间部分
*
* @param localdate
*/
private void changeWorkTime(LocalDateTime localdate) {
// 初始化 上班起止时间
String startWork = "";
String endWork = "";
// 2.计算第一天的上班时间和下班时间
LocalDateTime workStartTime = LocalDateTime.parse(localdate
.toLocalDate().toString() + "T" + startWork);
LocalDateTime wrokEndTime = LocalDateTime.parse(localdate.toLocalDate()
.toString() + "T" + endWork);
// 非工作时间的起止进行处理
if (localdate.isBefore(workStartTime)) { // 时间在上班前就把起始时间换成上班时间
localdate = workStartTime;
}
if (localdate.isAfter(wrokEndTime)) { // 时间在下班后就把起始时间换成下一天的上班时间
localdate = workStartTime.plusDays(1);
}
}
/**
* 周六日包含在节假日设置中。(节假日中不包含周六日倒班)
*
* @param startDate
* @param endDate
* @return
*/
public String getUseTimes(Date startDate, Date endDate) {
// 起止时间格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String str = sdf.format(startDate).replace(" ", "T");
String str2 = sdf.format(endDate).replace(" ", "T");
LocalDateTime start = LocalDateTime.parse(str);
LocalDateTime end = LocalDateTime.parse(str2);
// 除去首尾两天,计算其他天不是节假日的天数(逐天判断其他天是否为节假日,如果不是则加一)
int middleDays = 0;
LocalDate tempDate = start.toLocalDate();
// 循环每一天,计算上班的天数
while (!tempDate.isAfter(end.toLocalDate().minusDays(2))) {
tempDate = tempDate.plusDays(1);
// 不是节假日则添加
if (!isHoliday(tempDate))
middleDays++;
}
// 如果开始时间和结束时间是否为同一天
LocalDateTime tempEnd = LocalDateTime.parse(start.toLocalDate()
.toString() + "T" + end.toLocalTime().toString());
if (start.toLocalDate().until(end.toLocalDate()).getDays() > 0)
tempEnd.plusDays(1);
//判断开始时间和结束时间是否为节假日
long minutes = 0;
if (isHoliday(start.toLocalDate()) && isHoliday(tempEnd.toLocalDate()))
minutes = 0;
else {
// 2.如果开始时间是节假日,则直接置成第二天的零时
if (isHoliday(start.toLocalDate()))
start = LocalDateTime.parse(start.toLocalDate().plusDays(1)
.toString()
+ "T" + "00:00:00");
// 3.如果结束时间是节假日,则直接置成当天的零时
if (isHoliday(tempEnd.toLocalDate()))
tempEnd = LocalDateTime.parse(tempEnd.toLocalDate().toString()
+ "T" + "00:00:00");
changeWorkTime(start);
changeWorkTime(tempEnd);
minutes = start.until(tempEnd, ChronoUnit.MINUTES);
}
// 计算天 时 分
long day = minutes / 60 / 24 + middleDays;
long hours = minutes / 60 % 24;
long min = minutes % 60;
return day + "" + hours + "小时" + min + "";
}
/**
* 判断是否为节假日
*
* @param tempDate
* @return
*/
private boolean isHoliday(LocalDate tempDate) {
// 初始化 法定节假日
String holidays = "";
/*
* // 初始化 上班的周六日 //String workdays = ""; // 1.周六日上班或者不是节假日(不包含周六日)则添加
* //if (workdays.contains(tempDate.toString()) ||
* (tempDate.getDayOfWeek().getValue() != 6 &&
* tempDate.getDayOfWeek().getValue() != 7 &&
* !holidays.contains(tempDate.toString())))
*/
// 不是节假日,节假日包含周六日、国家法定节假日。(周六日正常上班的不包含)
if (!holidays.contains(tempDate.toString()))
return false;
return true;
}
}

View File

@@ -0,0 +1,261 @@
package com.yxt.jlzx.system.biz.index;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.index.*;
import io.swagger.annotations.Api;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author dimengzhe
* @Date 2021/11/26 14:44
* @Description 对接
*/
@Controller
@RequestMapping("/index")
@Api(tags = "对接")
public class IndexApiImpl implements IndexApi {
@Autowired
private IndexService indexService;
@Override
public ResultBean menusList(IndexMenuQuery indexMenuQuery) throws Exception {//获取菜单列表
String result = null;
// 请求接口地址
String url = IndexUtils.menuUrl;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("userId", indexMenuQuery.getUserId());
params.put("moduleId", indexMenuQuery.getModuleId().toString());
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
result = ConstantUtils.net2(url, params, "GET", ticket);
System.out.println(result);
return ResultBean.fireSuccess().setData(result);
}
@Override
public ResultBean rightList(String userId) throws Exception {//获取用户的权限列表
String result = null;
// 请求接口地址
String url = IndexUtils.rightUrl;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("userId", userId);
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
result = ConstantUtils.net2(url, params, "GET", ticket);
System.out.println(result);
return ResultBean.fireSuccess().setData(result);
}
@Override
public ResultBean<IndexDetailsUser> indexUserDetails(String code) {
return indexService.indexUserDetails(code);
}
@Override
public ResultBean<IndexDetailsOrg> indexOrgDetails(String organizationId) {
return indexService.indexOrgDetails(organizationId);
}
@Override
public ResultBean<IndexDetailsRegion> indexRegionDetails(IndexDetailsRegionQuery indexDetailsRegionQuery) {
return indexService.indexRegionDetails(indexDetailsRegionQuery);
}
@Override
public ResultBean<List<IndexUserListVo>> userList(IndexUserQuery indexUserQuery) {//获取具有某个权限的人员列表
ResultBean<List<IndexUserListVo>> rb = ResultBean.fireFail();
String result = null;
// 请求接口地址
String url = IndexUtils.userListUrl;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("right", indexUserQuery.getRight());
params.put("organizationId", indexUserQuery.getOrganizationId());
if (StringUtils.isNotBlank(indexUserQuery.getName())) {
params.put("name", indexUserQuery.getName());
}
result = indexService.common(params, url);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> dataList = ConstantUtils.getListData(map, "data");
List list = new ArrayList<>();
for (int i = 0; i < dataList.size(); i++) {
IndexUserListVo indexUserListVo = new IndexUserListVo();
Map<String, Object> dataMap = dataList.get(i);
String name = ConstantUtils.getString(dataMap, "name", "");
String id = ConstantUtils.getString(dataMap, "id", "");
indexUserListVo.setName(name);
indexUserListVo.setSid(id);
list.add(indexUserListVo);
}
return rb.success().setData(list);
}
@Override
public ResultBean<PagerVo<IndexOrgListVo>> orgList(IndexOrgListQuery indexOrgListQuery) {
ResultBean<PagerVo<IndexOrgListVo>> rb = ResultBean.fireFail();
String result = null;
// 请求接口地址
String url = IndexUtils.orgList;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("current", indexOrgListQuery.getCurrent().toString());
params.put("size", indexOrgListQuery.getSize().toString());
if (StringUtils.isNotBlank(indexOrgListQuery.getName())) {
params.put("name", indexOrgListQuery.getName());
}
if (StringUtils.isBlank(indexOrgListQuery.getArea())) {
//ToDo:需将区域修改为河北省的
params.put("area", "HN");
} else {
params.put("area", indexOrgListQuery.getArea());
}
if(StringUtils.isNotBlank(indexOrgListQuery.getOrganizationType())){
params.put("orgType",indexOrgListQuery.getOrganizationType());
}
result = indexService.common(params, url);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> dataMap = ConstantUtils.getMap(map, "data");
List<Map<String, Object>> list = ConstantUtils.getListData(dataMap, "records");
List<IndexOrgListVo> indexOrgListVoList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
Map<String, Object> listMap = list.get(i);
// 将 Map 转换为 实体类
IndexOrgListVo indexOrgListVo = JSON.parseObject(JSON.toJSONString(listMap), IndexOrgListVo.class);
indexOrgListVoList.add(indexOrgListVo);
}
Collections.sort(indexOrgListVoList, Comparator.comparing(IndexOrgListVo::getCreateTime));
PagerVo<IndexOrgListVo> pagerVo = new PagerVo<>();
Integer total = ConstantUtils.getInteger(dataMap, "total");
Integer size1 = ConstantUtils.getInteger(dataMap, "size");
Integer current1 = ConstantUtils.getInteger(dataMap, "current");
Integer pages = ConstantUtils.getInteger(dataMap, "pages");
pagerVo.setTotal(total);
pagerVo.setPages(pages);
pagerVo.setSize(size1);
pagerVo.setCurrent(current1);
pagerVo.setRecords(indexOrgListVoList);
System.out.println(result);
return rb.success().setData(pagerVo);
}
@Override
public ResultBean<IndexOrgCodeDetailsVo> selectOrgByCodeOrName(IndexOrgSelectQuery indexOrgSelectQuery) {
return indexService.selectOrgByCodeOrName(indexOrgSelectQuery);
}
@Override
public ResultBean saveOrg(IndexSaveOrgQuery indexSaveOrgQuery) {
String result = null;
// 请求接口地址
String url = IndexUtils.selectOrg;
// 请求参数
Map<String, String> params = new TreeMap<>();
if (StringUtils.isNotBlank(indexSaveOrgQuery.getCode())) {
params.put("code", indexSaveOrgQuery.getCode());
}
if (StringUtils.isNotBlank(indexSaveOrgQuery.getName())) {
params.put("name", indexSaveOrgQuery.getName());
}
if (indexSaveOrgQuery.getRegister() != null) {
params.put("register", indexSaveOrgQuery.getRegister().toString());
}
if (StringUtils.isNotBlank(indexSaveOrgQuery.getResidence())) {
params.put("residence", indexSaveOrgQuery.getResidence());
}
if (indexSaveOrgQuery.getSource() != null) {
params.put("source", indexSaveOrgQuery.getSource().toString());
}
if (StringUtils.isNotBlank(indexSaveOrgQuery.getUserName())) {
params.put("userName", indexSaveOrgQuery.getUserName());
}
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
try {
result = ConstantUtils.net2(url, params, "GET", ticket);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(result);
return ResultBean.fireSuccess().setData(result);
}
@Override
public ResultBean<List<IndexLbListVo>> selectLbList(IndexLbListQuery indexLbListQuery) {
return indexService.selectLbList(indexLbListQuery);
}
@Override
public ResultBean<IndexOrgUserVo> selectUserList(IndexUserListQuery indexUserListQuery) {
return indexService.selectUserList(indexUserListQuery);
}
@Override
public ResultBean<String> selectPathByCountyCode(String countyCode) {
return indexService.selectPathByCountyCode(countyCode);
}
/**
* 单点登录对接公共部分
*
* @return
*/
public String deptUsetList(String organizationId) {
return indexService.deptUsetList(organizationId);
}
}

View File

@@ -0,0 +1,461 @@
package com.yxt.jlzx.system.biz.index;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.jlcyry.api.staffinfo.StaffInfo;
import com.yxt.jlzx.jlcyry.api.staffinfo.StaffInfoApi;
import com.yxt.jlzx.jlcyry.api.stafforg.StaffOrgApi;
import com.yxt.jlzx.jlcyry.api.stafforg.StaffOrgVo;
import com.yxt.jlzx.system.api.department.DepartmentFourVo;
import com.yxt.jlzx.system.api.department.DepartmentOneVo;
import com.yxt.jlzx.system.api.department.DepartmentThreeVo;
import com.yxt.jlzx.system.api.department.DepartmentTwoVo;
import com.yxt.jlzx.system.api.index.*;
import com.yxt.jlzx.system.api.user.UserInfoVo;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author dimengzhe
* @Date 2022/3/2 11:11
* @Description
*/
@Service
public class IndexService {
@Autowired
private StaffInfoApi staffInfoApi;
@Autowired
private StaffOrgApi staffOrgApi;
/**
* 通过code参数获取用户详情
*
* @param code 临时code凭证
* @return
*/
public ResultBean<IndexDetailsUser> indexUserDetails(String code) {
ResultBean<IndexDetailsUser> rb = ResultBean.fireFail();
//请求接口地址
String url = IndexUtils.detailsUrl;
String result = "";
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("code", code);
result = common(params, url);
JSONObject jsonObject = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, Object>>() {
});
if (map.isEmpty()) {
return rb.setData(new IndexDetailsUser());
} else {
Map<String, Object> dataMap = ConstantUtils.getMap(map, "data");
Map<String, Object> userBaseInfoMap = ConstantUtils.getMap(dataMap, "userBaseInfo");
Map<String, Object> userLoginInfoMap = ConstantUtils.getMap(dataMap, "userLoginInfo");
List<String> roleList = ConstantUtils.getStringListData(dataMap, "roleIds");
// 将 Map 转换为 实体类
UserBaseInfo userBaseInfo = JSON.parseObject(JSON.toJSONString(userBaseInfoMap), UserBaseInfo.class);
UserLoginInfo userLoginInfo = JSON.parseObject(JSON.toJSONString(userLoginInfoMap), UserLoginInfo.class);
IndexDetailsUser indexDetailsUser = new IndexDetailsUser();
indexDetailsUser.setUserBaseInfo(userBaseInfo);
indexDetailsUser.setUserLoginInfo(userLoginInfo);
indexDetailsUser.setRoldIds(roleList);
return rb.success().setData(indexDetailsUser);
}
}
/**
* 通过单位id查询单位详情
*
* @param organizationId 单位id
* @return
*/
public ResultBean<IndexDetailsOrg> indexOrgDetails(String organizationId) {
ResultBean<IndexDetailsOrg> rb = ResultBean.fireFail();
//请求接口地址
String url = IndexUtils.orgDetails;
String result = "";
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("organizationId", organizationId);
result = common(params, url);
JSONObject jsonObject = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> dataMap = ConstantUtils.getMap(map, "data");
if (dataMap == null) {
return rb.setData(new IndexDetailsOrg());
}
// 将 Map 转换为 实体类
IndexDetailsOrg indexDetailsOrg = JSON.parseObject(JSON.toJSONString(dataMap), IndexDetailsOrg.class);
return rb.success().setData(indexDetailsOrg);
}
/**
* 获取区域列表
*
* @param indexDetailsRegionQuery 省市县code值
* @return
*/
public ResultBean<IndexDetailsRegion> indexRegionDetails(IndexDetailsRegionQuery indexDetailsRegionQuery) {
ResultBean<IndexDetailsRegion> rb = ResultBean.fireFail();
IndexDetailsRegion indexDetailsRegion = new IndexDetailsRegion();
String result = null;
// 请求接口地址
String url = IndexUtils.regionList;
// 请求参数
Map<String, String> params = new TreeMap<>();
result = common(params, url);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> dataMap = ConstantUtils.getMap(map, "data");
if (StringUtils.isNotBlank(indexDetailsRegionQuery.getProvinceCode())) {
Map<String, Object> provinceMap = ConstantUtils.getMap(dataMap, "86");
//根据省区划代码获取省名称
String province = ConstantUtils.getString(provinceMap, indexDetailsRegionQuery.getProvinceCode(), "");
indexDetailsRegion.setProvince(province);
if (StringUtils.isNotBlank(indexDetailsRegionQuery.getCityCode())) {
Map<String, Object> cityMap = ConstantUtils.getMap(dataMap, indexDetailsRegionQuery.getProvinceCode());
String city = ConstantUtils.getString(cityMap, indexDetailsRegionQuery.getCityCode(), "");
indexDetailsRegion.setCity(city);
if (StringUtils.isNotBlank(indexDetailsRegionQuery.getCountyCode())) {
Map<String, Object> countyMap = ConstantUtils.getMap(dataMap, indexDetailsRegionQuery.getCityCode());
String county = ConstantUtils.getString(countyMap, indexDetailsRegionQuery.getCountyCode(), "");
indexDetailsRegion.setCounty(county);
}
}
} else {
return rb.setData(indexDetailsRegion);
}
return rb.success().setData(indexDetailsRegion);
}
/**
* 根据县区级区划代码获取区域的全路径
*
* @param countyCode 县区级区划代码
* @return
*/
public ResultBean<String> selectPathByCountyCode(String countyCode) {
ResultBean<String> rb = ResultBean.fireFail();
String result = null;
// 请求接口地址
String url = IndexUtils.regionList;
// 请求参数
Map<String, String> params = new TreeMap<>();
result = common(params, url);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> dataMap = ConstantUtils.getMap(map, "data");
Map<String, Object> provinceMap = ConstantUtils.getMap(dataMap, "86");
List<String> keyList = new ArrayList<String>(provinceMap.keySet());
//省市县全路径
String regionPath = "";
//省
String provinceCode = "";
String cityCode = "";
boolean isTrue = false;
if (keyList.size() != 0) {
for (int i = 0; i < keyList.size(); i++) {
provinceCode = keyList.get(i);
//查询省下的市
Map<String, Object> cityMap = ConstantUtils.getMap(dataMap, keyList.get(i));
List<String> cityKeyList = new ArrayList<String>(cityMap.keySet());
for (int j = 0; j < cityKeyList.size(); j++) {
//查询市下所有的县区
cityCode = cityKeyList.get(j);
Map<String, Object> countyMap = ConstantUtils.getMap(dataMap, cityKeyList.get(j));
List<String> countyKeyList = new ArrayList<String>(countyMap.keySet());
if (countyKeyList.contains(countyCode)) {
isTrue = true;
regionPath = provinceCode + "/" + cityCode + "/" + countyCode;
} else {
continue;
}
}
}
}
if (!isTrue) {
return rb.setData(countyCode);
}
return rb.success().setData(regionPath);
}
/**
* 单点登录对接公共部分
*
* @param params 参数
* @param url 请求接口地址
* @return
*/
public String common(Map<String, String> params, String url) {
String result = "";
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
try {
result = ConstantUtils.net2(url, params, "GET", ticket);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public UserInfoVo selectUserInfo(UserBaseInfo userBaseInfo, UserLoginInfo userLoginInfo, List<String> roleList) {
UserInfoVo vo = new UserInfoVo();
vo.setSid(userLoginInfo.getId());
vo.setUserName(userLoginInfo.getName());
vo.setMobile(userBaseInfo.getPhone());
vo.setOrganizationSid(userBaseInfo.getOrganizationId());
vo.setIsAdmin(userBaseInfo.getType());
vo.setName(userBaseInfo.getName());
vo.setOrganizationName(userBaseInfo.getOrganizationName());
vo.setDepartmentName(userBaseInfo.getDepartmentName());
vo.setRoleName(userBaseInfo.getCurrentRole());
vo.setOrgRoleName(userBaseInfo.getCurrentRole());
if (StringUtils.isNotBlank(userBaseInfo.getOrganizationRegion())) {
if (userBaseInfo.getOrganizationRegion().indexOf(",") != -1) {
vo.setRegionSid("/" + userBaseInfo.getOrganizationRegion().replaceAll(",", "/"));
} else {
vo.setRegionSid("");
}
} else {
vo.setRegionSid("");
}
vo.setRoleSids(roleList);
//获取单位类别
List<String> list = new ArrayList<String>();
if (StringUtils.isNoneBlank(userBaseInfo.getOrganizationType())) {
String str = userBaseInfo.getOrganizationType();
if (str.indexOf(",") >= 0) {
String s[] = str.split(",");
for (int i = 0; i < s.length; i++) {
list.add(s[i]);
}
}
}
vo.setOrgTypeKeys(list);
String typeValue = "";
int type = userBaseInfo.getType();
if (type == 0) {
typeValue = "系统管理员";
} else if (type == 1) {
typeValue = "单位管理员";
} else if (type == 2) {
typeValue = "一般用户";
} else if (type == 3) {
typeValue = "注册用户";
}
vo.setOrgRoleName(typeValue);
return vo;
}
public StaffInfo selectStaff(UserBaseInfo userBaseInfo) {
StaffInfo staff = new StaffInfo();
int count = staffInfoApi.selectByIdCardCount(userBaseInfo.getIdCard());
if (count == 0) {
staff.setIdNo(userBaseInfo.getIdCard());
staff.setName(userBaseInfo.getName());
staff.setUSid(userBaseInfo.getUserId());
} else {
staff = staffInfoApi.selectByIdCard(userBaseInfo.getIdCard());
staff.setIdNo(userBaseInfo.getIdCard());
staff.setName(userBaseInfo.getName());
staff.setUSid(userBaseInfo.getUserId());
}
staffInfoApi.saveOrUpdate(staff);
ResultBean<StaffOrgVo> staffOrgInfo = staffOrgApi.staffOrgInfo(staff.getSid());
StaffOrgVo data = staffOrgInfo.getData();
if (staffOrgInfo.getSuccess()) {
if (StringUtils.isNoneBlank(userBaseInfo.getOrganizationId())) {
data.setOrgSid(userBaseInfo.getOrganizationId());
data.setOrganizationName(userBaseInfo.getOrganizationName());
}
} else {
if (StringUtils.isNoneBlank(userBaseInfo.getOrganizationId())) {
data.setOrgSid(userBaseInfo.getOrganizationId());
data.setOrganizationName(userBaseInfo.getOrganizationName());
data.setStaffSid(staff.getSid());
}
}
staffOrgApi.saveOrUpdate(data);
return staff;
}
/**
* 获取类别
*
* @param indexLbListQuery
* @return
*/
public ResultBean<List<IndexLbListVo>> selectLbList(IndexLbListQuery indexLbListQuery) {
ResultBean<List<IndexLbListVo>> rb = ResultBean.fireFail();
//请求接口地址
String url = IndexUtils.lbList;
String result = "";
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("typeCode", indexLbListQuery.getDictType());
result = common(params, url);
JSONObject jsonObject = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> list1 = ConstantUtils.getListData(map, "data");
List<IndexLbListVo> indexLbListVoList = new ArrayList<>();
if (StringUtils.isNotBlank(indexLbListQuery.getDictKey())) {
if (list1.size() > 0) {
for (int i = 0; i < list1.size(); i++) {
IndexLbListVo indexLbListVo = JSON.parseObject(JSON.toJSONString(list1.get(i)), IndexLbListVo.class);
if (indexLbListQuery.getDictKey().equals(indexLbListVo.getDictKey())) {
indexLbListVoList.add(indexLbListVo);
} else {
continue;
}
}
}
} else {
if (list1.size() > 0) {
for (int i = 0; i < list1.size(); i++) {
IndexLbListVo indexLbListVo = JSON.parseObject(JSON.toJSONString(list1.get(i)), IndexLbListVo.class);
indexLbListVoList.add(indexLbListVo);
}
}
}
return rb.success().setData(indexLbListVoList);
}
/**
* 获取单位下的所有人员信息
*
* @param indexUserListQuery
* @return
*/
public ResultBean<IndexOrgUserVo> selectUserList(IndexUserListQuery indexUserListQuery) {
ResultBean<IndexOrgUserVo> rb = ResultBean.fireFail();
//请求接口地址
String url = IndexUtils.userList;
String result = "";
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("current", indexUserListQuery.getCurrent().toString());
params.put("size", indexUserListQuery.getSize().toString());
params.put("orgId", indexUserListQuery.getOrgId());
result = common(params, url);
JSONObject jsonObject = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String,Object> map1 = ConstantUtils.getMap(map,"data");
List<Map<String, Object>> mapList = ConstantUtils.getListData(map1, "data");
return rb.success().setData(null);
}
public String deptUsetList(String organizationId) {
ResultBean<IndexDetailsOrg> rb = ResultBean.fireFail();
//请求接口地址
String url = IndexUtils.deptUserList;
String result = "";
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("orgId", organizationId);
result = common(params, url);
return result;
}
public ResultBean<IndexOrgCodeDetailsVo> selectOrgByCodeOrName(IndexOrgSelectQuery indexOrgSelectQuery) {
ResultBean<IndexOrgCodeDetailsVo> rb = ResultBean.fireFail();
String result = null;
// 请求接口地址
String url = IndexUtils.selectOrg;
// 请求参数
Map<String, String> params = new TreeMap<>();
if (StringUtils.isNotBlank(indexOrgSelectQuery.getCreditCode())) {
params.put("creditCode", indexOrgSelectQuery.getCreditCode());
}
if (StringUtils.isNotBlank(indexOrgSelectQuery.getName())) {
params.put("name", indexOrgSelectQuery.getName());
}
if (indexOrgSelectQuery.getType() != null) {
params.put("type", indexOrgSelectQuery.getType().toString());
}
result = common(params, url);
System.out.println(result);
JSONObject jsonObject = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(jsonObject.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> dataMap = ConstantUtils.getMap(map, "data");
// 将 Map 转换为 实体类
IndexOrgCodeDetailsVo indexOrgCodeDetailsVo = JSON.parseObject(JSON.toJSONString(dataMap), IndexOrgCodeDetailsVo.class);
if (indexOrgCodeDetailsVo == null) {
return rb.setData(new IndexOrgCodeDetailsVo());
}
return rb.success().setData(indexOrgCodeDetailsVo);
}
public Map<String,Object> selectByOrgSid(String orgSid,String deptId){
Map<String,Object> deptMap = new HashMap<>();
List<DepartmentOneVo> list=new ArrayList<DepartmentOneVo>();
DepartmentOneVo v=new DepartmentOneVo();
String deptUsetList = deptUsetList(orgSid);
JSONObject jsonObject1 = JSONObject.parseObject(deptUsetList);
Map<String, Object> map = JSONObject.parseObject(jsonObject1.toJSONString(), new TypeReference<Map<String, Object>>() {
});
List<Map<String, Object>> listData = ConstantUtils.getListData(map, "data");
Map<String, Object> dataMap=listData.get(0);
// 将 Map 转换为 实体类
IndexDeptUser indexDeptUser= JSON.parseObject(JSON.toJSONString(dataMap), IndexDeptUser.class);
if(indexDeptUser!=null) {
List<IndexDeptUserOne> children = indexDeptUser.getChildren();
if(children!=null) {
for (int i = 0; i < children.size(); i++) {
IndexDeptUserOne indexDeptUserOne = children.get(i);
if(indexDeptUserOne != null){
if(StringUtils.isNotBlank(deptId)){
if(deptId.equals(indexDeptUserOne.getId().toString())){
String deptName = indexDeptUserOne.getName();
String id = indexDeptUserOne.getOwnerId();
deptMap.put("deptName",deptName);
deptMap.put("deptId",id);
break;
}
}
}
}
}
}
return deptMap;
}
}

View File

@@ -0,0 +1,243 @@
package com.yxt.jlzx.system.biz.menu;
import com.yxt.jlzx.system.api.menu.*;
import com.yxt.jlzx.system.api.region.RegionVo;
import io.swagger.annotations.Api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import javafx.beans.binding.ObjectExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.source.Source;
import com.yxt.jlzx.system.biz.source.SourceService;
/**
* @author yxt_mtl
* @date 2020/9/30 09:10
* @description 菜单信息
*/
@Controller
@RequestMapping("v1/menus")
@Api(tags = "菜单管理")
public class MenuApiImpl implements MenuApi {
@Autowired
private MenuService menuService;
@Autowired
private SourceService sourceService;
/**
* 菜单分页列表
*
* @param pagerQuery 查询条件
* @return 菜单分页列表
*/
@Override
public ResultBean<PagerVo<MenuVo>> pageList(PagerQuery<MenuQuery> pagerQuery) {
ResultBean<PagerVo<MenuVo>> rb = ResultBean.fireFail();
IPage<MenuVo> page = menuService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<MenuVo> pv_result = PagerUtil.pageToVo(page, null);
return rb.success().setData(pv_result);
}
/**
* 菜单树形分页列表
*
* @param query 查询条件
* @return 菜单分页列表
*/
@Override
public ResultBean<List<MenuTreeVo>> treePageList(MenuQuery query) {
ResultBean<List<MenuTreeVo>> rb = ResultBean.fireFail();
query.setPSid("0");
List<MenuVo> pv_result = menuService.list(query);
List<MenuTreeVo> menuTreeVo_list = new ArrayList<>();
for (int i = 0; i < pv_result.size(); i++) {
MenuQuery menuQuery = new MenuQuery();
menuQuery.setPSid(pv_result.get(i).getSid());
MenuTreeVo treeVo = new MenuTreeVo();
treeVo.setMenuVo(pv_result.get(i));
treeVo.setChilds(menuService.list(menuQuery));
menuTreeVo_list.add(treeVo);
}
return rb.success().setData(menuTreeVo_list);
}
@Override
public ResultBean<List<MenuTree2Vo>> treePageList2(MenuTreeQuery query) {
ResultBean<List<MenuTree2Vo>> rb = ResultBean.fireFail();
List<MenuTree2Vo> menuTree2VoList = menuService.treeList(query);
return rb.success().setData(menuTree2VoList);
}
/**
* 所有菜单树形列表,1资源名称2一级菜单3二级菜单...
*
* @return 所有菜单树形列表
*/
@Override
public ResultBean<List<Map<String, Object>>> list() {
//以下有关资源的代码,需要通过获取动态的资源列表
List<Map<String, Object>> list_vo = new ArrayList<Map<String, Object>>();
List<Source> list_sources = sourceService.list();
for (int s = 0; s < list_sources.size(); s++) {
Map<String, Object> map_source = new HashMap<String, Object>();
map_source.put("sourceSid", list_sources.get(s).getSid());
map_source.put("sourceId", list_sources.get(s).getSourceId());
map_source.put("sourceName", list_sources.get(s).getSourceName());
map_source.put("childMenus", menuService.getMenuTree(list_sources.get(s).getSid(), "0"));
list_vo.add(map_source);
}
ResultBean<List<Map<String, Object>>> objectResultBean = ResultBean.fireSuccess();
return objectResultBean.setData(list_vo);
}
/**
* 保存
*
* @param menuDto 菜单dto对象
* @return ResultBean
*/
@Override
public ResultBean save(MenuDto menuDto) {
Menu menu = new Menu();
menuDto.fillEntity(menu);
Map<String, Object> map = new HashMap<String, Object>();
map.put("menuName", menu.getMenuName());
map.put("sourceSid", menu.getSourceSid());
map.put("pSid", menu.getPSid());
List<Menu> list = menuService.listByMap(map);
if (list.size() > 0) {
return ResultBean.fireFail().setMsg("菜单名称已存在!");
}
if (!menuService.save(menu)) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setData(menu.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值.
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean update(MenuDto menuDto, String sid) throws Exception {
Menu menu = menuService.fetchBySid(sid);
if (null == menu) {
return ResultBean.fireFail().setMsg("该菜单不存在");
}
Map<String, Object> map = new HashMap<>();
map.put("menuName", menuDto.getMenuName());
map.put("sourceSid", menuDto.getSourceSid());
map.put("pSid", menu.getPSid());
// List<Menu> list = menuService.listByMap(map);
// if (list.size() > 0) {
// return ResultBean.fireFail().setMsg("菜单名称已存在!");
// }
if (0 == menuService.updateBySid(menuDto.toMap(), sid)) {
return ResultBean.fireFail().setMsg("更新失败");
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
/**
* 修改排序号
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean updateSortNo(String sid, int sortNo) throws Exception {
Menu menu = menuService.fetchBySid(sid);
if (null == menu) {
return ResultBean.fireFail().setMsg("该菜单不存在");
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("sortNo", sortNo);
if (0 == menuService.updateBySid(map, sid)) {
return ResultBean.fireFail().setMsg("更新失败");
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
@Override
public ResultBean<List<Menu>> listByMapOne(Map<String, Object> columnMap) {
List<Menu> list_child_menu = menuService.listByMap(columnMap);
return new ResultBean<List<Menu>>().success().setData(list_child_menu);
}
/**
* 删除
*
* @param sid 菜单sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
//判断该菜单下是否有子集菜单,若存在则先删除子集
List<Menu> menuList = menuService.selectByPsid(sid);
if (menuList.size() > 0) {
return ResultBean.fireFail().setMsg("该菜单下有子集菜单,请先删除子集菜单");
}
if (0 == menuService.deleteBySid(sid)) {
return ResultBean.fireFail().setMsg("删除失败");
}
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 修改页面初始化数据
*
* @param sid 菜单sid
* @return ResultBean
*/
@Override
public ResultBean<MenuVo> getVo(String sid) {
Menu menu = menuService.fetchBySid(sid);
if (null == menu) {
return new ResultBean().fail().setData(null);
}
MenuVo menuVo = new MenuVo();
menuVo.setSid(menu.getSid());
menuVo.setMenuName(menu.getMenuName());
menuVo.setMenuUrl(menu.getMenuUrl());
menuVo.setIconUrl(menu.getIconUrl());
menuVo.setPageUrl(menu.getPageUrl());
menuVo.setPSid(menu.getPSid());
menuVo.setSourceSid(menu.getSourceSid());
menuVo.setSortNo(menu.getSortNo());
menuVo.setAlwaysShow(menu.getAlwaysShow());
return new ResultBean().success().setData(menuVo);
}
@Override
public ResultBean<List<MenuVo>> list(@Valid MenuQuery query) {
// TODO Auto-generated method stub
return null;
}
}

View File

@@ -0,0 +1,38 @@
package com.yxt.jlzx.system.biz.menu;
import java.util.List;
import com.yxt.jlzx.system.api.menu.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
/**
* @author yxt_mtl
* @date 2020/9/30 09:23
* @description
*/
@Mapper
public interface MenuMapper extends BaseMapper<Menu> {
//分页列表
IPage<MenuVo> pageList(IPage<MenuQuery> page, @Param(Constants.WRAPPER) Wrapper<MenuVo> qw);
//不分页列表
List<MenuVo> list(@Param("query") MenuQuery query);
/**
* 查询该菜单下是否存在子集
*
* @param sid 父级sid
* @return
*/
List<Menu> selectByPsid(String sid);
List<MenuTree2Vo> treeList(@Param("query") MenuTreeQuery query);
List<MenuTree2Vo> treeList1(@Param("query") MenuTreeQuery query);
}

View File

@@ -0,0 +1,141 @@
<?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.yxt.jlzx.system.biz.menu.MenuMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.menu.MenuVo">
SELECT m.sid,
m.menuName,
m.menuUrl,
m.pageUrl,
m.iconUrl,
m.sourceSid,
m.isShow,
m.pSid,
m.remarks,
m.sortNo,
m.pageName,
s.sourceName,
m.alwaysShow
FROM menu m
LEFT JOIN source s ON s.sid = m.sourceSid
${ew.customSqlSegment}
</select>
<select id="list" resultType="com.yxt.jlzx.system.api.menu.MenuVo">
SELECT m.sid,
m.menuName,
m.menuUrl,
m.pageUrl,
m.pageName,
m.pageUrlRedirect,
m.pageAliasName,
m.iconUrl,
m.sourceSid,
s.sourceName,
m.isShow,
m.pSid,
m.alwaysShow,
<if test="query.pSid != null and query.pSid != ''">
(select menuName from menu where sid = m.psid) pname,
</if>
<if test="query.pSid == null and query.pSid == ''">
"" pname,
</if>
m.remarks,
m.sortNo
FROM menu m
LEFT JOIN source s ON s.sid = m.sourceSid
where 1 = 1
<if test="query.menuName != null and query.menuName != ''">
and m.menuName like concat('%', #{query.menuName}, '%')
</if>
<if test="query.pSid != null and query.pSid != ''">
and m.pSid = #{query.pSid}
</if>
<if test="query.sourceSid != null and query.sourceSid != ''">
and m.sourceSid = #{query.sourceSid}
</if>
<if test="query.sourceName != null and query.sourceName != ''">
and s.sourceName like concat('%', #{query.sourceName}, '%')
</if>
order by m.sourceSid, m.sortNo
</select>
<select id="selectByPsid" resultType="com.yxt.jlzx.system.api.menu.Menu">
SELECT *
FROM menu
WHERE pSid = #{sid}
</select>
<select id="treeList" resultType="com.yxt.jlzx.system.api.menu.MenuTree2Vo">
SELECT m.sid,
m.menuName,
m.menuUrl,
m.pageUrl,
m.pageName,
m.pageUrlRedirect,
m.pageAliasName,
m.iconUrl,
m.sourceSid,
s.sourceName,
m.isShow,
m.pSid,
m.alwaysShow,
<if test="query.pSid != null and query.pSid != ''">
(select menuName from menu where sid = #{query.pSid}) pname,
</if>
<if test="query.pSid == null and query.pSid == ''">
'' pname,
</if>
m.remarks,
m.sortNo
FROM menu m
LEFT JOIN source s ON s.sid = m.sourceSid
where 1 = 1
<if test="query.menuName != null and query.menuName != ''">
and m.menuName like concat('%', #{query.menuName}, '%')
</if>
<if test="query.pSid != null and query.pSid != ''">
and m.pSid = #{query.pSid}
</if>
<if test="query.sourceSid != null and query.sourceSid != ''">
and m.sourceSid = #{query.sourceSid}
</if>
<if test="query.sourceName != null and query.sourceName != ''">
and s.sourceName like concat('%', #{query.sourceName}, '%')
</if>
order by m.sourceSid, m.sortNo
</select>
<select id="treeList1" resultType="com.yxt.jlzx.system.api.menu.MenuTree2Vo">
SELECT m.sid,
m.menuName,
m.menuUrl,
m.pageUrl,
m.pageName,
m.pageUrlRedirect,
m.pageAliasName,
m.iconUrl,
m.sourceSid,
s.sourceName,
m.isShow,
m.pSid,
m.alwaysShow,
m.remarks,
m.sortNo
FROM menu m
LEFT JOIN source s ON s.sid = m.sourceSid
where 1 = 1
<if test="query.menuName != null and query.menuName != ''">
and m.menuName like concat('%', #{query.menuName}, '%')
</if>
<if test="query.sid != null and query.sid != ''">
and m.sid = #{query.sid}
</if>
<if test="query.sourceSid != null and query.sourceSid != ''">
and m.sourceSid = #{query.sourceSid}
</if>
<if test="query.sourceName != null and query.sourceName != ''">
and s.sourceName like concat('%', #{query.sourceName}, '%')
</if>
order by m.sourceSid, m.sortNo
</select>
</mapper>

View File

@@ -0,0 +1,402 @@
package com.yxt.jlzx.system.biz.menu;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.menu.*;
import com.yxt.jlzx.system.api.role.RoleQuery;
import com.yxt.jlzx.system.api.rolemenu.RoleMenuQuery;
import com.yxt.jlzx.system.api.rolemenu.RoleMenuVo;
import com.yxt.jlzx.system.api.source.Source;
import com.yxt.jlzx.system.api.systemlog.SystemLogQuery;
import com.yxt.jlzx.system.api.systemlog.SystemLogVo;
import com.yxt.jlzx.system.biz.source.SourceService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author yxt_mtl
* @date 2020/9/30 09:21
* @description
*/
@Service
public class MenuService extends MybatisBaseService<MenuMapper, Menu> {
@Autowired
SourceService sourceService;
// 分页列表
public IPage<MenuVo> pageList(PagerQuery<MenuQuery> pagerQuery) {
// mybits所用的分页对对象
IPage<MenuQuery> page = PagerUtil.queryToPage(pagerQuery);
// mybits所用的查询条件封装类
QueryWrapper<MenuVo> qw = buildQueryWrapper(pagerQuery.getParams());
return baseMapper.pageList(page, qw);
}
// 不分页列表
public List<MenuVo> list(MenuQuery query) {
// mybits所用的查询条件封装类
//QueryWrapper<MenuVo> qw = buildQueryWrapperForList(query);
return baseMapper.list(query);
}
/**
* 解析和组装查询条件封装在qw中
*
* @param pagerQuery
* @return
*/
private QueryWrapper<MenuVo> buildQueryWrapperForList(MenuQuery query) {
QueryWrapper<MenuVo> qw = new QueryWrapper<>();
if (query != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(query
.getMenuName()))
qw.like("m.menuName", query.getMenuName());
if (org.apache.commons.lang3.StringUtils.isNotBlank(query
.getPSid()))
qw.eq("m.pSid", query.getPSid());
if (org.apache.commons.lang3.StringUtils.isNotBlank(query
.getSourceSid()))
qw.eq("m.sourceSid", query.getSourceSid());
if (org.apache.commons.lang3.StringUtils.isNotBlank(query
.getSourceName()))
qw.eq("s.sourceName", query.getSourceName());
qw.orderByAsc("sourceSid,sortNo");
}
return qw;
}
/**
* 解析和组装查询条件封装在qw中
*
* @param pagerQuery
* @return
*/
private QueryWrapper<MenuVo> buildQueryWrapper(MenuQuery pagerQuery) {
QueryWrapper<MenuVo> qw = new QueryWrapper<>();
if (pagerQuery != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery
.getMenuName()))
qw.like("m.menuName", pagerQuery.getMenuName());
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery
.getSourceName()))
qw.like("s.sourceName", pagerQuery.getSourceName());
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery
.getPSid()))
qw.eq("m.pSid", pagerQuery.getPSid());
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery
.getSourceSid()))
qw.eq("m.sourceSid", pagerQuery.getSourceSid());
qw.orderByAsc("m.sourceSid,m.sortNo");
}
return qw;
}
//菜单管理--菜单层级列表--开始
/**
* 获取给定资源和菜单的子菜单树形列表
*
* @return 所有菜单列表
*/
public List<Map<String, Object>> getMenuTree(String sourceSid,
String menuSid) {
// 1.查询所有source
// 2.遍历list_source,根据sourcesid和pid=0获取第一层级list_menu1
// 3.遍历第一层级list_menu1,根据psid=menu1.sid获取第二层级list_menu2
List<Map<String, Object>> list_menus_map = new ArrayList<Map<String, Object>>();
Map<String, Object> map_menu_arg = new HashMap<String, Object>();
map_menu_arg.put("sourceSid", sourceSid);
map_menu_arg.put("pSid", menuSid);
List<Menu> list_menu = listByMap(map_menu_arg);
for (int i = 0; i < list_menu.size(); i++) {
Map<String, Object> map_menu = new HashMap<String, Object>();
map_menu.put("sid", list_menu.get(i).getSid());
map_menu.put("menuName", list_menu.get(i).getMenuName());
map_menu.put("menuUrl", list_menu.get(i).getMenuUrl());
map_menu.put("pageUrl", list_menu.get(i).getPageUrl());
map_menu.put("iconUrl", list_menu.get(i).getIconUrl());
map_menu.put("isShow", list_menu.get(i).getIsShow());
getChildMenus(list_menu.get(i).getSid(), map_menu);
list_menus_map.add(map_menu);
}
return list_menus_map;
}
/**
* 获取给定菜单的子菜单列表
*
* @param menuSid
* @param map_menu
*/
private void getChildMenus(String menuSid, Map<String, Object> map_menu) {
Map<String, Object> map_arg = new HashMap<String, Object>();
map_arg.put("pSid", menuSid);
List<Menu> list_child_menu = listByMap(map_arg);
// if(list_child_menu.size()>0)
// {
List<Map<String, Object>> list_child = new ArrayList<Map<String, Object>>();
for (int i = 0; i < list_child_menu.size(); i++) {
Map<String, Object> map_child_menu = new HashMap<String, Object>();
map_child_menu.put("sid", list_child_menu.get(i).getSid());
map_child_menu
.put("menuName", list_child_menu.get(i).getMenuName());
map_child_menu.put("menuUrl", list_child_menu.get(i).getMenuUrl());
map_child_menu.put("pageUrl", list_child_menu.get(i).getPageUrl());
map_child_menu.put("iconUrl", list_child_menu.get(i).getIconUrl());
map_child_menu.put("isShow", list_child_menu.get(i).getIsShow());
list_child.add(map_child_menu);
getChildMenus(list_child_menu.get(i).getSid(), map_child_menu);
}
map_menu.put("childMenus", list_child);
// }
}
//菜单管理--菜单层级列表--结束
///以下为重构内容
/**
* 所有资源的菜单树形列表角色授权时的菜单列表map_rolemenus
* 树形层级:第一级资源名称 第二级一级菜单 第三级二级菜单
*
* @param query:[sourceSid]
* @return
*/
public List<Map<String, Object>> getMenuTree(Map<String, Object> map_selectMenus) {
List<Map<String, Object>> list_vo = new ArrayList<Map<String, Object>>();
//获取资源列表
List<Source> list_sources = sourceService.list();
//遍历资源列表
for (int s = 0; s < list_sources.size(); s++) {
Map<String, Object> map_source = new HashMap<String, Object>();
map_source.put("sid", list_sources.get(s).getSid());
map_source.put("sourceId", list_sources.get(s).getSourceId());
map_source.put("menuName", list_sources.get(s).getSourceName());
MenuQuery query = new MenuQuery();
query.setSourceSid(list_sources.get(s).getSid());
//资源的所有菜单列表
List<MenuVo> list_menuofSource = list(query);
//获取资源下面的菜单树形列表
map_source.put("children", this.getSourceMenuTree(list_menuofSource, map_selectMenus));
list_vo.add(map_source);
}
return list_vo;
}
///----获某个资源的菜单树形列表(内存操作) 开始----
/**
* 资源菜单树形列表
*
* @param query:roleSids,sourceSid
* @return 资源菜单树形列表(第一级一级菜单 第二级二级菜单)
*/
public List<Map<String, Object>> getSourceMenuTree(List<MenuVo> list_menu, Map<String, Object> map_selectMenus) {
//获取当前资源的菜单列表
List<Map<String, Object>> list_menus_map = new ArrayList<Map<String, Object>>();
//获取资源第一级菜单列表
List<MenuVo> list_firstLevel_menu = list_menu.stream().filter(s -> s.getPSid().equals("0")).collect(Collectors.toList());
//遍历资源的第一级菜单
for (int i = 0; i < list_firstLevel_menu.size(); i++) {
Map<String, Object> map_firstLevel_menu = getMenuTreeFromStream(list_firstLevel_menu.get(i).getSid(), list_menu, map_selectMenus);
//把该菜单挂在当前菜单列表中
if (null != map_firstLevel_menu)
list_menus_map.add(map_firstLevel_menu);
}
return list_menus_map;
}
/**
* 递归把list转换成菜单树形列表
*
* @param psid
* @param list_menu
* @return
*/
private Map<String, Object> getMenuTreeFromStream(String psid, List<MenuVo> list_menu, Map<String, Object> map_selectMenus) {
//获取当前菜单
List<MenuVo> list_current_menu = list_menu.stream().filter(s -> s.getSid().equals(psid)).collect(Collectors.toList());
if (null == list_current_menu || 0 == list_current_menu.size())
return null;
Map<String, Object> map_menu = getMenuMap(list_current_menu.get(0), map_selectMenus);
//2.获取菜单的子菜单列表
//存储最终子菜单列表结果
List<Map<String, Object>> list_child = new ArrayList<Map<String, Object>>();
//获取子菜单列表
List<MenuVo> list_child_menu = list_menu.stream().filter(s -> s.getPSid().equals(psid)).collect(Collectors.toList());
for (int i = 0; i < list_child_menu.size(); i++) {
//获取该菜单子菜单列表
Map<String, Object> map_child_menu = getMenuTreeFromStream(list_child_menu.get(i).getSid(), list_menu, map_selectMenus);
//把该菜单挂在当前菜单列表中
if (null != map_child_menu)
list_child.add(map_child_menu);
}
//把该菜单列表放到父菜单的childMenus中
map_menu.put("children", list_child);
return map_menu;
}
/**
* 构造菜单的结果map
*
* @param RoleMenuVo:菜单Vo实体对象
* @param map_rolemenus:需要选中的菜单map
* @return
*/
private Map<String, Object> getMenuMap(MenuVo menuVo, Map<String, Object> map_selectMenus) {
Map<String, Object> map_menu = new HashMap<String, Object>();
if (null != map_selectMenus) {
//角色授权时,菜单列表
map_menu.put("sid", menuVo.getSid());
map_menu.put("menuName", menuVo.getMenuName() + (StringUtils.isNotBlank(menuVo.getRemarks()) ? "(" + menuVo.getRemarks() + ")" : ""));
map_menu.put("menuUrl", menuVo.getMenuUrl());
map_menu.put("pageUrl", menuVo.getPageUrl());
map_menu.put("iconUrl", menuVo.getIconUrl());
map_menu.put("isShow", menuVo.getIsShow());
if (menuVo.getAlwaysShow() == 0) {
map_menu.put("alwaysShow", false);
} else if (menuVo.getAlwaysShow() == 1) {
map_menu.put("alwaysShow", true);
}
//如果角色已有的菜单则设置选中并移除map中的项否则设置不选中
if (map_selectMenus.containsKey(menuVo.getSid())) {
map_menu.put("isCheck", 1);
map_selectMenus.remove(menuVo.getSid());
} else {
map_menu.put("isCheck", 0);
}
//2021.09.16添加待办的数量
map_menu.put("menuTaskCount", menuVo.getMenuTaskCount());
} else {
//左侧菜单列表
Map<String, Object> map_meta = new HashMap<String, Object>();
map_meta.put("title", menuVo.getMenuName());
map_meta.put("icon", menuVo.getIconUrl());
map_menu.put("meta", map_meta);
map_menu.put("redirect", menuVo.getPageUrlRedirect());
//路径
map_menu.put("path", menuVo.getPageUrl() != null && !menuVo.getPageUrl().equals("") ? menuVo.getPageUrl() : "/" + menuVo.getPageName());
map_menu.put("name", menuVo.getPageAliasName() != null && !menuVo.getPageAliasName().equals("") ? menuVo.getPageAliasName() : menuVo.getPageUrl());
//组件名
map_menu.put("component", menuVo.getPageName());
if (menuVo.getAlwaysShow() == 0) {
map_menu.put("alwaysShow", false);
} else if (menuVo.getAlwaysShow() == 1) {
map_menu.put("alwaysShow", true);
}
//2021.09.16添加待办的数量
map_menu.put("menuTaskCount", menuVo.getMenuTaskCount());
}
return map_menu;
}
/**
* 查询该菜单下是否存在子集
*
* @param sid 父级sid
* @return
*/
public List<Menu> selectByPsid(String sid) {
return baseMapper.selectByPsid(sid);
}
public List<MenuTree2Vo> treeList(MenuTreeQuery query) {
if (StringUtils.isBlank(query.getMenuName()) && StringUtils.isBlank(query.getSourceName())) {
query.setPSid("0");
List<MenuTree2Vo> list = baseMapper.treeList(query);
getChildMenu(list, query);
return list;
} else {
query.setPSid("0");
List<MenuTree2Vo> list = baseMapper.treeList(query);
if (list.size() == 0) {
query.setPSid("");
List<MenuTree2Vo> listChildren = baseMapper.treeList(query);
return listChildren;
} else {
getChildMenu(list, query);
return list;
}
}
}
public void getChildMenu(List<MenuTree2Vo> list, MenuTreeQuery query) {
list.forEach(menuTree -> {
String sid = menuTree.getSid();
query.setPSid(sid);
List<MenuTree2Vo> listChildren = baseMapper.treeList(query);
menuTree.setChilds(listChildren);
getChildMenu(listChildren, query);
});
}
public void getParentMenu(List<MenuTree2Vo> list, MenuTreeQuery query) {
list.forEach(menuTree -> {
if (menuTree != null) {
String pSid = menuTree.getPSid();
if (!"0".equals(pSid)) {
query.setSid(pSid);
List<MenuTree2Vo> listParent = baseMapper.treeList1(query);
if (listParent.size() != 0) {
listParent.forEach(a -> {
list.add(a);
});
}
getParentMenu(listParent, query);
}
}
});
}
}

View File

@@ -0,0 +1,64 @@
package com.yxt.jlzx.system.biz.organization;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.organization.AppOrganizationApi;
import com.yxt.jlzx.system.api.organization.AppOrganizationQuery;
import com.yxt.jlzx.system.api.organization.AppOrganizationVo;
import com.yxt.jlzx.system.api.user.User;
import com.yxt.jlzx.system.biz.user.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* @author dimengzhe
* @date 2020/12/9 9:21
* @description
*/
@Controller
@RequestMapping("v1/apporganizations")
@Api(tags = "app机构接口")
public class AppOrganizationApiImpl implements AppOrganizationApi {
@Autowired
private OrganizationService organizationService;
@Autowired
private UserService userService;
@Override
public ResultBean isCheck(AppOrganizationQuery appOrganizationQuery) {
//验证机构名称唯一
String name = appOrganizationQuery.getName();
int isOnlyByName = organizationService.selectByName(name);
if (isOnlyByName > 0) {
return ResultBean.fireFail().setMsg("单位名称已存在");
}
//验证机构代码唯一
String orgCode = appOrganizationQuery.getOrgCode();
int length = orgCode.length();
if (orgCode.length() != 18 && orgCode.length() != 9) {
return ResultBean.fireFail().setMsg("机构代码应为9位或18位");
}
int isOnlyByOrgCode = organizationService.selectByOrgCode(orgCode);
if (isOnlyByOrgCode > 0) {
return ResultBean.fireFail().setMsg("机构代码已存在");
}
//验证用户名和机构代码是否一致
String userName = appOrganizationQuery.getUserName();
if (!userName.equals(orgCode)) {
return ResultBean.fireFail().setMsg("登录用户名与机构代码不一致");
}
User user1 = userService.selectByUserName(userName);
if (user1 != null) {
return ResultBean.fireFail().setMsg("登录用户名已存在");
}
return ResultBean.fireSuccess().setMsg("");
}
@Override
public ResultBean<AppOrganizationVo> selectAppVo() {
AppOrganizationVo appOrganizationVo = organizationService.selectAppVo();
return new ResultBean<AppOrganizationVo>().success().setData(appOrganizationVo);
}
}

View File

@@ -0,0 +1,201 @@
package com.yxt.jlzx.system.biz.organization;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.organization.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/8/28 11:03
* @description 机构信息
*/
@Mapper
public interface OrganizationMapper extends BaseMapper<Organization> {
/**
* 行政机构分页列表
*
* @param pagerQuery 查询条件
* @param page 分页的数据结果
* @return 行政机构的分页列表
*/
public IPage<AdministrativeAgenciesVo> administrativeAgenciesPageList(
IPage<?> page, @Param(Constants.WRAPPER) Wrapper<AdministrativeAgenciesVo> qw);
public IPage<QtTechnicalInstitutionsVo> qtjsjg01(
IPage<?> page, @Param(Constants.WRAPPER) Wrapper<QtTechnicalInstitutionsVo> qw);
public IPage<QjsydwVo> qjsydw01(
IPage<?> page, @Param(Constants.WRAPPER) Wrapper<QjsydwVo> qw);
public IPage<QjsydwVo> searchqjsydw(IPage<OrganizationQuery> page,
@Param(Constants.WRAPPER) Wrapper<QjsydwVo> qw);
/**
* 技术机构分页列表
*
* @param pagerQuery 查询条件
* @param page 分页的数据结果
* @return 技术机构的分页列表
*/
public IPage<TechnicalInstitutionsVo> technicalInstitutionsPageList(IPage<?> page, @Param(Constants.WRAPPER) Wrapper<TechnicalInstitutionsVo> qw);
/**
* 单位信息修改初始化
*
* @param organizationSid 单位sid
* @return
*/
public OrganizationInitVo organizationInit(String organizationSid);
/**
* 根据机构名称查询机构信息表中是否有此名称的机构(验证机构名称是否唯一)
*
* @param name 机构名称
* @return 此名称的机构信息数量
*/
public int selectByName(String name);
public String selectByNameOne(String name);
/**
* 根据机构名称查询机构信息表中除此id的机构外是否还含有机构名称为name的机构验证机构名称的唯一性修改
*
* @param name 机构名称
* @param id 机构id
* @return 除此机构外机构名称为name的机构的数量
*/
public int selectByNameAndId(String name, Integer id);
/**
* 根据机构代码查询机构信息表中是否有此机构代码的机构(验证机构代码的唯一性)
*
* @param orgCode 机构代码
* @return 此机构代码的机构信息数量
*/
public int selectByOrgCode(String orgCode);
public Organization selectByOrgCode1(String orgCode);
/**
* 根据机构代码查询除此机构外其他机构是否存在机构代码为orgCode的机构验证机构代码的唯一性修改
*
* @param orgCode 机构代码
* @param id 机构id
* @return 除此机构外机构代码为orgCode的机构的数量
*/
public int selectByOrgCodeAndId(String orgCode, Integer id);
public int updateState(@Param("state") Integer state, @Param("sid") String sid);
/**
* 单位注册待审核列表
*
* @param pagerQuery 查询条件
* @param page 分页
* @return 单位注册待审核列表state为1的数据
*/
public IPage<OrganizationVerifyVo> verifyList(IPage<?> page, @Param(Constants.WRAPPER) Wrapper<OrganizationVerifyVo> qw);
/**
* 入职单位
*
* @return
*/
public List<InductionUnitVo> inductionUnitList();
/**
* 单位信息详情
*
* @param sid 单位sid
* @return
*/
public OrganizationDetailsVo organizationDetails(String sid);
/**
* 单位注册信息详情
*
* @param sid 单位sid
* @return 单位注册信息详情数据
*/
public OrganizationRegisterDetailsVo organizationRegisterDetails(String sid);
public int updateByIsDelete(String sid);
public List<String> regionSidList(String regionSid);
public AppOrganizationVo selectAppVo();
public List<Organization> selectByIsVerify();
public IPage<AdministrativeAgenciesVo> administrativeAgenciesPageListNew(IPage<OrganizationQuery> page,
@Param(Constants.WRAPPER) Wrapper<AdministrativeAgenciesVo> qw);
public OrganizationInitVo selectNameBySid(String sid);
/**
* 技术机构分页列表
*
* @param page 分页的数据结果
* @return 技术机构的分页列表
*/
public IPage<TechnicalInstitutionsVo> technicalInstitutionsPageListNew(IPage<OrganizationQuery> page, @Param(Constants.WRAPPER) Wrapper<TechnicalInstitutionsVo> qw);
public IPage<QtTechnicalInstitutionsVo> searchqtjsjg(IPage<OrganizationQuery> page, @Param(Constants.WRAPPER) Wrapper<QtTechnicalInstitutionsVo> qw);
public IPage<OrganizationVo2> searchzzdw(IPage<OrganizationQuery> page, @Param(Constants.WRAPPER) Wrapper<OrganizationVo2> qw);
public Organization selectByOrgName(String orgName);
List<Organization> selectOrgGOngshiByRegion(@Param("regionSid") String regionSid, @Param("dwjb") String dwjb);
List<Organization> selectUnconfirmedByPsid(@Param("regionSid") String regionSid);
List<Organization> selectExpireByPsid(@Param("regionSid") String regionSid, @Param("format") String format);
IPage<Organization> selectExpireOrganization(IPage<OrganizationQuery> page, @Param(Constants.WRAPPER) Wrapper<Organization> qw);
public int saveList(List<Organization> punishmentList);
Integer selectNumberConfirListShi(@Param("regionSid") String regionSid, @Param("format") String format);
OrgUpdateInitVo orgUpdateInit(@Param("userName") String userName, @Param("path") String path);
int orgUpdate(@Param("sid") String sid, @Param("gisInfo") String gisInfo, @Param("postAddress") String postAddress, @Param("businessLicense") String businessLicense,
@Param("contactMobile") String contactMobile, @Param("contactTelephone") String contactTelephone, @Param("contactMan") String contactMan, @Param("legalperson") String legalperson, @Param("orgName") String orgName, @Param("regionSid") String regionSid);
int updateGrantNo(@Param("sid") String sid, @Param("grantNo") String grantNo);
Organization getServicePhone(@Param("regionSid") String regionSid, @Param("dwjb") String dwjb);
/*
查询省级下市的所有企业数量
*/
List<OrganizationTreeVo> getCompanyNumber(@Param("industryType") String industryType, @Param("provinceSid") String provinceSid, @Param("citySid") String citySid, @Param("countySid") String countySid);
/*
按照行业分类,查询所有企业
*/
List<OrganizationTreeVo> getIndustryNumber(@Param("industryType") String industryType, @Param("citySid") String citySid, @Param("countySid") String countySid);
AdministrativeAgenciesVo administrativeAgenciesBydictcode(@Param("dictCode") String dictCode);
OrganizationVo selectOrgByName(@Param(Constants.WRAPPER) Wrapper<OrganizationVo> qw);
List<Organization> selectByconfirmDate(@Param("datestr") String datestr);
List<Organization> selectconfirmedBySid(@Param("regionSid") String regionSid,@Param("state") String state);
IPage<Organization> selectconfirmedBySidPage(IPage<OrganizationQuery> page, @Param(Constants.WRAPPER)QueryWrapper<Organization> qw);
IPage<Organization> selectRevokeBySidPage(IPage<OrganizationQuery> page, @Param(Constants.WRAPPER)QueryWrapper<Organization> qw);
}

View File

@@ -0,0 +1,736 @@
<?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.yxt.jlzx.system.biz.organization.OrganizationMapper">
<resultMap id="appOrganizationMap" type="com.yxt.jlzx.system.api.organization.AppOrganizationVo">
<collection property="dictCommonListVoList" ofType="DictCommonListVo"
select="dwlbTypeList" column="dictType">
</collection>
<collection property="dictCommonListVoList2" ofType="DictCommonListVo"
select="dwjbList" column="dwjbType">
<result column="dictKey" jdbcType="VARCHAR" property="dictKey"/>
<result column="dictType" jdbcType="VARCHAR" property="dictType"/>
<result column="dictValue" jdbcType="VARCHAR" property="dictValue"/>
</collection>
<collection property="regionVoListProvince" ofType="RegionVo"
select="regionVoList" column="pSid">
<result column="dictKey" jdbcType="VARCHAR" property="dictKey"/>
<result column="dictType" jdbcType="VARCHAR" property="dictType"/>
<result column="dictValue" jdbcType="VARCHAR" property="dictValue"/>
</collection>
</resultMap>
<resultMap id="regionMap" type="com.yxt.jlzx.system.api.region.RegionVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="sid" jdbcType="VARCHAR" property="sid"/>
<result column="pSid" jdbcType="VARCHAR" property="pSid"/>
<result column="districtCode" jdbcType="INTEGER" property="districtCode"/>
<result column="sidPath" jdbcType="VARCHAR" property="sidPath"/>
</resultMap>
<select id="regionVoList" parameterType="com.yxt.jlzx.system.api.region.RegionVo" resultMap="regionMap">
SELECT name,
sid,
pSid,
districtCode,
sidPath
FROM region
WHERE level = 1
AND pSid = #{pSid}
</select>
<resultMap id="organizationVerifyMap" type="com.yxt.jlzx.system.api.organization.OrganizationVerifyVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="orgCode" jdbcType="VARCHAR" property="orgCode"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="county" jdbcType="VARCHAR" property="county"/>
<result column="contactMan" jdbcType="VARCHAR" property="contactMan"/>
<result column="contactMobile" jdbcType="VARCHAR" property="contactMobile"/>
</resultMap>
<!-- <resultMap id="organizationDetailsMap" type="com.yxt.jlzx.system.api.organization.OrganizationDetailsVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="orgCode" jdbcType="VARCHAR" property="orgCode"/>
<result column="orgAddress" jdbcType="VARCHAR" property="orgAddress"/>
<result column="contactTelephone" jdbcType="VARCHAR" property="contactTelephone"/>
<result column="region" jdbcType="VARCHAR" property="region"/>
<result column="memberNum" jdbcType="INTEGER" property="memberNum"/>
<result column="contactMobile" jdbcType="VARCHAR" property="contactMobile"/>
<result column="postAddress" jdbcType="VARCHAR" property="postAddress"/>
<result column="postcode" jdbcType="VARCHAR" property="postcode"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="gisInfo" jdbcType="VARCHAR" property="gisInfo"/>
<result column="dwType" jdbcType="VARCHAR" property="dwType"/>
<result column="businessLicense" jdbcType="VARCHAR" property="businessLicense"/>
<result column="dwjb" jdbcType="VARCHAR" property="dwjb"/>
</resultMap>-->
<!-- <resultMap id="organizationRegisterDetailsMap"
type="com.yxt.jlzx.system.api.organization.OrganizationRegisterDetailsVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="orgCode" jdbcType="VARCHAR" property="orgCode"/>
<result column="organizationName" jdbcType="VARCHAR" property="organizationName"/>
<result column="photoPath" jdbcType="VARCHAR" property="photoPath"/>
<result column="region" jdbcType="VARCHAR" property="region"/>
<result column="idNo" jdbcType="VARCHAR" property="idNo"/>
<result column="contactMobile" jdbcType="VARCHAR" property="contactMobile"/>
<result column="postAddress" jdbcType="VARCHAR" property="postAddress"/>
<result column="userName" jdbcType="VARCHAR" property="userName"/>
<result column="mobile" jdbcType="VARCHAR" property="mobile"/>
<result column="gisInfo" jdbcType="VARCHAR" property="gisInfo"/>
<result column="dwType" jdbcType="VARCHAR" property="dwType"/>
<result column="businessLicense" jdbcType="VARCHAR" property="businessLicense"/>
<result column="idFrontPhoto" jdbcType="VARCHAR" property="idFrontPhoto"/>
<result column="idBackPhoto" jdbcType="VARCHAR" property="idBackPhoto"/>
<result column="grantPhoto" jdbcType="VARCHAR" property="grantPhoto"/>
<result column="orgAddress" jdbcType="VARCHAR" property="orgAddress"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
</resultMap>-->
<!-- <resultMap id="organizationInitMap" type="com.yxt.jlzx.system.api.organization.OrganizationInitVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="orgCode" jdbcType="VARCHAR" property="orgCode"/>
<result column="orgAddress" jdbcType="VARCHAR" property="orgAddress"/>
<result column="contactTelephone" jdbcType="VARCHAR" property="contactTelephone"/>
<result column="province" jdbcType="VARCHAR" property="province"/>
<result column="city" jdbcType="VARCHAR" property="city"/>
<result column="contactMobile" jdbcType="VARCHAR" property="contactMobile"/>
<result column="postAddress" jdbcType="VARCHAR" property="postAddress"/>
<result column="postcode" jdbcType="VARCHAR" property="postcode"/>
<result column="county" jdbcType="VARCHAR" property="county"/>
<result column="gisInfo" jdbcType="VARCHAR" property="gisInfo"/>
<result column="dwType" jdbcType="VARCHAR" property="dwType"/>
<result column="businessLicense" jdbcType="VARCHAR" property="businessLicense"/>
<result column="dictType" jdbcType="VARCHAR" property="dictType"/>
<result column="staffNum" jdbcType="INTEGER" property="staffNum"/>
<result column="dwjbType" jdbcType="VARCHAR" property="dwjbType"/>
<result column="dwjb" jdbcType="VARCHAR" property="dwjb"/>
<collection property="dwTypeList" ofType="DictCommonListVo"
select="dwlbTypeList" column="dictType">
<result column="dictKey" jdbcType="VARCHAR" property="dictKey"/>
<result column="dictType" jdbcType="VARCHAR" property="dictType"/>
<result column="dictValue" jdbcType="VARCHAR" property="dictValue"/>
</collection>
<collection property="dwjbList" ofType="DictCommonListVo"
select="dwjbList" column="dwjbType">
<result column="dictKey" jdbcType="VARCHAR" property="dictKey"/>
<result column="dictType" jdbcType="VARCHAR" property="dictType"/>
<result column="dictValue" jdbcType="VARCHAR" property="dictValue"/>
</collection>
</resultMap>-->
<resultMap id="inductionUnitMap" type="com.yxt.jlzx.system.api.organization.InductionUnitVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="sid" jdbcType="VARCHAR" property="sid"/>
</resultMap>
<select id="dwlbTypeList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dictValue, dictKey, dictType
FROM dict_common
WHERE dictType = #{dictType}
</select>
<select id="dwjbList" resultType="com.yxt.jlzx.system.api.dictcommon.DictCommonListVo">
SELECT dictValue, dictKey, dictType
FROM dict_common
WHERE dictType = #{dwjbType}
</select>
<select id="verifyList" resultType="com.yxt.jlzx.system.api.organization.OrganizationVerifyVo">
SELECT o.name,
o.orgCode,
o.contactMan,
o.contactMobile,
r1.name province,
r2.name city,
r3.name county,
o.state,
o.sid
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="administrativeAgenciesPageList"
resultType="com.yxt.jlzx.system.api.organization.AdministrativeAgenciesVo">
SELECT o.sid,
o.name,
o.dwjb,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="qtjsjg01"
resultType="com.yxt.jlzx.system.api.organization.QtTechnicalInstitutionsVo">
SELECT o.sid,
o.name,
o.dwjb,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="qjsydw01"
resultType="com.yxt.jlzx.system.api.organization.QjsydwVo">
SELECT o.sid,
o.name,
o.dwjb,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="technicalInstitutionsPageList"
resultType="com.yxt.jlzx.system.api.organization.TechnicalInstitutionsVo">
SELECT o.sid,
o.name,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
(SELECT COUNT(oc.id) FROM jlzx_base.org_cert oc WHERE oc.orgSid = o.sid) orgCertNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
left join jlzx_base.organization_label ol ON o.sid = ol.orgSid
${ew.customSqlSegment}
</select>
<select id="selectByName" resultType="java.lang.Integer">
SELECT count(name)
FROM organization
WHERE name = #{name}
</select>
<select id="selectByNameOne" resultType="java.lang.String">
SELECT orgCode
FROM organization
WHERE name = #{name}
</select>
<select id="selectByOrgCode" resultType="java.lang.Integer">
SELECT count(orgCode)
FROM organization
WHERE orgCode = #{orgCode}
</select>
<select id="selectByOrgName" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT *
FROM organization
WHERE name = #{orgName}
</select>
<select id="selectByNameAndId" resultType="java.lang.Integer">
SELECT count(name)
FROM organization
WHERE name = #{param1}
AND id &lt;&gt; #{param2}
</select>
<select id="selectByOrgCodeAndId" resultType="java.lang.Integer">
SELECT count(orgCode)
FROM organization
WHERE orgCode = #{param1}
AND id &lt;&gt; #{param2}
</select>
<update id="updateState">
UPDATE organization
SET state = #{state}
WHERE sid = #{sid}
</update>
<select id="inductionUnitList" resultType="java.util.List" resultMap="inductionUnitMap">
SELECT o.name, o.sid
FROM organization o
WHERE o.state = 2
AND o.isDelete = 0
</select>
<select id="organizationDetails" resultType="com.yxt.jlzx.system.api.organization.OrganizationDetailsVo">
SELECT o.name,
o.contactMobile,
o.contactMan,
o.orgCode,
o.businessLicense,
o.postcode,
o.postAddress,
o.contactTelephone,
o.gisInfo,
o.email,
o.orgAddress,
CONCAT(r1.name, r2.name, r3.name) region,
CONCAT(r1.districtCode,",", r2.districtCode,",", r3.districtCode) dictCode,
dc1.dictValue dwjb,
o.prepareNum memberNum
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
LEFT JOIN dict_common dc1 ON dc1.dictKey = o.dwjb AND dc1.dictType = 'dwjb'
WHERE o.sid = #{sid}
</select>
<select id="organizationRegisterDetails"
resultType="com.yxt.jlzx.system.api.organization.OrganizationRegisterDetailsVo">
SELECT o.name,
o.contactMobile,
o.contactMan,
o.orgCode,
o.businessLicense,
o.postcode,
o.postAddress,
o.gisInfo,
o.orgAddress,
o.state,
CONCAT(r1.name, r2.name, r3.name) region,
dc2.dictValue dwjb,
u.userName,
CASE o.state
WHEN 1 THEN sa.name
WHEN 2 THEN si.name
END AS name,
CASE o.state
WHEN 1 THEN sa.mobile
WHEN 2 THEN si.mobile
END AS mobile,
CASE o.state
WHEN 1 THEN sa.idNo
WHEN 2 THEN si.idNo
END AS idNo,
CASE o.state
WHEN 1 THEN sa.userName
WHEN 2 THEN u.userName
END AS userName,
CASE o.state
WHEN 1 THEN sa.idBackPhoto
WHEN 2 THEN si.idBackPhoto
END AS idBackPhoto,
CASE o.state
WHEN 1 THEN sa.idFrontPhoto
WHEN 2 THEN si.idFrontPhoto
END AS idFrontPhoto,
CASE o.state
WHEN 1 THEN sa.grantPhoto
WHEN 2 THEN si.grantPhoto
END AS grantPhoto,
CASE o.state
WHEN 1 THEN sa.photoPath
WHEN 2 THEN si.photoPath
END AS photoPath
FROM jlzx_system.organization o
LEFT JOIN jlzx_system.user u ON u.userName = o.orgCode AND isadmin = 1
LEFT JOIN jlzx_system.staff_apply sa ON sa.userName = u.userName
LEFT JOIN jlzx_base.staffinfo si ON si.sid = u.staffSid
LEFT JOIN jlzx_system.region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN jlzx_system.region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN jlzx_system.region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
LEFT JOIN jlzx_system.dict_common dc2 ON dc2.dictKey = o.dwjb AND dc2.dictType = 'dwjb'
WHERE o.sid = #{sid}
</select>
<select id="organizationInit" resultType="com.yxt.jlzx.system.api.organization.OrganizationInitVo">
SELECT o.name,
o.contactMobile,
o.contactMan,
o.orgCode,
o.businessLicense,
o.postcode,
o.postAddress,
o.contactTelephone,
o.gisInfo,
o.email,
o.orgAddress,
dc2.dictValue dwjb,
r1.sid province,
r2.sid city,
r3.sid county,
o.prepareNum staffNum
FROM organization o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
LEFT JOIN jlzx_system.dict_common dc2 ON dc2.dictKey = o.dwjb AND dc2.dictType = 'dwjb'
WHERE o.sid = #{sid}
</select>
<update id="updateByIsDelete">
UPDATE organization
SET isDelete = 1
WHERE sid = #{sid}
</update>
<select id="regionSidList" resultType="java.lang.String">
SELECT sid
FROM organization
WHERE regionSid LIKE concat(#{regionSid}, '%')
</select>
<select id="selectAppVo" resultMap="appOrganizationMap">
SELECT 'dwlb' dictType,
'dwjb' dwjbType,
'0' pSid
FROM jlzx_system.dict_common
LIMIT 1
</select>
<select id="selectByIsVerify" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT *
FROM organization
WHERE state = 2
</select>
<select id="administrativeAgenciesPageListNew"
resultType="com.yxt.jlzx.system.api.organization.AdministrativeAgenciesVo">
SELECT o.sid,
o.name,
o.dwjb,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN org_type t ON t.orgSid = o.sid
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="technicalInstitutionsPageListNew"
resultType="com.yxt.jlzx.system.api.organization.TechnicalInstitutionsVo">
SELECT o.sid,
o.name,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
(SELECT COUNT(oc.id) FROM jlzx_base.org_cert oc WHERE oc.orgSid = o.sid) orgCertNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN org_type t ON t.orgSid = o.sid
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="searchqtjsjg"
resultType="com.yxt.jlzx.system.api.organization.QtTechnicalInstitutionsVo">
SELECT o.sid,
o.name,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
(SELECT COUNT(oc.id) FROM jlzx_base.org_cert oc WHERE oc.orgSid = o.sid) orgCertNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN org_type t ON t.orgSid = o.sid
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="searchzzdw"
resultType="com.yxt.jlzx.system.api.organization.OrganizationVo2">
SELECT *,
(SELECT COUNT(oc.id) FROM jlzx_base.org_cert oc WHERE oc.orgSid = o.sid) orgCertNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN org_type t ON t.orgSid = o.sid
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="searchqjsydw"
resultType="com.yxt.jlzx.system.api.organization.QjsydwVo">
SELECT o.sid,
o.name,
o.dwjb,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
r1.name province,
r2.name city,
r3.name county
FROM organization o
LEFT JOIN org_type t ON t.orgSid = o.sid
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
${ew.customSqlSegment}
</select>
<select id="selectNameBySid" resultType="com.yxt.jlzx.system.api.organization.OrganizationInitVo">
SELECT name
FROM organization
WHERE sid = #{sid}
</select>
<select id="selectOrgGOngshiByRegion" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT r.name,
COUNT(*) as allcount
FROM
organization o
INNER JOIN jlzx_cxjl.promise p ON o.sid = p.orgSid
<if test="dwjb == '0001'">
LEFT JOIN region r ON r.sid = SUBSTRING(o.regionSid, 39, 36)
</if>
<if test="dwjb == '0002'">
INNER JOIN region r on r.sidPath = o.regionSid
</if>
WHERE r.pSid = #{regionSid}
GROUP BY name
ORDER BY allcount DESC
</select>
<select id="selectUnconfirmedByPsid" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM organization o
LEFT JOIN region r ON r.sidPath = o.regionSid
WHERE o.sid NOT IN (SELECT orgSid FROM jlzx_cxjl.orgconfirm_record)
AND r.sidPath = #{regionSid}
</select>
<select id="selectExpireByPsid" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM organization o
INNER JOIN jlzx_cxjl.orgconfirm_record org ON o.sid = org.orgSid
LEFT JOIN region r ON r.sidPath = o.regionSid
WHERE o.confirmDate &lt; #{format}
AND r.sidPath = #{regionSid}
</select>
<select id="selectExpireOrganization" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM organization o
INNER JOIN jlzx_cxjl.orgconfirm_record org ON o.sid = org.orgSid
LEFT JOIN region r ON r.sidPath = o.regionSid
${ew.customSqlSegment}
</select>
<insert id="saveList" parameterType="java.util.List">
INSERT INTO organization(sid, name, orgCode, contactMan, contactTelephone, contactMobile, orgAddress,
industryCategory, regionSid, legalperson, email, state, promiseState)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.sid}, #{item.name,jdbcType=VARCHAR}, #{item.orgCode,jdbcType=VARCHAR},
#{item.contactMan,jdbcType=VARCHAR}, #{item.contactTelephone,jdbcType=VARCHAR},
#{item.contactMobile,jdbcType=VARCHAR}
, #{item.orgAddress,jdbcType=VARCHAR}, #{item.industryCategory,jdbcType=VARCHAR},
#{item.regionSid,jdbcType=VARCHAR}, #{item.legalperson,jdbcType=VARCHAR}, #{item.email,jdbcType=VARCHAR},
2, #{item.promiseState,jdbcType=INTEGER})
</foreach>
</insert>
<select id="selectNumberConfirListShi" resultType="java.lang.Integer">
SELECT count(*)
FROM organization o
INNER JOIN jlzx_cxjl.promise p on o.sid = p.orgSid
where o.confirmDate &lt; #{format}
and o.regionSid LIKE concat('%', #{regionSid}, '%')
</select>
<select id="selectByOrgCode1" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT *
FROM organization o
WHERE o.orgCode = #{orgCode}
</select>
<select id="orgUpdateInit" resultType="com.yxt.jlzx.system.api.organization.OrgUpdateInitVo">
SELECT o.orgCode,
o.sid,
o.name orgName,
o.contactMobile,
o.contactTelephone,
o.postAddress,
o.gisInfo,
o.contactMan,
o.legalperson,
concat(#{path}, o.businessLicense) businessLicense,
concat(#{path}, si.grantPhoto) grantPhoto,
SUBSTRING(o.regionSid, 2, 36) province,
SUBSTRING(o.regionSid, 39, 36) city,
SUBSTRING(o.regionSid, 76, 36) county
FROM organization o
left join user u ON o.sid = u.organizationSid
left join jlzx_base.staffinfo si ON u.staffSid = si.sid
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
where u.userName = #{userName}
</select>
<update id="orgUpdate">
UPDATE organization
SET gisInfo = #{gisInfo},
postAddress = #{postAddress},
contactTelephone = #{contactTelephone},
contactMobile = #{contactMobile},
businessLicense = #{businessLicense},
contactMan = #{contactMan},
legalperson = #{legalperson},
regionSid = #{regionSid},
name = #{orgName}
WHERE sid = #{sid}
</update>
<update id="updateGrantNo">
UPDATE jlzx_base.staffinfo
SET grantPhoto = #{grantNo}
where sid = #{sid}
</update>
<select id="getServicePhone" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM jlzx_system.organization o
WHERE o.regionSid LIKE CONCAT('%', #{regionSid}, '%')
AND o.dwjb = #{dwjb}
limit 1
</select>
<select id="getCompanyNumber" resultType="com.yxt.jlzx.system.api.organization.OrganizationTreeVo">
select reg.name as Name, temp.count as quantity from (
SELECT t.regionSid as regionId,
count(1) as count
FROM jlzx_system.organization as t
INNER JOIN jlzx_cxjl.promise as p on t.sid = p.orgSid
WHERE substr(SUBSTRING_INDEX(t.regionSid, '/', 2), 2) = #{provinceSid}
and p.state = 2
<if test="citySid != null and citySid != ''">
and t.regionSid like concat(concat('%', #{citySid}), '%')
</if>
<if test="countySid != null and countySid != ''">
and t.regionSid like concat(concat('%', #{countySid}), '%')
</if>
<if test="industryType != null and industryType != ''">
and t.industryCategory = #{industryType}
</if>
GROUP BY SUBSTRING_INDEX(t.regionSid, '/', 3),
<if test="countySid != null and countySid != ''">
SUBSTRING_INDEX(t.regionSid, '/', -1),
</if>
SUBSTRING_INDEX(SUBSTRING_INDEX(t.regionSid, '/', 3), '/', - 1)
)as temp
INNER JOIN jlzx_system.region as reg on
<choose>
<when test="countySid != null and countySid != ''">
SUBSTRING_INDEX(temp.regionid, '/', -1) = reg.sid
</when>
<otherwise>
SUBSTRING_INDEX(SUBSTRING_INDEX(temp.regionid, '/', 3), '/', -1)
=reg.sid
</otherwise>
</choose>
</select>
<select id="getIndustryNumber" resultType="com.yxt.jlzx.system.api.organization.OrganizationTreeVo">
select t.industryCategory as name, count(1) as quantity
from jlzx_system.organization as t
INNER JOIN jlzx_cxjl.promise as pro
on t.sid = pro.orgSid
where pro.state = 2
<if test="citySid != null and citySid != ''">
and t.regionSid like concat(concat('%', #{citySid}), '%')
</if>
<if test="countySid != null and countySid != ''">
and t.regionSid like concat(concat('%', #{countySid}), '%')
</if>
<if test="industryType != null and industryType != ''">
and t.industryCategory = #{industryType}
</if>
group by industryCategory
</select>
<select id="administrativeAgenciesBydictcode" resultType="com.yxt.jlzx.system.api.organization.AdministrativeAgenciesVo">
select max(o.id),o.sid,
o.name,
o.dwjb,
o.orgCode,
o.contactMan,
o.contactMobile,
o.prepareNum staffNum,
r1.name province,
r2.name city,
r3.name county
from jlzx_system.organization as o
LEFT JOIN region r1 ON r1.sid = SUBSTRING(o.regionSid, 2, 36)
LEFT JOIN region r2 ON r2.sid = SUBSTRING(o.regionSid, 39, 36)
LEFT JOIN region r3 ON r3.sid = SUBSTRING(o.regionSid, 76, 36)
LEFT JOIN org_type t ON t.orgSid = o.sid
where t.orgTypeKey="0002" and o.dwjb="0003"
<if test="dictCode!= null and dictCode!=''">
and r3.districtCode= #{dictCode}
</if>
</select>
<select id="selectOrgByName" resultType="com.yxt.jlzx.system.api.organization.OrganizationVo">
SELECT o.name entname, o.orgCode uniscid
FROM organization o
${ew.customSqlSegment}
</select>
<select id="selectByconfirmDate" resultType="com.yxt.jlzx.system.api.organization.Organization">
select * from organization o where DATE_FORMAT(o.confirmDate, '%Y-%m-%d') = #{datestr}
</select>
<select id="selectconfirmedBySid" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM organization o
LEFT JOIN region r ON r.sidPath = o.regionSid
inner JOIN jlzx_cxjl.orgconfirm_record rec ON rec.orgSid = o.Sid
WHERE r.sidPath = #{regionSid} and rec.state = #{state}
</select>
<select id="selectconfirmedBySidPage" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM organization o
LEFT JOIN region r ON r.sidPath = o.regionSid
inner JOIN jlzx_cxjl.orgconfirm_record rec ON rec.orgSid = o.Sid
${ew.customSqlSegment}
</select>
<select id="selectRevokeBySidPage" resultType="com.yxt.jlzx.system.api.organization.Organization">
SELECT o.*
FROM organization o
LEFT JOIN region r ON r.sidPath = o.regionSid
inner JOIN jlzx_cxjl.orgconfirm_record rec ON rec.orgSid = o.Sid
${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,90 @@
package com.yxt.jlzx.system.biz.orgbookdef;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.DateUtils;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.orgbookdef.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Date;
/**
* @author dimengzhe
* @date 2021/8/9 18:14
* @description
*/
@Controller
@RequestMapping("v1/orgbookdefs")
@Api(tags = "单位授权书模板管理")
public class OrgBookDefApiImpl implements OrgBookDefApi {
@Autowired
private OrgBookDefService orgBookDefService;
@Override
public ResultBean save(OrgBookDefDto orgBookDefDto, String sid) {
if (StringUtils.isBlank(sid)) {
OrgBookDef orgBookDef = new OrgBookDef();
orgBookDefDto.fillEntity(orgBookDef);
boolean isSave = orgBookDefService.save(orgBookDef);
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setMsg("保存成功");
} else {
OrgBookDef orgBookDef = orgBookDefService.fetchBySid(sid);
if (null == orgBookDef) {
return ResultBean.fireFail().setMsg("该模板信息不存在");
}
if (0 == orgBookDefService.updateBySid(orgBookDefDto.toMap(), sid)) {
return ResultBean.fireFail().setMsg("更新失败");
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
}
@Override
public ResultBean<OrgBookDefVo> initOrgBookDef() {
OrgBookDefVo orgBookDef = orgBookDefService.selectOrgBookOne();
return new ResultBean<OrgBookDefVo>().success().setData(orgBookDef);
}
@Override
public ResultBean<OrgBookDefOneVo> initOrgBook(OrgBookDefQuery orgBookDefQuery) {
OrgBookDefOneVo orgBookDefOneVo = new OrgBookDefOneVo();
String name = orgBookDefQuery.getName();
String orgName = orgBookDefQuery.getOrgName();
String nameOne = orgBookDefQuery.getNameOne();
String idNo = orgBookDefQuery.getIdNo();
Date today = new Date();
String date = DateUtils.dateConvertStr(today, "yyyy-MM-dd");
String year = date.substring(0, 4);
String month = date.substring(5, 7);
String day = date.substring(8, 10);
OrgBookDefVo orgBookDefVo = orgBookDefService.selectOrgBookOne();
if (orgBookDefVo != null) {
String contents = orgBookDefVo.getContents();
String contents2 = contents.replace("[name]", name);
String contents3 = contents2.replace("[orgName]", orgName);
String contents4 = contents3.replace("[nameOne]", nameOne);
String contents5 = contents4.replace("[idNo]", idNo);
String contents6 = contents5.replace("[year]", year);
String contents7 = contents6.replace("[month]", month);
String contents8 = contents7.replace("[day]", day);
orgBookDefOneVo.setContents(contents8);
} else {
return new ResultBean<OrgBookDefOneVo>().fail().setMsg("请联系系统管理员设置模板");
}
return new ResultBean<OrgBookDefOneVo>().success().setData(orgBookDefOneVo);
}
}

View File

@@ -0,0 +1,24 @@
package com.yxt.jlzx.system.biz.orgbookdef;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.orgbookdef.OrgBookDef;
import com.yxt.jlzx.system.api.orgbookdef.OrgBookDefVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author dimengzhe
* @date 2021/8/9 18:26
* @description
*/
@Mapper
public interface OrgBookDefMapper extends BaseMapper<OrgBookDef> {
OrgBookDefVo selectOrgBookOne();
OrgBookDefVo selectOrgBookTwo(String sid);
}

View File

@@ -0,0 +1,15 @@
<?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.yxt.jlzx.system.biz.orgbookdef.OrgBookDefMapper">
<select id="selectOrgBookOne" resultType="com.yxt.jlzx.system.api.orgbookdef.OrgBookDefVo">
SELECT sid, title, contents
FROM jlzx_system.org_book_def
limit 1
</select>
<select id="selectOrgBookTwo" resultType="com.yxt.jlzx.system.api.orgbookdef.OrgBookDefVo">
SELECT sid, title, contents
FROM jlzx_system.org_book_def
WHERE sid = #{sid}
</select>
</mapper>

View File

@@ -0,0 +1,29 @@
package com.yxt.jlzx.system.biz.orgbookdef;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.jlzx.system.api.orgbookdef.OrgBookDef;
import com.yxt.jlzx.system.api.orgbookdef.OrgBookDefVo;
import org.springframework.stereotype.Service;
/**
* @author dimengzhe
* @date 2021/8/9 18:25
* @description
*/
@Service
public class OrgBookDefService extends MybatisBaseService<OrgBookDefMapper, OrgBookDef> {
public OrgBookDefVo selectOrgBookOne() {
return baseMapper.selectOrgBookOne();
}
public OrgBookDefVo selectOrgBookTwo(String sid) {
return baseMapper.selectOrgBookTwo(sid);
}
}

View File

@@ -0,0 +1,175 @@
package com.yxt.jlzx.system.biz.orgrole;
import io.swagger.annotations.Api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.orgrole.OrgRole;
import com.yxt.jlzx.system.api.orgrole.OrgRoleApi;
import com.yxt.jlzx.system.api.orgrole.OrgRoleDto;
import com.yxt.jlzx.system.api.orgrole.OrgRoleQuery;
import com.yxt.jlzx.system.api.orgrole.OrgRoleVo;
import com.yxt.jlzx.system.biz.orgrolemenu.OrgRoleMenuService;
import com.yxt.jlzx.system.biz.orguserrole.OrgUserRoleService;
/**
* @author dimengzhe
* @date 2021/1/11 17:35
* @description
*/
@Controller
@RequestMapping("v1/orgroles")
@Api(tags = "业务角色管理")
public class OrgRoleApiImpl implements OrgRoleApi {
@Autowired
private OrgRoleService orgRoleService;
@Autowired
private OrgRoleMenuService orgRoleMenuService;
@Autowired
private OrgUserRoleService orgUserRoleService;
/**
* 角色分页列表
*
* @param pagerQuery 查询条件
* @return 角色分页列表
*/
@Override
public ResultBean<PagerVo<OrgRoleVo>> pageList(PagerQuery<OrgRoleQuery> pagerQuery) {
ResultBean<PagerVo<OrgRoleVo>> rb = ResultBean.fireFail();
IPage<OrgRoleVo> page = orgRoleService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<OrgRoleVo> pv_result = PagerUtil.pageToVo(page, null);
return rb.success().setData(pv_result);
}
/**
* 保存
*
* @param roleDto 角色dto对象
* @return ResultBean
*/
@Override
public ResultBean save(OrgRoleDto roleDto) {
OrgRole role = new OrgRole();
roleDto.fillEntity(role);
Map<String, Object> map = new HashMap<String, Object>();
map.put("roleName", role.getRoleName());
map.put("orgSid", role.getOrgSid());
List<OrgRole> list = orgRoleService.listByMap(map);
if (list.size() > 0){
return ResultBean.fireFail().setMsg("角色名称已存在!");
}
if (!orgRoleService.save(role)){
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setData(role.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值.
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean update(OrgRoleDto roleDto, String sid) throws Exception {
OrgRole role = orgRoleService.fetchBySid(sid);
if (null == role){
return ResultBean.fireFail().setMsg("该记录不存在");
}
if (0 == orgRoleService.updateBySid(roleDto.toMap(), sid)){
return ResultBean.fireFail().setMsg("更新失败");
}
return ResultBean.fireSuccess().setMsg("更新成功");
}
/**
* 删除
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
OrgRole role = orgRoleService.fetchBySid(sid);
if (null == role){
return ResultBean.fireFail().setMsg("该记录不存在");
}
if (0 == orgRoleService.deleteBySid(sid)){
return ResultBean.fireFail().setMsg("删除失败");
}else {
orgRoleMenuService.deleteByRoleSid(sid);//关联 角色菜单表
orgUserRoleService.deleteByRoleSid(sid);
}
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 修改页面初始化数据
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean<OrgRoleVo> getVo(String sid) {
OrgRole role = orgRoleService.fetchBySid(sid);
if (null == role){
return new ResultBean().fail().setData(null);
}
OrgRoleVo roleVo = new OrgRoleVo();
roleVo.setSid(role.getSid());
roleVo.setRoleName(role.getRoleName());
roleVo.setRemarks(role.getRemarks());
return new ResultBean().success().setData(roleVo);
}
@Override
public ResultBean setIsEnable(String sid, Integer isEnable) {
OrgRole role = orgRoleService.fetchBySid(sid);
if (role == null) {
return ResultBean.fireFail().setMsg("此角色已不存在");
}
int i = orgRoleService.updateIsEnable(sid, isEnable);
if (i == 0) {
return ResultBean.fireFail().setMsg("设置失败");
}
return ResultBean.fireSuccess().setMsg("设置成功");
}
@Override
public ResultBean<List<OrgRoleVo>> list(@Valid OrgRoleQuery query) {
List<OrgRoleVo> list = new ArrayList<OrgRoleVo>();
ResultBean<List<OrgRoleVo>> rb=ResultBean.fireFail();
if(null==query)
return rb.setData(list);
list=orgRoleService.list(query);
return rb.setData(list).success();
}
}

View File

@@ -0,0 +1,34 @@
package com.yxt.jlzx.system.biz.orgrole;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.orgrole.OrgRole;
import com.yxt.jlzx.system.api.orgrole.OrgRoleQuery;
import com.yxt.jlzx.system.api.orgrole.OrgRoleVo;
import com.yxt.jlzx.system.api.role.RoleVo;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author yxt_mtl
* @date 2020/9/29 13:45
* @description
*/
@Mapper
public interface OrgRoleMapper extends BaseMapper<OrgRole> {
//分页列表
IPage<OrgRoleVo> pageList(IPage<OrgRoleQuery> page, @Param(Constants.WRAPPER) Wrapper<OrgRoleVo> qw);
public int updateIsEnable(@Param("sid") String sid, @Param("isEnable") Integer isEnable);
List<OrgRoleVo> list(@Param(Constants.WRAPPER) QueryWrapper<OrgRoleVo> qw);
}

View File

@@ -0,0 +1,20 @@
<?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.yxt.jlzx.system.biz.orgrole.OrgRoleMapper">
<select id="pageList" resultType="com.yxt.jlzx.system.api.orgrole.OrgRoleVo">
SELECT r.sid, r.roleName, r.remarks, r.isEnable
FROM org_role r LEFT JOIN organization o ON o.sid = r.orgSid
${ew.customSqlSegment}
</select>
<update id="updateIsEnable">
UPDATE jlzx_system.org_role
SET isEnable = #{isEnable}
WHERE sid = #{sid}
</update>
<select id="list" resultType="com.yxt.jlzx.system.api.orgrole.OrgRoleVo">
SELECT sid, roleName, remarks, isEnable
FROM org_role r ${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,68 @@
package com.yxt.jlzx.system.biz.orgrole;
import java.util.List;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.orgrole.OrgRole;
import com.yxt.jlzx.system.api.orgrole.OrgRoleQuery;
import com.yxt.jlzx.system.api.orgrole.OrgRoleVo;
/**
* @author yxt_mtl
* @date 2020/9/29 13:40
* @description
*/
@Service
public class OrgRoleService extends MybatisBaseService<OrgRoleMapper, OrgRole> {
// 分页列表
public IPage<OrgRoleVo> pageList(PagerQuery<OrgRoleQuery> pagerQuery) {
// mybits所用的分页对对象
IPage<OrgRoleQuery> page = PagerUtil.queryToPage(pagerQuery);
// mybits所用的查询条件封装类
QueryWrapper<OrgRoleVo> qw = buildQueryWrapper(pagerQuery.getParams());
return baseMapper.pageList(page, qw);
}
public List<OrgRoleVo> list(OrgRoleQuery query) {
// mybits所用的查询条件封装类
QueryWrapper<OrgRoleVo> qw = buildQueryWrapper(query);
return baseMapper.list(qw);
}
/**
* 解析和组装查询条件封装在qw中
*
* @param pagerQuery
* @return
*/
private QueryWrapper<OrgRoleVo> buildQueryWrapper(OrgRoleQuery pagerQuery) {
QueryWrapper<OrgRoleVo> qw = new QueryWrapper<>();
if (pagerQuery != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(pagerQuery.getRoleName())) {
qw.like("r.roleName", pagerQuery.getRoleName());
}
if (StringUtils.isNotBlank(pagerQuery.getOrgSid())) {
qw.eq("r.orgSid", pagerQuery.getOrgSid());
}
qw.orderByAsc("r.createTime");
}
return qw;
}
public int updateIsEnable(String sid, Integer isEnable) {
return baseMapper.updateIsEnable(sid, isEnable);
}
}

View File

@@ -0,0 +1,330 @@
package com.yxt.jlzx.system.biz.orgrolefunction;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.orgrole.OrgRole;
import com.yxt.jlzx.system.api.orgrolefunction.*;
import com.yxt.jlzx.system.api.orguserrole.OrgUserRole;
import com.yxt.jlzx.system.api.role.Role;
import com.yxt.jlzx.system.api.role.RoleQuery;
import com.yxt.jlzx.system.api.role.RoleVo;
import com.yxt.jlzx.system.api.sysfunction.SysFunctionVo;
import com.yxt.jlzx.system.api.sysrolefunction.RoleFunQuery;
import com.yxt.jlzx.system.api.sysrolefunction.SysRoleFunction;
import com.yxt.jlzx.system.api.sysrolefunction.SysRoleFunctionQueryOne;
import com.yxt.jlzx.system.api.user.UserStaffOneVo;
import com.yxt.jlzx.system.biz.orgrole.OrgRoleService;
import com.yxt.jlzx.system.biz.orgtype.OrgTypeService;
import com.yxt.jlzx.system.biz.orguserrole.OrgUserRoleService;
import com.yxt.jlzx.system.biz.role.RoleService;
import com.yxt.jlzx.system.biz.sysfunction.SysFunctionService;
import com.yxt.jlzx.system.biz.sysrolefunction.SysRoleFunctionService;
import com.yxt.jlzx.system.biz.user.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author dimengzhe
* @date 2021/9/24 16:24
* @description 业务角色和功能
*/
@Api(tags = "业务角色与功能关联表")
@RestController
@RequestMapping("v1/orgrolefunctions")
public class OrgRoleFunctionApiImpl implements OrgRoleFunctionApi {
@Autowired
private OrgRoleService orgRoleService;
@Autowired
private OrgRoleFunctionService orgRoleFunctionService;
@Autowired
private OrgUserRoleService orgUserRoleService;
@Autowired
private SysFunctionService sysFunctionService;
@Autowired
private UserService userService;
@Autowired
private OrgTypeService orgTypeService;
@Autowired
private RoleService roleService;
@Autowired
private SysRoleFunctionService sysRoleFunctionService;
@Override
public ResultBean updateRoleAndFunction(OrgRoleFunctionDto dto) {
String orgRoleSid = dto.getOrgRoleSid();
String functionSids = dto.getFunctionSid();
if (StringUtils.isBlank(orgRoleSid)) {
return ResultBean.fireFail().setMessage("业务角色sid不能为空");
} else {
OrgRole orgRole = orgRoleService.fetchBySid(orgRoleSid);
if (orgRole == null) {
return ResultBean.fireFail().setMessage("业务角色sid不存在");
}
}
orgRoleFunctionService.deleteByRoleSid(orgRoleSid);
if (!StringUtils.isBlank(functionSids)) {
String[] sids = functionSids.split(",");
for (String sid : sids) {
OrgRoleFunction orgRoleFunction = new OrgRoleFunction();
orgRoleFunction.setOrgRoleSid(orgRoleSid);
orgRoleFunction.setFunctionSid(sid);
orgRoleFunctionService.save(orgRoleFunction);
}
}
ResultBean rb = ResultBean.fireFail();
return rb.success();
}
@Override
public ResultBean<List<OrgRoleFunctionVo>> getFunctionList(OrgRoleFunctionQuery orgRoleFunctionQuery) {
ResultBean<List<OrgRoleFunctionVo>> rb = ResultBean.fireFail();
List<OrgRoleFunctionVo> list = new ArrayList<>();
//如果业务角色存在,则查询业务角色功能,如果不存在,则查询平台角色功能
OrgUserRole userRole = orgUserRoleService.selectByUserSid(orgRoleFunctionQuery.getUserSid());
if (null != userRole) {
OrgRoleFunctionQueryOne queryOne = new OrgRoleFunctionQueryOne();
queryOne.setRoleSid(userRole.getRoleSid());
queryOne.setSourceSid(orgRoleFunctionQuery.getSourceSid());
queryOne.setUserSid(userRole.getUserSid());
list = orgRoleFunctionService.selectRoleFunction(queryOne);
} else {
List<String> roleSids = userService.getUserRoleSids(orgRoleFunctionQuery.getUserSid());
RoleFunQuery roleFunQuery = new RoleFunQuery();
roleFunQuery.setRoleSids(roleSids);
roleFunQuery.setSourceSid(orgRoleFunctionQuery.getSourceSid());
roleFunQuery.setUserSid(orgRoleFunctionQuery.getUserSid());
list = orgRoleFunctionService.getFunctionList(roleFunQuery);
}
return new ResultBean<List<OrgRoleFunctionVo>>().success().setData(list);
}
@Override
public ResultBean<List<Map<String, Object>>> getFunction(OrgRoleFunctionQueryTwo orgRoleFunctionQueryTwo) {
List<Map<String, Object>> list_vo = new ArrayList<Map<String, Object>>();
ResultBean<List<Map<String, Object>>> rb = ResultBean.fireFail();
if (orgRoleFunctionQueryTwo == null) {
rb.setData(list_vo);
}
//根据orgSid获取单位的类型
List<String> orgTypeKeys = orgTypeService.findTypeKeysByOrgSid(orgRoleFunctionQueryTwo.getOrgSid());
if (null == orgTypeKeys || orgTypeKeys.size() == 0) {
rb.setData(list_vo);
}
List<String> roleSids = new ArrayList<>();
//根据userType和单位类型获取平台角色roleSids单位一般用户
RoleQuery roleQuery = new RoleQuery();
roleQuery.setUserType(orgRoleFunctionQueryTwo.getUserType());
roleQuery.setOrgTypeKeys(orgTypeKeys);
List<RoleVo> list_roleVo = roleService.list(roleQuery);
for (int i = 0; i < list_roleVo.size(); i++) {
roleSids.add(list_roleVo.get(i).getSid());
}
List<RoleVo> list_role = new ArrayList<>();
if (orgRoleFunctionQueryTwo.getUserType().equals("2")) {
roleQuery.setUserType("1");
list_role = roleService.list(roleQuery);
for (int i = 0; i < list_role.size(); i++) {
roleSids.add(list_role.get(i).getSid());
}
}
//获取业务角色拥有的功能列表
OrgRoleFunctionQueryOne orgRoleFunctionQueryOne = new OrgRoleFunctionQueryOne();
orgRoleFunctionQueryOne.setRoleSid(orgRoleFunctionQueryTwo.getRoleSid());
List<OrgRoleFunctionVo> list_fun = orgRoleFunctionService.list(orgRoleFunctionQueryOne);
Map<String, Object> map = new HashMap<>();
//遍历角色的功能列表
for (int i = 0; i < list_fun.size(); i++) {
map.put(list_fun.get(i).getSid(), i);
}
//
SysRoleFunctionQueryOne sysRoleFunctionQueryOne = new SysRoleFunctionQueryOne();
sysRoleFunctionQueryOne.setRoleSids(roleSids);
list_vo = sysRoleFunctionService.getFunctionTreeOfRoles(sysRoleFunctionQueryOne, map);
return new ResultBean<List<Map<String, Object>>>().success().setData(list_vo);
}
/**
* 2021.09.29
*
* @param pagerQuery
* @return
*/
//根据功能sid和单位sid查询该单位哪些用户拥有此功能权限
@Override
public ResultBean<PagerVo<UserStaffOneVo>> getUserByFunction(PagerQuery<OrgRoleFunctionQuery3> pagerQuery) {
//功能逻辑根据功能sid和单位sid去 OrgRoleFunction单位业务角色和功能关联表查询数据。
// 情况1有数据则根据返回数据去org_user_role表中查询用户信息然后返回数据在org_user_role表中查询不到数据则去 SysRoleFunction系统角色和功能关联表中查询查询中需要根据角色是否为管理员还是一般用户进行区分
// 情况2无数据去 SysRoleFunction系统角色和功能关联表中查询查询中需要根据角色是否为管理员还是一般用户进行区分
//根据功能Sid从org_role_function查询信息
List<OrgRoleFunction> orgrolefunctionList = orgRoleFunctionService.selectByFunctionSid(pagerQuery.getParams().getFunction());
if (orgrolefunctionList != null && orgrolefunctionList.size() > 0) {
//根据查到的rolesid去 org_user_role 查出用户 可能会有多个用户
String orgRoleSid = "";
for (int j = 0; j < orgrolefunctionList.size(); j++) {
//将查询的角色Sid拼接起来
orgRoleSid += orgrolefunctionList.get(j).getOrgRoleSid() + "/";
}
//2021.10.13
List<OrgUserRole> orgUserRole = orgUserRoleService.selectByRolesSid1(orgRoleSid, pagerQuery.getParams().getOrgSid());
if (orgUserRole.size() != 0) {
String userSid = "";
//如果有数据
for (int i = 0; i < orgUserRole.size(); i++) {
userSid += orgUserRole.get(i).getUserSid() + "/"; //将多个UserSid拼接起来
}
pagerQuery.getParams().setUserSid(userSid);
IPage<UserStaffOneVo> page1 = orgUserRoleService.selectByUser(pagerQuery);
PagerVo<UserStaffOneVo> pv_result = PagerUtil.pageToVo(page1, null);
return new ResultBean<PagerVo<UserStaffOneVo>>().success().setData(pv_result);
} else {
// //在org_user_role 查不到数据在去role中根据rolesid查有哪些单位类型看他给的单位sid有这个单位类型直接取user表根据单位sid查出数据
// String dwSid = roleService.selectFindDwSid(orgrolefunction.getOrgRoleSid(),pagerQuery.getParams().getOrgSid());
// if(dwSid != null){
// pagerQuery.getParams().setDwSid(dwSid);
// IPage<UserStaffOneVo> userdata = orgUserRoleService.selectBydwSid(pagerQuery);
// PagerVo<UserStaffOneVo> userdatapager = PagerUtil.pageToVo(userdata,null);
// return new ResultBean<PagerVo<UserStaffOneVo>>().success().setData(userdatapager);
// }
List<SysRoleFunction> sysRoleFunction = sysRoleFunctionService.selectByFunctionSid(pagerQuery.getParams().getFunction());
if (sysRoleFunction.size() != 0) {
String roleSid = "";
for (int j = 0; j < sysRoleFunction.size(); j++) {
//将查询的角色Sid拼接起来
roleSid += sysRoleFunction.get(j).getRoleSid() + "/";
}
//在org_user_role 查不到数据在去role中根据rolesid查有哪些单位类型看他给的单位sid有这个单位类型直接取user表根据单位sid查出数据
String dwSid = roleService.selectFindDwSid1(roleSid, pagerQuery.getParams().getOrgSid());
if (dwSid != null) {
List<Integer> lists1 = new ArrayList<>();
if (org.apache.commons.lang3.StringUtils.isNotBlank(roleSid)) {
String[] str = roleSid.split("/");
for (int i = 0; i < str.length; i++) {
Role role = roleService.fetchBySid(str[i]);
if (role != null && role.getState() == 1) {
lists1.add(role.getState());
}
}
}
pagerQuery.getParams().setDwSid(dwSid);
IPage<UserStaffOneVo> userdata = orgUserRoleService.selectBydwSid1(pagerQuery, lists1);
PagerVo<UserStaffOneVo> userdatapager = PagerUtil.pageToVo(userdata, null);
return new ResultBean<PagerVo<UserStaffOneVo>>().success().setData(userdatapager);
}
}
}
} else {
//传的功能sid在0rg_role_fuinction 查不到数据,就是 sys_role_function 表里面去查
List<SysRoleFunction> sysRoleFunction = sysRoleFunctionService.selectByFunctionSid(pagerQuery.getParams().getFunction());
if (sysRoleFunction.size() != 0) {
String roleSid = "";
for (int j = 0; j < sysRoleFunction.size(); j++) {
//将查询的角色Sid拼接起来
roleSid += sysRoleFunction.get(j).getRoleSid() + "/";
}
//如果不为空
// List<OrgUserRole> orgUserRole = orgUserRoleService.selectByRolesSid1(roleSid);
// if(orgUserRole.size() != 0){
// String userSid = "";
// //如果有数据
// for(int i=0;i<orgUserRole.size();i++){
// userSid+=orgUserRole.get(i).getUserSid()+"/";
// }
// pagerQuery.getParams().setUserSid(userSid);
// IPage<UserStaffOneVo> page1 = orgUserRoleService.selectByUser(pagerQuery);
// PagerVo<UserStaffOneVo> pv_result = PagerUtil.pageToVo(page1, null);
// return new ResultBean<PagerVo<UserStaffOneVo>>().success().setData(pv_result);
//
// }else {
//在org_user_role 查不到数据在去role中根据rolesid查有哪些单位类型看他给的单位sid有这个单位类型直接取user表根据单位sid查出数据
String dwSid = roleService.selectFindDwSid1(roleSid, pagerQuery.getParams().getOrgSid());
if (dwSid != null) {
List<Integer> lists1 = new ArrayList<>();
if (org.apache.commons.lang3.StringUtils.isNotBlank(roleSid)) {
String[] str = roleSid.split("/");
for (int i = 0; i < str.length; i++) {
Role role = roleService.fetchBySid(str[i]);
if (role != null && role.getState() == 1) {
lists1.add(role.getState());
}
}
}
pagerQuery.getParams().setDwSid(dwSid);
IPage<UserStaffOneVo> userdata = orgUserRoleService.selectBydwSid1(pagerQuery, lists1);
PagerVo<UserStaffOneVo> userdatapager = PagerUtil.pageToVo(userdata, null);
return new ResultBean<PagerVo<UserStaffOneVo>>().success().setData(userdatapager);
}
// }
}
}
return new ResultBean<PagerVo<UserStaffOneVo>>().success().setData(new PagerVo<UserStaffOneVo>());
//setMessage("该信息没有记录!");
}
@Override
public ResultBean<List<SysFunctionVo>> getfunctionByUserSid(OrgRoleFunctionQueryThree orgRoleFunctionQueryThree) {
String userSid = orgRoleFunctionQueryThree.getUserSid(); //获取用户的Sid
List<String> roleSids = orgRoleFunctionQueryThree.getRoleSids(); //获取业务角色的Sid可能会有多个
OrgUserRole orgUserRole = orgUserRoleService.selectByUserSid(userSid); //根据用户的Sid查询用户的再单位的角色
List<String> listStr = new ArrayList<String>();
//如果单位角色不为空
if (orgUserRole != null) {
String orgRoleSid = orgUserRole.getRoleSid(); //取出用户的角色
List<OrgRoleFunction> list = orgRoleFunctionService.selectByOrgRoleSid(orgRoleSid); //根据角色来查询中都有什么功能
if (list != null && list.size() > 0) {
for (int i = 0; list.size() > i; i++) {
listStr.add(list.get(i).getFunctionSid()); //将功能的Sid添加进list集合
}
List<SysFunctionVo> lists = sysFunctionService.selectBySids(listStr); //再通过sys_function表中查询此用户是否有此功能
return new ResultBean<List<SysFunctionVo>>().success().setData(lists);
} else {
List<SysRoleFunction> sysRoleFunctionList = sysRoleFunctionService.selectByRoleSids(roleSids); //根据业务角色的Sid查询业务角色都有哪些功能
if (sysRoleFunctionList != null && sysRoleFunctionList.size() > 0) {
for (int i = 0; sysRoleFunctionList.size() > i; i++) {
listStr.add(sysRoleFunctionList.get(i).getFunctionSid());
}
List<SysFunctionVo> lists = sysFunctionService.selectBySids(listStr); //通过功能的Sid将查询是否有此功能。
return new ResultBean<List<SysFunctionVo>>().success().setData(lists);
} else {
return new ResultBean<List<SysFunctionVo>>().success().setData(null).setMsg("该用户未查询到功能");
}
}
} else { //如果查询到单位角色,则再系统角色中查找当前用户信息
if (roleSids.size() != 0) {
List<SysRoleFunction> sysRoleFunctionList = sysRoleFunctionService.selectByRoleSids(roleSids); //sys_role_function表中查询当前用户角色的Sid
if (sysRoleFunctionList != null && sysRoleFunctionList.size() > 0) {
for (int i = 0; sysRoleFunctionList.size() > i; i++) {
listStr.add(sysRoleFunctionList.get(i).getFunctionSid());
}
List<SysFunctionVo> lists = sysFunctionService.selectBySids(listStr); //通过function的Sid再sys_function表中查询当前是否有此权限
return new ResultBean<List<SysFunctionVo>>().success().setData(lists);
} else {
return new ResultBean<List<SysFunctionVo>>().success().setData(null).setMsg("该用户未查询到功能");
}
}else{
return new ResultBean<List<SysFunctionVo>>().success().setData(null).setMsg("该用户未查询到功能");
}
}
}
}

View File

@@ -0,0 +1,36 @@
package com.yxt.jlzx.system.biz.orgrolefunction;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunction;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author dimengzhe
* @date 2021/9/24 16:44
* @description
*/
@Mapper
public interface OrgRoleFunctionMapper extends BaseMapper<OrgRoleFunction> {
/**
* 根据该业务下勾选的功能数据
*
* @param orgRoleSid 业务角色sid
* @return
*/
int deleteByRoleSid(String orgRoleSid);
List<OrgRoleFunctionVo> list(@Param(Constants.WRAPPER) Wrapper<OrgRoleFunctionVo> qw);
List<OrgRoleFunctionVo> listOne(@Param(Constants.WRAPPER) Wrapper<OrgRoleFunctionVo> qw);
//2021.09.29 根据功能Sid查询org_role_function表中数据
List<OrgRoleFunction> selectByFunctionSid(@Param("function") String function);
List<OrgRoleFunction> selectByOrgRoleSid(@Param("orgRoleSid") String orgRoleSid);
}

View File

@@ -0,0 +1,38 @@
<?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.yxt.jlzx.system.biz.orgrolefunction.OrgRoleFunctionMapper">
<delete id="deleteByRoleSid">
DELETE
FROM org_role_function
where orgRoleSid = #{orgRoleSid}
</delete>
<select id="list" resultType="com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionVo">
SELECT f.actionUrl, f.funId, f.name, f.sid
FROM sys_function f
left join org_role_function rf ON f.sid = rf.functionSid
left join sys_source_function sf ON sf.functionSid = f.sid
${ew.customSqlSegment}
</select>
<!--平台角色下列表-->
<select id="listOne" resultType="com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionVo">
SELECT f.actionUrl, f.funId, f.name, f.sid
FROM sys_function f
left join sys_role_function rf ON f.sid = rf.functionSid
left join sys_source_function sf ON sf.functionSid = f.sid
${ew.customSqlSegment}
</select>
<select id="selectByFunctionSid" resultType="com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunction">
select *
from org_role_function
where functionSid = #{function}
and isDelete = '0'
</select>
<select id="selectByOrgRoleSid" resultType="com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunction">
select *
from org_role_function
where orgRoleSid = #{orgRoleSid}
and isDelete = '0'
</select>
</mapper>

View File

@@ -0,0 +1,117 @@
package com.yxt.jlzx.system.biz.orgrolefunction;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunction;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionQueryOne;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionVo;
import com.yxt.jlzx.system.api.sysrolefunction.RoleFunQuery;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author dimengzhe
* @date 2021/9/24 16:43
* @description
*/
@Service
public class OrgRoleFunctionService extends MybatisBaseService<OrgRoleFunctionMapper, OrgRoleFunction> {
public int deleteByRoleSid(String roleSid) {
return baseMapper.deleteByRoleSid(roleSid);
}
public List<OrgRoleFunctionVo> selectRoleFunction(OrgRoleFunctionQueryOne queryOne) {
//获取当前资源下的功能列表
// queryOne.setParentSid("0");
List<OrgRoleFunctionVo> list_function = list(queryOne);
// getChildMenu(list_function, queryOne);
return list_function;
}
public List<OrgRoleFunctionVo> getFunctionList(RoleFunQuery roleFunQuery) {
// roleFunQuery.setParentSid("0");
List<OrgRoleFunctionVo> listFun = listOne(roleFunQuery);
// getChildMenuOne(listFun, roleFunQuery);
return listFun;
}
public List<OrgRoleFunctionVo> listOne(RoleFunQuery roleFunQuery) {
QueryWrapper<OrgRoleFunctionVo> qw = new QueryWrapper<>();
if (roleFunQuery != null) {
if (StringUtils.isNotBlank(roleFunQuery.getSourceSid())) {
qw.eq("sf.sourceSid", roleFunQuery.getSourceSid());
}
if (roleFunQuery.getRoleSids() != null && roleFunQuery.getRoleSids().size() != 0) {
qw.in("rf.roleSid", roleFunQuery.getRoleSids());
}
if (StringUtils.isNotBlank(roleFunQuery.getParentSid())) {
qw.eq("f.parentSid", roleFunQuery.getParentSid());
}
}
return baseMapper.listOne(qw);
}
// 不分页列表
public List<OrgRoleFunctionVo> list(OrgRoleFunctionQueryOne queryOne) {
QueryWrapper<OrgRoleFunctionVo> qw = new QueryWrapper<>();
if (queryOne != null) {
if (StringUtils.isNotBlank(queryOne.getSourceSid())) {
qw.eq("sf.sourceSid", queryOne.getSourceSid());
}
if (StringUtils.isNotBlank(queryOne.getRoleSid())) {
qw.in("rf.orgRoleSid", queryOne.getRoleSid());
}
if (StringUtils.isNotBlank(queryOne.getParentSid())) {
qw.eq("f.parentSid", queryOne.getParentSid());
}
}
return baseMapper.list(qw);
}
/**
* 2021.09.29
* @param function
* @return
*/
public List<OrgRoleFunction> selectByFunctionSid(String function) {
//功能Sid不能为空
if(function == null){
return new ArrayList<OrgRoleFunction>();
}
return baseMapper.selectByFunctionSid(function);
}
public List<OrgRoleFunction> selectByOrgRoleSid(String orgRoleSid) {
// TODO Auto-generated method stub
return baseMapper.selectByOrgRoleSid(orgRoleSid);
}
// public void getChildMenu(List<OrgRoleFunctionVo> list, OrgRoleFunctionQueryOne queryOne) {
// list.forEach(functionVo -> {
// String sid = functionVo.getSid();
// queryOne.setParentSid(sid);
// List<OrgRoleFunctionVo> listChildren = list(queryOne);
//// functionVo.setChilds(listChildren);
// getChildMenu(listChildren, queryOne);
// });
// }
//
// public void getChildMenuOne(List<OrgRoleFunctionVo> list, RoleFunQuery roleFunQuery) {
// list.forEach(functionVo -> {
// String sid = functionVo.getSid();
// roleFunQuery.setParentSid(sid);
// List<OrgRoleFunctionVo> listChildren = listOne(roleFunQuery);
//// functionVo.setChilds(listChildren);
// getChildMenuOne(listChildren, roleFunQuery);
// });
// }
}

View File

@@ -0,0 +1,222 @@
package com.yxt.jlzx.system.biz.orgrolemenu;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.orgrolemenu.*;
import com.yxt.jlzx.system.api.role.RoleQuery;
import com.yxt.jlzx.system.api.role.RoleVo;
import com.yxt.jlzx.system.api.rolemenu.RoleMenuQuery;
import com.yxt.jlzx.system.biz.orgrole.OrgRoleService;
import com.yxt.jlzx.system.biz.orgtype.OrgTypeService;
import com.yxt.jlzx.system.biz.orguserrole.OrgUserRoleService;
import com.yxt.jlzx.system.biz.role.RoleService;
import com.yxt.jlzx.system.biz.rolemenu.RoleMenuService;
import com.yxt.jlzx.system.biz.user.UserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yxt_mtl
* @date 2020/10/04 2235
* @description 角色授权信息
*/
@Controller
@RequestMapping("v1/orgrolemenus")
@Api(tags = "业务角色授权管理")
public class OrgRoleMenuApiImpl implements OrgRoleMenuApi {
@Autowired
OrgRoleMenuService orgRoleMenuService;
@Autowired
OrgRoleService orgRoleService;
@Autowired
OrgUserRoleService orgUserRoleService;
@Autowired
RoleService roleService;
@Autowired
RoleMenuService roleMenuService;
@Autowired
UserService userService;
@Autowired
OrgTypeService orgTypeService;
/**
* 获业务取角色的资源左侧菜单列表(业务角色存在则获取业务角色的菜单列表,否则获取平台角色的菜单列表)
*
* @return 获业务取角色的资源左侧菜单列表
*/
// @Override
// public ResultBean<List<Map<String, Object>>> getSourceMenuTree(OrgUserSourceQuery query) {
// ResultBean<List<Map<String, Object>>> rb=ResultBean.fireFail();
// List<Map<String, Object>> list=new ArrayList<>();
// if(null==query)
// return rb.setData(list);
//
// //if业务角色存在则查询业务角色的菜单列表否则查询平台角色的菜单列表
// OrgUserRole userRole=orgUserRoleService.selectByUserSid(query.getUserSid());
// if(null!=userRole)
// {
// OrgRoleMenuQuery orgRoleMenuQuery=new OrgRoleMenuQuery();
// orgRoleMenuQuery.setRoleSid(userRole.getRoleSid());
// orgRoleMenuQuery.setSourceSid(query.getSourceSid());
// //========== 添加开始 =========================
// //用户的Sid
// orgRoleMenuQuery.setUserSid(userRole.getUserSid());
// //========= 添加结束 ==========================
// list=orgRoleMenuService.getSourceMenuTree(orgRoleMenuQuery,null);
//
// }
// else
// {
// //根据用户获取平台角色s
// List<String> roleSids=userService.getUserRoleSids(query.getUserSid());
// RoleMenuQuery roleMenuQuery=new RoleMenuQuery();
// roleMenuQuery.setRoleSids(roleSids);
// roleMenuQuery.setSourceSid(query.getSourceSid());
// //===================== 添加开始 ==========================
// //用户的Sid
// roleMenuQuery.setUserSid(query.getUserSid());
// //===================== 添加开始 ==========================
// list=roleMenuService.getSourceMenuTreeOfRoles(roleMenuQuery, null);
// }
// return rb.success().setData(list);
// }
/**
* 获业务取角色的资源左侧菜单列表
*
* @return 获业务取角色的资源左侧菜单列表
*/
@Override
public ResultBean<List<Map<String, Object>>> getSourceMenuTree(OrgUserSourceQuery query) {
ResultBean<List<Map<String, Object>>> rb=ResultBean.fireFail();
List<Map<String, Object>> list=new ArrayList<>();
if(null==query)
return rb.setData(list);
list=orgRoleMenuService.getSourceMenuTree(query,null);
return rb.success().setData(list);
}
/**
* 获取业务角色授权时的初始化平台角色的菜单列表树(拥有的菜单选中)
*
* @param roleSid
* @return
*/
@Override
public ResultBean<List<Map<String, Object>>> getMenuTree(OrgRoleMenuQuery2 query) {
List<Map<String, Object>> list_vo = new ArrayList<Map<String, Object>>();
ResultBean<List<Map<String, Object>>> rb=ResultBean.fireFail();
if(null==query)
rb.setData(list_vo);
//根据orgSid获取orgTypeKeys
List<String> orgTypeKeys=orgTypeService.findTypeKeysByOrgSid(query.getOrgSid());
if(null==orgTypeKeys || orgTypeKeys.size()==0)
rb.setData(list_vo);
List<String> roleSids=new ArrayList<>();
//根据usertype和orgTypeKeys获取平台角色roleSids单位一般用户角色
RoleQuery roleQuery= new RoleQuery();
roleQuery.setUserType(query.getUserType());
roleQuery.setOrgTypeKeys(orgTypeKeys);
List<RoleVo> list_roleVo= roleService.list(roleQuery);
for(int i=0;i<list_roleVo.size();i++)
{
roleSids.add(list_roleVo.get(i).getSid());
}
//如果是一般用户时,则同时获取对应单位性质的管理员角色
List<RoleVo> list_roleVo2=new ArrayList<>();
if(query.getUserType().trim().equals("2"))
{
roleQuery.setUserType("1");
list_roleVo2= roleService.list(roleQuery);
for(int i=0;i<list_roleVo2.size();i++)
{
roleSids.add(list_roleVo2.get(i).getSid());
}
}
//获取业务角色拥有的菜单列表
OrgRoleMenuQuery orgRoleMenuQuery=new OrgRoleMenuQuery();
orgRoleMenuQuery.setRoleSid(query.getRoleSid());
List<OrgRoleMenuVo> list_menuvo = orgRoleMenuService.list(orgRoleMenuQuery);
//角色菜单列表的map
Map<String, Object> map_rolemenus = new HashMap<String, Object>();
//遍历角色的菜单列表
for (int i = 0; i < list_menuvo.size(); i++)
map_rolemenus.put(list_menuvo.get(i).getMenuSid(), i);
//调用RoleMenuService的getMenuTreeOfRoles方法获取所有平台角色roleSids的菜单列表并设置目前业务角色拥有的菜单选中
RoleMenuQuery roleMenuQuery=new RoleMenuQuery();
roleMenuQuery.setRoleSids(roleSids);
list_vo=roleMenuService.getMenuTreeOfRoles(roleMenuQuery, map_rolemenus);
return rb.success().setData(list_vo);
}
/**
* 删除角色授权的菜单项
*
* @param
* @return ResultBean
*/
@Override
public ResultBean delete(String roleSid) throws Exception {
// 先删除角色的授权菜单列表
orgRoleMenuService.deleteByRoleSid(roleSid);
return ResultBean.fireSuccess().setData(roleSid);
}
/**
* 保存角色授权的菜单项
*
* @param
* @return ResultBean
*/
@Override
public ResultBean<String> update(OrgRoleMenusDto roleMenusDto)
throws Exception {
ResultBean<String> resultBean = ResultBean.fireFail();
List<OrgRoleMenuDto> list_dto = roleMenusDto.getRoleMenus();
if (null == list_dto) {
return resultBean;
}
// 先删除角色的授权菜单列表
orgRoleMenuService.deleteByRoleSid(roleMenusDto.getRoleSid());
if (0 < list_dto.size()) {
List<OrgRoleMenu> list_entity = new ArrayList<OrgRoleMenu>();
for (int i = 0; i < list_dto.size(); i++) {
OrgRoleMenu rm = new OrgRoleMenu();
list_dto.get(i).fillEntity(rm);
list_entity.add(rm);
}
// 再插入新的列表
orgRoleMenuService.saveBatch(list_entity);
}
return resultBean.success().setData(roleMenusDto.getRoleSid());
}
}

View File

@@ -0,0 +1,37 @@
package com.yxt.jlzx.system.biz.orgrolemenu;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.orgrolemenu.*;
import com.yxt.jlzx.system.api.rolemenu.RoleMenuVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author yxt_mtl
* @date 2020/10/04 22:29
* @description
*/
@Mapper
public interface OrgRoleMenuMapper extends BaseMapper<OrgRoleMenu> {
//删除角色的授权列表
void deleteByRoleSid(String roleSid);
//不分页列表
List<OrgRoleMenuVo> list(@Param(Constants.WRAPPER) Wrapper<OrgRoleMenuVo> qw);
//================ 添加开始 ================================
//菜单栏待办数量
List<OrgMenuTaskCountVo> getOrgMenuTaskCounts(@Param(Constants.WRAPPER) Wrapper<OrgMenuTaskCountVo> qw);
//================ 添加结束 ================================
//2021.09.16 查询文件传送待办数量
public int selectUnReadNum(@Param("userSid") String userSid);
}

View File

@@ -0,0 +1,44 @@
<?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.yxt.jlzx.system.biz.orgrolemenu.OrgRoleMenuMapper">
<select id="list" parameterType="com.yxt.jlzx.system.api.menu.MenuQuery"
resultType="com.yxt.jlzx.system.api.orgrolemenu.OrgRoleMenuVo">
SELECT distinct rm.menuSid,
m.menuName,
m.menuUrl,
m.pageUrl,
m.pageName,
m.pageUrlRedirect,
m.pageAliasName,
m.iconUrl,
m.sourceSid,
m.isShow,
m.pSid,
m.sortNo,
m.remarks,
m.alwaysShow
FROM org_role_menu rm
LEFT JOIN menu m ON rm.menuSid = m.sid
${ew.customSqlSegment}
</select>
<select id="deleteByRoleSid">
DELETE
FROM org_role_menu
WHERE roleSid = #{roleSid}
</select>
<select id="getOrgMenuTaskCounts" resultType="com.yxt.jlzx.system.api.orgrolemenu.OrgMenuTaskCountVo">
SELECT COUNT(t.id) AS count
FROM workflow.wf_task t
JOIN workflow.wf_process p ON t.processSid = p.sid
JOIN workflow.wf_processType pt ON pt.sid = p.processTypeSid
JOIN workflow.wf_hist_order o ON t.orderSid = o.sid
${ew.customSqlSegment}
</select>
<select id="selectUnReadNum" resultType="java.lang.Integer">
SELECT count(*)
FROM jlzx_oa.oafile_receive
WHERE receiveUserSid = #{userSid}
AND state = 0
</select>
</mapper>

View File

@@ -0,0 +1,638 @@
package com.yxt.jlzx.system.biz.orgrolemenu;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.jlzx.system.api.index.IndexUtils;
import com.yxt.jlzx.system.api.orgrolemenu.*;
import com.yxt.workflow.api.task.WfTaskCountQuery;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
//import net.sf.json.JSONArray;
//import net.sf.json.JsonConfig;
/**
* @author yxt_mtl
* @date 2020/10/04 22:28
* @description
*/
@Service
public class OrgRoleMenuService extends
MybatisBaseService<OrgRoleMenuMapper, OrgRoleMenu> {
// 删除角色的授权列表
public void deleteByRoleSid(String roleSid) {
// baseMapper.deleteByRoleSid(roleSid);
Map<String, Object> map = new HashMap<String, Object>();
map.put("roleSid", roleSid);
baseMapper.deleteByMap(map);
}
///---重构开始----
///----获取菜单树形列表 开始----
///----获某个资源的菜单树形列表(内存操作) 开始----
/**
* 资源菜单树形列表
*
* @param query:roleSids,sourceSid
* @return 资源菜单树形列表(第一级一级菜单 第二级二级菜单)
*/
public List<Map<String, Object>> getSourceMenuTree(OrgRoleMenuQuery query, Map<String, Object> map_rolemenus) {
//query 资源Sid sourceSid 角色sid roleSid
//获取当前资源的菜单列表
List<Map<String, Object>> list_menus_map = new ArrayList<Map<String, Object>>();
if (null == query) {
return list_menus_map;
}
//资源的所有菜单列表
List<OrgRoleMenuVo> list_menu = list(query);
//================ 添加开始 ===================
//菜单栏中不同的项目分别查询待办数量
for (int i = 0; i < list_menu.size(); i++) {
//获取菜单名字
String NameType = list_menu.get(i).getMenuName();
WfTaskCountQuery wfTaskCount = new WfTaskCountQuery();
wfTaskCount.setActorSid(query.getUserSid());
wfTaskCount.setTaskType("0");
switch (NameType) {
case "公文中心":
wfTaskCount.setProcessTypeSid("0001");
break;
case "用车管理":
wfTaskCount.setProcessTypeSid("0003");
break;
case "用印管理":
wfTaskCount.setProcessTypeSid("0004");
break;
case "项目管理":
wfTaskCount.setProcessTypeSid("0005");
break;
case "物品领用":
wfTaskCount.setProcessTypeSid("0006");
break;
default:
wfTaskCount.setProcessTypeSid("0");
}
// 2021.09.16 如果是日常管理 ,则改变查询条件
QueryWrapper<OrgMenuTaskCountVo> qw = null;
if (("日常管理").equals(NameType)) {
//2021.09.16
qw = MenuDailyManagementQueryWrapper(wfTaskCount);
} else {
qw = MenuTaskCountQueryWrapper(wfTaskCount);
}
// QueryWrapper<OrgMenuTaskCountVo> qw = MenuTaskCountQueryWrapper(wfTaskCount);
List<OrgMenuTaskCountVo> wflist = baseMapper.getOrgMenuTaskCounts(qw);
if (wflist.size() > 0) {
list_menu.get(i).setMenuTaskCount(wflist.get(0).getCount());
}
//2021.09.16文件传送待办数量
if (NameType.equals("文件传送") || NameType.equals("个人中心")) {
int fileDelivery = baseMapper.selectUnReadNum(query.getUserSid());
list_menu.get(i).setMenuTaskCount(fileDelivery);
}
}
//================ 添加结束 ===================
//获取资源第一级菜单列表
List<OrgRoleMenuVo> list_firstLevel_menu = list_menu.stream().filter(s -> s.getPSid().equals("0")).collect(Collectors.toList());
//遍历资源的第一级菜单
for (int i = 0; i < list_firstLevel_menu.size(); i++) {
Map<String, Object> map_firstLevel_menu = getMenuTreeFromStream(list_firstLevel_menu.get(i).getMenuSid(), list_menu, map_rolemenus);
//把该菜单挂在当前菜单列表中
if (null != map_firstLevel_menu) {
list_menus_map.add(map_firstLevel_menu);
}
}
return list_menus_map;
}
// 单点登陆平台访问需要用的业务逻辑
public List<Map<String, Object>> getSourceMenuTree(OrgUserSourceQuery query, Map<String, Object> map_rolemenus) {
List<Map<String, Object>> list_menus_map = new ArrayList<Map<String, Object>>();
if (null == query) {
return list_menus_map;
}
String result = null;
// 请求接口地址
String url = IndexUtils.menuUrl;
// 请求参数
Map<String, String> params = new TreeMap<>();
params.put("userId", query.getUserSid());
if ("000010".equals(query.getSourceSid())) {
params.put("moduleId", "48");
}
if ("000002".equals(query.getSourceSid())) {
params.put("moduleId", "33");
}
if ("000003".equals(query.getSourceSid())) {
params.put("moduleId", "34");
}
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
try {
result = ConstantUtils.net2(url, params, "GET", ticket);
} catch (Exception e) {
e.printStackTrace();
}
JSONObject jsonObject = JSONObject.parseObject(result);
result = jsonObject.get("data").toString();
List<OrgRoleMenuVo2> list = (List<OrgRoleMenuVo2>) JSONArray.parseArray(result, OrgRoleMenuVo2.class);
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
//获取菜单名字
String NameType = list.get(i).getName();
WfTaskCountQuery wfTaskCount = new WfTaskCountQuery();
wfTaskCount.setActorSid(query.getUserSid());
wfTaskCount.setTaskType("0");
switch (NameType) {
case "公文中心":
wfTaskCount.setProcessTypeSid("0001");
break;
case "用车管理":
wfTaskCount.setProcessTypeSid("0003");
break;
case "用印管理":
wfTaskCount.setProcessTypeSid("0004");
break;
case "项目管理":
wfTaskCount.setProcessTypeSid("0005");
break;
case "物品领用":
wfTaskCount.setProcessTypeSid("0006");
break;
default:
wfTaskCount.setProcessTypeSid("0");
}
// 2021.09.16 如果是日常管理 ,则改变查询条件
QueryWrapper<OrgMenuTaskCountVo> qw = null;
if (("日常管理").equals(NameType)) {
//2021.09.16
qw = MenuDailyManagementQueryWrapper(wfTaskCount);
} else {
qw = MenuTaskCountQueryWrapper(wfTaskCount);
}
List<OrgMenuTaskCountVo> wflist = baseMapper.getOrgMenuTaskCounts(qw);
if (wflist.size() > 0) {
list.get(i).setMenuTaskCount(wflist.get(0).getCount());
}
//2021.09.16文件传送待办数量
if (NameType.equals("文件传送") || NameType.equals("个人中心")) {
int fileDelivery = baseMapper.selectUnReadNum(query.getUserSid());
list.get(i).setMenuTaskCount(fileDelivery);
}
Map<String, Object> map_menu = new HashMap<String, Object>();
OrgRoleMenuVo v = new OrgRoleMenuVo();
String menuSid = list.get(i).getId();
String description = list.get(i).getDescription();
String menuName = list.get(i).getName();
String menuUrl = list.get(i).getUrl();
List<String> stringList = Arrays.asList(menuUrl.split(";"));
menuUrl = stringList.get(0);
String name = stringList.get(1);
String pageUrl = "";
String iconUrl = list.get(i).getIcon();
String sourceSid = list.get(i).getModuleId();
String pSid = list.get(i).getParentId();
int sortNo = list.get(i).getOrderIndex();
int menuTaskCount = list.get(i).getMenuTaskCount();
List<OrgRoleMenuVo2> cildrenList = list.get(i).getChildren();
boolean alwaysShow = true;
Map<String, Object> map_meta = new HashMap<String, Object>();
map_meta.put("title", menuName);
map_meta.put("icon", iconUrl);
map_menu.put("meta", map_meta);
// map_menu.put("redirect", menuUrl);
//路径
map_menu.put("path", menuUrl);
// map_menu.put("name",menuUrl);
//组件名
map_menu.put("component", name);
//================= 添加开始 =======================
//添加待办的数量
map_menu.put("menuTaskCount", menuTaskCount);
List<Map<String, Object>> list_child = new ArrayList<Map<String, Object>>();
if (cildrenList != null && cildrenList.size() > 0) {
for (int j = 0; cildrenList.size() > j; j++) {
Map<String, Object> map_child_menu = new HashMap<String, Object>();
//获取菜单名字
OrgRoleMenuVo2 orgRoleMenuVo2 = cildrenList.get(j);
wfTaskCount.setActorSid(query.getUserSid());
wfTaskCount.setTaskType("0");
switch (NameType) {
case "公文中心":
wfTaskCount.setProcessTypeSid("0001");
break;
case "用车管理":
wfTaskCount.setProcessTypeSid("0003");
break;
case "用印管理":
wfTaskCount.setProcessTypeSid("0004");
break;
case "项目管理":
wfTaskCount.setProcessTypeSid("0005");
break;
case "物品领用":
wfTaskCount.setProcessTypeSid("0006");
break;
default:
wfTaskCount.setProcessTypeSid("0");
}
// 2021.09.16 如果是日常管理 ,则改变查询条件
if (("日常管理").equals(NameType)) {
//2021.09.16
qw = MenuDailyManagementQueryWrapper(wfTaskCount);
} else {
qw = MenuTaskCountQueryWrapper(wfTaskCount);
}
// QueryWrapper<OrgMenuTaskCountVo> qw = MenuTaskCountQueryWrapper(wfTaskCount);
wflist = baseMapper.getOrgMenuTaskCounts(qw);
if (wflist.size() > 0) {
cildrenList.get(j).setMenuTaskCount(wflist.get(0).getCount());
}
//2021.09.16文件传送待办数量
/* if (NameType.equals("文件传送") || NameType.equals("个人中心")) {
int fileDelivery = baseMapper.selectUnReadNum(query.getUserSid());
cildrenList.get(i).setMenuTaskCount(fileDelivery);
}*/
String description1 = orgRoleMenuVo2.getDescription();
String menuName1 = orgRoleMenuVo2.getName();
//2021.09.16文件传送待办数量
if (menuName1.equals("文件传送")) {
int fileDelivery = baseMapper.selectUnReadNum(query.getUserSid());
orgRoleMenuVo2.setMenuTaskCount(fileDelivery);
}
String menuUrl1 = orgRoleMenuVo2.getUrl();
List<String> stringList1 = Arrays.asList(menuUrl1.split(";"));
menuUrl1 = stringList1.get(0);
String name1 = stringList1.get(1);
String pageUrl1 = "";
String iconUrl1 = orgRoleMenuVo2.getIcon();
String sourceSid1 = orgRoleMenuVo2.getModuleId();
String pSid1 = orgRoleMenuVo2.getParentId();
boolean alwaysShow1 = true;
if (cildrenList.size() == 1) {
if (menuName1.equals(menuName)) {
alwaysShow = false;
}
}
int sortNo1 = orgRoleMenuVo2.getOrderIndex();
int menuTaskCount1 = orgRoleMenuVo2.getMenuTaskCount();
Map<String, Object> map_meta1 = new HashMap<String, Object>();
map_meta1.put("title", menuName1);
map_meta1.put("icon", iconUrl1);
map_child_menu.put("meta", map_meta1);
//路径
map_child_menu.put("path", menuUrl1);
//组件名
map_child_menu.put("component", name1);
map_child_menu.put("alwaysShow", alwaysShow1);
//================= 添加开始 =======================
//添加待办的数量
map_child_menu.put("menuTaskCount", menuTaskCount1);
//******************************************************************************
List<OrgRoleMenuVo2> cildrenList2 = cildrenList.get(j).getChildren();
List<Map<String, Object>> list_child2 = new ArrayList<Map<String, Object>>();
if (cildrenList2 != null && cildrenList2.size() > 0) {
for (int z = 0; cildrenList2.size() > z; z++) {
Map<String, Object> map_child_menu2 = new HashMap<String, Object>();
//获取菜单名字
OrgRoleMenuVo2 orgRoleMenuVo3 = cildrenList2.get(z);
wfTaskCount.setActorSid(query.getUserSid());
wfTaskCount.setTaskType("0");
switch (NameType) {
case "公文中心":
wfTaskCount.setProcessTypeSid("0001");
break;
case "用车管理":
wfTaskCount.setProcessTypeSid("0003");
break;
case "用印管理":
wfTaskCount.setProcessTypeSid("0004");
break;
case "项目管理":
wfTaskCount.setProcessTypeSid("0005");
break;
case "物品领用":
wfTaskCount.setProcessTypeSid("0006");
break;
default:
wfTaskCount.setProcessTypeSid("0");
}
// 2021.09.16 如果是日常管理 ,则改变查询条件
if (("日常管理").equals(NameType)) {
//2021.09.16
qw = MenuDailyManagementQueryWrapper(wfTaskCount);
} else {
qw = MenuTaskCountQueryWrapper(wfTaskCount);
}
wflist = baseMapper.getOrgMenuTaskCounts(qw);
if (wflist.size() > 0) {
cildrenList2.get(z).setMenuTaskCount(wflist.get(0).getCount());
}
if (NameType.equals("文件传送") || NameType.equals("个人中心")) {
int fileDelivery = baseMapper.selectUnReadNum(query.getUserSid());
cildrenList.get(j).setMenuTaskCount(fileDelivery);
}
String description2 = orgRoleMenuVo3.getDescription();
String menuName2 = orgRoleMenuVo3.getName();
String menuUrl2 = orgRoleMenuVo3.getUrl();
List<String> stringList2 = Arrays.asList(menuUrl2.split(";"));
menuUrl2 = stringList2.get(0);
String name2 = stringList2.get(1);
String pageUrl2 = "";
String iconUrl2 = orgRoleMenuVo3.getIcon();
String sourceSid2 = orgRoleMenuVo3.getModuleId();
String pSid2 = orgRoleMenuVo2.getParentId();
boolean alwaysShow2 = true;
if (cildrenList2.size() == 1) {
if (menuName2.equals(menuName1)) {
alwaysShow1 = false;
}
}
if (cildrenList2.get(z).getChildren().size() == 0) {
alwaysShow2 = false;
}
int sortNo2 = orgRoleMenuVo3.getOrderIndex();
int menuTaskCount2 = orgRoleMenuVo3.getMenuTaskCount();
Map<String, Object> map_meta2 = new HashMap<String, Object>();
map_meta2.put("title", menuName2);
map_meta2.put("icon", iconUrl2);
map_child_menu2.put("meta", map_meta2);
//路径
map_child_menu2.put("path", menuUrl2);
//组件名
map_child_menu2.put("component", name2);
map_child_menu2.put("alwaysShow", alwaysShow2);
//================= 添加开始 =======================
//添加待办的数量
map_child_menu2.put("menuTaskCount", menuTaskCount2);
list_child2.add(map_child_menu2);
}
} else {
alwaysShow1 = false;
}
map_child_menu.put("alwaysShow", alwaysShow1);
map_child_menu.put("children", list_child2);
//********************************************************************************
list_child.add(map_child_menu);
}
} else {
alwaysShow = false;
}
map_menu.put("children", list_child);
map_menu.put("alwaysShow", alwaysShow);
list_menus_map.add(map_menu);
}
return list_menus_map;
} else {
return list_menus_map;
}
}
/**
* 递归把list转换成菜单树形列表
*
* @param psid
* @param list_menu
* @return
*/
private Map<String, Object> getMenuTreeFromStream(String psid, List<OrgRoleMenuVo> list_menu, Map<String, Object> map_rolemenus) {
//获取当前菜单
List<OrgRoleMenuVo> list_current_menu = list_menu.stream().filter(s -> s.getMenuSid().equals(psid)).collect(Collectors.toList());
if (null == list_current_menu || 0 == list_current_menu.size())
return null;
Map<String, Object> map_menu = getMenuMap(list_current_menu.get(0), map_rolemenus);
//2.获取菜单的子菜单列表
//存储最终子菜单列表结果
List<Map<String, Object>> list_child = new ArrayList<Map<String, Object>>();
//获取子菜单列表
List<OrgRoleMenuVo> list_child_menu = list_menu.stream().filter(s -> s.getPSid().equals(psid)).collect(Collectors.toList());
for (int i = 0; i < list_child_menu.size(); i++) {
//获取该菜单子菜单列表
Map<String, Object> map_child_menu = getMenuTreeFromStream(list_child_menu.get(i).getMenuSid(), list_menu, map_rolemenus);
//把该菜单挂在当前菜单列表中
if (null != map_child_menu) {
list_child.add(map_child_menu);
}
}
//把该菜单列表放到父菜单的childMenus中
map_menu.put("children", list_child);
return map_menu;
}
///----获某个资源的菜单树形列表(内存操作) 结束----
/**
* 构造菜单的结果map
*
* @param menuVo:菜单Vo实体对象
* @param map_rolemenus:需要选中的菜单map
* @return
*/
private Map<String, Object> getMenuMap(OrgRoleMenuVo menuVo, Map<String, Object> map_rolemenus) {
Map<String, Object> map_menu = new HashMap<String, Object>();
if (null != map_rolemenus) {
//角色授权时,菜单列表
map_menu.put("sid", menuVo.getMenuSid());
map_menu.put("menuName", menuVo.getMenuName());
map_menu.put("menuUrl", menuVo.getMenuUrl());
map_menu.put("pageUrl", menuVo.getPageUrl());
map_menu.put("iconUrl", menuVo.getIconUrl());
map_menu.put("isShow", menuVo.getIsShow());
//================= 添加开始 =======================
//添加待办的数量
map_menu.put("menuTaskCount", menuVo.getMenuTaskCount());
//================ 添加结束 ========================
if (menuVo.getAlwaysShow() == 0) {
map_menu.put("alwaysShow", false);
} else if (menuVo.getAlwaysShow() == 1) {
map_menu.put("alwaysShow", true);
}
//如果角色已有的菜单则设置选中并移除map中的项否则设置不选中
if (map_rolemenus.containsKey(menuVo.getMenuSid())) {
map_menu.put("isCheck", 1);
map_rolemenus.remove(menuVo.getMenuSid());
} else {
map_menu.put("isCheck", 0);
}
} else {
//左侧菜单列表
Map<String, Object> map_meta = new HashMap<String, Object>();
map_meta.put("title", menuVo.getMenuName());
map_meta.put("icon", menuVo.getIconUrl());
map_menu.put("meta", map_meta);
map_menu.put("redirect", menuVo.getPageUrlRedirect());
//路径
map_menu.put("path", menuVo.getPageUrl() != null && !menuVo.getPageUrl().equals("") ? menuVo.getPageUrl() : "/" + menuVo.getPageName());
map_menu.put("name", menuVo.getPageAliasName() != null && !menuVo.getPageAliasName().equals("") ? menuVo.getPageAliasName() : menuVo.getPageUrl());
//组件名
map_menu.put("component", menuVo.getPageName());
if (menuVo.getAlwaysShow() == 0) {
map_menu.put("alwaysShow", false);
} else if (menuVo.getAlwaysShow() == 1) {
map_menu.put("alwaysShow", true);
}
//================= 添加开始 =======================
//添加待办的数量
map_menu.put("menuTaskCount", menuVo.getMenuTaskCount());
//================= 添加结束 =======================
}
return map_menu;
}
///---重构结束----
// 不分页列表
public List<OrgRoleMenuVo> list(OrgRoleMenuQuery query) {
// mybits所用的查询条件封装类
QueryWrapper<OrgRoleMenuVo> qw = buildQueryWrapper(query);
return baseMapper.list(qw);
}
/**
* 解析和组装查询条件封装在qw中
*
* @param query
* @return
*/
private QueryWrapper<OrgRoleMenuVo> buildQueryWrapper(OrgRoleMenuQuery query) {
QueryWrapper<OrgRoleMenuVo> qw = new QueryWrapper<>();
if (query != null) {
if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getSourceSid())) {
qw.eq("m.sourceSid", query.getSourceSid());
}
if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getRoleSid())) {
qw.in("rm.roleSid", query.getRoleSid());
}
//if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getOrgSid()))
//qw.in("rm.orgSid", query.getOrgSid());
//if (org.apache.commons.lang3.StringUtils.isNotBlank(query.getPSid()))
//qw.eq("m.pSid", query.getPSid());
qw.eq("m.isShow", 1);
qw.orderByAsc("m.sortNo");
}
return qw;
}
// ====================== 添加开始 ===========================================
/**
* 处理获取菜单栏数量条件
*
* @param query
*/
private QueryWrapper<OrgMenuTaskCountVo> MenuTaskCountQueryWrapper(
WfTaskCountQuery query) {
QueryWrapper<OrgMenuTaskCountVo> qw = new QueryWrapper<>();
if (query != null) {
if (query.getActorSid() != null && org.apache.commons.lang3.StringUtils.isNotBlank(query.getActorSid())) {
qw.eq("t.createBySid", query.getActorSid());
}
if (StringUtils.isNotBlank(query.getProcessTypeSid())) {
qw.eq("p.processTypeSid", query.getProcessTypeSid());
}
if (StringUtils.isNotBlank(query.getTaskType())) {
// qw.eq("t.taskType", query.getTaskType());
//2021.10.15 查询待办、待阅
qw.in("t.taskType", "0", "1");
}
qw.eq("o.isDelete", 0);
// qw.groupBy("t.taskType");
qw.orderByAsc("t.taskType");
}
return qw;
}
// ====================== 添加结束 ===========================================
/**
* 2021.09.16处理日常管理获取菜单栏数量条件
*
* @param query
*/
private QueryWrapper<OrgMenuTaskCountVo> MenuDailyManagementQueryWrapper(
WfTaskCountQuery query) {
QueryWrapper<OrgMenuTaskCountVo> qw = new QueryWrapper<>();
if (query != null) {
if (query.getActorSid() != null && org.apache.commons.lang3.StringUtils.isNotBlank(query.getActorSid())) {
qw.eq("t.createBySid", query.getActorSid());
}
if (StringUtils.isNotBlank(query.getProcessTypeSid())) {
qw.in("p.processTypeSid", "0003", "0004", "0005", "0006");
}
if (StringUtils.isNotBlank(query.getTaskType())) {
qw.eq("t.taskType", query.getTaskType());
}
qw.eq("o.isDelete", 0);
qw.groupBy("t.taskType");
qw.orderByAsc("t.taskType");
}
return qw;
}
}

View File

@@ -0,0 +1,105 @@
package com.yxt.jlzx.system.biz.orgtype;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.jlcyry.api.clientalterrecord.ClientAlterRecord;
import com.yxt.jlzx.jlcyry.api.clientalterrecord.ClientAlterRecordVo;
import com.yxt.jlzx.jlcyry.api.workexperience.WorkExperience;
import com.yxt.jlzx.system.api.orgrole.*;
import com.yxt.jlzx.system.api.orgtype.OrgType;
import com.yxt.jlzx.system.api.orgtype.OrgTypeApi;
import com.yxt.jlzx.system.api.orgtype.OrgTypeDto;
import com.yxt.jlzx.system.api.orgtype.OrgTypeQuery;
import com.yxt.jlzx.system.api.orgtype.OrgTypeVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.Valid;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author dimengzhe
* @date 2021/1/11 17:35
* @description
*/
@Controller
@RequestMapping("v1/orgtypes")
@Api(tags = "单位类型")
public class OrgTypeApiImpl implements OrgTypeApi {
@Autowired
private OrgTypeService orgTypeService;
@Override
public ResultBean<List<OrgTypeVo>> list(@Valid OrgTypeQuery query) {
// TODO Auto-generated method stub
return null;
}
@Override
public ResultBean<PagerVo<OrgTypeVo>> pageList(@Valid PagerQuery<OrgTypeQuery> pagerQuery) {
ResultBean<PagerVo<OrgTypeVo>> rb = ResultBean.fireFail();
IPage<OrgTypeVo> page = orgTypeService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<OrgTypeVo> pv_result = PagerUtil.pageToVo(page, null);
return rb.success().setData(pv_result);
}
@Override
public ResultBean save(@Valid OrgTypeDto dto) {
OrgType orgType = dto.toEntity();
boolean isSave = orgTypeService.save(orgType);
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setMsg("保存成功");
}
@Override
public ResultBean update(@Valid OrgTypeDto dto, String sid) throws Exception {
OrgType orgType = orgTypeService.fetchBySid(sid);
if (orgType == null) {
return ResultBean.fireFail().setMsg("该工作经历不存在");
}
int i = orgTypeService.updateBySid(dto.toMap(orgType), sid);
if (i <= 0) {
return ResultBean.fireFail().setMsg("修改失败");
}
return ResultBean.fireSuccess().setMsg("修改成功");
}
@Override
public ResultBean delete(String sid) {
// TODO Auto-generated method stub
return null;
}
@Override
public ResultBean<OrgTypeVo> getVo(String sid) {
ResultBean<OrgTypeVo> resultBean=ResultBean.fireFail();
OrgType orgType=orgTypeService.fetchBySid(sid);
OrgTypeVo vo=new OrgTypeVo();
vo.fromEntity(orgType);
return resultBean.success().setData(vo);
}
@Override
public List<String> findTypeKeysByOrgSid(String orgSid){
return orgTypeService.findTypeKeysByOrgSid(orgSid);
}
}

View File

@@ -0,0 +1,31 @@
package com.yxt.jlzx.system.biz.orgtype;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.jlcyry.api.clientalterrecord.ClientAlterRecordQuery;
import com.yxt.jlzx.jlcyry.api.clientalterrecord.ClientAlterRecordVo;
import com.yxt.jlzx.system.api.orgtype.OrgType;
import com.yxt.jlzx.system.api.orgtype.OrgTypeQuery;
import com.yxt.jlzx.system.api.orgtype.OrgTypeVo;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author dimengzhe
* @date 2021/1/19 11:40
* @description
*/
@Mapper
public interface OrgTypeMapper extends BaseMapper<OrgType> {
IPage<OrgTypeVo> pageList(IPage<OrgTypeQuery> page,@Param(Constants.WRAPPER) Wrapper<OrgTypeVo> qw);
List<OrgTypeVo> selectTypeBysid(String orgSid);
void deleteByOrgSid(String organizationSid);
//2021.10.07
Integer selectByOrgSid(@Param("orgSid") String orgSid);
}

View File

@@ -0,0 +1,20 @@
<?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.yxt.jlzx.system.biz.orgtype.OrgTypeMapper">
<select id="selectTypeBysid" resultType="com.yxt.jlzx.system.api.orgtype.OrgTypeVo">
SELECT *
FROM org_type
WHERE orgSid = #{orgSid}
</select>
<select id="pageList" resultType="com.yxt.jlzx.system.api.orgtype.OrgTypeVo">
select * from org_type
${ew.customSqlSegment} WHERE orgSid = #{orgSid}
</select>
<select id="selectByOrgSid" resultType="java.lang.Integer">
select count(*) from org_type where orgSid=#{orgSid}
</select>
<delete id="deleteByOrgSid">
delete from org_type where orgsid=#{organizationSid}
</delete>
</mapper>

View File

@@ -0,0 +1,98 @@
package com.yxt.jlzx.system.biz.orgtype;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.organization.Organization;
import com.yxt.jlzx.system.api.orgtype.OrgType;
import com.yxt.jlzx.system.api.orgtype.OrgTypeQuery;
import com.yxt.jlzx.system.api.orgtype.OrgTypeVo;
import com.yxt.jlzx.system.biz.organization.OrganizationService;
/**
* @author dimengzhe
* @date 2021/1/19 11:40
* @description
*/
@Service
public class OrgTypeService extends MybatisBaseService<OrgTypeMapper, OrgType> {
@Autowired
private OrganizationService organizationService;
public List<String> findTypeKeysByOrgSid(String orgSid) {
List<String> list=new ArrayList<>();
//yxt_mtl 2021-05-09 增加,解决省市县区三级技术机构角色无法区分的问题
//start:增加一个判断,如果是行政机构,则判断级别:省局、市局、县区局。怎分别对应省行政机关管理员、市行政机关管理员、县区行政机关管理员
Organization org=organizationService.fetchBySid(orgSid);
if(org==null)
return list;
List<OrgTypeVo> vos=baseMapper.selectTypeBysid(orgSid);
for(int i=0;i<vos.size();i++)
{
//if为行政机构,且不是省级机构,则需要转化为对应的市级或县区级行政机构角色
if(vos.get(i).getOrgTypeKey().equals("0002") && !org.getDwjb().equals("0001"))
{
list.add(vos.get(i).getOrgTypeKey()+org.getDwjb());
}
else
list.add(vos.get(i).getOrgTypeKey());
}
return list;
}
public IPage<OrgTypeVo> pageList(@Valid PagerQuery<OrgTypeQuery> pagerQuery) {
// TODO Auto-generated method stub
IPage<OrgTypeQuery> page = PagerUtil.queryToPage(pagerQuery);
QueryWrapper<OrgTypeVo> qw = buildQueryWrapper(pagerQuery.getParams());
return baseMapper.pageList(page, qw);
}
/**
* 解析和组装查询条件封装在qw中
*
* @param pagerQuery
* @return
*/
private QueryWrapper<OrgTypeVo> buildQueryWrapper(OrgTypeQuery pagerQuery) {
QueryWrapper<OrgTypeVo> qw = new QueryWrapper<>();
if (pagerQuery != null) {
if(StringUtils.isNoneBlank(pagerQuery.getOrgSid())) {
qw.eq("orgSid", pagerQuery.getOrgSid());
}
}
qw.orderByDesc("createTime");
return qw;
}
public void deleteByOrgSid(String organizationSid) {
// TODO Auto-generated method stub
baseMapper.deleteByOrgSid(organizationSid);
}
//2021.10.07 根据单位Sid查询是否是制造单位
public Integer selectByOrgSid(String orgSid){
if(orgSid == null && orgSid.length()<=0){
return 1;
}
return baseMapper.selectByOrgSid(orgSid);
}
}

View File

@@ -0,0 +1,132 @@
package com.yxt.jlzx.system.biz.orguserrole;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.system.api.orgrole.OrgRoleVo;
import com.yxt.jlzx.system.api.orguserrole.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yxt_mtl
* @date 2020/9/29 13:30
* @description 用户角色信息
*/
@Controller
@RequestMapping("v1/orguserroles")
@Api(tags = "用户业务角色管理")
public class OrgUserRoleApiImpl implements OrgUserRoleApi {
@Autowired
private OrgUserRoleService userRoleService;
/**
* 根据userSid查询
*
* @param userSid 用户sid
* @return ResultBean
*/
@Override
public ResultBean<OrgUserRoleVo> getUserRole(String userSid) {
OrgUserRole userRole = userRoleService.selectByUserSid(userSid);
if (null == userRole) {
return new ResultBean().fail().setData(null);
}
OrgUserRoleVo vo = new OrgUserRoleVo();
vo.setSid(userRole.getSid());
vo.setUserSid(userRole.getUserSid());
vo.setRoleSid(userRole.getRoleSid());
vo.setOrgSid(userRole.getOrgSid());
return new ResultBean().success().setData(vo);
}
/**
* 保存
*
* @param userRoleDto 用户角色dto对象
* @return ResultBean
*/
@Override
public ResultBean save(OrgUserRoleDto userRoleDto) {
OrgUserRole userRole = userRoleService.selectByUserSid(userRoleDto.getUserSid());
if (userRole != null) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("roleSid", userRoleDto.getRoleSid());
map.put("userSid", userRoleDto.getUserSid());
map.put("orgSid", userRoleDto.getOrgSid());
userRoleService.updateBySid(map, userRole.getSid());
}else {
Map<String, Object> map = new HashMap<String, Object>();
map.put("roleSid", userRoleDto.getRoleSid());
map.put("userSid", userRoleDto.getUserSid());
map.put("orgSid", userRoleDto.getOrgSid());
userRoleService.insert(map);
}
return ResultBean.fireSuccess().setMsg("设置成功");
}
/**
* 删除用户角色
*
* @param userSid 用户sid
* @param roleSid 角色sid
* @return ResultBean
*/
@Override
public ResultBean delete(String userSid, String roleSid) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("roleSid", roleSid);
map.put("userSid", userSid);
List<OrgUserRole> list = userRoleService.listByMap(map);
if (list.size() == 0) {
return ResultBean.fireFail().setMsg("用户角色不存在!");
}
if (0 == userRoleService.deleteBySid(list.get(0).getSid())) {
return ResultBean.fireFail().setMsg("删除失败");
}
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 根据用户sid更新用户角色sid
*
* @param userSid 用户sid
* @param roleSid 角色sid
* @return
*/
@Override
public ResultBean<Integer> updateRoleSid(String userSid, String roleSid) {
int i = userRoleService.updateRoleSid(userSid, roleSid);
if (i == 0) {
return new ResultBean<Integer>().fail().setMsg("");
}
return new ResultBean<Integer>().success().setMsg("");
}
/**
* 初始化设置用户角色
*
* @param userSid 用户sid
* @return
*/
@Override
public ResultBean<OrgInitUserRoleVo> initUserRole(String userSid) {
OrgInitUserRoleVo initUserRoleVo = userRoleService.selectByUserSidOne(userSid);
List<OrgRoleVo> roleList = userRoleService.selectList();
initUserRoleVo.setRoleVoList(roleList);
return new ResultBean<OrgInitUserRoleVo>().success().setData(initUserRoleVo);
}
@Override
public ResultBean deleteByUserSid(String userSid) {
// TODO Auto-generated method stub
userRoleService.deleteByUserSid(userSid);
return new ResultBean().success().setMsg("删除成功");
}
}

View File

@@ -0,0 +1,66 @@
package com.yxt.jlzx.system.biz.orguserrole;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.orgrole.OrgRoleVo;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionQuery3;
import com.yxt.jlzx.system.api.orguserrole.OrgInitUserRoleVo;
import com.yxt.jlzx.system.api.orguserrole.OrgUserRole;
import com.yxt.jlzx.system.api.user.UserStaffOneVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* @author yxt_mtl
* @date 2020/10/06 21:41
* @description
*/
@Mapper
public interface OrgUserRoleMapper extends BaseMapper<OrgUserRole> {
/**
* 根据用户sid查询用户角色信息
*
* @param userSid 用户sid
* @return
*/
public OrgUserRole selectByUserSid(String userSid);
/**
* 根据用户sid更新角色sid
*
* @param userSid 用户sid
* @param roleSid 角色sid
* @return
*/
public int updateRoleSid(@Param("userSid") String userSid, @Param("roleSid") String roleSid);
public OrgInitUserRoleVo selectByUserSidOne(String userSid);
public List<OrgRoleVo> selectList();
public int deleteByRoleSid(String roleSid);
public void deleteByUserSid(String staffSid);
//2021.09.29
List<OrgUserRole> selectByRolesSid(@Param("orgRoleSid") String orgRoleSid);
//2021.09.29
IPage<UserStaffOneVo> selectByFindUser(IPage<OrgRoleFunctionQuery3> page, @Param(Constants.WRAPPER) QueryWrapper<UserStaffOneVo> qw);
//2021.09.29
IPage<UserStaffOneVo> selectbyFindDwSid(IPage<OrgRoleFunctionQuery3> page, @Param(Constants.WRAPPER) QueryWrapper<UserStaffOneVo> qw);
//2021.09.29
List<OrgUserRole> selectByRolesSid1(@Param(Constants.WRAPPER) Wrapper<OrgUserRole> qw);
//2021.09.29
IPage<UserStaffOneVo> selectbyFindDwSid1(IPage<OrgRoleFunctionQuery3> page,@Param(Constants.WRAPPER) QueryWrapper<UserStaffOneVo> qw);
}

View File

@@ -0,0 +1,69 @@
<?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.yxt.jlzx.system.biz.orguserrole.OrgUserRoleMapper">
<select id="selectByUserSid" resultType="com.yxt.jlzx.system.api.orguserrole.OrgUserRole">
SELECT *
FROM org_user_role
WHERE userSid = #{userSid}
</select>
<update id="updateRoleSid">
UPDATE org_user_role
SET roleSid = #{roleSid}
WHERE userSid = #{userSid}
</update>
<select id="selectByUserSidOne" resultType="com.yxt.jlzx.system.api.orguserrole.OrgInitUserRoleVo">
SELECT ur.sid,
ur.roleSid,
ur.userSid,
u.userName
FROM jlzx_system.org_user_role ur
LEFT JOIN user u ON u.sid = ur.userSid
WHERE u.sid = #{userSid}
</select>
<select id="selectList" resultType="com.yxt.jlzx.system.api.orgrole.OrgRoleVo">
SELECT ro.sid, ro.roleName, ro.remarks
FROM org_role ro
</select>
<select id="selectByRolesSid" resultType="com.yxt.jlzx.system.api.orguserrole.OrgUserRole">
select *
from org_user_role
where roleSid = #{orgRoleSid}
and isDelete = '0'
</select>
<select id="selectByFindUser" resultType="com.yxt.jlzx.system.api.user.UserStaffOneVo">
select u.sid,u.userName,u.staffSid,u.isAdmin,u.organizationSid,s.name,s.mobile
from user u
join jlzx_base.staffinfo s
on u.staffSid = s.Sid
${ew.customSqlSegment}
</select>
<select id="selectbyFindDwSid" resultType="com.yxt.jlzx.system.api.user.UserStaffOneVo">
select u.sid,u.userName,u.staffSid,u.isAdmin,u.organizationSid,s.name,s.mobile
from user u
join jlzx_base.staffinfo s
on u.staffSid = s.Sid
${ew.customSqlSegment}
</select>
<select id="selectByRolesSid1" resultType="com.yxt.jlzx.system.api.orguserrole.OrgUserRole">
select *
from org_user_role
${ew.customSqlSegment}
</select>
<select id="selectbyFindDwSid1" resultType="com.yxt.jlzx.system.api.user.UserStaffOneVo">
select u.sid,u.userName,u.staffSid,u.isAdmin,u.organizationSid,s.name,s.mobile
from user u
join jlzx_base.staffinfo s
on u.staffSid = s.Sid
${ew.customSqlSegment}
</select>
<delete id="deleteByRoleSid">
delete from org_user_role where roleSid=#{roleSid}
</delete>
<delete id="deleteByUserSid">
delete from org_user_role where userSid=#{userSid}
</delete>
</mapper>

View File

@@ -0,0 +1,211 @@
package com.yxt.jlzx.system.biz.orguserrole;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.orgrole.OrgRole;
import com.yxt.jlzx.system.api.orgrole.OrgRoleVo;
import com.yxt.jlzx.system.api.orgrolefunction.OrgRoleFunctionQuery3;
import com.yxt.jlzx.system.api.orguserrole.OrgInitUserRoleVo;
import com.yxt.jlzx.system.api.orguserrole.OrgUserRole;
import com.yxt.jlzx.system.api.user.UserStaffOneVo;
import com.yxt.jlzx.system.biz.orgrole.OrgRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author yxt_mtl
* @date 2020/10/06 21:37
* @description
*/
@Service
public class OrgUserRoleService extends MybatisBaseService<OrgUserRoleMapper, OrgUserRole> {
@Autowired
private OrgRoleService orgRoleService;
/**
* 根据用户sid查询用户的角色
*
* @param userSid 用户sid
* @return
*/
public OrgUserRole selectByUserSid(String userSid) {
return baseMapper.selectByUserSid(userSid);
}
/**
* 根据用户sid更新角色sid
*
* @param userSid 用户sid
* @param roleSid 角色sid
* @return
*/
public int updateRoleSid(String userSid, String roleSid) {
return baseMapper.updateRoleSid(userSid, roleSid);
}
public OrgInitUserRoleVo selectByUserSidOne(String userSid){
return baseMapper.selectByUserSidOne(userSid);
}
public List<OrgRoleVo> selectList(){
return baseMapper.selectList();
}
//根据org_role sid删除
public int deleteByRoleSid(String roleSid){
return baseMapper.deleteByRoleSid(roleSid);
}
public String getOrgRoleNameByUserSid(String userSid) {
OrgUserRole userRole=selectByUserSid(userSid);
if(null!=userRole)
{
OrgRole orgRole= orgRoleService.fetchBySid(userRole.getRoleSid());
if(null!=orgRole)
return orgRole.getRoleName();
else
return "";
}
return "";
}
public void deleteByUserSid(String userSid) {
// TODO Auto-generated method stub
baseMapper.deleteByUserSid(userSid);
}
/**
* 2021.09.29
* @param orgRoleSid
* @return
*/
public List<OrgUserRole> selectByRolesSid(String orgRoleSid) {
if(orgRoleSid == null){
return new ArrayList<>();
}
return baseMapper.selectByRolesSid(orgRoleSid);
}
//2021.09.29
public IPage<UserStaffOneVo> selectByUser(PagerQuery<OrgRoleFunctionQuery3> pagerQuery) {
IPage<OrgRoleFunctionQuery3> page = PagerUtil.queryToPage(pagerQuery);
QueryWrapper<UserStaffOneVo> qw = buildOrgUserRoleWrapper(pagerQuery.getParams());
return baseMapper.selectByFindUser(page,qw);
}
//2021.09.29
// public IPage<UserStaffOneVo> selectBydwSid(PagerQuery<OrgRoleFunctionQuery3> pagerQuery) {
// IPage<OrgRoleFunctionQuery3> page = PagerUtil.queryToPage(pagerQuery);
// QueryWrapper<UserStaffOneVo> qw = buildOrgUserRoleWrapper1(pagerQuery.getParams());
// return baseMapper.selectbyFindDwSid(page,qw);
// }
//2021.09.29
private QueryWrapper<UserStaffOneVo> buildOrgUserRoleWrapper(OrgRoleFunctionQuery3 params) {
QueryWrapper<UserStaffOneVo> qw = new QueryWrapper<>();
if(params != null){
if(params.getUserSid()!= null
&& org.apache.commons.lang3.StringUtils
.isNotBlank(params.getUserSid())){
List<String> list = new ArrayList<>();
String[] s = params.getUserSid().split("/");
for(int i=0;i<s.length;i++){
list.add(s[i]);
}
qw.in("u.Sid",list);
}else{
qw.eq("0","1");
}
if(params.getName()!= null
&& org.apache.commons.lang3.StringUtils
.isNotBlank(params.getName())){
qw.like("s.name",params.getName());
}
qw.orderByDesc("u.createTime");
qw.eq("u.isdelete",0);
}
return qw;
}
//2021.09.29
private QueryWrapper<UserStaffOneVo> buildOrgUserRoleWrapper1(OrgRoleFunctionQuery3 params,List<Integer> lists) {
QueryWrapper<UserStaffOneVo> qw = new QueryWrapper<>();
if(params != null){
if(params.getDwSid()!= null
&& org.apache.commons.lang3.StringUtils
.isNotBlank(params.getDwSid())){
qw.eq("u.organizationSid",params.getDwSid());
}else{
qw.eq("0","1");
}
if(params.getName()!= null
&& org.apache.commons.lang3.StringUtils
.isNotBlank(params.getName())){
qw.like("s.name",params.getName());
}
qw.eq("u.isdelete",0);
if(lists!=null) {
//2021.10.13
qw.in("u.isAdmin",lists);
}
qw.orderByDesc("u.createTime");
}
return qw;
}
/**
* 2021.10.13
* @param orgRoleSid
* @return
*/
public List<OrgUserRole> selectByRolesSid1(String orgRoleSid,String orgSid) {
if(orgRoleSid == null && orgSid == null){
return new ArrayList<>();
}
QueryWrapper<OrgUserRole> qw = buildQueryWrapper(orgRoleSid,orgSid);
return baseMapper.selectByRolesSid1(qw);
}
//2021.10.13
private QueryWrapper<OrgUserRole> buildQueryWrapper(String orgRoleSid,String orgSid) {
QueryWrapper<OrgUserRole> qw = new QueryWrapper<>();
if(orgRoleSid != null && orgRoleSid.length()>0 && orgSid != null && orgSid.length()>0 ){
if(org.apache.commons.lang3.StringUtils.isNotBlank(orgRoleSid)){
String[] str = orgRoleSid.split("/");
List<String> lists = new ArrayList<>();
for(int i=0;i<str.length;i++){
lists.add(str[i]);
}
qw.in("roleSid",lists);
//2021.10.13
qw.eq("orgSid",orgSid);
}
}else{
qw.eq("0","1");
}
qw.eq("isDelete","0");
return qw;
}
//2021.09.29
public IPage<UserStaffOneVo> selectBydwSid1(PagerQuery<OrgRoleFunctionQuery3> pagerQuery,List<Integer> lists) {
IPage<OrgRoleFunctionQuery3> page = PagerUtil.queryToPage(pagerQuery);
QueryWrapper<UserStaffOneVo> qw = buildOrgUserRoleWrapper1(pagerQuery.getParams(),lists);
return baseMapper.selectbyFindDwSid1(page,qw);
}
}

View File

@@ -0,0 +1,76 @@
package com.yxt.jlzx.system.biz.photocommon;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.yxt.common.base.config.component.FileUploadComponent;
import com.yxt.common.core.result.ResultBean;
import com.yxt.jlzx.jlcyry.api.education.Education;
import com.yxt.jlzx.system.api.photocommon.PhotoCommon;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonApi;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonDto;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonQuery;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonVo;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
import javax.validation.Valid;
/**
* @author dimengzhe
* @date 2020/9/16 14:15
* @description
*/
@Controller
@RequestMapping("/photoCommon")
@Api(tags = "附件接口")
@ApiSort(40)
public class PhotoCommonApiImpl implements PhotoCommonApi {
@Autowired
private FileUploadComponent fileUploadComponent;
@Autowired
private PhotoCommonService photoCommonService;
@Override
public ResultBean save(@Valid PhotoCommonDto PhotoCommonDto) {
PhotoCommon PhotoCommon=PhotoCommonDto.toEntity();
String path=fileUploadComponent.getUrlPrefix();
if(PhotoCommon.getFilePath().indexOf(path)>-1) {
PhotoCommon.setFilePath(PhotoCommon.getFilePath().replace(path, ""));
}
boolean isSave = photoCommonService.save(PhotoCommon);
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setMsg("保存成功");
}
@Override
public ResultBean deleteBylinkSidAndType(PhotoCommonQuery query) {
String type=query.getType();
String linkSid=query.getLinkSid();
if(StringUtils.isNoneBlank(type)&&StringUtils.isNoneBlank(linkSid)) {
int i=photoCommonService.deleteBylinkSidAndType(query);
return new ResultBean().setMsg("成功删除"+i+"");
}else {
return new ResultBean().setMsg("删除失败");
}
}
@Override
public ResultBean<List<PhotoCommonVo>> queryBylinkSidAndType(PhotoCommonQuery query) {
String type=query.getType();
String linkSid=query.getLinkSid();
if(StringUtils.isNoneBlank(type)&&StringUtils.isNoneBlank(linkSid)) {
List<PhotoCommonVo> list=photoCommonService.queryBylinkSidAndType(query);
return new ResultBean<List<PhotoCommonVo>>().fail().setData(list);
} else{
return new ResultBean<List<PhotoCommonVo>>().fail().setMsg("参数不能有空值");
}
}
}

View File

@@ -0,0 +1,25 @@
package com.yxt.jlzx.system.biz.photocommon;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.jlzx.system.api.photocommon.PhotoCommon;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonQuery;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonVo;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
/**
* @author dimengzhe
* @date 2020/9/15 11:01
* @description
*/
@Mapper
public interface PhotoCommonMapper extends BaseMapper<PhotoCommon> {
public int updateFilePath(String staffSid,String type,String filePath);
public int deleteBylinkSidAndType(PhotoCommonQuery query);
public List<PhotoCommonVo> queryBylinkSidAndType(PhotoCommonQuery query);
}

View File

@@ -0,0 +1,19 @@
<?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.yxt.jlzx.system.biz.photocommon.PhotoCommonMapper">
<update id="updateFilePath">
update photocommon
set FilePath = #{param3}
where linkSid = #{param1}
and type = #{param2}
</update>
<delete id="deleteBylinkSidAndType" parameterType="com.yxt.jlzx.system.api.photocommon.PhotoCommonQuery">
delete from photocommon where linkSid=#{linkSid} and type=#{type}
</delete>
<select id="queryBylinkSidAndType" resultType="com.yxt.jlzx.system.api.photocommon.PhotoCommonVo" parameterType="com.yxt.jlzx.system.api.photocommon.PhotoCommonQuery">
select concat(#{path},`filePath`) as filePath, type,linkSid from photocommon where linkSid=#{linkSid} and type=#{type}
</select>
</mapper>

View File

@@ -0,0 +1,40 @@
package com.yxt.jlzx.system.biz.photocommon;
import com.yxt.common.base.config.component.FileUploadComponent;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.jlzx.system.api.photocommon.PhotoCommon;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonQuery;
import com.yxt.jlzx.system.api.photocommon.PhotoCommonVo;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author dimengzhe
* @date 2020/9/15 11:01
* @description
*/
@Service
public class PhotoCommonService extends MybatisBaseService<PhotoCommonMapper, PhotoCommon> {
@Autowired
private FileUploadComponent fileUploadComponent;
public int updateFilePath(String staffSid,String type,String filePath){
return baseMapper.updateFilePath(staffSid,type,filePath);
}
public int deleteBylinkSidAndType(PhotoCommonQuery query) {
// TODO Auto-generated method stub
return baseMapper.deleteBylinkSidAndType(query);
}
public List<PhotoCommonVo> queryBylinkSidAndType(PhotoCommonQuery query) {
// TODO Auto-generated method stub
String path=fileUploadComponent.getUrlPrefix();
query.setPath(path);
return baseMapper.queryBylinkSidAndType(query);
}
}

View File

@@ -0,0 +1,310 @@
package com.yxt.jlzx.system.biz.region;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.yxt.common.base.utils.ConstantUtils;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.index.IndexUtils;
import com.yxt.jlzx.system.api.region.*;
import io.swagger.annotations.Api;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author dimengzhe
* @date 2020/8/31 9:42
* @description 区域
*/
@Controller
@RequestMapping("/region")
@Api(tags = "区域模块接口")
@ApiSort(50)
public class RegionApiImpl implements RegionApi {
@Autowired
private RegionService regionService;
/**
* 分页列表
*
* @param pagerQuery
* @return
*/
@Override
public ResultBean<PagerVo<RegionListVo>> pagerList(PagerQuery<RegionQuery> pagerQuery) {
ResultBean<PagerVo<RegionListVo>> rb = ResultBean.fireFail();
IPage<RegionListVo> page = regionService.pageList(pagerQuery);
PagerVo<RegionListVo> pv = new PagerVo<>();
//把Ipage转换为PageVo
PagerVo<RegionListVo> pv1 = PagerUtil.pageToVo(page, pv);
return rb.success().setData(pv1);
}
/**
* 区域保存
*
* @param regionDto 区域dto对象
* @return ResultBean
*/
@Override
public ResultBean save(@Valid RegionDto regionDto) {
Region region = new Region();
regionDto.fillEntity(region);
//根据pSid查询上一级
String pSid = regionDto.getPsid();
String sidPath = "";
if ("0".equals(pSid)) {
sidPath = "/" + region.getSid();
} else {
Region region1 = regionService.selectByPsid(pSid);
sidPath = region1.getSidPath() + "/" + region.getSid();
}
region.setSidPath(sidPath);
region.setPSid(pSid);
boolean isSave = regionService.save(region);
if (!isSave) {
return ResultBean.fireFail().setMsg("保存失败");
}
return ResultBean.fireSuccess().setMsg("保存成功");
}
/**
* 区域修改
*
* @param regionDto 区域dto对象
* @param sid 区域sid
* @return ResultBean
*/
@Override
public ResultBean update(@Valid RegionDto regionDto, String sid) {
//根据sid查询区域是否存在
Region region = regionService.fetchBySid(sid);
if (region == null) {
return ResultBean.fireFail().setMsg("该区域不存在");
}
int i = regionService.updateBySid(regionDto.toMap(), sid);
if (i <= 0) {
return ResultBean.fireFail().setMsg("修改失败");
}
return ResultBean.fireSuccess().setMsg("修改成功");
}
@Override
public ResultBean get(String sid) {
QueryWrapper<Region> wrapper = new QueryWrapper<>();
wrapper.eq("sid",sid);
Region region = regionService.getOne(wrapper);
return ResultBean.fireSuccess().setData(region);
}
/**
* 删除区域
*
* @param sid 区域sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
//根据sid查询区域是否存在
Region region = regionService.fetchBySid(sid);
if (region == null) {
return ResultBean.fireFail().setMsg("该区域不存在");
}
//查询区域是否有下级
int j = regionService.selectRegionBySid(sid);
if (j > 0) {
return ResultBean.fireFail().setMsg("该区域有下级,请先删除下级数据。");
}
int i = regionService.deleteBySid(sid);
if (i == 0) {
return ResultBean.fireFail().setMsg("删除失败");
}
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 区域获取省
*
* @return ResultBean
*/
@Override
public ResultBean getProvince() throws Exception {
String result = null;
// 请求接口地址
String url = IndexUtils.regionList;
// 请求参数
Map<String, String> params = new TreeMap<>();
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
result = ConstantUtils.net2(url, params, "GET", ticket);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> mapOne = ConstantUtils.getMap(map, "data");
Map<String, Object> map2 = ConstantUtils.getMap(mapOne, "86");
TreeMap<String,Object> treemap = new TreeMap(map2);
List list = new ArrayList();
for (Map.Entry<String, Object> entry : treemap.entrySet()) {
RegionVo regionVo = new RegionVo();
regionVo.setName(entry.getValue().toString());
regionVo.setSid(entry.getKey());
regionVo.setDistrictCode(entry.getKey());
regionVo.setSidPath("/"+entry.getKey());
regionVo.setPSid("0");
list.add(regionVo);
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
return ResultBean.fireSuccess().setData(list);
}
@Override
public ResultBean getCity(String sid) throws Exception {
String result = null;
// 请求接口地址
String url = IndexUtils.regionList;
// 请求参数
Map<String, String> params = new TreeMap<>();
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
result = ConstantUtils.net2(url, params, "GET", ticket);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> mapOne = ConstantUtils.getMap(map, "data");
Map<String, Object> map2 = ConstantUtils.getMap(mapOne, sid);
TreeMap<String,Object> treemap = new TreeMap(map2);
List list = new ArrayList();
for (Map.Entry<String, Object> entry : treemap.entrySet()) {
RegionVo regionVo = new RegionVo();
regionVo.setName(entry.getValue().toString());
regionVo.setSid(entry.getKey());
regionVo.setDistrictCode(entry.getKey());
regionVo.setPSid(sid);
regionVo.setSidPath("/"+sid+"/"+entry.getKey());
list.add(regionVo);
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
return ResultBean.fireSuccess().setData(list);
}
/**
* 根据市查询该市下的所有县区
*
* @param sid 市sid
* @return 某市下的所有县区
*/
@Override
public ResultBean getCounty(String sid) throws Exception {
String result = null;
// 请求接口地址
String url = IndexUtils.regionList;
// 请求参数
Map<String, String> params = new TreeMap<>();
//签名
String signature = DigestUtils.sha1Hex(params.entrySet().stream().map(kv -> kv.getKey() + "=" + kv.getValue()).collect(Collectors.joining("&")) + IndexUtils.secret);
String ticket = String.format("Credential=%s;Signature=%s", IndexUtils.appId, signature);
String requestPayload = params.entrySet().stream().map(kv -> {
try {
return kv.getKey() + "=" + URLEncoder.encode(kv.getValue(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.joining("&"));
result = ConstantUtils.net2(url, params, "GET", ticket);
JSONObject object = JSONObject.parseObject(result);
Map<String, Object> map = JSONObject.parseObject(object.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> mapOne = ConstantUtils.getMap(map, "data");
Map<String, Object> map2 = ConstantUtils.getMap(mapOne, sid);
mapOne.get(sid);
List<String> keylist=new ArrayList<String>(mapOne.keySet());
String shengParth="";
if(keylist!=null) {
for (int i = 0; i < keylist.size(); i++) {
Map<String,Object> st=ConstantUtils.getMap(mapOne, keylist.get(i));
if(st.containsKey(sid)) {
shengParth=keylist.get(i);
break;
}
}
}
TreeMap<String,Object> treemap = new TreeMap(map2);
List list = new ArrayList();
for (Map.Entry<String, Object> entry : treemap.entrySet()) {
RegionVo regionVo = new RegionVo();
regionVo.setName(entry.getValue().toString());
regionVo.setSid(entry.getKey());
regionVo.setDistrictCode(entry.getKey());
regionVo.setPSid(sid);
regionVo.setSidPath("/"+shengParth+"/"+sid+"/"+entry.getKey());
list.add(regionVo);
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
}
return ResultBean.fireSuccess().setData(list);
}
@Override
public ResultBean<Region> seletBySid(String sid) {
Region region = regionService.fetchBySid(sid);
if (region == null) {
region = new Region();
return new ResultBean<Region>().fail().setData(region);
}
return new ResultBean<Region>().success().setData(region);
}
//2021.10.25 根据区域全Sid查询区域代码
@Override
public ResultBean<Region> selectBySidPath(String sidPath) {
//全区域Sid不能为空
if(sidPath == null && sidPath.length()<=0){
return new ResultBean<Region>().fail().setMessage("区域信息为空,请检查!");
}
Region region = regionService.selectBySidPath(sidPath);
return new ResultBean<Region>().success().setData(region);
}
}

View File

@@ -0,0 +1,63 @@
package com.yxt.jlzx.system.biz.region;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.jlzx.system.api.region.Region;
import com.yxt.jlzx.system.api.region.RegionListVo;
import com.yxt.jlzx.system.api.region.RegionQuery;
import com.yxt.jlzx.system.api.region.RegionVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/8/31 9:44
* @description 区域
*/
@Mapper
public interface RegionMapper extends BaseMapper<Region> {
/**
* 查询该区域是否有下级
*
* @param sid 区域sid
* @return int
*/
public int selectRegionBySid(String sid);
/**
* 获取区域的省
*
* @return list
*/
public List<RegionVo> getProvince();
/**
* 根据选择的省查询该省下所有市
*
* @param sid 省的sid
* @return 该省下所有的市的list
*/
public List<RegionVo> getCity(String sid);
/**
* 根据选择的市查询该市下的所有县区
*
* @param sid 市的sid
* @return 该市下的所有县区的list
*/
public List<RegionVo> getCounty(String sid);
List<Region> selectByCode(String code);
IPage<RegionListVo> pageList(IPage<RegionQuery> page, @Param(Constants.WRAPPER) Wrapper<RegionListVo> qw);
public Region selectByPsid(String pSid);
//2021.10.25 根据全区域信息查询区域信息
Region selectBySidPath(@Param("sidPath") String sidPath);
}

View File

@@ -0,0 +1,71 @@
<?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.yxt.jlzx.system.biz.region.RegionMapper">
<resultMap id="regionMap" type="com.yxt.jlzx.system.api.region.RegionVo">
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="sid" jdbcType="VARCHAR" property="sid"/>
<result column="pSid" jdbcType="VARCHAR" property="pSid"/>
<result column="districtCode" jdbcType="INTEGER" property="districtCode"/>
<result column="sidPath" jdbcType="VARCHAR" property="sidPath"/>
</resultMap>
<select id="selectRegionBySid" resultType="java.lang.Integer">
SELECT count(*)
FROM region
WHERE pSid = #{sid}
</select>
<select id="getProvince" parameterType="com.yxt.jlzx.system.api.region.RegionVo" resultMap="regionMap">
SELECT name,
sid,
pSid,
districtCode,
sidPath
FROM region
WHERE level = 1
AND pSid = 0
</select>
<select id="getCity" parameterType="com.yxt.jlzx.system.api.region.RegionVo" resultMap="regionMap">
SELECT name,
sid,
pSid,
districtCode,
sidPath
FROM region
WHERE level = 2
AND pSid = #{sid}
ORDER BY sortNo+0
</select>
<select id="getCounty" parameterType="com.yxt.jlzx.system.api.region.RegionVo" resultMap="regionMap">
SELECT name,
sid,
pSid,
districtCode,
sidPath
FROM region
WHERE level = 3
AND pSid = #{sid}
</select>
<select id="selectByCode" resultType="com.yxt.jlzx.system.api.region.Region">
SELECT *
FROM region
WHERE districtCode = #{code}
</select>
<select id="pageList" resultType="com.yxt.jlzx.system.api.region.RegionListVo">
SELECT r.name, r.districtCode, r.sortNo, r.sid
from region r
${ew.customSqlSegment}
</select>
<select id="selectByPsid" resultType="com.yxt.jlzx.system.api.region.Region">
SELECT *
FROM region
WHERE sid = #{pSid}
</select>
<select id="selectBySidPath" resultType="com.yxt.jlzx.system.api.region.Region">
select * from region where sidPath = #{sidPath}
</select>
</mapper>

View File

@@ -0,0 +1,106 @@
package com.yxt.jlzx.system.biz.region;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.jlzx.system.api.region.Region;
import com.yxt.jlzx.system.api.region.RegionListVo;
import com.yxt.jlzx.system.api.region.RegionQuery;
import com.yxt.jlzx.system.api.region.RegionVo;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author dimengzhe
* @date 2020/8/31 9:43
* @description
*/
@Service
public class RegionService extends MybatisBaseService<RegionMapper, Region> {
/**
* 根据sid查询该区域是否有下级
*
* @param sid 区域sid
* @return int
*/
public int selectRegionBySid(String sid) {
return baseMapper.selectRegionBySid(sid);
}
/**
* 获取区域省
*
* @return list
*/
public List<RegionVo> getProvince() {
return baseMapper.getProvince();
}
/**
* 获取某省下的所有市
*
* @param sid 省sid
* @return 该省下的所有市的list
*/
public List<RegionVo> getCity(String sid) {
return baseMapper.getCity(sid);
}
/**
* 获取某市下的所有区县
*
* @param sid 市sid
* @return 该市下的所有县区的list
*/
public List<RegionVo> getCounty(String sid) {
return baseMapper.getCounty(sid);
}
public List<Region> selectByCode(String code) {
return baseMapper.selectByCode(code);
}
// 分页列表
public IPage<RegionListVo> pageList(PagerQuery<RegionQuery> pagerQuery) {
// mybits所用的分页对对象
IPage<RegionQuery> page = PagerUtil.queryToPage(pagerQuery);
// mybits所用的查询条件封装类
QueryWrapper<RegionListVo> qw = buildQueryWrapper(pagerQuery.getParams());
return baseMapper.pageList(page, qw);
}
private QueryWrapper<RegionListVo> buildQueryWrapper(RegionQuery pagerQuery) {
QueryWrapper<RegionListVo> qw = new QueryWrapper<>();
if (pagerQuery != null) {
String code = pagerQuery.getDistrictCode();
if (StringUtils.isNotBlank(code)) {
qw.eq("r.districtCode", code);
}
String pSid = pagerQuery.getPsid();
qw.eq("r.pSid", pSid);
String name = pagerQuery.getName();
if (StringUtils.isNotBlank(name)) {
qw.like("r.name", name);
}
qw.orderByDesc("r.createTime");
}
return qw;
}
public Region selectByPsid(String pSid) {
return baseMapper.selectByPsid(pSid);
}
//2021.10.25
public Region selectBySidPath(String sidPath) {
Region region = baseMapper.selectBySidPath(sidPath);
return region;
}
}

View File

@@ -0,0 +1,165 @@
package com.yxt.jlzx.system.biz.role;
import io.swagger.annotations.Api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yxt.common.base.utils.PagerUtil;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.jlzx.system.api.dictcommon.DictCommonApi;
import com.yxt.jlzx.system.api.dictcommon.DictCommonVo;
import com.yxt.jlzx.system.api.role.Role;
import com.yxt.jlzx.system.api.role.RoleApi;
import com.yxt.jlzx.system.api.role.RoleDto;
import com.yxt.jlzx.system.api.role.RoleQuery;
import com.yxt.jlzx.system.api.role.RoleVo;
/**
* @author yxt_mtl
* @date 2020/9/29 13:30
* @description 角色信息
*/
@Controller
@RequestMapping("v1/roles")
@Api(tags = "平台角色管理")
public class RoleApiImpl implements RoleApi {
@Autowired
private RoleService roleService;
/**
* 角色分页列表
*
* @param pagerQuery 查询条件
* @return 角色分页列表
*/
@Override
public ResultBean<PagerVo<RoleVo>> pageList(PagerQuery<RoleQuery> pagerQuery) {
ResultBean<PagerVo<RoleVo>> rb = ResultBean.fireFail();
IPage<RoleVo> page = roleService.pageList(pagerQuery);
//把Ipage转换为PageVo
PagerVo<RoleVo> pv_result = PagerUtil.pageToVo(page, null);
List<RoleVo> list = pv_result.getRecords();
return rb.success().setData(pv_result);
}
/**
* 保存
*
* @param roleDto 角色dto对象
* @return ResultBean
*/
@Override
public ResultBean save(RoleDto roleDto) {
Role role = new Role();
roleDto.fillEntity(role);
Map<String, Object> map = new HashMap<String, Object>();
map.put("roleName", role.getRoleName());
List<Role> list = roleService.listByMap(map);
if (list.size() > 0)
return ResultBean.fireFail().setMsg("角色名称已存在!");
if (!roleService.save(role))
return ResultBean.fireFail().setMsg("保存失败");
return ResultBean.fireSuccess().setData(role.getSid());
}
/**
* 修改(@PathVariable是spring3.0的一个新功能:接收请求路径中占位符的值.
* 通过 @PathVariable 可以将URL中占位符参数{xxx}绑定到处理器类的方法形参中@PathVariable(“xxx“) )
*
* @param
* @return ResultBean
*/
@Override
public ResultBean update(RoleDto roleDto, String sid) throws Exception {
Role role = roleService.fetchBySid(sid);
if (null == role)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == roleService.updateBySid(roleDto.toMap(), sid))
return ResultBean.fireFail().setMsg("更新失败");
return ResultBean.fireSuccess().setMsg("更新成功");
}
/**
* 删除
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean delete(String sid) {
Role role = roleService.fetchBySid(sid);
if (null == role)
return ResultBean.fireFail().setMsg("该记录不存在");
if (0 == roleService.deleteBySid(sid))
return ResultBean.fireFail().setMsg("删除失败");
return ResultBean.fireSuccess().setMsg("删除成功");
}
/**
* 修改页面初始化数据
*
* @param sid 角色sid
* @return ResultBean
*/
@Override
public ResultBean<RoleVo> getVo(String sid) {
Role role = roleService.fetchBySid(sid);
if (null == role)
return new ResultBean().fail().setData(null);
RoleVo roleVo = new RoleVo();
roleVo.setSid(role.getSid());
roleVo.setRoleName(role.getRoleName());
roleVo.setRemarks(role.getRemarks());
return new ResultBean().success().setData(roleVo);
}
@Override
public ResultBean setIsEnable(String sid, Integer isEnable) {
Role role = roleService.fetchBySid(sid);
if (role == null) {
return ResultBean.fireFail().setMsg("此角色已不存在");
}
int i = roleService.updateIsEnable(sid, isEnable);
if (i == 0) {
return ResultBean.fireFail().setMsg("设置失败");
}
return ResultBean.fireSuccess().setMsg("设置成功");
}
@Override
public ResultBean<List<RoleVo>> list(RoleQuery query) {
List<RoleVo> list = new ArrayList<RoleVo>();
ResultBean<List<RoleVo>> rb=ResultBean.fireFail();
if(null==query)
return rb.setData(list);
list=roleService.list(query);
return rb.setData(list).success();
}
}

Some files were not shown because too many files have changed in this diff Show More