目录添加图片模板、目录树添加业务类型

master
hansha 2 years ago
parent 030e15e783
commit ae07d1a409

@ -24,6 +24,9 @@ public class TreeSelect implements Serializable
/** 节点名称 */
private String label;
/** 业务类型 */
private String ywType;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
@ -51,9 +54,18 @@ public class TreeSelect implements Serializable
{
this.id = catalog.getId();
this.label = catalog.getMuName();
this.ywType=catalog.getYwType();
this.children = catalog.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
}
public String getYwType() {
return ywType;
}
public void setYwType(String ywType) {
this.ywType = ywType;
}
public Long getId()
{
return id;

@ -41,9 +41,14 @@ public class DaCatalog extends BaseEntity
@Excel(name = "业务类型(字典)")
private String ywType;
/** 业务类型(字典) */
@Excel(name = "图片模板")
private String picPath;
/** 菜单状态0正常 1停用 */
@Excel(name = "菜单状态", readConverterExp = "0=正常,1=停用")
private String status;
/** 子目录 */
private List<DaCatalog> children = new ArrayList<DaCatalog>();
public void setId(Long id)
@ -68,6 +73,14 @@ public class DaCatalog extends BaseEntity
this.muName = muName;
}
public String getPicPath() {
return picPath;
}
public void setPicPath(String picPath) {
this.picPath = picPath;
}
public String getMuName()
{
return muName;
@ -127,6 +140,7 @@ public class DaCatalog extends BaseEntity
.append("ancestors", getAncestors())
.append("orderNum", getOrderNum())
.append("ywType", getYwType())
.append("picPath", getPicPath())
.append("status", getStatus())
.append("remark", getRemark())
.append("createBy", getCreateBy())

@ -23,6 +23,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
/**
* Controller
@ -33,6 +34,8 @@ import java.util.List;
@RestController
@RequestMapping("/dangan/collect")
public class DangAnCollectController extends BaseController {
@Autowired
private Executor threadPoolTaskExecutor;
@Autowired
private ServerConfig serverConfig;
@Autowired
@ -45,35 +48,7 @@ public class DangAnCollectController extends BaseController {
private String url;
/**
*
*/
@PostMapping("/save")
public AjaxResult save(@RequestPart("file") MultipartFile file, @RequestPart("picRecard") DaPicturesRecard picRecard) {
try {
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
//保存图片对应信息
picRecard.setPicName(file.getOriginalFilename());
picRecard.setPicUrl(url);
picRecard.setCreateBy(getUsername());
AjaxResult ajax = AjaxResult.success();
daPicturesRecardService.insertDaPicturesRecard(picRecard);
ajax.put("data", picRecard);
/*ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename());*/
return ajax;
} catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}
/**
* /
* /
*/
@PostMapping("/saves")
public AjaxResult saves(@RequestPart("files") MultipartFile[] files, @RequestPart("picRecard") DaPicturesRecard picRecard) throws Exception {
@ -130,8 +105,8 @@ public class DangAnCollectController extends BaseController {
*/
@PostMapping("/recongnize")
public AjaxResult recognize(@RequestBody DaPicturesRecard[] picRecards) {
try {
String ywType = picRecards[0].getYwType();
//获取所有的文件
List<File> files = new ArrayList<>();
for (DaPicturesRecard picRecard : picRecards) {
@ -139,18 +114,123 @@ public class DangAnCollectController extends BaseController {
File file = new File(path);
files.add(file);
}
// TODO 调用第三方接口识别信息
//String result= CallThirdInterface.callThirdInterface1();
String result = CallThirdInterface.callThirdInterface(url, files, "option1");
// TODO————————多线程循环调用第三方接口
long start =System.currentTimeMillis();
/*List<CompletableFuture<String>> futures = new ArrayList<>();
List<String> results = new ArrayList<>();
for(File file :files){
System.out.println("线程执行前----------------"+file.getName());
futures.add(CompletableFuture.supplyAsync(() ->testAsync(file,picRecards[0].getYwType()) , threadPoolTaskExecutor)); // 用自定义线程池
}
// 所有请求完成后处理逻辑
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).thenRun(() -> {
//join控制线程顺序
results = futures.stream().map(CompletableFuture::join).collect(Collectors.toList());
logger.info("线程执行完毕:{}", JSON.toJSONString(results));
});
long end =System.currentTimeMillis();
logger.info("CompletableFuture耗时--——————————————————》"+ (end-start)+"ms");*/
//不使用循环调用接口 直接传递数组
String result = CallThirdInterface.callThirdInterface(url, files, ywType);
System.out.println(result);
long end =System.currentTimeMillis();
logger.info("CompletableFuture耗时--——————————————————》"+ (end-start)+"ms");
// TODO 根据业务类型存储识别后的信息
switch(ywType){
case "0" :
break;
case "1" :
break;
case "2" :
//daCzrkdjService.insertDaCzrkdj();
break;
case "3" :
//识别成功的图片 ,修改图片信息记录表为已识别
for (DaPicturesRecard picRecard : picRecards) {
break;
case "4" :
break;
case "5" :
break;
case "6" :
break;
}
//识别成功的图片 ,修改图片信息记录表为已识别 可以用多线程
/*for (DaPicturesRecard picRecard : picRecards) {
picRecard.setRecognize("1");
daPicturesRecardService.updateDaPicturesRecard(picRecard);
}*/
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
}
return AjaxResult.success();
}
/**
* ocr N
*/
@PostMapping("/recongnize2")
public AjaxResult recognize2(@RequestBody DaPicturesRecard chekedRecard[],@RequestBody DaPicturesRecard[] unchekedRecards) {
try {
String ywType = chekedRecard[0].getYwType();
//获取所有的文件
List<File> files = new ArrayList<>();
for (DaPicturesRecard picRecard : chekedRecard) {
String path = getPath(picRecard.getPicUrl());
File file = new File(path);
files.add(file);
}
// TODO————————多线程循环调用第三方接口
long start =System.currentTimeMillis();
String result = CallThirdInterface.callThirdInterface(url, files, ywType);
System.out.println(result);
long end =System.currentTimeMillis();
logger.info("CompletableFuture耗时--——————————————————》"+ (end-start)+"ms");
// TODO 根据业务类型存储识别后的信息
switch(ywType){
case "0" :
break;
case "1" :
break;
case "2" :
//daCzrkdjService.insertDaCzrkdj();
break;
case "3" :
break;
case "4" :
break;
case "5" :
break;
case "6" :
break;
}
//识别成功的图片 ,修改图片信息记录表为已识别 可以用多线程
/*for (DaPicturesRecard picRecard : picRecards) {
picRecard.setRecognize("1");
daPicturesRecardService.updateDaPicturesRecard(picRecard);
}*/
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
@ -158,6 +238,29 @@ public class DangAnCollectController extends BaseController {
return AjaxResult.success();
}
/**
* 线
*/
public String testAsync(File file,String ywType){
String result = null;
try {
Thread.sleep(10);
logger.info("开始执行异步线程-————————————————————————————————————>>" );
//调用接口
//根据接口返回值判断list中的值 是否匹配
//返回处理后的结果
List<File> files = new ArrayList<>();
files.add(file);
result = CallThirdInterface.callThirdInterface(url, files, ywType);
System.out.println(result);
} catch (InterruptedException e) {
logger.error(e.getMessage(),e);
e.printStackTrace();
}
return result;
}
/**
*
*/

@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ancestors" column="ancestors" />
<result property="orderNum" column="order_num" />
<result property="ywType" column="yw_type" />
<result property="picPath" column="pic_path" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDaCatalogVo">
select id, mu_name, pid, ancestors, order_num, yw_type, status, remark, create_by, create_time, update_by, update_time from da_catalog
select id, mu_name, pid, ancestors, order_num, yw_type, pic_path, status, remark, create_by, create_time, update_by, update_time from da_catalog
</sql>
<select id="selectDaCatalogList" parameterType="DaCatalog" resultMap="DaCatalogResult">
@ -31,8 +32,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="ywType != null and ywType != ''"> and yw_type = #{ywType}</if>
<if test="picPath != null and picPath != ''"> and pic_path = #{picPath}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
</where>
order by pid, order_num
</select>
<select id="selectDaCatalogById" parameterType="Long" resultMap="DaCatalogResult">
@ -75,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="ywType != null">yw_type,</if>
<if test="picPath != null">pic_path,</if>
<if test="status != null">status,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
@ -88,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="ywType != null">#{ywType},</if>
<if test="picPath != null">#{picPath},</if>
<if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
@ -105,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="ywType != null">yw_type = #{ywType},</if>
<if test="picPath != null">pic_path = #{picPath},</if>
<if test="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>

Loading…
Cancel
Save