Commit 5d0d1b2d authored by guozhipeng's avatar guozhipeng

代码合并

parent e5822190
......@@ -248,7 +248,8 @@ sap.ui.define(
var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = {
'x-csrf-token': that.getStorage().get("csrfToken")
'x-csrf-token': that.getStorage().get("csrfToken"),
'Content-Type': 'application/json'
};
}
headers.language=that.language;
......@@ -407,7 +408,8 @@ sap.ui.define(
var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = {
'x-csrf-token': that.getStorage().get("csrfToken")
'x-csrf-token': that.getStorage().get("csrfToken"),
'Content-Type': 'application/json'
};
}
headers.language=that.language;
......@@ -550,7 +552,8 @@ sap.ui.define(
var headers = {};//headers: headers,
if (that.getStorage().get("csrfToken") != null && that.getStorage().get("csrfToken") !== undefined) {
headers = {
'x-csrf-token': that.getStorage().get("csrfToken")
'x-csrf-token': that.getStorage().get("csrfToken"),
'Content-Type': 'application/json'
};
}
headers.language=that.language;
......
......@@ -171,7 +171,7 @@ sap.ui.define([
MessageBox.warning(this.i18n("Msg_input_username_password"));
return;
}*/
console.log("onLoginUrl=", that.baseUrl+"login/login");
console.log("onLoginUrl=", that.baseUrl+"login/oauth2Login");
that.getCsrfToken(csrfToken => {
console.log('【获取到的 CSRF Token】 ', csrfToken);
var csrfTokenStorage = that.getStorage().get("csrfToken")
......@@ -191,7 +191,7 @@ sap.ui.define([
method: "POST",
headers: headers,
data: JSON.stringify(param),
url: that.baseUrl+"login/login",
url: that.baseUrl+"login/oauth2Login",
contentType: 'application/json',
dataType: 'json',
success: function(data){
......
......@@ -164,6 +164,22 @@ cf login -a https://api.cf.cn40.platform.sapcloud.cn -o "Shenzhen-Lianchuangjie-
输入密码: Gzp@123456 后回车。
## 代码合并差异文件
前端代码app差异文件
后端代码srv差异文件
lcj-btp-java\srv\src\main\java\customer\lianchuangjie\common\config\CorsConfig.java
lcj-btp-java\srv\src\main\java\customer\lianchuangjie\common\filter\OperateAuthFilter.java
lcj-btp-java\srv\src\main\java\customer\lianchuangjie\Application.java
## 部署到云服务器
### 使用mtaDeploy批处理部署
......
......@@ -50,7 +50,7 @@ public class LoginController {
@PostMapping(value = "/login")
public Result login(@RequestBody JSONObject jsonObject, HttpServletRequest req) {
/*String language = req.getHeader("language");
String language = req.getHeader("language");
// return loginService.login(UserLogin);
if (StringUtils.isEmpty(jsonObject.getString("userLoginId"))) {
return Result.error("用户名不能为空");
......@@ -63,8 +63,18 @@ public class LoginController {
return Result.error(MessageUtil.get("user_login_passwordWeak", language));
}
return loginService.login(jsonObject, req);*/
return loginService.oauthLogin(jsonObject, req);
return loginService.login(jsonObject, req);
}
/**
* BTP oauth2 鉴权登录
* @param jsonObject
* @param req
* @return
*/
@PostMapping(value = "/oauth2Login")
public Result oauth2Login(@RequestBody JSONObject jsonObject, HttpServletRequest req) {
return loginService.oauth2Login(jsonObject, req);
}
@PostMapping(value = "/updatePasswordAll")
......
......@@ -9,6 +9,11 @@ import jakarta.servlet.http.HttpServletRequest;
public interface LoginService {
public Result login(JSONObject jsonObject, HttpServletRequest req);
//新的鉴权方式
public Result oauthLogin(JSONObject jsonObject, HttpServletRequest req);
/**
* BTP oauth2 鉴权登录
* @param jsonObject
* @param req
* @return
*/
public Result oauth2Login(JSONObject jsonObject, HttpServletRequest req);
}
......@@ -36,7 +36,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import static customer.lianchuangjie.common.util.ConvertUtils.getSuffix;
......@@ -55,8 +54,6 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment
private AttachmentProductBatchDao attachmentProductBatchDao;
@Autowired
private GoldSampleDao goldSampleDao;
@Autowired
private MultipartResolver multipartResolver;
/**
* 批量上传
......@@ -68,51 +65,39 @@ public class AttachmentServiceImpl extends ServiceImpl<AttachmentDao, Attachment
@Transactional(rollbackFor = Exception.class)
public Result<?> batchUpload(HttpServletRequest request, String language) {
String message = "";
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
List<JSONObject> results = new ArrayList<>();
// 获取原始请求对象
HttpServletRequest originalRequest = request;
while (originalRequest instanceof javax.servlet.http.HttpServletRequestWrapper) {
originalRequest = (HttpServletRequest) ((javax.servlet.http.HttpServletRequestWrapper) originalRequest).getRequest();
log.info("[originalRequest instanceof javax.servlet.http.HttpServletRequestWrapper]true");
}
if (multipartResolver.isMultipart(originalRequest)) {
log.info("[multipartResolver.isMultipart(originalRequest)]true");
MultipartHttpServletRequest multipartRequest = multipartResolver.resolveMultipart(originalRequest);
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
log.info("[fileMap.entrySet()]for");
JSONObject item = new JSONObject();
MultipartFile file = entity.getValue();// 获取上传文件对象
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
JSONObject item = new JSONObject();
MultipartFile file = entity.getValue();// 获取上传文件对象
try {
if (file != null) { // 文件不为空
String originalFilename = file.getOriginalFilename();
long size = file.getSize();
String contentType = file.getContentType();
String fileId = FileServerUtil.upload(file.getInputStream(), file.getOriginalFilename(), FileServerUtil.Timeout.BEST);
item.put("fileId", fileId);//文件服务器生成的文件ID
item.put("fileName", originalFilename);//原始文件名
item.put("fileSize", size);//文件大小 字节 byte
item.put("contentType", contentType);//文件类型
item.put("fileSuffix", getSuffix(originalFilename));//文件后缀名
results.add(item);
} else {
throw new BtpException(MessageUtil.get("paramNotEmpty", new Object[] { "" }, language));
}
} catch (Exception e) {
message = "" + (e.getMessage() != null ? e.getMessage() : e);
log.error(message);
throw new BtpException(MessageUtil.get("error", new Object[] { message }, language));
} finally {
try {
if (file != null) { // 文件不为空
String originalFilename = file.getOriginalFilename();
long size = file.getSize();
String contentType = file.getContentType();
String fileId = FileServerUtil.upload(file.getInputStream(), file.getOriginalFilename(), FileServerUtil.Timeout.BEST);
item.put("fileId", fileId);//文件服务器生成的文件ID
item.put("fileName", originalFilename);//原始文件名
item.put("fileSize", size);//文件大小 字节 byte
item.put("contentType", contentType);//文件类型
item.put("fileSuffix", getSuffix(originalFilename));//文件后缀名
results.add(item);
} else {
throw new BtpException(MessageUtil.get("paramNotEmpty", new Object[] { "" }, language));
}
} catch (Exception e) {
file.getInputStream().close();
} catch (IOException e) {
message = "" + (e.getMessage() != null ? e.getMessage() : e);
log.error(message);
throw new BtpException(MessageUtil.get("error", new Object[] { message }, language));
} finally {
try {
file.getInputStream().close();
} catch (IOException e) {
message = "" + (e.getMessage() != null ? e.getMessage() : e);
log.error(message);
}
}
}
} else {
log.info("[multipartResolver.isMultipart(originalRequest)]false");
}
if (results.size() > 0) {
Result<Object> ok = Result.ok(MessageUtil.get("success", new Object[] { message }, language));
......
......@@ -69,8 +69,6 @@ public class LoginServiceImpl implements LoginService {
try {
// 打印日志
log.info("【用户ID:{},尝试登录】", userLoginId);
log.info("authorization {}", req.getHeader("authorization"));
log.info("cookie {}", req.getHeader("cookie"));
String finalUserLoginId = userLoginId;
CqnSelect cqnselect = Select.from(UserLogin_.class)
......@@ -100,7 +98,10 @@ public class LoginServiceImpl implements LoginService {
// 创建Get请求
HttpGet httpGet = new HttpGet(uri);
//添加鉴权 authorization Basic c2FiaW5lOnBhc3Nfc2FiaW5l
httpGet.setHeader("authorization", req.getHeader("authorization"));
String authorization = req.getHeader("authorization");
if (authorization != null && !"".equals(authorization)) {
httpGet.setHeader("authorization", req.getHeader("authorization"));
}
JSONObject jsonObject1 = null;
HttpResponse res = client.execute(httpGet);
// 返回json格式:
......@@ -130,8 +131,14 @@ public class LoginServiceImpl implements LoginService {
return result;
}
/**
* BTP oauth2 鉴权登录
* @param jsonObject
* @param req
* @return
*/
@Override
public Result oauthLogin(JSONObject jsonObject, HttpServletRequest req) {
public Result oauth2Login(JSONObject jsonObject, HttpServletRequest req) {
Result result = new Result<>();
String userLoginId = null;
String username = null;//用户名 邮箱
......
......@@ -4229,6 +4229,25 @@ public class PartyServiceImpl implements PartyService {
return Result.error((MessageUtil.get("party_partyIsNull", language)));
}
List<PartyRole> partyRoleList = partyRoleDao.selectListByPartyId(partyId);
List<PartyRole> customer = StreamApiUtil.filter(partyRoleList, item->"CUSTOMER".equals(item.getRoleTypeId()));
List<PartyRole> supplier = StreamApiUtil.filter(partyRoleList, item->"SUPPLIER".equals(item.getRoleTypeId()));
//更新客户角色
if (CollectionUtils.isNotEmpty(customer)) {
JSONObject objectCustomer = new JSONObject();
objectCustomer.put("partyId", partyId);
objectCustomer.put("ruleCode", "customer");
Result resultCustomer = updatePartyCompanyByRoleToSap(objectCustomer, language);
}
//更新供应商角色
if (CollectionUtils.isNotEmpty(supplier)) {
JSONObject objectSupplier = new JSONObject();
objectSupplier.put("partyId", partyId);
objectSupplier.put("ruleCode", "supplier");
Result resultSupplier = updatePartyCompanyByRoleToSap(objectSupplier, language);
}
JSONObject json = new JSONObject();
JSONObject object = new JSONObject();
String groupName = partyGroup.getGroupName();
......@@ -4357,7 +4376,7 @@ public class PartyServiceImpl implements PartyService {
Result roleResult = updateBpRoleToSap(object, language);
if (roleResult.isSuccess()) {
}else {
return Result.error(roleResult.getMessage());
/*return Result.error(roleResult.getMessage());*/
}
}
for (Party party : companyList) {
......@@ -4373,6 +4392,41 @@ public class PartyServiceImpl implements PartyService {
return Result.ok(MessageUtil.get("success", language));
}
public Result syncCompanyToPartySap(JSONObject jsonObject, String language) {
String companyCode = jsonObject.getString("companyCode");
List<CompanyParty> companyPartyList = companyPartyDao.selectListByCompanyCode(companyCode);
List<CompanyParty> list = new ArrayList<>();
if (CollectionUtils.isEmpty(companyPartyList)) {
List<PartyGroup> partyGroupList = partyGroupDao.selectListByIsSyncSapIsY();
List<CompanyParty> companyPartyListNew = new ArrayList<>();
partyGroupList.forEach(
party -> {
CompanyParty companyParty = CompanyParty.create();
companyParty.setCompanyCode(companyCode);
companyParty.setPartyId(party.getPartyId());
companyParty.setIsSync("N");
companyPartyListNew.add(companyParty);
}
);
companyPartyDao.insertBatch(companyPartyListNew, companyPartyListNew.size());
list = companyPartyListNew;
}else {
list = companyPartyDao.selectListByCompanyCodeAndIsSync(companyCode);
}
for (CompanyParty companyParty : list) {
JSONObject jsonObjectParty = new JSONObject();
jsonObjectParty.put("partyId", companyParty.getPartyId());
jsonObjectParty.put("companyCode", companyCode);
Result result = syncPartyToSap(jsonObject ,language);
if (!result.isSuccess()) {
}
companyParty.setIsSync("Y");
companyPartyDao.updateById(companyParty);
}
return Result.ok(MessageUtil.get("success", language));
}
@Override
public Result updateCustomerCompanyPayment(JSONObject jsonObject, String language) {
String partyId = jsonObject.getString("partyId");
......@@ -5309,6 +5363,19 @@ public class PartyServiceImpl implements PartyService {
}
};
Future<String> future1 = executor.submit(task);
//客户同步公司
ExecutorService executorParty = Executors.newFixedThreadPool(2);
Callable<String> taskParty = new Callable<String>() {
@Override
public String call() throws Exception {
// 调用接口的逻辑
JSONObject jsonObjectParty = new JSONObject();
jsonObjectParty.put("companyCode", jsonObject.getString("partyId"));
Result resultCompany = syncPartyCompanyToSap(jsonObjectParty, language);
return "";
}
};
Future<String> futureParty = executorParty.submit(taskParty);
return response;
} catch (Exception e) {
throw new BtpException(MessageUtil.get("exception", new Object[]{StringUtils.isEmpty(e.getMessage()) ? e : e.getMessage()}, language));
......
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