Merge branch 'develop_migration' into 'develop_master'
Develop migration See merge request LiuChao/foton-slrs-system-rest!298
This commit is contained in:
+39
-78
@@ -12,6 +12,9 @@ import com.adc.da.http.PageInfo;
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.common.Page;
|
||||
import com.adc.da.login.util.JwtUtils;
|
||||
import com.adc.da.slrs.sarUser.entity.TsUser;
|
||||
import com.adc.da.slrs.sarUser.service.ITsUserService;
|
||||
import com.adc.da.sys.common.EmailUtils;
|
||||
import com.adc.da.sys.entity.UserEO;
|
||||
import com.adc.da.sys.service.IUserEOService;
|
||||
@@ -30,12 +33,14 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -52,94 +57,50 @@ public class WorkFlowController {
|
||||
@Value("${stand.edit.file.path}")
|
||||
private String standEditFilePath;
|
||||
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
|
||||
@Autowired
|
||||
private ITsUserService userService;
|
||||
|
||||
// @Autowired
|
||||
// private ExportExcelMapper exportExcelMapper;
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "手机获取token")
|
||||
@PostMapping(value = "/loginMobile")
|
||||
@ResponseBody
|
||||
public ResponseMessage<String> loginMobile(String taskIds, String pId) throws UnsupportedEncodingException {
|
||||
BusProcessNew busProcessNew = workFlowFeignClient.queryDetail(taskIds);
|
||||
if(busProcessNew == null || StringUtils.isBlank(busProcessNew.getUserId())){
|
||||
return Result.error("r0011", "用户不存在");
|
||||
}
|
||||
TsUser userEO = userService.getById(busProcessNew.getUserId());
|
||||
if (null == userEO) {
|
||||
return Result.error("r0011", "用户不存在");
|
||||
}
|
||||
if(userEO.getDisableFlag().equals("1")){
|
||||
return Result.error("r0011", "帐号已禁用");
|
||||
}
|
||||
String token = jwtUtils.generateToken(userEO.getUserId());
|
||||
userEO.setToken(token);
|
||||
// 加密重要信息
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
String userStr = JSON.toJSONString(userEO);
|
||||
String userStr2 = URLEncoder.encode(userStr,"UTF-8");
|
||||
userStr = encoder.encode(userStr2.getBytes());
|
||||
return Result.success(userStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation(value = "查询在线编辑流程汇总文件编辑对象")
|
||||
@GetMapping("/processModelHisOneCount")
|
||||
public BusProcessModelHis processModelHisOneCount(@RequestParam("pid") String pid){
|
||||
return workFlowFeignClient.processModelHisOneCount(pid);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFile")
|
||||
public void recieveFile(HttpServletRequest request, HttpServletResponse response, String fileNm,String standNo,String pid,String taskId){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
try {
|
||||
PrintWriter writer = response.getWriter();
|
||||
String body = "";
|
||||
try {
|
||||
Scanner scanner = new Scanner(request.getInputStream());
|
||||
scanner.useDelimiter("\\A");
|
||||
body = scanner.hasNext() ? scanner.next() : "";
|
||||
scanner.close();
|
||||
} catch (Exception ex) {
|
||||
writer.write("get request.getInputStream error:" + ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (body.isEmpty()) {
|
||||
writer.write("empty request.getInputStream");
|
||||
return;
|
||||
}
|
||||
|
||||
net.sf.json.JSONObject jsonObj = net.sf.json.JSONObject.fromObject(body);
|
||||
logger.info("**********onlyoffice接收文档接口获得结果body************" + body);
|
||||
int status = (Integer) jsonObj.get("status");
|
||||
|
||||
int saved = 0;
|
||||
if (status == 2 || status == 3)//MustSave, Corrupted
|
||||
{
|
||||
String downloadUri = (String) jsonObj.get("url");
|
||||
|
||||
try {
|
||||
logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri);
|
||||
if (StringUtils.isNotEmpty(downloadUri)) {
|
||||
File file = new File(standEditFilePath + standNo + "\\" + fileNm);
|
||||
downloadNetFile(downloadUri, file);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
saved = 1;
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + ex.getMessage());
|
||||
logger.error(ex.getMessage(),ex);
|
||||
}
|
||||
} else if (status == 4) {
|
||||
logger.info("**********onlyoffice接收文档接口开始修改文件状态状态4************");
|
||||
|
||||
logger.info("**********onlyoffice接收文档接口修改文件状态成功状态4************");
|
||||
}
|
||||
logger.info("onlyoffice编辑完成--------------");
|
||||
writer.write("{\"error\":" + saved + "}");
|
||||
|
||||
// 更新在线编辑当前节点编辑状态
|
||||
workFlowFeignClient.processModelHisOneUpdStatus(pid,taskId);
|
||||
} catch (IOException e) {
|
||||
logger.info("**********onlyoffice接收文档接口异常************" + e.getMessage());
|
||||
logger.error(e.getMessage(),e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void downloadNetFile(String downloadUrl, File file) {
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file);
|
||||
URL url = new URL(downloadUrl);
|
||||
URLConnection connection = url.openConnection();
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
int length = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((length = inputStream.read(bytes)) != -1) {
|
||||
fileOutputStream.write(bytes, 0, length);
|
||||
}
|
||||
fileOutputStream.close();
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
logger.error("download error ! url :{}, exception:{}", downloadUrl, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新在线编辑流程当前节点编辑状态")
|
||||
@GetMapping("/processModelHisOneUpd")
|
||||
public BusProcessModelHis processModelHisOneUpd(@RequestParam("pid") String pid,@RequestParam("taskId") String taskId){
|
||||
|
||||
@@ -66,6 +66,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
// onlyOffice 回调
|
||||
addInterceptor.excludePathPatterns("/api/lawss/activiti/recieveFile");
|
||||
|
||||
// 手机获取token
|
||||
addInterceptor.excludePathPatterns("/api/lawss/activiti/loginMobile");
|
||||
|
||||
addInterceptor.excludePathPatterns("/api/lawss/activiti/processModelHisOne");
|
||||
|
||||
addInterceptor.excludePathPatterns("/api/lawss/activiti/processModelHisOneCount");
|
||||
|
||||
@@ -150,6 +150,10 @@ public class TsUser extends BaseEntity {
|
||||
@TableField(exist = false)
|
||||
private Integer size;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String token;
|
||||
|
||||
|
||||
public TsUser() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user