srms接口修改
This commit is contained in:
+39
-1
@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.modules.docking.srms.dto.ProductDesign;
|
||||
import com.jero.modules.docking.srms.service.SrmsApiService;
|
||||
import com.jero.modules.docking.srms.vo.ByFileRows;
|
||||
import com.jero.modules.docking.srms.vo.StandardPageVO;
|
||||
@@ -130,4 +129,43 @@ public class SrmsApiController {
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErr("操作失败"));
|
||||
}
|
||||
}
|
||||
|
||||
// @ApiOperation("零部件分类树同步接口")
|
||||
@PostMapping("/syncPartData")
|
||||
public JSONObject syncPartData(@RequestBody JSONObject json, HttpServletRequest req){
|
||||
try {
|
||||
Result<String> re = srmsApiService.syncPartData(json,req);
|
||||
if(!re.isSuccess()){
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper(re.getMessage()));
|
||||
}
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper();
|
||||
jsonResponses.put("Result",re.getResult());
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
log.error("零部件分类树同步接口异常:",e);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper("操作失败"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @ApiOperation("E采通获取标准信息")
|
||||
@PostMapping("/getEStandardInfo")
|
||||
public JSONObject getEStandardInfo(@RequestBody JSONObject json, HttpServletRequest req){
|
||||
try {
|
||||
// todo
|
||||
Result<List<JSONObject>> re = srmsApiService.getEStandardInfo(json,req);
|
||||
if(!re.isSuccess()){
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper(re.getMessage()));
|
||||
}
|
||||
List<JSONObject> page = re.getResult();
|
||||
JSONObject jsonPage = new JSONObject();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper();
|
||||
jsonResponses.put("Result",jsonPage);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
log.error("E采通获取标准信息异常:",e);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper("操作失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -73,29 +73,29 @@
|
||||
<if test="standardNumber != null and standardNumber != ''">
|
||||
and standard_number = #{standardNumber}
|
||||
</if>
|
||||
<if test="queryLabels != null and queryLabels != ''">
|
||||
and standard_number = #{queryLabels}
|
||||
</if>
|
||||
union all
|
||||
select id from laws_overseas_standard where del_flag = 0 and standard_state = 6
|
||||
<if test="standardNumber != null and standardNumber != ''">
|
||||
and standard_number = #{standardNumber}
|
||||
</if>
|
||||
<if test="queryLabels != null and queryLabels != ''">
|
||||
and standard_number = #{queryLabels}
|
||||
</if>
|
||||
union all
|
||||
select id from laws_enterprise_standard where del_flag = 0 and standard_state = 6
|
||||
<if test="standardNumber != null and standardNumber != ''">
|
||||
and standard_number = #{standardNumber}
|
||||
</if>
|
||||
<if test="queryLabels != null and queryLabels != ''">
|
||||
and standard_number = #{queryLabels}
|
||||
</if>
|
||||
) law
|
||||
left join sar_file_split_info s on s.standard_id = law.id and s.del_flag = 0
|
||||
left join laws_document_split l on s.id = l.info_id and l.del_flag = 0
|
||||
where l.item_content is not null and l.item_content != '' limit 1
|
||||
where
|
||||
l.item_content is not null
|
||||
and l.item_content != ''
|
||||
<if test="queryLabels != null and queryLabels != ''">
|
||||
and
|
||||
<foreach collection="queryLabels.split(',')" item="item" separator="and" open="(" close=")">
|
||||
FIND_IN_SET(#{item},l.property_tag)
|
||||
</foreach>
|
||||
</if>
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="getByLawsStandardPage" resultType="com.jero.modules.docking.srms.vo.StandardPageVO">
|
||||
|
||||
+20
@@ -66,4 +66,24 @@ public interface SrmsApiService {
|
||||
*/
|
||||
Result<IPage<StandardPageVO>> getByLawsStandardPage(JSONObject json, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* 零部件分类树同步接口
|
||||
* @author LQT
|
||||
* @date 2024/1/26 16:05
|
||||
* @param json
|
||||
* @param req
|
||||
* @return com.jero.common.api.vo.Result<java.lang.String>
|
||||
*/
|
||||
Result<String> syncPartData(JSONObject json, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* E采通获取标准信息
|
||||
* @author LQT
|
||||
* @date 2024/1/26 15:08
|
||||
* @param json
|
||||
* @param req
|
||||
* @return com.jero.common.api.vo.Result<java.util.List<com.alibaba.fastjson.JSONObject>>
|
||||
*/
|
||||
Result<List<JSONObject>> getEStandardInfo(JSONObject json, HttpServletRequest req);
|
||||
|
||||
}
|
||||
|
||||
+60
-23
@@ -10,7 +10,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.api.ISysBaseAPI;
|
||||
import com.jero.common.system.util.JwtUtil;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.MD5Util;
|
||||
import com.jero.common.util.RedisUtil;
|
||||
@@ -95,8 +94,11 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
private String backUrlOther;
|
||||
@Value("${srms.other_md5_mark}")
|
||||
private String otherMd5Mark;
|
||||
@Value("${srms.etton_sys_code}")
|
||||
private String ettonSysCode;
|
||||
@Value("${srms.etton_sys_user}")
|
||||
private String ettonSysUser;
|
||||
|
||||
private static final String SRMS_TOKEN = "srms_token_";
|
||||
private static final String REQUESTS = "Requests";
|
||||
private static final String SYS_ERR = "系统验证失败";
|
||||
private static final String STANDARD_NAME = "standardName";
|
||||
@@ -118,21 +120,19 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
LambdaQueryWrapper<LawsSysApiInfo> queryLawsSysApiInfo = new LambdaQueryWrapper<>();
|
||||
queryLawsSysApiInfo.eq(LawsSysApiInfo::getAppKey,byTokenRequests.getAppkey());
|
||||
queryLawsSysApiInfo.eq(LawsSysApiInfo::getSecret,byTokenRequests.getSecret());
|
||||
long l = lawsSysApiInfoService.count(queryLawsSysApiInfo);
|
||||
if(l == 0){
|
||||
LawsSysApiInfo lawsSysApiInfo = lawsSysApiInfoService.getOne(queryLawsSysApiInfo,false);
|
||||
if(Objects.isNull(lawsSysApiInfo)){
|
||||
return Result.error(SYS_ERR);
|
||||
}
|
||||
Result<JSONObject> re = Result.OK();
|
||||
String tokenKey = SRMS_TOKEN + byTokenRequests.getUsername() + byTokenRequests.getAppkey();
|
||||
// 验证用户是否存在token,存在不再重复获取
|
||||
if(redisUtil.hasKey(tokenKey)){
|
||||
JSONObject js = new JSONObject();
|
||||
js.put("token",redisUtil.get(tokenKey));
|
||||
re.setResult(js);
|
||||
Result<JSONObject> re;
|
||||
// E彩通访问,使用默认账户
|
||||
if(Objects.equals(ettonSysCode,lawsSysApiInfo.getSysCode())){
|
||||
re = loginService.srmsByToken(ettonSysUser);
|
||||
String token = re.getResult().get("token").toString();
|
||||
String tokenKey = byTokenRequests.getUsername() + token;
|
||||
redisUtil.set(tokenKey,token,3600);
|
||||
}else{
|
||||
re = loginService.srmsByToken(byTokenRequests.getUsername());
|
||||
String token = re.getResult().get("token").toString();
|
||||
redisUtil.set(tokenKey,token,JwtUtil.EXPIRE_TIME / 1000);
|
||||
}
|
||||
return re;
|
||||
}catch (Exception e){
|
||||
@@ -294,20 +294,20 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
List<ProductDesign> listProductDesign = new ArrayList<>();
|
||||
String queryLabels = "queryLabels";
|
||||
for (Object request : rows) {
|
||||
JSONObject js = JSON.parseObject(JSON.toJSONString(request));
|
||||
// todo || !js.containsKey("queryLabels")
|
||||
if(!js.containsKey("ID") || !js.containsKey(STANDARD_NUMBER) ){
|
||||
Result.error(ADD_NOT_NULL);
|
||||
if(!js.containsKey("ID") || !js.containsKey(STANDARD_NUMBER) || !js.containsKey(queryLabels)){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
// todo || Objects.isNull(js.get("queryLabels"))
|
||||
if(Objects.isNull(js.get("ID")) || Objects.isNull(js.get(STANDARD_NUMBER))){
|
||||
Result.error(ADD_NOT_NULL);
|
||||
if(StringUtils.isBlank(js.getString("ID")) || StringUtils.isBlank(js.getString(STANDARD_NUMBER))
|
||||
|| StringUtils.isBlank(js.getString(queryLabels))){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
ProductDesign productDesign = new ProductDesign();
|
||||
productDesign.setId(js.get("ID").toString());
|
||||
productDesign.setStandardNumber(js.get(STANDARD_NUMBER).toString());
|
||||
productDesign.setQueryLabels(js.get("queryLabels").toString());
|
||||
productDesign.setId(js.getString("ID"));
|
||||
productDesign.setStandardNumber(js.getString(STANDARD_NUMBER));
|
||||
productDesign.setQueryLabels(js.getString(queryLabels));
|
||||
listProductDesign.add(productDesign);
|
||||
}
|
||||
try {
|
||||
@@ -316,7 +316,7 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
String str = lawsStandardMapper.getStandardByProductDesign(productDesign.getStandardNumber(),productDesign.getQueryLabels());
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("ID",productDesign.getId());
|
||||
obj.put("queryLabels",productDesign.getQueryLabels());
|
||||
obj.put(queryLabels,productDesign.getQueryLabels());
|
||||
obj.put("itemContent",str);
|
||||
obj.put(STANDARD_NUMBER,productDesign.getStandardNumber());
|
||||
listObj.add(obj);
|
||||
@@ -554,4 +554,41 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result<List<JSONObject>> getEStandardInfo(JSONObject json, HttpServletRequest req) {
|
||||
// 验证token
|
||||
String token = req.getHeader(X_ACCESS_TOKEN);
|
||||
if(StringUtils.isBlank(token) || !Objects.equals(TokenUtils.getTokenByRequest(req),token)){
|
||||
return Result.error(SYS_ERR);
|
||||
}
|
||||
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
|
||||
JSONArray rows = JSON.parseArray(JSON.toJSONString(requests.get("Rows")));
|
||||
if(CollectionUtils.isEmpty(rows)){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
for (Object request : rows) {
|
||||
JSONObject js = JSON.parseObject(JSON.toJSONString(request));
|
||||
if(js.containsKey("PartNum") && StringUtils.isBlank(js.getString("PartNum"))){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
List<JSONObject> listObj = new ArrayList<>();
|
||||
for (Object request : rows) {
|
||||
// todo
|
||||
}
|
||||
return Result.OK(listObj);
|
||||
}catch (Exception e){
|
||||
log.error("设计导航-产品设计条款查询异常:",e);
|
||||
return Result.error("操作失败" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> syncPartData(JSONObject json, HttpServletRequest req) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+27
-1
@@ -9,7 +9,7 @@ import com.jero.common.constant.CommonConstant;
|
||||
* @date 2024/1/18 14:45
|
||||
*/
|
||||
public class ResponsesUtil {
|
||||
|
||||
private ResponsesUtil(){}
|
||||
|
||||
public static JSONObject getJsonResult(Object jsonMessageHeader,JSONObject jsonResponses) {
|
||||
JSONObject json = new JSONObject();
|
||||
@@ -22,6 +22,19 @@ public class ResponsesUtil {
|
||||
return getJsonOk("");
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOkUpper() {
|
||||
return getJsonOkUpper("");
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOkUpper(String message) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("SrmsCode",CommonConstant.SC_OK_200);
|
||||
jsonResponses.put("Message",message);
|
||||
jsonResponses.put("Success",true);
|
||||
jsonResponses.put("Timestamp",System.currentTimeMillis());
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonOk(String message) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("srmsCode",CommonConstant.SC_OK_200);
|
||||
@@ -31,6 +44,19 @@ public class ResponsesUtil {
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErrUpper() {
|
||||
return getJsonErrUpper("");
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErrUpper(String message) {
|
||||
JSONObject jsonResponses = new JSONObject();
|
||||
jsonResponses.put("SrmsCode",CommonConstant.SC_INTERNAL_SERVER_ERROR_500);
|
||||
jsonResponses.put("Message",message);
|
||||
jsonResponses.put("Success",false);
|
||||
jsonResponses.put("Timestamp",System.currentTimeMillis());
|
||||
return jsonResponses;
|
||||
}
|
||||
|
||||
public static JSONObject getJsonErr() {
|
||||
return getJsonErr("");
|
||||
}
|
||||
|
||||
@@ -489,3 +489,7 @@ srms:
|
||||
back_url_other: http://localhost:8184/${srms.back_url_pdf}&fullfilename={file_name}
|
||||
# 其他文件水印标识
|
||||
other_md5_mark: cnhtc
|
||||
# E彩通标识
|
||||
etton_sys_code: ETTON
|
||||
# E彩通默认账户
|
||||
etton_sys_user: etton
|
||||
|
||||
Reference in New Issue
Block a user