Commit 6ba46bd0 authored by wangqiang's avatar wangqiang

ICM计划自动导入;修改IED计划状态

parent a4270d0d
......@@ -57,7 +57,18 @@ public class ExtICMExternalInterfacePlanController<V extends ExtICMExternalInter
@ApiOperation(value = "导出ICM计划", notes = "导出ICM计划", httpMethod = "GET")
@GetMapping(value = "/exportICMPlan")
public ApiResult exportPlan(HttpServletResponse response, @RequestParam("ids") List<Long> ids) throws IOException {
return ApiResult.ok(extICMExternalInterfacePlanService.exportICMPlan(response, ids),"IED计划导出成功");
return ApiResult.ok(extICMExternalInterfacePlanService.exportICMPlan(response, ids),"ICM计划导出成功");
}
/**
*
* @param id PBO Document文档对象的id
* @return
*/
@ApiOperation("ICM计划自动导入")
@GetMapping(value = "/autoImportICMPlan")
public ApiResult autoImportICMPlan( @RequestParam("id")long id){
return ApiResult.ok(extICMExternalInterfacePlanService.autoImportICMPlan(id),"ICM计划自动导入成功");
}
}
......
......@@ -67,10 +67,16 @@ public class ExtIEDPlanController<V extends ExtIEDPlanVO, S extends ExtIEDPlanSe
return ApiResult.ok(extIEDPlanService.createIEDPlanTask(extIEDPlanVO),"成功创建IED计划任务");
}
/**
*
* @param id document文档id
* @param planState IED计划状态
* @return
*/
@ApiOperation(value = "修改IED计划状态", notes = "修改IED计划状态")
@GetMapping(value = "/updatePlanState")
public ApiResult updatePlanState(@RequestParam("id") Long id,@RequestParam("planState")String planState){
return ApiResult.ok(extIEDPlanService.updatePlanState(id,planState),"更新状态成功");
return ApiResult.ok(extIEDPlanService.updatePlanState(id,planState),"更新计划状态成功");
}
}
......
......@@ -20,4 +20,6 @@ public interface ExtICMExternalInterfacePlanService<V extends ExtICMExternalInte
String importICMPlan(InputStream inputStream, String projectId);
String exportICMPlan(HttpServletResponse response, List<String> ids) throws IOException;
String autoImportICMPlan(long id);
}
......@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.io.FileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.yonde.dcs.document.common.entity.vo.DxDocumentVO;
import com.yonde.dcs.feign.expand.ExtDxDocumentServiceFeign;
import com.yonde.dcs.plan.common.constants.Constants;
import com.yonde.dcs.plan.common.vo.ExtICMPlanExcelVO;
import com.yonde.dcs.plan.common.vo.ExtIEDPlanExcelVO;
......@@ -35,6 +37,7 @@ import com.yonde.dcs.plan.common.vo.ExtICMExternalInterfacePlanVO;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.core.service.ExtICMExternalInterfacePlanService;
import com.yonde.dcs.plan.core.repository.ExtICMExternalInterfacePlanRepository;
......@@ -60,6 +63,9 @@ public class ExtICMExternalInterfacePlanServiceImpl<V extends ExtICMExternalInte
@Autowired
private FileManagerFeignService fileManagerFeignService;
@Autowired
private ExtDxDocumentServiceFeign docCenterFeignService;
@Autowired
ExtICMExternalInterfacePlanRepository<ExtICMExternalInterfacePlan> extICMExternalInterfacePlanRepository;
......@@ -123,6 +129,8 @@ public class ExtICMExternalInterfacePlanServiceImpl<V extends ExtICMExternalInte
return ApiResult.SUCCESS;
}
private List<ExtICMPlanExcelVO> transformationObject(List<V> extICMPlanList) {
List<ExtICMPlanExcelVO> extICMPlanExcelVOList = new ArrayList<>();
for (ExtICMExternalInterfacePlanVO extICMPlanVO : extICMPlanList) {
......@@ -132,6 +140,35 @@ public class ExtICMExternalInterfacePlanServiceImpl<V extends ExtICMExternalInte
}
return extICMPlanExcelVOList;
}
@Override
public String autoImportICMPlan(long id) {
InputStream inputStream = null;
CustomMultipartFile multipartFile = null;
Long fileId = null;
DxDocumentVO dxDocumentVO = docCenterFeignService.getDocumentWithFiles(id);
if(!ObjectUtils.isEmpty(dxDocumentVO)){
try {
//todo 取固定类型附件
fileId = dxDocumentVO.getObjFileLinks().get(0).getTarget().getId();
multipartFile = fileManagerFeignService.feignDownloadIO(fileId);
} catch (IOException e) {
log.info("[自动导入ICM计划] >>> 文件服务下载文档附件:{}--失败!", fileId);
throw new DxBusinessException("500", "文件服务文档附件失败:" + fileId);
}
try {
inputStream = new ByteArrayInputStream(multipartFile.getBytes());
importICMPlan(inputStream,dxDocumentVO.getDxContextId().toString());
} catch (IOException e) {
log.info("[自动导入ICM计划] >>> 文件服务下载的文件:{}--转换为输入流失败!", fileId);
throw new DxBusinessException("500", "文件服务下载的文件转换为输入流失败:" + fileId);
}
}else {
log.info("根据计划文档id:" + id + "未查到相关数据");
}
return ApiResult.SUCCESS;
}
}
package com.yonde.dcs.plan.core.service.impl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.EasyExcel;
......@@ -23,10 +24,12 @@ import com.yonde.dcs.plan.core.service.ExtIEDPlanService;
import com.yonde.dcs.plan.core.util.CommonUtils;
import com.yonde.dcs.plan.core.util.FileUtils;
import com.yonde.dcs.plan.core.util.ResourceHelper;
import com.yonde.dcs.plan.core.util.SearchUtil;
import com.yonde.dcs.plan.entity.po.ExtIEDPlan;
import com.yonde.dcs.plan.entity.po.ExtIEDPlanDocLink;
import com.yonde.dex.basedata.data.search.SearchItem;
import com.yonde.dex.basedata.data.search.SearchItems;
import com.yonde.dex.basedata.data.search.SearchQueryBuilder;
import com.yonde.dex.basedata.data.search.SearchQueryCondition;
import com.yonde.dex.basedata.entity.api.ApiResult;
import com.yonde.dex.basedata.entity.api.CustomMultipartFile;
......@@ -52,6 +55,7 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
......@@ -175,13 +179,23 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String createIEDPlanTask(ExtIEDPlanVO extIEDPlanVO) {
System.out.println(JSONUtil.toJsonStr(extIEDPlanVO));
DxDocumentVO dxDocumentVO = new DxDocumentVO();
DxDocumentVOExpand dxDocumentExpand = new DxDocumentVOExpand();
//文件类型 --文件、图册
//文件分类--需要取英文
dxDocumentVO.setSubTypeName(extIEDPlanVO.getFileClassify());
//todo 需要取英文动态类型
if(!StringUtils.isEmpty(extIEDPlanVO.getFileClassify())){
if(extIEDPlanVO.getFileClassify().contains("技术文件")){
dxDocumentVO.setSubTypeName("TechnicalFile");
}else {
//todo wq暂时先不设置其它动态类型
log.info("IED计划除技术文件类型的文件还未设置其它类型");
}
}
//文件编号
dxDocumentVO.setNumber(extIEDPlanVO.getFileNumber());
......@@ -206,7 +220,6 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
ExtIEDPlanDocLinkVO extIEDPlanDocLinkVO = new ExtIEDPlanDocLinkVO();
extIEDPlanDocLinkVO.setTargetId(dxDocumentVOForDB.getId());
extIEDPlanDocLinkVO.setSourceId(extIEDPlanVO.getId());
extIEDPlanDocLinkVO.setCreateTime(LocalDateTime.now());
extIEDPlanDocLinkVO.setOperator(OperatorType.ADD);
extIEDPlanDocLinkService.saveRecursion(extIEDPlanDocLinkVO);
......@@ -221,14 +234,31 @@ public class ExtIEDPlanServiceImpl<V extends ExtIEDPlanVO> implements ExtIEDPlan
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String updatePlanState(Long id,String planState) {
if(!StringUtils.isEmpty(planState)){
this.changeStatus(id,planState,true);
SearchQueryCondition queryCondition = SearchUtil.buildQuery("targetId", SearchItem.Operator.EQ, id);
// SearchQueryCondition condition = SearchQueryCondition.builder()
// .searchItems(SearchItems.builder()
// .item(new SearchItem("targetId", SearchItem.Operator.EQ, id, null))
// .build())
// .build();
List<ExtIEDPlanDocLinkVO> content = extIEDPlanDocLinkService.findRecursion(queryCondition).getContent();
Long iedPlanId = content.get(0).getSourceId();
if(!ObjectUtil.isEmpty(iedPlanId)){
this.changeStatus(iedPlanId,planState,true);
}else {
throw new DxBusinessException("500","根据文档id:"+id+",未查到相关计划");
}
}else {
throw new DxBusinessException("500","参数不能为空");
}
return ApiResult.SUCCESS;
}
}
package com.yonde.dcs.plan.feign;
import com.yonde.dcs.plan.common.vo.ExtICMExternalInterfacePlanVO;
import com.yonde.dex.basedata.entity.api.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.yonde.dcs.plan.feign.shadow.ExtICMExternalInterfacePlanServiceFeignShadow;
......@@ -16,4 +18,13 @@ import com.yonde.dcs.plan.feign.shadow.ExtICMExternalInterfacePlanServiceFeignSh
@FeignClient(value = "${dcs.feign.INET-PLAN}", path = "/ExtICMExternalInterfacePlan")
public interface ExtICMExternalInterfacePlanServiceFeign<V extends ExtICMExternalInterfacePlanVO> extends ExtICMExternalInterfacePlanServiceFeignShadow<V> {
/**
*
* @param id PBO Document文档对象的id
* @return
*/
@ApiOperation("ICM计划自动导入")
@GetMapping(value = "/autoImportICMPlan")
public String autoImportICMPlan(@RequestParam("id")long id);
}
......@@ -24,6 +24,6 @@ public interface ExtIEDPlanServiceFeign<V extends ExtIEDPlanVO> extends ExtIEDPl
@ApiOperation(value = "修改IED计划状态", notes = "修改IED计划状态")
@GetMapping(value = "/updatePlanState")
public String updatePlanState(@RequestParam(name = "IED计划id",value = "id") Long id, @RequestParam(value = "planState")String planState);
public String updatePlanState(@RequestParam("id")Long id, @RequestParam(value = "planState")String planState);
}
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