添加零部件分类树同步接口
This commit is contained in:
+12
-12
@@ -37,6 +37,7 @@ public class SrmsApiController {
|
||||
private SrmsApiService srmsApiService;
|
||||
|
||||
private static final String MESSAGE_HEADER = "MessageHeader";
|
||||
private static final String RESULT = "Result";
|
||||
|
||||
@ApiOperation("获取token")
|
||||
@AutoLog(value = "获取token")
|
||||
@@ -48,7 +49,7 @@ public class SrmsApiController {
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErr(re.getMessage(),re.getCode()));
|
||||
}
|
||||
String token = re.getResult().get("token").toString();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk(re.getMessage());
|
||||
jsonResponses.put("token",token);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
@@ -67,7 +68,7 @@ public class SrmsApiController {
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErr(re.getMessage(),re.getCode()));
|
||||
}
|
||||
List<ByFileRows> list = re.getResult();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk(re.getMessage());
|
||||
jsonResponses.put("Rows",list);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
@@ -86,7 +87,7 @@ public class SrmsApiController {
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErr(re.getMessage(),re.getCode()));
|
||||
}
|
||||
List<JSONObject> list = re.getResult();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk(re.getMessage());
|
||||
jsonResponses.put("Rows",list);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
@@ -105,8 +106,8 @@ public class SrmsApiController {
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErr(re.getMessage(),re.getCode()));
|
||||
}
|
||||
List<StandardTree> list = re.getResult();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk();
|
||||
jsonResponses.put("result",JSON.toJSONString(list));
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk(re.getMessage());
|
||||
jsonResponses.put(RESULT,JSON.toJSONString(list));
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
log.error("获取所有体系数据异常:",e);
|
||||
@@ -130,8 +131,8 @@ public class SrmsApiController {
|
||||
jsonPage.put("size",page.getSize());
|
||||
jsonPage.put("total",page.getTotal());
|
||||
jsonPage.put("Rows_Result",page.getRecords());
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk();
|
||||
jsonResponses.put("Result",jsonPage);
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOk(re.getMessage());
|
||||
jsonResponses.put(RESULT,jsonPage);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
log.error("分页查询标准数据异常:",e);
|
||||
@@ -139,7 +140,7 @@ public class SrmsApiController {
|
||||
}
|
||||
}
|
||||
|
||||
// @ApiOperation("零部件分类树同步接口")
|
||||
@ApiOperation("零部件分类树同步接口")
|
||||
@AutoLog(value = "零部件分类树同步接口")
|
||||
@PostMapping("/syncPartData")
|
||||
public JSONObject syncPartData(@RequestBody JSONObject json, HttpServletRequest req){
|
||||
@@ -148,8 +149,8 @@ public class SrmsApiController {
|
||||
if(!re.isSuccess()){
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper(re.getMessage(),re.getCode()));
|
||||
}
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper();
|
||||
jsonResponses.put("Result",re.getResult());
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper(re.getMessage());
|
||||
jsonResponses.put(RESULT,re.getResult());
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
log.error("零部件分类树同步接口异常:",e);
|
||||
@@ -169,10 +170,9 @@ public class SrmsApiController {
|
||||
if(!re.isSuccess()){
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),ResponsesUtil.getJsonErrUpper(re.getMessage(),re.getCode()));
|
||||
}
|
||||
List<JSONObject> page = re.getResult();
|
||||
JSONObject jsonPage = new JSONObject();
|
||||
JSONObject jsonResponses = ResponsesUtil.getJsonOkUpper();
|
||||
jsonResponses.put("Result",jsonPage);
|
||||
jsonResponses.put(RESULT,jsonPage);
|
||||
return ResponsesUtil.getJsonResult(json.get(MESSAGE_HEADER),jsonResponses);
|
||||
}catch (Exception e){
|
||||
log.error("E采通获取标准信息异常:",e);
|
||||
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.jero.modules.docking.srms.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lqt
|
||||
* @version 1.0
|
||||
* @date 2024/1/30 14:05
|
||||
*/
|
||||
@Data
|
||||
public class LawsPartStandard implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键ID*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private String id;
|
||||
/**分类内部码*/
|
||||
@ApiModelProperty(value = "分类内部码")
|
||||
private String partCategoryNum;
|
||||
/**分类名称 (编号+名称)*/
|
||||
@ApiModelProperty(value = "分类名称 (编号+名称)")
|
||||
private String partCategoryName;
|
||||
/**父级分类内部码(根节点0)*/
|
||||
@ApiModelProperty(value = "父级分类内部码(根节点0)")
|
||||
private String parentNum;
|
||||
/**备用字段1*/
|
||||
@ApiModelProperty(value = "备用字段1")
|
||||
private String remark1;
|
||||
/**备用字段2*/
|
||||
@ApiModelProperty(value = "备用字段2")
|
||||
private String remark2;
|
||||
/**备用字段3*/
|
||||
@ApiModelProperty(value = "备用字段3")
|
||||
private String remark3;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy年MM月dd日 EEEE")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private Date updateTime;
|
||||
/**删除状态(0-正常,1-删除)*/
|
||||
@ApiModelProperty(value = "删除状态(0-正常,1-删除)")
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.jero.modules.docking.srms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.jero.modules.docking.srms.entity.LawsPartStandard;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface LawsPartStandardMapper extends BaseMapper<LawsPartStandard> {
|
||||
|
||||
}
|
||||
+9
@@ -45,4 +45,13 @@ public interface LawsStandardMapper{
|
||||
IPage<StandardPageVO> getByLawsStandardPage(Page<StandardPageVO> page,
|
||||
@Param(Constants.WRAPPER) QueryWrapper<StandardPageVO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 更新父级id
|
||||
* @author LQT
|
||||
* @date 2024/1/30 15:07
|
||||
* @param
|
||||
* @return void
|
||||
*/
|
||||
void updatePartParentId();
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jero.modules.docking.srms.mapper.LawsPartStandardMapper">
|
||||
|
||||
</mapper>
|
||||
+3
@@ -142,4 +142,7 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="updatePartParentId">
|
||||
update laws_part_name l1 set parent_id = (select id from (select id from laws_part_name l2 where l2.code = l1.parent_code) aa)
|
||||
</update>
|
||||
</mapper>
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.modules.docking.srms.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.docking.srms.entity.LawsPartStandard;
|
||||
|
||||
/**
|
||||
* @Description: 系统对接信息
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ILawsPartStandardService extends IService<LawsPartStandard> {
|
||||
|
||||
}
|
||||
+10
@@ -76,6 +76,16 @@ public interface SrmsApiService {
|
||||
*/
|
||||
Result<String> syncPartData(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> syncPartStandard(JSONObject json, HttpServletRequest req);
|
||||
|
||||
/**
|
||||
* E采通获取标准信息
|
||||
* @author LQT
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.jero.modules.docking.srms.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.modules.docking.srms.entity.LawsPartStandard;
|
||||
import com.jero.modules.docking.srms.mapper.LawsPartStandardMapper;
|
||||
import com.jero.modules.docking.srms.service.ILawsPartStandardService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: jero-boot
|
||||
* @Date: 2023-10-18
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class ILawsPartStandardServiceImpl extends ServiceImpl<LawsPartStandardMapper, LawsPartStandard> implements ILawsPartStandardService {
|
||||
|
||||
}
|
||||
+61
-7
@@ -580,12 +580,71 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> syncPartData(JSONObject json, HttpServletRequest req) {
|
||||
try {
|
||||
// 验证Token有效性
|
||||
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
|
||||
if(!tokenOK){
|
||||
return Result.error(403,SYS_ERR);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
return Result.error(403,SYS_ERR);
|
||||
}
|
||||
try {
|
||||
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);
|
||||
}
|
||||
List<PartName> listPartName = new ArrayList<>();
|
||||
for (Object request : rows) {
|
||||
JSONObject js = JSON.parseObject(JSON.toJSONString(request));
|
||||
if(!js.containsKey("PartCategroyNum") || !js.containsKey("PartCategroyName") || !js.containsKey("ParentNum")){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
if(StringUtils.isBlank(js.getString("PartCategroyNum"))
|
||||
|| StringUtils.isBlank(js.getString("PartCategroyName"))
|
||||
|| StringUtils.isBlank(js.getString("ParentNum"))){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
PartName partName = new PartName();
|
||||
partName.setCode(js.getString("PartCategroyNum"));
|
||||
partName.setName(js.getString("PartCategroyName"));
|
||||
partName.setParentCode(js.getString("ParentNum"));
|
||||
partName.setRemark1(js.getString("Remark1"));
|
||||
partName.setRemark2(js.getString("Remark2"));
|
||||
partName.setRemark3(js.getString("Remark3"));
|
||||
listPartName.add(partName);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(listPartName)){
|
||||
// todo 是否清空数据
|
||||
partNameService.saveBatch(listPartName);
|
||||
// 更新父级id
|
||||
lawsStandardMapper.updatePartParentId();
|
||||
}
|
||||
return Result.OK("操作成功");
|
||||
}catch (Exception e){
|
||||
log.error("零部件分类树同步接口异常:",e);
|
||||
return Result.error("操作失败" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> syncPartStandard(JSONObject json, HttpServletRequest req) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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)){
|
||||
try {
|
||||
// 验证Token有效性
|
||||
boolean tokenOK = TokenUtils.verifyToken(req, sysBaseAPI, redisUtil);
|
||||
if(!tokenOK){
|
||||
return Result.error(403,SYS_ERR);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
return Result.error(403,SYS_ERR);
|
||||
}
|
||||
JSONObject requests = JSON.parseObject(JSON.toJSONString(json.get(REQUESTS)));
|
||||
@@ -611,9 +670,4 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
return Result.error("操作失败" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> syncPartData(JSONObject json, HttpServletRequest req) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user