Commit 2d6b4554 authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents 542f72b1 9dfe2add
......@@ -12,4 +12,6 @@ public class TransferModel extends UploadFileModel{
private String processDefinitionId;
private String result;
private String comment;
private Boolean autoConfirm;
}
package com.yeejoin.amos.avic.config;
import java.util.HashMap;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import lombok.Data;
@Component
@ConfigurationProperties(prefix = "amos.auth")
@EnableScheduling
@Data
public class AmosAuth {
private String userName;
private String password;
private String appKey;
private String product;
@Autowired
Privilege privilege;
HashMap<String, Object> model = null;
@PostConstruct
public void login() {
new Thread(new Runnable() {
@Override
public void run() {
boolean flag = false;
do {
try {
IdPasswordAuthModel arg0 = new IdPasswordAuthModel();
arg0.setLoginId(userName);
arg0.setPassword(DesUtil.encode(password, "qaz"));
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
FeignClientResult o = privilege.authClient.idpassword(arg0);
model = (HashMap<String, Object>) o.getResult();
flag = false;
} catch (Exception e) {
if (!flag) {
e.printStackTrace();
}
flag = true;
try {
Thread.sleep(5000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
} while (flag);
configureTasks();
}
}).start();
}
public String getToken() {
return model.get("token").toString();
}
public String getUserId() {
return model.get("userId").toString();
}
// 或直接指定时间间隔,例如:5秒
@Scheduled(fixedRate = 3600000)
private void configureTasks() {
RequestContext.setToken(getToken());
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
Privilege.agencyUserClient.getme();
}
}
......@@ -2,18 +2,16 @@ package com.yeejoin.amos.avic.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.Timer;
import java.util.TimerTask;
import java.util.stream.Collectors;
import javax.activation.DataHandler;
......@@ -41,6 +39,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
......@@ -48,7 +47,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.avic.config.AmosAuth;
import com.yeejoin.amos.avic.face.model.AvicCustomPathModel;
import com.yeejoin.amos.avic.face.model.TransferModel;
import com.yeejoin.amos.avic.face.orm.entity.AvicCustomPath;
......@@ -78,9 +77,15 @@ public class WebServicesFileFransferResource {
@Autowired
private AvicCustomPathService simpleService;
@Autowired
AmosAuth amosAuth;
@Value(value = "${upload.temp.dir}")
String tempDir;
@Value(value = "${avic.time.connection.timeout}")
long connectionTimeout;
@Value(value = "${avic.time.receive.timeout}")
long receiveTimeout;
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSSS");
......@@ -188,13 +193,36 @@ public class WebServicesFileFransferResource {
indicatorsManager.indicatorClient.saveBizRecord(transferModel.getTaskId(), bizTable.get("id").toString(),
list);
workflowManager.workflowClient.startFormByProcess(null, tmpl.get("processDefinition").toString());
// workflowManager.workflowClient.startFormByProcess(null, tmpl.get("processDefinition").toString());
indicatorsManager.indicatorClient.adopt(transferModel.getTaskId());
} catch (java.lang.Exception e) {
e.printStackTrace();
}
if (transferModel.getAutoConfirm()) {
Timer timer = new Timer();
timer.schedule(new MyTimerTask(transferModel), 1000);
}
return ResponseHelper.buildResponse(null);
}
class MyTimerTask extends TimerTask {
TransferModel transferModel;
MyTimerTask(TransferModel transferModel) {
this.transferModel = transferModel;
}
@Override
public void run() {
RequestContext.setToken(amosAuth.getToken());
RequestContext.setProduct(amosAuth.getProduct());
RequestContext.setAppKey(amosAuth.getAppKey());
postfile(transferModel);
}
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "传输")
......@@ -220,8 +248,8 @@ public class WebServicesFileFransferResource {
Client client = dcf.createClient(webserviceUrl);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(1000000); // 连接超时时间
policy.setReceiveTimeout(1000000);// 请求超时时间.
policy.setConnectionTimeout(connectionTimeout); // 连接超时时间
policy.setReceiveTimeout(receiveTimeout);// 请求超时时间.
conduit.setClient(policy);
if (ObjectUtils.isEmpty(transferModel.getAvicCode())) {
for (String file : transferModel.getFiles().stream().map(m -> m.getUrl())
......
......@@ -9,6 +9,7 @@ import javax.activation.DataHandler;
import javax.jws.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
......@@ -25,7 +26,8 @@ public class FileFransferServiceImpl implements FileFransferService {
@Autowired
AvicCustomPathService avicCustomPathService;
String baseDir = "E:\\webservice\\";
@Value("${avic.file.store.path}")
String baseDir;
@Override
public void useCodetransferFile(DataHandler handler, String fileName, String path, String code) {
......
......@@ -12,4 +12,7 @@ spring.redis.port=6379
spring.redis.password=yeejoin@2020
upload.temp.dir=E:\\ftp\\
avic.webservice.path=http://localhost:8808/avic/services/fileFransfer?wsdl
\ No newline at end of file
avic.file.store.path=E:\\webservice
avic.webservice.path=http://localhost:8808/avic/services/fileFransfer?wsdl
avic.time.connection.timeout=100000
avic.time.receive.timeout=100000
\ No newline at end of file
......@@ -207,7 +207,8 @@
'equipment' as componentKey,
'equipment' as `key`,
equ.img as imgPath,
spe.qr_code as equipCode,
-- spe.qr_code as equipCode,
spe.code as equipCode,
stru.source_id as parentId,
cat.id as equipId,
cat.code as categoryCode,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment