|  |  | 
 |  |  | import com.zt.life.modules.mainPart.taskReliability.model.ModelLine; | 
 |  |  | import com.zt.life.modules.mainPart.taskReliability.model.ModelRbd; | 
 |  |  | import com.zt.life.modules.mainPart.taskReliability.service.ModelLineService; | 
 |  |  | import com.zt.life.modules.mainPart.taskReliability.service.ModelRbdNodeService; | 
 |  |  | import io.swagger.annotations.Api; | 
 |  |  | import io.swagger.annotations.ApiImplicitParam; | 
 |  |  | import io.swagger.annotations.ApiImplicitParams; | 
 |  |  | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  | import springfox.documentation.annotations.ApiIgnore; | 
 |  |  |  | 
 |  |  | import java.util.Date; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  |  | 
 |  |  |     private static final String URL_REPLACE_STR = "URL_PREFIX_URL"; | 
 |  |  |     private static final String TOKEN_REPLACE_STR = "MY_TOKEN_MY"; | 
 |  |  |     private static final String TIMESTAMP_REPLACE_STR = "MY_TIMESTAMP_MY"; | 
 |  |  |     private static final String TOKEN_REPLACE_REGEX = "token=[0-9a-zA-Z]+&"; | 
 |  |  |     private static final String TIMESTAMP_REPLACE_REGEX = "&t=[0-9]+"; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ModelLineService modelLineService; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private PythonLib pythonLib; | 
 |  |  |     private ModelRbdNodeService modelRbdNodeService; | 
 |  |  |  | 
 |  |  |     @GetMapping("callPythonCalc") | 
 |  |  |     @ApiOperation("信息") | 
 |  |  |     public Result callPythonCalc() { | 
 |  |  |         Result result = pythonLib.callPython(); | 
 |  |  |  | 
 |  |  |         return result; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @GetMapping("getPythonCalcResult") | 
 |  |  |     @ApiOperation("信息") | 
 |  |  |     public Result<String> getPythonCalcResult() { | 
 |  |  |         String result = pythonLib.getPythonCalcResult(); | 
 |  |  |  | 
 |  |  |         return Result.ok(result); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @GetMapping("page") | 
 |  |  |     @ApiOperation("分页") | 
 |  |  | 
 |  |  |         if (data.getContent() != null) { | 
 |  |  |             data.setContent(data.getContent().replace(URL_REPLACE_STR, urlPref)); | 
 |  |  |             data.setContent(data.getContent().replace(TOKEN_REPLACE_STR, "token="+token+"&")); | 
 |  |  |             data.setContent(data.getContent().replace(TIMESTAMP_REPLACE_STR, "&t="+(new Date()).getTime())); | 
 |  |  |         } | 
 |  |  |         return Result.ok(data); | 
 |  |  |     } | 
 |  |  | 
 |  |  |         ValidatorUtils.validateEntity(modelRbd, AddGroup.class, DefaultGroup.class); | 
 |  |  |         modelRbd.setContent(modelRbd.getContent().replace(modelRbd.getUrlPref(), URL_REPLACE_STR)); | 
 |  |  |         modelRbd.setContent(modelRbd.getContent().replaceAll(TOKEN_REPLACE_REGEX, TOKEN_REPLACE_STR)); | 
 |  |  |         modelRbd.setContent(modelRbd.getContent().replaceAll(TIMESTAMP_REPLACE_REGEX, TIMESTAMP_REPLACE_STR)); | 
 |  |  |         modelRbdNodeService.saveNodeArr(modelRbd); | 
 |  |  |         modelLineService.insert(modelRbd); | 
 |  |  |  | 
 |  |  |         return Result.ok(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         ValidatorUtils.validateEntity(modelRbd, UpdateGroup.class, DefaultGroup.class); | 
 |  |  |         modelRbd.setContent(modelRbd.getContent().replace(modelRbd.getUrlPref(), URL_REPLACE_STR)); | 
 |  |  |         modelRbd.setContent(modelRbd.getContent().replaceAll(TOKEN_REPLACE_REGEX, TOKEN_REPLACE_STR)); | 
 |  |  |         modelRbd.setContent(modelRbd.getContent().replaceAll(TIMESTAMP_REPLACE_REGEX, TIMESTAMP_REPLACE_STR)); | 
 |  |  |         modelRbdNodeService.saveNodeArr(modelRbd); | 
 |  |  |         modelLineService.update(modelRbd); | 
 |  |  |  | 
 |  |  |         return Result.ok(); | 
 |  |  | 
 |  |  |     @ApiOperation("解析") | 
 |  |  |     @LogOperation("解析") | 
 |  |  |     public Result analyze(@RequestBody ModelRbd modelRbd) { | 
 |  |  |         modelLineService.update(modelRbd); | 
 |  |  |         update(modelRbd); | 
 |  |  |         boolean result = modelLineService.analyze(modelRbd); | 
 |  |  |         return result ? Result.ok() : Result.error("解析失败"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @PostMapping("layout") | 
 |  |  |     @ApiOperation("自动排版") | 
 |  |  |     @LogOperation("自动排版") | 
 |  |  |     public Result<ModelRbd> layout(@RequestBody ModelRbd modelRbd) { | 
 |  |  |         boolean result = modelLineService.layout(modelRbd); | 
 |  |  |         return result ? Result.ok(modelRbd) : Result.error("自动排版失败"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |