分类树标准法规回写接口
This commit is contained in:
@@ -160,6 +160,8 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put("/srms/getByLawsSystem", "anon");
|
||||
// 分页查询标准数据
|
||||
filterChainDefinitionMap.put("/srms/getByLawsStandardPage", "anon");
|
||||
// 分页查询标准数据
|
||||
filterChainDefinitionMap.put("/srms/syncPartData", "anon");
|
||||
|
||||
// 添加自己的过滤器并且取名为jwt
|
||||
Map<String, Filter> filterMap = new HashMap<>(1);
|
||||
|
||||
+5
-1
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.modules.docking.srms.entity.LawsPartStandard;
|
||||
import com.jero.modules.docking.srms.service.SrmsApiService;
|
||||
import com.jero.modules.docking.srms.vo.ByFileRows;
|
||||
import com.jero.modules.docking.srms.vo.StandardPageVO;
|
||||
@@ -158,7 +159,10 @@ public class SrmsApiController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/syncPartStandard")
|
||||
public Result<String> syncPartStandard(){
|
||||
return srmsApiService.syncPartStandard();
|
||||
}
|
||||
|
||||
// @ApiOperation("E采通获取标准信息")
|
||||
@AutoLog(value = "E采通获取标准信息")
|
||||
|
||||
+9
-6
@@ -24,15 +24,18 @@ public class LawsPartStandard implements Serializable {
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private String id;
|
||||
/**标准id*/
|
||||
@ApiModelProperty(value = "标准id")
|
||||
private String standardId;
|
||||
/**分类内部码*/
|
||||
@ApiModelProperty(value = "分类内部码")
|
||||
private String partCategoryNum;
|
||||
/**分类名称 (编号+名称)*/
|
||||
@ApiModelProperty(value = "分类名称 (编号+名称)")
|
||||
private String partCategoryName;
|
||||
/**父级分类内部码(根节点0)*/
|
||||
@ApiModelProperty(value = "父级分类内部码(根节点0)")
|
||||
private String parentNum;
|
||||
/**标准分类:设计规范:1释放规范:2*/
|
||||
@ApiModelProperty(value = "标准分类:设计规范:1释放规范:2")
|
||||
private String standardPdmType;
|
||||
/**标准编号*/
|
||||
@ApiModelProperty(value = "标准编号")
|
||||
private String standardNumber;
|
||||
/**备用字段1*/
|
||||
@ApiModelProperty(value = "备用字段1")
|
||||
private String remark1;
|
||||
|
||||
+12
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.docking.srms.entity.LawsPartStandard;
|
||||
import com.jero.modules.docking.srms.vo.ByFileRows;
|
||||
import com.jero.modules.docking.srms.vo.StandardPageVO;
|
||||
import com.jero.modules.docking.srms.vo.StandardVO;
|
||||
@@ -54,4 +55,15 @@ public interface LawsStandardMapper{
|
||||
*/
|
||||
void updatePartParentId();
|
||||
|
||||
/**
|
||||
* 获取所有 标准分类:
|
||||
* 设计规范:1
|
||||
* 释放规范:2 (系统中编码为4)
|
||||
* @author LQT
|
||||
* @date 2024/1/30 16:51
|
||||
* @param
|
||||
* @return void
|
||||
*/
|
||||
List<LawsPartStandard> getSyncPartStandard();
|
||||
|
||||
}
|
||||
|
||||
+25
-1
@@ -141,8 +141,32 @@
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getSyncPartStandard" resultType="com.jero.modules.docking.srms.entity.LawsPartStandard">
|
||||
SELECT
|
||||
a.id as standard_id,
|
||||
a.standard_number as standard_number,
|
||||
a.standard_class as standard_pdm_type,
|
||||
substring_index(substring_index(a.part_name, ',', b.help_topic_id + 1), ',', - 1) as part_category_num
|
||||
FROM (
|
||||
select
|
||||
id,
|
||||
standard_number,
|
||||
case when standard_class = 4 then 2 else standard_class end as standard_class,
|
||||
part_name
|
||||
from laws_enterprise_standard where standard_class in (1,4) and del_flag = 0 and part_name is not null
|
||||
) a
|
||||
INNER JOIN mysql.help_topic b
|
||||
ON b.help_topic_id < (length(a.part_name) - length(REPLACE(a.part_name, ',', '')) + 1)
|
||||
union all
|
||||
(select
|
||||
id as standard_id,
|
||||
standard_number,
|
||||
case when standard_class = 4 then 2 else standard_class end as standard_class,
|
||||
part_name
|
||||
from laws_enterprise_standard where standard_class in (1,4) and del_flag = 0 and ISNULL(part_name))
|
||||
</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>
|
||||
|
||||
+10
-3
@@ -80,11 +80,18 @@ public interface SrmsApiService {
|
||||
* 分类树标准法规回写
|
||||
* @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);
|
||||
Result<String> syncPartStandard();
|
||||
|
||||
/**
|
||||
* 发送分类树标准法规
|
||||
* @author LQT
|
||||
* @date 2024/1/30 17:15
|
||||
* @param
|
||||
* @return com.jero.common.api.vo.Result<java.lang.String>
|
||||
*/
|
||||
void sendPartStandard();
|
||||
|
||||
/**
|
||||
* E采通获取标准信息
|
||||
|
||||
+83
-10
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.CaseFormat;
|
||||
@@ -16,8 +17,10 @@ import com.jero.common.util.RedisUtil;
|
||||
import com.jero.common.util.TokenUtils;
|
||||
import com.jero.modules.docking.srms.dto.ByTokenRequests;
|
||||
import com.jero.modules.docking.srms.dto.ProductDesign;
|
||||
import com.jero.modules.docking.srms.entity.LawsPartStandard;
|
||||
import com.jero.modules.docking.srms.entity.LawsSysApiInfo;
|
||||
import com.jero.modules.docking.srms.mapper.LawsStandardMapper;
|
||||
import com.jero.modules.docking.srms.service.ILawsPartStandardService;
|
||||
import com.jero.modules.docking.srms.service.ILawsSysApiInfoService;
|
||||
import com.jero.modules.docking.srms.service.SrmsApiService;
|
||||
import com.jero.modules.docking.srms.vo.*;
|
||||
@@ -43,11 +46,13 @@ import org.apache.shiro.SecurityUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -83,6 +88,10 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
private PartNameService partNameService;
|
||||
@Resource
|
||||
private ILawsSysApiInfoService lawsSysApiInfoService;
|
||||
@Resource
|
||||
private ILawsPartStandardService lawsPartStandardService;
|
||||
@Resource
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Value("${srms.font_url_pdf}")
|
||||
private String fontUrlPdf;
|
||||
@@ -98,6 +107,8 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
private String ettonSysCode;
|
||||
@Value("${srms.etton_sys_user}")
|
||||
private String ettonSysUser;
|
||||
@Value("${srms.part_standard_url}")
|
||||
private String partStandardUrl;
|
||||
|
||||
private static final String REQUESTS = "Requests";
|
||||
private static final String SYS_ERR = "访问受限,token授权过期";
|
||||
@@ -106,6 +117,12 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
private static final String PUBLISH_OF_ORIGINAL = "publish_of_original";
|
||||
private static final String X_ACCESS_TOKEN = "X-Access-Token";
|
||||
private static final String ADD_NOT_NULL = "必填项不能为空";
|
||||
private static final String PART_CATEGROY_NUM = "PartCategroyNum";
|
||||
private static final String PART_CATEGROY_NAME = "PartCategroyName";
|
||||
private static final String PARENT_NUM = "ParentNum";
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Result<JSONObject> getByToken(JSONObject json) {
|
||||
@@ -600,25 +617,29 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
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")){
|
||||
if(!js.containsKey(PART_CATEGROY_NUM) || !js.containsKey(PART_CATEGROY_NAME) || !js.containsKey(PARENT_NUM)){
|
||||
return Result.error(ADD_NOT_NULL);
|
||||
}
|
||||
if(StringUtils.isBlank(js.getString("PartCategroyNum"))
|
||||
|| StringUtils.isBlank(js.getString("PartCategroyName"))
|
||||
|| StringUtils.isBlank(js.getString("ParentNum"))){
|
||||
if(StringUtils.isBlank(js.getString(PART_CATEGROY_NUM))
|
||||
|| StringUtils.isBlank(js.getString(PART_CATEGROY_NAME))
|
||||
|| StringUtils.isBlank(js.getString(PARENT_NUM))){
|
||||
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.setCode(js.getString(PART_CATEGROY_NUM));
|
||||
partName.setName(js.getString(PART_CATEGROY_NAME));
|
||||
partName.setParentCode(js.getString(PARENT_NUM));
|
||||
partName.setRemark1(js.getString("Remark1"));
|
||||
partName.setRemark2(js.getString("Remark2"));
|
||||
partName.setRemark3(js.getString("Remark3"));
|
||||
listPartName.add(partName);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(listPartName)){
|
||||
// todo 是否清空数据
|
||||
// 清空数据
|
||||
LambdaUpdateWrapper<PartName> updatePartName = new LambdaUpdateWrapper<>();
|
||||
updatePartName.eq(PartName::getDelFlag,"0");
|
||||
partNameService.remove(updatePartName);
|
||||
// 保存数据
|
||||
partNameService.saveBatch(listPartName);
|
||||
// 更新父级id
|
||||
lawsStandardMapper.updatePartParentId();
|
||||
@@ -631,8 +652,60 @@ public class SrmsApiServiceImpl implements SrmsApiService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> syncPartStandard(JSONObject json, HttpServletRequest req) {
|
||||
return null;
|
||||
public Result<String> syncPartStandard() {
|
||||
// 清理数据
|
||||
LambdaUpdateWrapper<LawsPartStandard> updateLawsPartStandard = new LambdaUpdateWrapper<>();
|
||||
updateLawsPartStandard.eq(LawsPartStandard::getDelFlag,"0");
|
||||
lawsPartStandardService.remove(updateLawsPartStandard);
|
||||
// 同步数据到分类树标准法规回写表
|
||||
List<LawsPartStandard> listLawsPartStandard = lawsStandardMapper.getSyncPartStandard();
|
||||
lawsPartStandardService.saveBatch(listLawsPartStandard);
|
||||
return Result.OK("操作成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPartStandard() {
|
||||
try {
|
||||
List<LawsPartStandard> listLawsPartStandard = lawsPartStandardService.list();
|
||||
JSONObject all = new JSONObject();
|
||||
JSONObject messageHeader = new JSONObject();
|
||||
String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
||||
// todo Interface_ID,UUID
|
||||
messageHeader.put("Interface_ID","");
|
||||
messageHeader.put("UUID","");
|
||||
messageHeader.put("MessageId","");
|
||||
messageHeader.put("Sender","SRMS");
|
||||
messageHeader.put("Receiver","PDM");
|
||||
messageHeader.put("SendDate",date.substring(0,8));
|
||||
messageHeader.put("SendTime",date.substring(8));
|
||||
all.put("MessageHeader",messageHeader);
|
||||
List<JSONObject> listObj = new ArrayList<>();
|
||||
if(!CollectionUtils.isEmpty(listLawsPartStandard)){
|
||||
for (LawsPartStandard lawsPartStandard : listLawsPartStandard) {
|
||||
JSONObject rows = new JSONObject();
|
||||
rows.put("PartCategroyNum",lawsPartStandard.getPartCategoryNum());
|
||||
rows.put("StandardPdmType",lawsPartStandard.getStandardPdmType());
|
||||
rows.put("StandardNumber",lawsPartStandard.getStandardNumber());
|
||||
rows.put("Remark1",lawsPartStandard.getRemark1());
|
||||
rows.put("Remark2",lawsPartStandard.getRemark2());
|
||||
rows.put("Remark3",lawsPartStandard.getRemark3());
|
||||
listObj.add(rows);
|
||||
}
|
||||
}
|
||||
JSONObject requests = new JSONObject();
|
||||
requests.put("Rows",listObj);
|
||||
all.put("Requests",requests);
|
||||
// todo url
|
||||
JSONObject reData = restTemplate.postForObject(partStandardUrl,all,JSONObject.class);
|
||||
log.info(JSON.toJSONString(reData));
|
||||
if(!Objects.isNull(reData) && reData.containsKey("Success") && Objects.equals("true",reData.getString("Success"))){
|
||||
log.info("分类树标准法规回写接口成功");
|
||||
}else{
|
||||
log.error("分类树标准法规回写接口失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("分类树标准法规回写接口失败",e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -493,3 +493,5 @@ srms:
|
||||
etton_sys_code: ETTON
|
||||
# E彩通默认账户
|
||||
etton_sys_user: etton
|
||||
# 分类树标准法规回写接口 url
|
||||
part_standard_url:
|
||||
|
||||
Reference in New Issue
Block a user