diff --git a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java index 40bfd1bfd..980c025a0 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java +++ b/jero-boot/jero-boot-base/jero-boot-base-core/src/main/java/com/jero/config/shiro/ShiroConfig.java @@ -143,6 +143,7 @@ public class ShiroConfig { filterChainDefinitionMap.put("/actuator/**", "anon"); filterChainDefinitionMap.put("/opensso/**", "anon"); //单点登录 + filterChainDefinitionMap.put("/phone/opensso/**", "anon"); //单点登录 filterChainDefinitionMap.put("/project/projectLibraryBase/getProjectInfo", "anon"); // 对接火山引擎接口-获取项目统计信息 filterChainDefinitionMap.put("/project/projectLibraryBase/getProjectProgressInfo", "anon"); // 对接火山引擎接口-获取项目统计信息 diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/config/entity/SysConfig.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/config/entity/SysConfig.java index 012ef73fb..0351866cd 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/config/entity/SysConfig.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/config/entity/SysConfig.java @@ -71,4 +71,10 @@ public class SysConfig implements Serializable { @ApiModelProperty(value = "配置信息说明") private java.lang.String configName; + + /**手机配置信息*/ + @Excel(name = "手机配置信息", width = 15) + @ApiModelProperty(value = "手机配置信息") + private java.lang.String phoneConfig; + } diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/PhoneSSOLoginController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/PhoneSSOLoginController.java new file mode 100644 index 000000000..75a2b76ee --- /dev/null +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/opensso/controller/PhoneSSOLoginController.java @@ -0,0 +1,222 @@ +package com.jero.modules.opensso.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.jero.common.api.vo.Result; +import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.constant.CommonConstant; +import com.jero.common.system.util.JwtUtil; +import com.jero.common.system.vo.LoginUser; +import com.jero.common.util.RedisUtil; +import com.jero.common.util.oConvertUtils; +import com.jero.modules.base.service.BaseCommonService; +import com.jero.modules.config.entity.SysConfig; +import com.jero.modules.config.service.ISysConfigService; +import com.jero.modules.system.entity.SysDepart; +import com.jero.modules.system.entity.SysRole; +import com.jero.modules.system.entity.SysUser; +import com.jero.modules.system.service.ISysDepartService; +import com.jero.modules.system.service.ISysDictService; +import com.jero.modules.system.service.ISysUserService; +import com.jero.modules.system.util.HttpRequestUtil; +import com.jero.modules.system.util.StringUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Author: liyawei + * @Description: + * @Date: Created in 11:19 2022/3/17 + */ +@RestController +@RequestMapping("/phone/opensso") +@Api(tags="单点登录") +@Slf4j +public class PhoneSSOLoginController { + @Autowired + private ISysUserService sysUserService; + @Autowired + private RedisUtil redisUtil; + @Autowired + private ISysDepartService sysDepartService; + @Autowired + private ISysDictService sysDictService; + @Resource + private BaseCommonService baseCommonService; + @Autowired + private ISysConfigService iSysConfigService; + + private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890"; + //密码登录错误的次数前缀 + public static final String RETRY_LOGIN_PREFIX = "login:retryLoginCount_"; + //密码登录错误的最大限制次数 + public static final int RETRY_LOGIN_MAX_COUNT = 5; + + @Value("${opensso.authorizeUrl}") + private String authorizeUrl; + @Value("${opensso.accessTokenUrl}") + private String accessTokenUrl; + @Value("${opensso.profileUrl}") + private String profileUrl; + @Value("${opensso.clientId}") + private String clientId; + @Value("${opensso.clientSecret}") + private String clientSecret; + @Value("${opensso.redirectUri}") + private String redirectUri; + + @AutoLog(value = "跳转至认证中心") + @ApiOperation(value = "跳转至认证中心", notes = "跳转至认证中心") + @GetMapping(value = "/ssoAuth") + public void ssoAuth(HttpServletRequest request, HttpServletResponse response){ + String callbackUri = "http%3A%2F%2F139.9.235.66%3A8008%2Fjero-boot%2Fopensso%2Fcallback"; + String authUrl = authorizeUrl +"?client_id=" + clientId + + "&redirect_uri=" + redirectUri + "&response_type=code"; + try { + response.sendRedirect(authUrl); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + //https://signin-test.nio.com/oauth2/authorize?client_id=100679&redirect_uri=http%3A%2F%2F139.9.235.66%3A8008%2Fjero-boot%2Fopensso%2Fcallback&response_type=code + //https://signin-test.nio.com/oauth2/authorize?client_id=100679&redirect_uri=http%3A%2F%2F139.9.235.66%3A8010&response_type=code + + //http://139.9.235.66:8010 + @AutoLog(value = "单点登录回调") + @ApiOperation(value = "单点登录回调", notes = "单点登录回调") + @GetMapping(value = "/callback") + public Result callback(@RequestParam(value = "code", required = false) String code, + HttpServletRequest request, HttpServletResponse response) throws IOException { + Result result = new Result(); + // 获取access_token + String getAccessTokenUrl = accessTokenUrl + "?client_id=" + clientId + "&client_secret=" + + clientSecret + "&redirect_uri=" + redirectUri + "&code=" + code; + log.info("access_token_url:" + getAccessTokenUrl); + Map headerMapToken = new HashMap<>(); + headerMapToken.put("Content-Type", "text/html;charset=utf-8"); + String accessTokenResult = HttpRequestUtil.getResponseOfGET(getAccessTokenUrl, headerMapToken); +// String accessTokenResult = "access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405"; + log.info("获取access_token返回结果:" + accessTokenResult); + // 返回结果:access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA----&expires=602405 + if(StringUtils.isEmpty(accessTokenResult) || !accessTokenResult.contains("access_token")){ + return Result.error("【单点登录】获取access_token失败"); + } + int start = accessTokenResult.indexOf("="); + int end = accessTokenResult.indexOf("&"); + String accessToken = accessTokenResult.substring(start+1, end); + + //https://signin-test.nio.com/oauth2/profile?access_token=2.0N6OFCARTH7MRCVPSENQONSA67WGHV4FDR25TSHFCCXI6FA3NRVAA---- + //获取登录用户 + String getProfileUrl = profileUrl + "?access_token=" + accessToken; + log.info("profile_url:" + getProfileUrl); + Map headerMapProfile = new HashMap<>(); + headerMapProfile.put("Content-Type", "application/json; charset=utf-8"); + String profileResult = HttpRequestUtil.getResponseOfGET(getProfileUrl, headerMapProfile); +// String profileResult = "{ id: \"chengjun.wang.o\", attributes: [{workNo: \"\"},{account_id: \"\"},{user_name: \"chengjun.wang.o\"},{email: \"chengjun.wang.o@nio.com\"}]}"; + log.info("获取profile返回结果:" + profileResult); + // 返回结果:{ id: "chengjun.wang.o", attributes: [{workNo: ""},{account_id: ""},{user_name: "chengjun.wang.o"},{email: "chengjun.wang.o@nio.com"}]} + JSONObject userThirdIdJson = JSONObject.parseObject(profileResult); + if(ObjectUtil.isEmpty(userThirdIdJson) || !userThirdIdJson.containsKey("id")){ + return Result.error("【单点登录】获取用户profile失败"); + } + String userThirdId = userThirdIdJson.getString("id"); + String username = userThirdId; + + //1. 校验用户是否有效 + //update-begin-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bug,if条件永远为false + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(SysUser::getUsername,username); + SysUser sysUser = sysUserService.getOne(queryWrapper); + //update-end-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bug,if条件永远为false + result = sysUserService.checkUserIsEffective(sysUser); + if(!result.isSuccess()) { + return result; + } + + //登录成功,清除错误登录次数 + redisUtil.del(RETRY_LOGIN_PREFIX + username); + + //用户登录信息 + userInfo(sysUser, result); + //update-begin--Author:wangshuai Date:20200714 for:登录日志没有记录人员 + LoginUser loginUser = new LoginUser(); + BeanUtils.copyProperties(sysUser, loginUser); + baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null,loginUser); + //update-end--Author:wangshuai Date:20200714 for:登录日志没有记录人员 + return result; + } + + /** + * 用户信息 + * + * @param sysUser + * @param result + * @return + */ + private Result userInfo(SysUser sysUser, Result result) { + String syspassword = sysUser.getPassword(); + String username = sysUser.getUsername(); + // 生成token + String token = JwtUtil.sign(username, syspassword); + // 设置token缓存有效时间 + redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); + redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); + + // 获取用户部门信息 + JSONObject obj = new JSONObject(); + List departs = sysDepartService.queryUserDeparts(sysUser.getId()); + obj.put("departs", departs); + if (departs == null || departs.size() == 0) { + obj.put("multi_depart", 0); + } else if (departs.size() == 1) { + sysUserService.updateUserDepart(username, departs.get(0).getOrgCode()); + obj.put("multi_depart", 1); + } else { + //查询当前是否有登录部门 + // update-begin--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去 + SysUser sysUserById = sysUserService.getById(sysUser.getId()); + if(oConvertUtils.isEmpty(sysUserById.getOrgCode())){ + sysUserService.updateUserDepart(username, departs.get(0).getOrgCode()); + } + // update-end--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去 + obj.put("multi_depart", 2); + } + + // 获取用户角色信息 + List userRoleListInfo = sysUserService.queryUserRoleListInfoByUserId(sysUser.getId()); + sysUser.setUserRoleList(userRoleListInfo); + + //获取配置信息 + List sysConfigs = iSysConfigService.queryList(); + if(CollectionUtils.isNotEmpty(sysConfigs)){ + for (SysConfig sysConfig : sysConfigs) { + obj.put(sysConfig.getConfigName(),sysConfig.getPhoneConfig()); + } + } + + obj.put("token", token); + obj.put("userInfo", sysUser); + obj.put("sysAllDictItems", sysDictService.queryAllDictItems()); + result.setResult(obj); + result.success("登录成功"); + return result; + } +} diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/PhoneCommonController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/PhoneCommonController.java new file mode 100644 index 000000000..ff4618f18 --- /dev/null +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/PhoneCommonController.java @@ -0,0 +1,774 @@ +package com.jero.modules.system.controller; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.jero.common.api.vo.Result; +import com.jero.common.constant.enums.CutEnum; +import com.jero.common.exception.JeroBootException; +import com.jero.common.system.api.ISysBaseAPI; +import com.jero.common.util.RestUtil; +import com.jero.common.util.TokenUtils; +import com.jero.common.util.oConvertUtils; +import com.jero.common.util.oss.CosBootUtil; +import com.jero.modules.oss.entity.OSSFile; +import com.jero.modules.oss.service.IOSSFileService; +import com.jero.modules.system.util.PDFUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.server.ServletServerHttpRequest; +import org.springframework.util.AntPathMatcher; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLDecoder; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +/** + *

+ * 用户表 前端控制器 + *

+ * + * @Author scott + * @since 2018-12-20 + */ +@Api(tags="文件通用") +@Slf4j +@RestController +@RequestMapping("/phone/sys/common") +public class PhoneCommonController { + + @Autowired + private ISysBaseAPI sysBaseAPI; + + @Resource + private IOSSFileService ossFileService; + + @Value(value = "${jero.path.upload}") + private String uploadpath; + + /** + * 本地:local minio:minio 阿里:alioss + */ + @Value(value="${jero.uploadType}") + private String uploadType; + /** + * 文件后缀黑名单 + */ + @Value(value="${jero.fileSuffixLimits}") + private String[] fileSuffixLimits; + + /** + * @Author 政辉 + * @return + */ + @GetMapping("/403") + public Result noauth() { + return Result.error("没有权限,请联系管理员授权"); + } + +// /** +// * 文件上传统一方法 +// * @param request +// * @param response +// * @return +// */ +// @PostMapping(value = "/upload") +// public Result upload(HttpServletRequest request, HttpServletResponse response) { +// Result result = new Result<>(); +// String savePath = ""; +// String bizPath = request.getParameter("biz"); +// MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; +// // 获取上传文件对象 +// MultipartFile file = multipartRequest.getFile("file"); +// // 文件类型是否处于黑名单 +// if(CommonUtils.limitFileSuffix(file.getOriginalFilename(),fileSuffixLimits)){ +// result.setMessage("该文件类型不允许上传"); +// result.setSuccess(false); +// result.setCode(0); +// return result; +// } +// if(oConvertUtils.isEmpty(bizPath)){ +// bizPath = ""; +// } +// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ +// // 本地上传 +// savePath = CommonUtils.uploadLocal(file,bizPath,uploadpath); +// }else{ +// // minio上传 +// savePath = CommonUtils.upload(file, bizPath, uploadType); +// } +// if(oConvertUtils.isNotEmpty(savePath)){ +// //上传成功 进行数据库存储 +// OSSFile ossFile = new OSSFile(); +// // 文件名 +// String fileName = file.getOriginalFilename(); +// fileName = CommonUtils.getFileName(fileName); +// ossFile.setFileName(fileName); +// ossFile.setUrl(savePath); +// ossFileService.save(ossFile); +// result.setMessage(savePath); +// result.setResult(ossFile); +// result.setSuccess(true); +// }else { +// result.setMessage("上传失败!"); +// result.setSuccess(false); +// } +// return result; +// } + + /** + * 文件上传统一方法 + * + * @param request + * @param response + * @return + */ + @ApiOperation(value="文件上传统一方法", notes="文件上传统一方法") + @PostMapping(value = "/upload") + public Result upload(HttpServletRequest request, HttpServletResponse response, + @RequestParam(value = "state",required = false) String state, + @RequestParam(value = "cut",required = false) String cut) { + Result result = new Result<>(); + String bizPath = request.getParameter("biz"); + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象 + if (oConvertUtils.isEmpty(bizPath)) { + bizPath = ""; +// if (CommonConstant.UPLOAD_TYPE_OSS.equals(uploadType)) { +// //未指定目录,则用阿里云默认目录 upload +// bizPath = "upload"; +// } else { +// bizPath = ""; +// } + } + if(file.getOriginalFilename().length()>100){ + if(StringUtils.equals(cut,CutEnum.CN.getValue())){ + throw new JeroBootException("文件名长度不能超过100位,请检查!"); + }else if(StringUtils.equals(cut,CutEnum.EN.getValue())){ + throw new JeroBootException("File name length cannot exceed 100 characters, please check!"); + } + } +// OSSFile oSSFile = ossFileService.uploadLocal(file, bizPath,state,cut); + OSSFile oSSFile = ossFileService.uploadLocalOfCos(file, bizPath,state,cut); // 切换cos + if (oConvertUtils.isNotEmpty(oSSFile)) { + result.setResult(oSSFile); + result.setSuccess(true); + } else { + if("cut".equals(CutEnum.CN.getValue())){ + result.setMessage("上传失败!"); + }else{ + result.setMessage("fail to upload!"); + } + result.setSuccess(false); + } + return result; + } + + public static void main(String[] args) { + + } + + /** + * 查看已上传的文件 + * @param id + * @return + */ + @ApiOperation(value="查看已上传的文件", notes="查看已上传的文件") + @GetMapping(value = "/getFileInfos") + public Result getFileInfos(String id) { + List fileInfos = ossFileService.getFileInfos(id); + return Result.OK(fileInfos); + } + + + /** + * 预览图片&下载文件 + * + * @param id 传入文件id + * @param request + * @param response + */ +// @GetMapping(value = "/download/{id}") +// public void view(@PathVariable String id,HttpServletRequest request, HttpServletResponse response) { +// // 查询数据表数据是否存在 +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(OSSFile::getId,id); +// OSSFile ossFile = ossFileService.getOne(queryWrapper); +// if( null == ossFile){ +// throw new JeroBootException("文件不存在.."); +// } +// String fileUrl = ossFile.getUrl(); +// InputStream inputStream = null; +// OutputStream outputStream = null; +// try { +// String fileName = ""; +// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ +// //本地下载 +// String filePath = uploadpath + File.separator + fileUrl; +// File file = new File(filePath); +// if(!file.exists()){ +// response.setStatus(404); +// throw new RuntimeException("文件不存在.."); +// } +// // 文件名称 +// fileName = file.getName(); +// inputStream = new BufferedInputStream(new FileInputStream(filePath)); +// }else if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ +// // minio 下载 +// // 通过MinioUtil查询时 只需要桶后面的路径 +// String minioUrl = MinioUtil.getMinioUrl(); +// // Linux/unix 系统下文件路径分隔符为"/" 获取minio与存储桶的路径 +// minioUrl = minioUrl + MinioUtil.getBucketName() + "/"; +// String url = fileUrl.replace(minioUrl, ""); +// // 文件名称 +// fileName = ossFile.getFileName(); +// inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url); +// } +// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); +//// response.setContentType("application/force-download");// 设置强制下载不打开 +// outputStream = response.getOutputStream(); +// byte[] buf = new byte[1024]; +// int len; +// while ((len = inputStream.read(buf)) > 0) { +// outputStream.write(buf, 0, len); +// } +// response.flushBuffer(); +// } catch (IOException e) { +// log.error("预览文件失败" + e.getMessage()); +// response.setStatus(404); +// e.printStackTrace(); +// } finally { +// if (inputStream != null) { +// try { +// inputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// if (outputStream != null) { +// try { +// outputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// } +// +// } + /** + * word,excel预览 + * + * @param id 传入文件id + * @param request + * @param response + */ + @GetMapping(value = "/download/{id}") + public void downLoad(@PathVariable("id") String id,HttpServletRequest request, HttpServletResponse response) { + if(StringUtils.isBlank(id)){ + throw new JeroBootException("参数信息不全"); + } + id = id.split("\\.")[0]; + // 查询数据表数据是否存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OSSFile::getId,id); + OSSFile ossFile = ossFileService.getOne(queryWrapper); + if( null == ossFile){ + throw new JeroBootException("文件不存在"); + } + InputStream inputStream = null; + OutputStream outputStream = null; + try { + //本地下载 + String filePath = ossFile.getUrl(); + File file = new File(filePath); + if(!CosBootUtil.doesObjectExist(filePath)){ + response.setStatus(404); + throw new RuntimeException("文件不存在.."); + } + // 文件名称 + response.setContentType("application/force-download");// 设置强制下载不打开 + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); + inputStream = CosBootUtil.download(filePath); + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (IOException e) { + log.error("文件下载失败" + e.getMessage()); + response.setStatus(404); + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + } + } + + /** + * word,excel预览 cos + * + * @param id 传入文件id + * @param request + * @param response + */ + @GetMapping(value = "/downLoadFile") + public void downLoadFromCos(String id,HttpServletRequest request, HttpServletResponse response,String userName) { + if(StringUtils.isBlank(id)){ + throw new JeroBootException("参数信息不全"); + } + id = id.split("\\.")[0]; + // 查询数据表数据是否存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OSSFile::getId,id); + OSSFile ossFile = ossFileService.getOne(queryWrapper); + if( null == ossFile){ + throw new JeroBootException("文件不存在"); + } + InputStream inputStream = null; + OutputStream outputStream = null; + File newFile =null; + try { + String fileName = ""; + //本地下载 + String filePath = ossFile.getUrl(); + if(!CosBootUtil.doesObjectExist(filePath)){ + response.setStatus(404); + throw new RuntimeException("文件不存在.."); + } + // 文件名称 + fileName = ossFile.getFileName(); + response.setContentType("application/force-download");// 设置强制下载不打开 + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); + + File file = new File(filePath); + if(file.getName().endsWith(".pdf") || file.getName().endsWith(".PDF")){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String currentTime = sdf.format(new Date()); + String waterContent = userName+" "+currentTime; + InputStream download = CosBootUtil.download(filePath); + newFile = PDFUtils.PDFWatermark(download,uploadpath,file.getName(),waterContent); + inputStream = new FileInputStream(newFile.getPath()); + }else{ + inputStream = CosBootUtil.download(filePath); + } + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (IOException e) { + log.error("文件下载失败" + e.getMessage()); + response.setStatus(404); + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + + } + if (newFile != null) { + try { + newFile.delete(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + } + + } + } + + /** + * word,excel预览 cos -pdf无水印 + * + * @param id 传入文件id + * @param request + * @param response + */ + @GetMapping(value = "/downLoadFileNOMark") + public void downLoadFileNoPDFWatermarkCos(String id,HttpServletRequest request, HttpServletResponse response,String userName) { + if(StringUtils.isBlank(id)){ + throw new JeroBootException("参数信息不全"); + } + id = id.split("\\.")[0]; + // 查询数据表数据是否存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OSSFile::getId,id); + OSSFile ossFile = ossFileService.getOne(queryWrapper); + if( null == ossFile){ + throw new JeroBootException("文件不存在"); + } + InputStream inputStream = null; + OutputStream outputStream = null; + File newFile =null; + try { + String fileName = ""; + //本地下载 + String filePath = ossFile.getUrl(); + if(!CosBootUtil.doesObjectExist(filePath)){ + response.setStatus(404); + throw new RuntimeException("文件不存在.."); + } + // 文件名称 + fileName = ossFile.getFileName(); + response.setContentType("application/force-download");// 设置强制下载不打开 + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); + + File file = new File(filePath); + inputStream = CosBootUtil.download(filePath); + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (IOException e) { + log.error("文件下载失败" + e.getMessage()); + response.setStatus(404); + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + + } + if (newFile != null) { + try { + newFile.delete(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + } + + } + } + + /** + * 文件下载 + * + * @param id 传入文件id + * @param request + * @param response + */ +// @GetMapping(value = "/downLoadFile") + public void downLoadFile(String id,HttpServletRequest request, HttpServletResponse response) { + // 查询数据表数据是否存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OSSFile::getId,id); + OSSFile ossFile = ossFileService.getOne(queryWrapper); + if( null == ossFile){ + throw new JeroBootException("文件不存在"); + } + InputStream inputStream = null; + OutputStream outputStream = null; + try { + String fileName = ""; + //本地下载 + String filePath = ossFile.getUrl(); + File file = new File(filePath); + if(!file.exists()){ + response.setStatus(404); + throw new RuntimeException("文件不存在.."); + } + // 文件名称 + fileName = file.getName(); + inputStream = new BufferedInputStream(new FileInputStream(filePath)); + response.setContentType("application/force-download");// 设置强制下载不打开 + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); + inputStream = new BufferedInputStream(new FileInputStream(filePath)); + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (IOException e) { + log.error("文件下载失败" + e.getMessage()); + response.setStatus(404); + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + } + + } + /** + * 文件预览PDF + * + * @param id 传入文件id + * @param request + * @param response + */ + @GetMapping(value = "/pdf/viewFile") + public void viewFile(String id,HttpServletRequest request, HttpServletResponse response,String userName) { + // 查询数据表数据是否存在 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OSSFile::getId,id); + OSSFile ossFile = ossFileService.getOne(queryWrapper); + if( null == ossFile){ + throw new JeroBootException("文件不存在.."); + } + InputStream inputStream = null; + OutputStream outputStream = null; + String fileName = ""; + try { + //本地下载 + String filePath = ossFile.getUrl(); + boolean b = CosBootUtil.doesObjectExist(filePath); + if (!b) { + response.setStatus(404); + throw new RuntimeException("文件不存在.."); + } + InputStream download = CosBootUtil.download(filePath); + File file = new File(filePath); + //水印内容 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String currentTime = sdf.format(new Date()); + String waterContent = userName+" "+currentTime; +// String waterContent = "water mark";//临时定义(水印信息通过传过来) + File newFile = PDFUtils.PDFWatermark(download,uploadpath,file.getName(),waterContent); + // 文件名称 + fileName = file.getName(); + inputStream = new BufferedInputStream(new FileInputStream(newFile)); + response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); + response.setContentType("application/force-download");// 设置强制下载不打开 + outputStream = response.getOutputStream(); + byte[] buf = new byte[1024]; + int len; + while ((len = inputStream.read(buf)) > 0) { + outputStream.write(buf, 0, len); + } + response.flushBuffer(); + } catch (IOException e) { + log.error("文件下载失败" + e.getMessage()); + response.setStatus(404); + e.printStackTrace(); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + File fileTemp = new File(uploadpath + File.separator +fileName); + fileTemp.delete(); + } + + } +// /** +// * 文件预览PDF +// * +// * @param id 传入文件id +// * @param request +// * @param response +// */ +// @GetMapping(value = "/pdf/viewFile") +// public void viewFile(String id,HttpServletRequest request, HttpServletResponse response) { +// // 查询数据表数据是否存在 +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(OSSFile::getId,id); +// OSSFile ossFile = ossFileService.getOne(queryWrapper); +// if( null == ossFile){ +// throw new JeroBootException("文件不存在.."); +// } +// InputStream inputStream = null; +// OutputStream outputStream = null; +// try { +// String fileName = ""; +// //本地下载 +// String filePath = ossFile.getUrl(); +// File file = new File(filePath); +// //水印内容 +// String waterContent = "water mark";//临时定义(水印信息通过传过来) +// File newFile = PDFUtils.PDFWatermark(file,waterContent); +// String path = newFile.getPath(); +//// String substring = path.substring(filePath.length(), path.length()); +// +// if(!file.exists()){ +// response.setStatus(404); +// throw new RuntimeException("文件不存在.."); +// } +// // 文件名称 +// fileName = file.getName(); +// inputStream = new BufferedInputStream(new FileInputStream(path)); +// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); +// response.setContentType("application/force-download");// 设置强制下载不打开 +// outputStream = response.getOutputStream(); +// byte[] buf = new byte[1024]; +// int len; +// while ((len = inputStream.read(buf)) > 0) { +// outputStream.write(buf, 0, len); +// } +// response.flushBuffer(); +// } catch (IOException e) { +// log.error("文件下载失败" + e.getMessage()); +// response.setStatus(404); +// e.printStackTrace(); +// } finally { +// if (inputStream != null) { +// try { +// inputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// if (outputStream != null) { +// try { +// outputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// } +// +// } + + /** + * @功能:pdf预览Iframe + * @param modelAndView + * @return + */ + @RequestMapping("/pdf/pdfPreviewIframe") + public ModelAndView pdfPreviewIframe(ModelAndView modelAndView) { + modelAndView.setViewName("pdfPreviewIframe"); + return modelAndView; + } + + /** + * 把指定URL后的字符串全部截断当成参数 + * 这么做是为了防止URL中包含中文或者特殊字符(/等)时,匹配不了的问题 + * @param request + * @return + */ + private static String extractPathFromPattern(final HttpServletRequest request) { + String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); + String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); + return new AntPathMatcher().extractPathWithinPattern(bestMatchPattern, path); + } + + /** + * 中转HTTP请求,解决跨域问题 + * + * @param url 必填:请求地址 + * @return + */ + @RequestMapping("/transitRESTful") + public Result transitRESTful(@RequestParam("url") String url, HttpServletRequest request) { + try { + ServletServerHttpRequest httpRequest = new ServletServerHttpRequest(request); + // 中转请求method、body + HttpMethod method = httpRequest.getMethod(); + JSONObject params; + try { + params = JSON.parseObject(JSON.toJSONString(httpRequest.getBody())); + } catch (Exception e) { + params = new JSONObject(); + } + // 中转请求问号参数 + JSONObject variables = JSON.parseObject(JSON.toJSONString(request.getParameterMap())); + variables.remove("url"); + // 在 headers 里传递Token + String token = TokenUtils.getTokenByRequest(request); + HttpHeaders headers = new HttpHeaders(); + headers.set("X-Access-Token", token); + // 发送请求 + String httpURL = URLDecoder.decode(url, "UTF-8"); + ResponseEntity response = RestUtil.request(httpURL, method, headers , variables, params, String.class); + // 封装返回结果 + Result result = new Result<>(); + int statusCode = response.getStatusCodeValue(); + result.setCode(statusCode); + result.setSuccess(statusCode == 200); + String responseBody = response.getBody(); + try { + // 尝试将返回结果转为JSON + Object json = JSON.parse(responseBody); + result.setResult(json); + } catch (Exception e) { + // 转成JSON失败,直接返回原始数据 + result.setResult(responseBody); + } + return result; + } catch (Exception e) { + log.debug("中转HTTP请求失败", e); + return Result.error(e.getMessage()); + } + } + +} diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/controller/PhoneProblemKnowledgeBaseEOController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/controller/PhoneProblemKnowledgeBaseEOController.java index 34299cb40..3e210a832 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/controller/PhoneProblemKnowledgeBaseEOController.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/controller/PhoneProblemKnowledgeBaseEOController.java @@ -152,7 +152,7 @@ public class PhoneProblemKnowledgeBaseEOController extends JeroController queryById(@RequestParam(name="id",required=true) String id, @RequestParam(name="cut",required=true) String cut) { - ProblemKnowledgeBaseEO problemKnowledgeBaseEO = problemKnowledgeBaseEOService.queryById(id,cut); + ProblemKnowledgeBaseEO problemKnowledgeBaseEO = problemKnowledgeBaseEOService.phoneQueryById(id,cut); if(problemKnowledgeBaseEO==null) { return Result.error("未找到对应数据"); } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/IProblemKnowledgeBaseEOService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/IProblemKnowledgeBaseEOService.java index 0c3131507..276f32100 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/IProblemKnowledgeBaseEOService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/problemKnowledgeBase/service/IProblemKnowledgeBaseEOService.java @@ -57,6 +57,8 @@ public interface IProblemKnowledgeBaseEOService extends IService sysConfigs = iSysConfigService.queryList(); + if(org.apache.commons.collections.CollectionUtils.isNotEmpty(sysConfigs)){ + for (SysConfig sysConfig : sysConfigs) { + if(sysConfig.getConfigName().equals("domainWebImgURL")){ + String pcUrl = sysConfig.getConfig(); + String phoneUrl = sysConfig.getPhoneConfig(); + String content = problemKnowledgeBaseEO.getContent().replace(pcUrl,phoneUrl); + content = content.replace("jero-boot/","jero-boot/phone/"); + problemKnowledgeBaseEO.setContent(content); + break; + } + } + } + + List problemKnowledgeBaseEOList = new ArrayList<>(); + if (ObjectUtils.isNotEmpty(problemKnowledgeBaseEO)) { + problemKnowledgeBaseEOList.add(problemKnowledgeBaseEO); + } + this.disposeData(problemKnowledgeBaseEOList,cut); + if (CollectionUtils.isNotEmpty(problemKnowledgeBaseEOList)) { + problemKnowledgeBaseEO = problemKnowledgeBaseEOList.get(0); + } + return problemKnowledgeBaseEO; + } /** * 列表查询 diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/wkflow/controller/PhoneworkFlowController.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/wkflow/controller/PhoneworkFlowController.java new file mode 100644 index 000000000..be53e0e48 --- /dev/null +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/wkflow/controller/PhoneworkFlowController.java @@ -0,0 +1,244 @@ +package com.jero.modules.wkflow.controller; + +import com.jero.common.api.vo.Result; +import com.jero.common.aspect.annotation.AutoLog; +import com.jero.common.constant.WebsocketConst; +import com.jero.common.system.vo.LoginUser; +import com.jero.modules.message.websocket.WebSocket; +import com.jero.modules.project.entity.ConditionAssessmentEO; +import com.jero.modules.project.enums.CurrentProjectStatusEnum; +import com.jero.modules.project.enums.ProjectRoleEnum; +import com.jero.modules.project.service.IConditionAssessmentEOService; +import com.jero.modules.wkflow.entity.BusMes; +import com.jero.modules.wkflow.enums.FlowTypeEnum; +import com.jero.modules.wkflow.feginClient.impl.WorkFlowFeignClientImpl; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import net.sf.json.JSONObject; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; + +@Slf4j +@Api(tags="工作流管理") +@RestController +@RequestMapping("/phone/workFlow") +public class PhoneworkFlowController { + + @Autowired + private WorkFlowFeignClientImpl workFlowFeignClient; + + @Autowired + private IConditionAssessmentEOService conditionAssessmentEOService; + + @Autowired + private WebSocket webSocket; + + public Result activiti_define_start(@RequestBody JSONObject jsonObject){ + return workFlowFeignClient.activiti_define_start(jsonObject); + } + + @AutoLog(value = "启动流程-以流程定义id") + @ApiOperation(value="启动流程-以流程定义id", notes="启动流程-以流程定义id") + @PostMapping("/startProcess") + public Result startProcess(@RequestBody JSONObject jsonObject){ + String type = jsonObject.getString("type"); + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + jsonObject.put("loginUserId", currentUser.getId()); + jsonObject.put("loginUserName", currentUser.getUsername()); + if(StringUtils.equals(type,FlowTypeEnum.RWQRLC.getValue())){ + /*jsonObject.put("id", FlowTypeEnum.RWQRLC.getProcessDefinitionKey()); //流程定义id + return this.activiti_define_start(jsonObject);*/ + jsonObject.put("processDefinitionKey", FlowTypeEnum.RWQRLC.getProcessDefinitionKey()); + return this.startTaskToConfirmProcess(jsonObject); + }else if(StringUtils.equals(type,FlowTypeEnum.SJFHXSHLC.getValue())){ + jsonObject.put("id", FlowTypeEnum.SJFHXSHLC.getProcessDefinitionKey()); + //initConditionAssessmentEO(jsonObject); + return this.activiti_define_start(jsonObject); + }else if(StringUtils.equals(type,FlowTypeEnum.PREHOMOQRLC.getValue())){ + jsonObject.put("id", FlowTypeEnum.PREHOMOQRLC.getProcessDefinitionKey()); + //initConditionAssessmentEO(jsonObject); + return this.activiti_define_start(jsonObject); + }else if(StringUtils.equals(type,FlowTypeEnum.YZFHXSCLC.getValue())){ + jsonObject.put("id", FlowTypeEnum.YZFHXSCLC.getProcessDefinitionKey()); + //initConditionAssessmentEO(jsonObject); + return this.activiti_define_start(jsonObject); + }else if(StringUtils.equals(type,FlowTypeEnum.FGYJSJLC.getValue())){ + jsonObject.put("id", FlowTypeEnum.FGYJSJLC.getProcessDefinitionKey()); + return this.activiti_define_start(jsonObject); + }else if(StringUtils.equals(type,FlowTypeEnum.FGJSPG.getValue())){ + jsonObject.put("processDefinitionKey", FlowTypeEnum.FGJSPG.getProcessDefinitionKey()); + return this.startLawsTechnologyEvaluationProcess(jsonObject); + }else if(StringUtils.equals(type,FlowTypeEnum.XGJFWLC.getValue())){ + jsonObject.put("id", FlowTypeEnum.XGJFWLC.getProcessDefinitionKey()); + return this.activiti_define_start(jsonObject); + }else{ + return null; + } + } + + @AutoLog(value = "完成任务") + @ApiOperation(value="完成任务", notes="完成任务") + @PostMapping("/completeTask") + public Result completeTaskByUserId(@RequestBody BusMes busMes){ + if(StringUtils.isEmpty(busMes.getUserId())){ + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + busMes.setUserId(currentUser.getId()); + } + Result str = workFlowFeignClient.completeTaskByUserId(busMes); + if(str.getCode() == 500){ + str.setSuccess(false); + } + sendWebsocket(busMes.getTaskId(),busMes.getTaskId()); + return str; + } + + @AutoLog(value = "批量完成任务") + @ApiOperation(value="批量完成任务", notes="批量完成任务") + @PostMapping("/completeTaskBatch") + public Result completeTaskByUserIdBatch(@RequestBody BusMes busMes){ + if(StringUtils.isEmpty(busMes.getUserId())){ + LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + busMes.setUserId(currentUser.getId()); + } + Result str = workFlowFeignClient.completeTaskByUserIdBatch(busMes); + if(str.getCode() == 500){ + str.setSuccess(false); + } +// sendWebsocket(busMes.getTaskId(),busMes.getTaskId()); + return str; + } + + public void sendWebsocket(String msgId, String msgTet) { + com.alibaba.fastjson.JSONObject obj = new com.alibaba.fastjson.JSONObject(); + obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_TOPIC); + obj.put(WebsocketConst.MSG_ID, msgId); + obj.put(WebsocketConst.MSG_TXT, msgTet); + webSocket.sendMessage(obj.toJSONString()); + } + + @AutoLog(value = "通过流程实例id查询当前待办的流程实例是否结束") + @ApiOperation(value="通过流程实例id查询当前待办的流程实例是否结束", notes="通过流程实例id查询当前待办的流程实例是否结束") + @GetMapping("/queryTaskWhetherToEnd") + public String queryTaskWhetherToEnd(@RequestParam("prcId") String prcId) { + return workFlowFeignClient.queryTaskWhetherToEnd(prcId); + } + + @AutoLog(value = "改派") + @ApiOperation(value="改派", notes="改派") + @GetMapping("/changeAssigneeNew") + public Result run(@RequestParam("taskId")String taskId,@RequestParam("assignee") String assignee, + @RequestParam("userId")String userId,@RequestParam("pId") String pId) { + return workFlowFeignClient.run(taskId,assignee,userId,pId); + } + + @AutoLog(value = "保存任务第一步") + @ApiOperation(value="保存任务第一步", notes="保存任务第一步") + @PostMapping("/saveTaskFirst") + public Result saveTaskFirst(BusMes busMes){ + return workFlowFeignClient.saveTaskFirst(busMes); + } + + @AutoLog(value = "查询流程是否结束") + @ApiOperation(value="查询流程是否结束", notes="查询流程是否结束") + @GetMapping("/isEnd") + public String isEnd(@RequestParam("pId")String pId){ + return workFlowFeignClient.isEnd(pId); + } + + @AutoLog(value = "删除流程") + @ApiOperation(value="删除流程", notes="删除流程") + @GetMapping("/deleteProcessInstance") + public Result deleteProcessInstance(@RequestParam("pId")String pId){ + return workFlowFeignClient.deleteProcessInstance(pId); + } + + @AutoLog(value = "流程实例明细列表") + @ApiOperation(value="流程实例明细列表", notes="流程实例明细列表") + @GetMapping("/get_list_by_instance") + public List> get_list_by_instance(@RequestParam("prcNum") String prcNum,@RequestParam("cut") String cut,@RequestParam("prcType") String prcType,@RequestParam(value="sortWord",required = false)String sortWord,@RequestParam(value="shunxu",required = false) String shunxu){ + return workFlowFeignClient.get_list_by_instance(prcNum,cut,prcType,sortWord,shunxu); + } + + @AutoLog(value = "获取图片") + @ApiOperation(value="获取图片", notes="获取图片") + @GetMapping("/getImg") + public void getImg(@RequestParam("prcNum")String prcNum,HttpServletResponse response) throws IOException { + OutputStream os = null; + response.setContentType("image/jpg"); + response.flushBuffer(); + os = response.getOutputStream(); + os.write(workFlowFeignClient.getImg(prcNum)); + os.flush(); + os.close(); + } + + @AutoLog(value = "强制撤回") + @ApiOperation(value="强制撤回", notes="强制撤回") + @GetMapping("/forceRecall") + public Result forceRecall(@RequestParam("prcId") String prcId){ + return workFlowFeignClient.forceRecall(prcId); + } + + @AutoLog(value = "查询流程列表") + @ApiOperation(value="查询流程列表", notes="查询流程列表") + @GetMapping("/modelListPage") + public Result> modelListPage(@RequestParam(value="name",required = false)String name, @RequestParam(value="category_id ",required = false)String category_id, + @RequestParam("current")int current, @RequestParam("size")int size){ + return workFlowFeignClient.modelListPage(name,category_id,current,size); + } + + @AutoLog(value = "根据流程实例id查询流程历史") + @ApiOperation(value="根据流程实例id查询流程历史", notes="根据流程实例id查询流程历史") + @GetMapping("/queryProcessHistoryByPrcId") + public List> queryProcessHistoryByPrcId(@RequestParam("prcId") String prcId,@RequestParam("cut") String cut,@RequestParam("prcType") String prcType,@RequestParam(value="sortWord",required = false)String sortWord,@RequestParam(value="shunxu",required = false) String shunxu){ + return workFlowFeignClient.queryProcessHistoryByPrcId(prcId,cut,prcType,sortWord,shunxu); + } + + /** + * 初始化这条法规的 当前项目状态 + */ + public void initConditionAssessmentEO(JSONObject jsonObject){ + Object msg = jsonObject.get("msg"); + Map projectLawsInventoryMap = com.alibaba.fastjson.JSONObject.parseObject(com.alibaba.fastjson.JSONObject.toJSONString(msg), Map.class); + + ConditionAssessmentEO conditionAssessmentEO = new ConditionAssessmentEO(); + conditionAssessmentEO.setRoleCode(ProjectRoleEnum.REGULATI_AND_HOMOLOGATION_ENGINEER.getValue()); + conditionAssessmentEO.setProjectLawsInventoryId(projectLawsInventoryMap.get("id").toString()); + conditionAssessmentEO.setConditionAssessment(CurrentProjectStatusEnum.BLUE.getValue()); + conditionAssessmentEOService.addOrUpdate(conditionAssessmentEO); + } + + /** + * 启动流程-法规技术评估流程 + * @param jsonObject + * @return + */ + public Result startLawsTechnologyEvaluationProcess(@RequestBody JSONObject jsonObject){ + return workFlowFeignClient.startLawsTechnologyEvaluationProcess(jsonObject); + } + + /** + * 启动流程-任务确认流程 + * @param jsonObject + * @return + */ + public Result startTaskToConfirmProcess(@RequestBody JSONObject jsonObject){ + return workFlowFeignClient.startTaskToConfirmProcess(jsonObject); + } + + @AutoLog(value = "根据taskId删除流程") + @ApiOperation(value="根据taskId删除流程", notes="根据taskId删除流程") + @GetMapping("/deleteProcessInstanceByTaskId") + public Result deleteProcessInstanceByTaskId(@RequestParam("taskId")String taskId){ + return workFlowFeignClient.deleteProcessInstance(taskId); + } +}