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

master
hansha 2 years ago
parent 030e15e783
commit ae07d1a409

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

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

@ -23,6 +23,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
/** /**
* Controller * Controller
@ -33,6 +34,8 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/dangan/collect") @RequestMapping("/dangan/collect")
public class DangAnCollectController extends BaseController { public class DangAnCollectController extends BaseController {
@Autowired
private Executor threadPoolTaskExecutor;
@Autowired @Autowired
private ServerConfig serverConfig; private ServerConfig serverConfig;
@Autowired @Autowired
@ -45,35 +48,7 @@ public class DangAnCollectController extends BaseController {
private String url; 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") @PostMapping("/saves")
public AjaxResult saves(@RequestPart("files") MultipartFile[] files, @RequestPart("picRecard") DaPicturesRecard picRecard) throws Exception { public AjaxResult saves(@RequestPart("files") MultipartFile[] files, @RequestPart("picRecard") DaPicturesRecard picRecard) throws Exception {
@ -130,8 +105,8 @@ public class DangAnCollectController extends BaseController {
*/ */
@PostMapping("/recongnize") @PostMapping("/recongnize")
public AjaxResult recognize(@RequestBody DaPicturesRecard[] picRecards) { public AjaxResult recognize(@RequestBody DaPicturesRecard[] picRecards) {
try { try {
String ywType = picRecards[0].getYwType();
//获取所有的文件 //获取所有的文件
List<File> files = new ArrayList<>(); List<File> files = new ArrayList<>();
for (DaPicturesRecard picRecard : picRecards) { for (DaPicturesRecard picRecard : picRecards) {
@ -139,18 +114,123 @@ public class DangAnCollectController extends BaseController {
File file = new File(path); File file = new File(path);
files.add(file); files.add(file);
} }
// TODO 调用第三方接口识别信息 // TODO————————多线程循环调用第三方接口
//String result= CallThirdInterface.callThirdInterface1(); long start =System.currentTimeMillis();
String result = CallThirdInterface.callThirdInterface(url, files, "option1"); /*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); System.out.println(result);
long end =System.currentTimeMillis();
logger.info("CompletableFuture耗时--——————————————————》"+ (end-start)+"ms");
// TODO 根据业务类型存储识别后的信息 // TODO 根据业务类型存储识别后的信息
//daCzrkdjService.insertDaCzrkdj();
//识别成功的图片 ,修改图片信息记录表为已识别 switch(ywType){
for (DaPicturesRecard picRecard : picRecards) { 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"); picRecard.setRecognize("1");
daPicturesRecardService.updateDaPicturesRecard(picRecard); 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return AjaxResult.error(e.getMessage()); return AjaxResult.error(e.getMessage());
@ -158,6 +238,29 @@ public class DangAnCollectController extends BaseController {
return AjaxResult.success(); 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="ancestors" column="ancestors" />
<result property="orderNum" column="order_num" /> <result property="orderNum" column="order_num" />
<result property="ywType" column="yw_type" /> <result property="ywType" column="yw_type" />
<result property="picPath" column="pic_path" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
@ -20,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectDaCatalogVo"> <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> </sql>
<select id="selectDaCatalogList" parameterType="DaCatalog" resultMap="DaCatalogResult"> <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="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if> <if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="ywType != null and ywType != ''"> and yw_type = #{ywType}</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> <if test="status != null and status != ''"> and status = #{status}</if>
</where> </where>
order by pid, order_num
</select> </select>
<select id="selectDaCatalogById" parameterType="Long" resultMap="DaCatalogResult"> <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="ancestors != null">ancestors,</if>
<if test="orderNum != null">order_num,</if> <if test="orderNum != null">order_num,</if>
<if test="ywType != null">yw_type,</if> <if test="ywType != null">yw_type,</if>
<if test="picPath != null">pic_path,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</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="ancestors != null">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if> <if test="orderNum != null">#{orderNum},</if>
<if test="ywType != null">#{ywType},</if> <if test="ywType != null">#{ywType},</if>
<if test="picPath != null">#{picPath},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</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="ancestors != null">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if> <if test="orderNum != null">order_num = #{orderNum},</if>
<if test="ywType != null">yw_type = #{ywType},</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="status != null">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>

Loading…
Cancel
Save