修改图片本地化存储及一键查重功能

dev
sunchenliang 1 year ago
parent 8e539e83de
commit aa2ea3a0dd

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.jyjz.xiaoyao.admin.service.LogService;
import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil;
import cn.jyjz.xiaoyao.common.base.vo.UserToken;
@ -38,10 +39,10 @@ import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@Api(tags="ocr_图片管理")
@Api(tags = "ocr_图片管理")
@RestController
@RequestMapping("/ocr/ocrPicture")
public class OcrPictureController extends BaseController{
public class OcrPictureController extends BaseController {
private Logger log = LoggerFactory.getLogger(this.getClass());
@ -57,6 +58,7 @@ public class OcrPictureController extends BaseController{
private UserService userService;
@Resource
private LogService logService;
/**
*
*
@ -64,42 +66,43 @@ public class OcrPictureController extends BaseController{
* @return
*/
//@AutoLog(value = "ocr_picture-分页列表查询")
@ApiOperation(value="关闭工单", notes="关闭工单")
@ApiOperation(value = "关闭工单", notes = "关闭工单")
@GetMapping(value = "/closeorder")
public ResultVo<List<OcrPicture>> closeorder(@RequestParam(name="orderid",required=true) String orderid,
public ResultVo<List<OcrPicture>> closeorder(@RequestParam(name = "orderid", required = true) String orderid,
HttpServletRequest req) {
return ocrTaskchildPictureService.closeOrder(orderid)?ResultVoUtil.success():ResultVoUtil.error("失败");
return ocrTaskchildPictureService.closeOrder(orderid) ? ResultVoUtil.success() : ResultVoUtil.error("失败");
}
/**
* @MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc=
*@MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc=
*
* @param ocrPicture
* @param req
* @return
* @MM1vvPNHRprA7ScHnwE+WG6yz7hcA/u3tzMj6pSdvwc=
*/
//@AutoLog(value = "ocr_picture-分页列表查询")
@ApiOperation(value="任务查询", notes="任务查询")
@ApiOperation(value = "任务查询", notes = "任务查询")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "izClose", value = "是否关闭0关闭1开启", required = true),
@ApiImplicitParam(paramType = "path",name = "tasktype", value = "任务状态1待审批:2审批中 :3合格 :4不合格", required = true)
@ApiImplicitParam(paramType = "path", name = "izClose", value = "是否关闭0关闭1开启", required = true),
@ApiImplicitParam(paramType = "path", name = "tasktype", value = "任务状态1待审批:2审批中 :3合格 :4不合格", required = true)
})
@GetMapping(value = "/listorder")
public ResultVo<List<OcrPicture>> listorder(OcrPicture ocrPicture,
@RequestParam(name="izClose") String izClose,
@RequestParam(name="tasktype") String tasktype,
@RequestParam(name = "izClose") String izClose,
@RequestParam(name = "tasktype") String tasktype,
HttpServletRequest req) {
//租户主键,由前端页面传送
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
if (StringUtils.isBlank(tenantId)) {
return ResultVoUtil.error("租户主键不能为空");
}
//获取当前登录人
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(req));
List<OcrPicture> pageList = ocrPictureService.listByTaskChild(tenantId,userToken.getLoginname(),izClose,tasktype,null);
List<OcrPicture> pageList = ocrPictureService.listByTaskChild(tenantId, userToken.getLoginname(), izClose, tasktype, null);
return ResultVoUtil.success(pageList);
}
@ -112,11 +115,11 @@ public class OcrPictureController extends BaseController{
* @return
*/
//@AutoLog(value = "ocr_picture-分页列表查询")
@ApiOperation(value="一键查重", notes="一键查重")
@ApiOperation(value = "一键查重", notes = "一键查重")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "search_month", value = "搜索时间21,一周内22两周内1进一个月2:进两个月3近三个月、6近六个月、9近九个月、12近12个月", required = true),
@ApiImplicitParam(paramType = "path",name = "search_history", value = "是否查询历史记录0不查询1查询", required = true)
@ApiImplicitParam(paramType = "path", name = "search_month", value = "搜索时间21,一周内22两周内1进一个月2:进两个月3近三个月、6近六个月、9近九个月、12近12个月", required = true),
@ApiImplicitParam(paramType = "path", name = "search_history", value = "是否查询历史记录0不查询1查询", required = true)
})
@GetMapping(value = "/createorder")
public ResultVo createorder(OcrPicture ocrPicture,
@ -127,7 +130,7 @@ public class OcrPictureController extends BaseController{
//租户主键,由前端页面传送
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
if (StringUtils.isBlank(tenantId)) {
return ResultVoUtil.error("租户主键不能为空");
}
@ -147,38 +150,36 @@ public class OcrPictureController extends BaseController{
// queryWrapper.le("create_time",DataUtil.afterDateByWeek(Integer.parseInt(search_month) - 20));
// }
String search_month = req.getParameter("search_month");
if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0){
queryWrapper.le("create_time",DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
if (StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0) {
queryWrapper.le("create_time", DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
}
//判断是否需要查询历史记录
if(search_history.equals("0")){
if (search_history.equals("0")) {
queryWrapper.eq("taskstatus", search_history);
}
//根据参数枚举获取检索参数并映射为数据库的字段的key-v map
Map<String,Object> paraMap = new HashMap<>();
for(SearchConfigEnum config : SearchConfigEnum.values()){
Map<String, Object> paraMap = new HashMap<>();
for (SearchConfigEnum config : SearchConfigEnum.values()) {
String searchvalue = req.getParameter(config.getId());
if(StringUtils.isNotBlank(searchvalue)){
paraMap.put(config.getMeaning(),searchvalue);
if (StringUtils.isNotBlank(searchvalue)) {
paraMap.put(config.getMeaning(), searchvalue);
}
}
//调用查询参数解析方法解析为queryWrapper
queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper,paraMap);
queryWrapper.eq("tenant_id",tenantId);
queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper, paraMap);
queryWrapper.eq("tenant_id", tenantId);
List<OcrPicture> pageList = ocrPictureService.listPage(queryWrapper);
if(null != pageList && !pageList.isEmpty()){
if(pageList.size() == 1){
if (null != pageList && !pageList.isEmpty()) {
if (pageList.size() == 1) {
return ResultVoUtil.error("查重数据至少要有两条。");
}else{
return ocrPictureService.createTaskChild(pageList,tenantId,userToken,search_month, req,buessinessno);
} else {
return ocrPictureService.createPackageTask(pageList, tenantId, userToken, search_month, req, buessinessno);
}
}else{
} else {
return ResultVoUtil.error("没有查重数据。");
}
}
@ -193,20 +194,20 @@ public class OcrPictureController extends BaseController{
* @return
*/
//@AutoLog(value = "ocr_picture-分页列表查询")
@ApiOperation(value="图片分页列表查询", notes="图片分页列表查询@MMlvuvNARprA7ScHnwE+WFPWEBliKUwgUPHdB2Ue9Bw=")
@ApiOperation(value = "图片分页列表查询", notes = "图片分页列表查询@MMlvuvNARprA7ScHnwE+WFPWEBliKUwgUPHdB2Ue9Bw=")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "search_month", value = "搜索时间3近三个月、6近六个月、9近九个月、12近12个月、99一年以上全部", required = true),
@ApiImplicitParam(paramType = "path",name = "search_history", value = "是否查询历史记录0不查询1查询", required = true)
@ApiImplicitParam(paramType = "path", name = "search_month", value = "搜索时间3近三个月、6近六个月、9近九个月、12近12个月、99一年以上全部", required = true),
@ApiImplicitParam(paramType = "path", name = "search_history", value = "是否查询历史记录0不查询1查询", required = true)
})
@GetMapping(value = "/list")
public ResultVo<IPage<OcrPicture>> queryPageList(OcrPicture ocrPicture,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
//租户主键,由前端页面传送
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
if (StringUtils.isBlank(tenantId)) {
return ResultVoUtil.error("租户主键不能为空");
}
@ -215,32 +216,32 @@ public class OcrPictureController extends BaseController{
//是否查询历史记录
String search_history = req.getParameter("search_history");
//判断是否需要查询历史记录
if(search_history.equals("0")){
if (search_history.equals("0")) {
queryWrapper.eq("taskstatus", search_history);
}
String search_month = req.getParameter("search_month");
if(StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0){
queryWrapper.le("create_time",DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
if (StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0) {
queryWrapper.le("create_time", DataUtil.afterDateByMonth(Integer.parseInt(search_month)));
}
//根据参数枚举获取检索参数并映射为数据库的字段的key-v map
Map<String,Object> paraMap = new HashMap<>();
for(SearchConfigEnum config : SearchConfigEnum.values()){
Map<String, Object> paraMap = new HashMap<>();
for (SearchConfigEnum config : SearchConfigEnum.values()) {
String searchvalue = req.getParameter(config.getId());
if(!StringUtils.isEmpty(searchvalue)){
paraMap.put(config.getMeaning(),searchvalue);
if (!StringUtils.isEmpty(searchvalue)) {
paraMap.put(config.getMeaning(), searchvalue);
}
}
//调用查询参数解析方法解析为queryWrapper
queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper,paraMap);
queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper, paraMap);
queryWrapper.eq("tenant_id",tenantId);
queryWrapper.eq("tenant_id", tenantId);
Page<OcrPicture> page = new Page<OcrPicture>(pageNo, pageSize);
IPage<OcrPicture> pageList = ocrPictureService.page(page, queryWrapper);
for(OcrPicture ocrPicture1:pageList.getRecords()){
if(StringUtils.isNotBlank(ocrPicture1.getPictureclassid())){
for (OcrPicture ocrPicture1 : pageList.getRecords()) {
if (StringUtils.isNotBlank(ocrPicture1.getPictureclassid())) {
OcrPictureclass ocrPictureclass = this.ocrPictureclassService.getById(ocrPicture1.getPictureclassid());
ocrPicture1.setOcrPictureclass(ocrPictureclass);
}
@ -258,26 +259,26 @@ public class OcrPictureController extends BaseController{
* @param req
* @return
*/
@ApiOperation(value="图片分页列表查询-根据用户预设检索条件查询", notes="")
@ApiOperation(value = "图片分页列表查询-根据用户预设检索条件查询", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "header", name = "X-Tenant-Id", value = "租户主键,用户登录时的信息“tenantList”中获得。", dataType = "String", required = true),
@ApiImplicitParam(paramType = "path",name = "userSearchId", value = "预设检索条件id", required = true),
@ApiImplicitParam(paramType = "path", name = "userSearchId", value = "预设检索条件id", required = true),
})
@GetMapping(value = "/listByUserSearchId")
public ResultVo<IPage<OcrPicture>> queryPageByUserSearchId(
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
//租户主键,由前端页面传送
String tenantId = req.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
if (StringUtils.isBlank(tenantId)) {
return ResultVoUtil.error("租户主键不能为空");
}
//获取用户预设检索条件id
String userSearchId = req.getParameter("userSearchId");
IPage<OcrPicture> pageList = ocrPictureService.queryPageByUserSearchId(pageNo,pageSize,userSearchId);
IPage<OcrPicture> pageList = ocrPictureService.queryPageByUserSearchId(pageNo, pageSize, userSearchId);
return ResultVoUtil.success(pageList);
}
@ -289,17 +290,17 @@ public class OcrPictureController extends BaseController{
* @return
*/
//@AutoLog(value = "ocr_picture-分页列表查询")
@ApiOperation(value="图片信息接收", notes="图片信息接收")
@ApiOperation(value = "图片信息接收", notes = "图片信息接收")
@PostMapping(value = "/loadpicture")
public ResultVo loadpicture(OcrPicture ocrPicture,
HttpServletRequest request) {
BufferedReader streamReader = null;
try {
streamReader = new BufferedReader( new InputStreamReader(request.getInputStream(),"UTF-8"));
streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
} catch (IOException e) {
log.error("【数据接收】jsonFormatError:{}",e);
logService.addLog(101,"接收数据失败。",null,null);
log.error("【数据接收】jsonFormatError:{}", e);
logService.addLog(101, "接收数据失败。", null, null);
ResultVoUtil.error("失败");
}
StringBuilder sb = new StringBuilder();
@ -309,11 +310,11 @@ public class OcrPictureController extends BaseController{
sb.append(inputStr);
}
} catch (IOException e) {
log.error("【数据接收】jsonFormatError:{}",e);
logService.addLog(101,"接收数据失败。",null,null);
log.error("【数据接收】jsonFormatError:{}", e);
logService.addLog(101, "接收数据失败。", null, null);
}
logService.addLog(101,"接收数据成功。",null,null);
logService.addLog(101, "接收数据成功。", null, null);
JSONObject jsonArray = JSONObject.parseObject(sb.toString());
@ -321,7 +322,7 @@ public class OcrPictureController extends BaseController{
//this.ocrPictureService
//TODO AI获取图片分类接口
logService.addLog(102,"AI获取图片分类接口。",null,null);
logService.addLog(102, "AI获取图片分类接口。", null, null);
return ResultVoUtil.success();
}

@ -26,274 +26,281 @@ import java.util.stream.Stream;
import java.util.stream.Collectors;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "图片信息表", title = "图片信息表")
@ApiModel(value="图片信息表", description="图片信息表")
@ApiModel(value = "图片信息表", description = "图片信息表")
@TableName(value = "ocr_picture")
public class OcrPicture implements BaseDto,java.io.Serializable {
public class OcrPicture implements BaseDto, java.io.Serializable {
private static final long serialVersionUID = -10378331243377607L;
@ApiModelProperty(value ="主键")
@TableId(value = "id",type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
@TableField(value="ID")
@TableField(value = "ID")
private Long id;
@ApiModelProperty(value ="创建人")
@TableField(value="create_by")
@ApiModelProperty(value = "创建人")
@TableField(value = "create_by")
private String createBy;
@ApiModelProperty(value ="创建时间")
@TableField(value="create_time")
@ApiModelProperty(value = "创建时间")
@TableField(value = "create_time")
@JsonSerialize(using = DateSerializer.class)
private Long createTime;
@ApiModelProperty(value ="修改人")
@TableField(value="update_by")
@ApiModelProperty(value = "修改人")
@TableField(value = "update_by")
private String updateBy;
@ApiModelProperty(value ="修改时间")
@TableField(value="update_time")
@ApiModelProperty(value = "修改时间")
@TableField(value = "update_time")
@JsonSerialize(using = DateSerializer.class)
private Long updateTime;
@ApiModelProperty(value ="分类表主键--通过“图片分类”字段做匹配,如果没有自动添加")
@TableField(value="classificationid")
@ApiModelProperty(value = "分类表主键--通过“图片分类”字段做匹配,如果没有自动添加")
@TableField(value = "classificationid")
private String classificationid;
@ApiModelProperty(value ="图片类型--通过“AI图片分类接口获得”")
@TableField(value="pictureclassid")
@ApiModelProperty(value = "图片类型--通过“AI图片分类接口获得”")
@TableField(value = "pictureclassid")
private String pictureclassid;
@Schema(description = "图片类型相似度,图片类型--通过“AI图片分类接口获得”")
@TableField(value="pictureclassscores")
@TableField(value = "pictureclassscores")
private String pictureclassscores;
@ApiModelProperty(value ="图片真假0:假1真")
@TableField(value="iztrueorfalse",updateStrategy = FieldStrategy.IGNORED)
@ApiModelProperty(value = "图片真假0:假1真")
@TableField(value = "iztrueorfalse", updateStrategy = FieldStrategy.IGNORED)
private Integer iztrueorfalse;
@ApiModelProperty(value ="选判真假原因id,从字典表中获得,其他时,当前字段为零")
@TableField(value="judgeid",updateStrategy = FieldStrategy.IGNORED)
@ApiModelProperty(value = "选判真假原因id,从字典表中获得,其他时,当前字段为零")
@TableField(value = "judgeid", updateStrategy = FieldStrategy.IGNORED)
@JsonSerialize(using = ToStringSerializer.class)
private Long judgeid;
@ApiModelProperty(value ="图片为假的其他原因长度不超过50个汉字")
@TableField(value="judgedesc",updateStrategy = FieldStrategy.IGNORED)
@ApiModelProperty(value = "图片为假的其他原因长度不超过50个汉字")
@TableField(value = "judgedesc", updateStrategy = FieldStrategy.IGNORED)
private String judgedesc;
@ApiModelProperty(value ="公司ID")
@ApiModelProperty(value = "公司ID")
@JsonSerialize(using = ToStringSerializer.class)
@TableField(value="tenant_id")
@TableField(value = "tenant_id")
private Long tenantId;
@ApiModelProperty(value ="公司状态")
@TableField(value="tenantstatus")
@ApiModelProperty(value = "公司状态")
@TableField(value = "tenantstatus")
private String tenantstatus;
@ApiModelProperty(value ="公司代码,第三方系统")
@TableField(value="plantCode")
@ApiModelProperty(value = "公司代码,第三方系统")
@TableField(value = "plantCode")
private String plantcode;
@ApiModelProperty(value ="公司名称")
@TableField(value="tenantname")
@ApiModelProperty(value = "公司名称")
@TableField(value = "tenantname")
private String tenantname;
@ApiModelProperty(value ="业务主体ID--图片主键")
@TableField(value="pictureid")
@ApiModelProperty(value = "业务主体ID--图片主键")
@TableField(value = "pictureid")
private String pictureid;
@ApiModelProperty(value ="业务主体名称--图片成名")
@TableField(value="picturename")
@ApiModelProperty(value = "业务主体名称--图片成名")
@TableField(value = "picturename")
private String picturename;
@ApiModelProperty(value ="图片名称")
@TableField(value="imgName")
@ApiModelProperty(value = "图片名称")
@TableField(value = "imgName")
private String imgname;
@ApiModelProperty(value ="图片地址")
@TableField(value="imgUrl")
@ApiModelProperty(value = "图片地址")
@TableField(value = "imgUrl")
private String imgurl;
@ApiModelProperty(value ="业务主体状态")
@TableField(value="picturestatus")
@ApiModelProperty(value = "业务主体状态")
@TableField(value = "picturestatus")
private String picturestatus;
@ApiModelProperty(value ="源项目id")
@TableField(value="projectId")
@ApiModelProperty(value = "源项目id")
@TableField(value = "projectId")
private String projectid;
@ApiModelProperty(value ="项目名称")
@TableField(value="projectIdName")
@ApiModelProperty(value = "项目名称")
@TableField(value = "projectIdName")
private String projectidname;
@ApiModelProperty(value ="项目状态")
@TableField(value="projectstatus")
@ApiModelProperty(value = "项目状态")
@TableField(value = "projectstatus")
private String projectstatus;
@ApiModelProperty(value ="源计划id")
@TableField(value="planId")
@ApiModelProperty(value = "源计划id")
@TableField(value = "planId")
private String planid;
@ApiModelProperty(value ="计划名称")
@TableField(value="planName")
@ApiModelProperty(value = "计划名称")
@TableField(value = "planName")
private String planname;
@ApiModelProperty(value ="计划状态")
@TableField(value="planstatus")
@ApiModelProperty(value = "计划状态")
@TableField(value = "planstatus")
private String planstatus;
@ApiModelProperty(value ="所属子计划ID")
@TableField(value="planchildid")
@ApiModelProperty(value = "所属子计划ID")
@TableField(value = "planchildid")
private String planchildid;
@ApiModelProperty(value ="所属子计划名称")
@TableField(value="planchildname")
@ApiModelProperty(value = "所属子计划名称")
@TableField(value = "planchildname")
private String planchildname;
@ApiModelProperty(value ="所属子计划状态")
@TableField(value="planchildstatus")
@ApiModelProperty(value = "所属子计划状态")
@TableField(value = "planchildstatus")
private String planchildstatus;
@ApiModelProperty(value ="上传时间")
@ApiModelProperty(value = "上传时间")
@JsonSerialize(using = DateNotimeSerializer.class)
@TableField(value="upTime")
@TableField(value = "upTime")
private Long uptime;
@ApiModelProperty(value ="生成时间")
@ApiModelProperty(value = "生成时间")
@JsonSerialize(using = DateNotimeSerializer.class)
@TableField(value="genTime")
@TableField(value = "genTime")
private Long gentime;
@ApiModelProperty(value ="色彩空间")
@TableField(value="space")
@ApiModelProperty(value = "色彩空间")
@TableField(value = "space")
private String space;
@ApiModelProperty(value ="来源")
@TableField(value="source")
@ApiModelProperty(value = "来源")
@TableField(value = "source")
private String source;
@ApiModelProperty(value ="上报者头像--接口传送")
@TableField(value="upHead")
@ApiModelProperty(value = "上报者头像--接口传送")
@TableField(value = "upHead")
private String uphead;
@ApiModelProperty(value ="上报人主键")
@TableField(value="upuserid")
@ApiModelProperty(value = "上报人主键")
@TableField(value = "upuserid")
private String upuserid;
@ApiModelProperty(value ="上报者名称--接口传送")
@TableField(value="upName")
@ApiModelProperty(value = "上报者名称--接口传送")
@TableField(value = "upName")
private String upname;
@ApiModelProperty(value ="发布地区,拜访城市,城市名称,例如:北京市、天津市、石家庄市")
@TableField(value="releaseArea")
@ApiModelProperty(value = "发布地区,拜访城市,城市名称,例如:北京市、天津市、石家庄市")
@TableField(value = "releaseArea")
private String releasearea;
@ApiModelProperty(value ="拜访省份")
@TableField(value="releaseProvince")
@ApiModelProperty(value = "拜访省份")
@TableField(value = "releaseProvince")
private String releaseprovince;
@ApiModelProperty(value ="任务id")
@TableField(value="remark")
@ApiModelProperty(value = "任务id")
@TableField(value = "remark")
private String remark;
@ApiModelProperty(value ="任务名称,源系统")
@TableField(value="taskName")
@ApiModelProperty(value = "任务名称,源系统")
@TableField(value = "taskName")
private String taskname;
@ApiModelProperty(value ="是否已经生成任务,01是")
@TableField(value="taskstatus")
@ApiModelProperty(value = "是否已经生成任务,01是")
@TableField(value = "taskstatus")
private String taskstatus;
@ApiModelProperty(value ="是否已经审批0未生成1审批中2已审批")
@TableField(value="work_status")
@ApiModelProperty(value = "是否已经审批0未生成1审批中2已审批")
@TableField(value = "work_status")
private String workStatus;
@ApiModelProperty(value ="现项目ID")
@TableField(value="categoryid")
@ApiModelProperty(value = "现项目ID")
@TableField(value = "categoryid")
private Long categoryid;
@ApiModelProperty(value ="任务-工单主键")
@TableField(value="taskchildpictureid")
@ApiModelProperty(value = "任务-工单主键")
@TableField(value = "taskchildpictureid")
private String taskchildpictureid;
@ApiModelProperty(value ="提报人")
@TableField(value="field1")
@ApiModelProperty(value = "提报人")
@TableField(value = "field1")
private String field1;
@ApiModelProperty(value ="拜访客户类型")
@TableField(value="field2")
@ApiModelProperty(value = "拜访客户类型")
@TableField(value = "field2")
private String field2;
@ApiModelProperty(value ="拜访客户名称,终端名称,例如中日友好医院")
@TableField(value="field3")
@ApiModelProperty(value = "拜访客户名称,终端名称,例如中日友好医院")
@TableField(value = "field3")
private String field3;
@ApiModelProperty(value ="任务来源")
@TableField(value="field4")
@ApiModelProperty(value = "任务来源")
@TableField(value = "field4")
private String field4;
@ApiModelProperty(value ="厂商")
@TableField(value="field5")
@ApiModelProperty(value = "厂商")
@TableField(value = "field5")
private String field5;
@ApiModelProperty(value ="拜访客户级别")
@TableField(value="field6")
@ApiModelProperty(value = "拜访客户级别")
@TableField(value = "field6")
private String field6;
@ApiModelProperty(value ="科室名称")
@TableField(value="field7")
@ApiModelProperty(value = "科室名称")
@TableField(value = "field7")
private String field7;
@ApiModelProperty(value ="拜访小结")
@TableField(value="field8")
@ApiModelProperty(value = "拜访小结")
@TableField(value = "field8")
private String field8;
@ApiModelProperty(value ="产品名称")
@TableField(value="field9")
@ApiModelProperty(value = "产品名称")
@TableField(value = "field9")
private String field9;
@ApiModelProperty(value ="地区定位信息例如北京市朝阳区文苑路10号")
@TableField(value="field10")
@ApiModelProperty(value = "地区定位信息例如北京市朝阳区文苑路10号")
@TableField(value = "field10")
private String field10;
@ApiModelProperty(value ="拜访日期")
@TableField(value="field11")
@ApiModelProperty(value = "拜访日期")
@TableField(value = "field11")
private String field11;
@ApiModelProperty(value ="定位距离")
@TableField(value="field12")
@ApiModelProperty(value = "定位距离")
@TableField(value = "field12")
private String field12;
@ApiModelProperty(value ="病历号")
@TableField(value="field13")
@ApiModelProperty(value = "病历号")
@TableField(value = "field13")
private String field13;
@ApiModelProperty(value ="是否重复")
@TableField(value="field14")
@ApiModelProperty(value = "是否重复")
@TableField(value = "field14")
private String field14;
@ApiModelProperty(value ="任务类型")
@TableField(value="field15")
@ApiModelProperty(value = "任务类型")
@TableField(value = "field15")
private String field15;
@ApiModelProperty(value ="任务状态")
@TableField(value="field16")
@ApiModelProperty(value = "任务状态")
@TableField(value = "field16")
private String field16;
@Schema(description = "拜访项目类别")
@TableField(value="field17")
@TableField(value = "field17")
private String field17;
@Schema(description = "备用字段")
@TableField(value="field18")
@TableField(value = "field18")
private String field18;
@Schema(description = "本地图片地址")
@TableField(value = "local_pictrue_url")
private String localpictrueurl;
@Schema(description = "是否已下载到本地")
@TableField(value = "is_download")
private Integer isdownload;
@ApiModelProperty(value = "图片查重的比对图片集合")
@TableField(exist = false)
private List<OcrPicture> listCom;
@ -322,75 +329,77 @@ public class OcrPicture implements BaseDto,java.io.Serializable {
@TableField(exist = false)
@JsonIgnore
private final Map<String,String> query = Stream.of(
new SimpleEntry<>("ID","id"),
new SimpleEntry<>("create_by","createBy"),
new SimpleEntry<>("create_time","createTime"),
new SimpleEntry<>("update_by","updateBy"),
new SimpleEntry<>("update_time","updateTime"),
new SimpleEntry<>("classificationid","classificationid"),
new SimpleEntry<>("pictureclassid","pictureclassid"),
new SimpleEntry<>("pictureclassscores","pictureclassscores"),
new SimpleEntry<>("iztrueorfalse","iztrueorfalse"),
new SimpleEntry<>("judgeid","judgeid"),
new SimpleEntry<>("judgedesc","judgedesc"),
new SimpleEntry<>("tenant_id","tenantId"),
new SimpleEntry<>("tenantstatus","tenantstatus"),
new SimpleEntry<>("plantCode","plantcode"),
new SimpleEntry<>("tenantname","tenantname"),
new SimpleEntry<>("pictureid","pictureid"),
new SimpleEntry<>("picturename","picturename"),
new SimpleEntry<>("imgName","imgname"),
new SimpleEntry<>("imgUrl","imgurl"),
new SimpleEntry<>("picturestatus","picturestatus"),
new SimpleEntry<>("projectId","projectid"),
new SimpleEntry<>("projectIdName","projectidname"),
new SimpleEntry<>("projectstatus","projectstatus"),
new SimpleEntry<>("planId","planid"),
new SimpleEntry<>("planName","planname"),
new SimpleEntry<>("planstatus","planstatus"),
new SimpleEntry<>("planchildid","planchildid"),
new SimpleEntry<>("planchildname","planchildname"),
new SimpleEntry<>("planchildstatus","planchildstatus"),
new SimpleEntry<>("upTime","uptime"),
new SimpleEntry<>("genTime","gentime"),
new SimpleEntry<>("space","space"),
new SimpleEntry<>("source","source"),
new SimpleEntry<>("upHead","uphead"),
new SimpleEntry<>("upuserid","upuserid"),
new SimpleEntry<>("upName","upname"),
new SimpleEntry<>("releaseArea","releasearea"),
new SimpleEntry<>("releaseProvince","releaseprovince"),
new SimpleEntry<>("remark","remark"),
new SimpleEntry<>("taskName","taskname"),
new SimpleEntry<>("taskstatus","taskstatus"),
new SimpleEntry<>("work_status","workStatus"),
new SimpleEntry<>("categoryid","categoryid"),
new SimpleEntry<>("taskchildpictureid","taskchildpictureid"),
new SimpleEntry<>("field1","field1"),
new SimpleEntry<>("field2","field2"),
new SimpleEntry<>("field3","field3"),
new SimpleEntry<>("field4","field4"),
new SimpleEntry<>("field5","field5"),
new SimpleEntry<>("field6","field6"),
new SimpleEntry<>("field7","field7"),
new SimpleEntry<>("field8","field8"),
new SimpleEntry<>("field9","field9"),
new SimpleEntry<>("field10","field10"),
new SimpleEntry<>("field11","field11"),
new SimpleEntry<>("field12","field12"),
new SimpleEntry<>("field13","field13"),
new SimpleEntry<>("field14","field14"),
new SimpleEntry<>("field15","field15"),
new SimpleEntry<>("field16","field16"),
new SimpleEntry<>("field17","field17"),
new SimpleEntry<>("field18","field18")
private final Map<String, String> query = Stream.of(
new SimpleEntry<>("ID", "id"),
new SimpleEntry<>("create_by", "createBy"),
new SimpleEntry<>("create_time", "createTime"),
new SimpleEntry<>("update_by", "updateBy"),
new SimpleEntry<>("update_time", "updateTime"),
new SimpleEntry<>("classificationid", "classificationid"),
new SimpleEntry<>("pictureclassid", "pictureclassid"),
new SimpleEntry<>("pictureclassscores", "pictureclassscores"),
new SimpleEntry<>("iztrueorfalse", "iztrueorfalse"),
new SimpleEntry<>("judgeid", "judgeid"),
new SimpleEntry<>("judgedesc", "judgedesc"),
new SimpleEntry<>("tenant_id", "tenantId"),
new SimpleEntry<>("tenantstatus", "tenantstatus"),
new SimpleEntry<>("plantCode", "plantcode"),
new SimpleEntry<>("tenantname", "tenantname"),
new SimpleEntry<>("pictureid", "pictureid"),
new SimpleEntry<>("picturename", "picturename"),
new SimpleEntry<>("imgName", "imgname"),
new SimpleEntry<>("imgUrl", "imgurl"),
new SimpleEntry<>("picturestatus", "picturestatus"),
new SimpleEntry<>("projectId", "projectid"),
new SimpleEntry<>("projectIdName", "projectidname"),
new SimpleEntry<>("projectstatus", "projectstatus"),
new SimpleEntry<>("planId", "planid"),
new SimpleEntry<>("planName", "planname"),
new SimpleEntry<>("planstatus", "planstatus"),
new SimpleEntry<>("planchildid", "planchildid"),
new SimpleEntry<>("planchildname", "planchildname"),
new SimpleEntry<>("planchildstatus", "planchildstatus"),
new SimpleEntry<>("upTime", "uptime"),
new SimpleEntry<>("genTime", "gentime"),
new SimpleEntry<>("space", "space"),
new SimpleEntry<>("source", "source"),
new SimpleEntry<>("upHead", "uphead"),
new SimpleEntry<>("upuserid", "upuserid"),
new SimpleEntry<>("upName", "upname"),
new SimpleEntry<>("releaseArea", "releasearea"),
new SimpleEntry<>("releaseProvince", "releaseprovince"),
new SimpleEntry<>("remark", "remark"),
new SimpleEntry<>("taskName", "taskname"),
new SimpleEntry<>("taskstatus", "taskstatus"),
new SimpleEntry<>("work_status", "workStatus"),
new SimpleEntry<>("categoryid", "categoryid"),
new SimpleEntry<>("taskchildpictureid", "taskchildpictureid"),
new SimpleEntry<>("field1", "field1"),
new SimpleEntry<>("field2", "field2"),
new SimpleEntry<>("field3", "field3"),
new SimpleEntry<>("field4", "field4"),
new SimpleEntry<>("field5", "field5"),
new SimpleEntry<>("field6", "field6"),
new SimpleEntry<>("field7", "field7"),
new SimpleEntry<>("field8", "field8"),
new SimpleEntry<>("field9", "field9"),
new SimpleEntry<>("field10", "field10"),
new SimpleEntry<>("field11", "field11"),
new SimpleEntry<>("field12", "field12"),
new SimpleEntry<>("field13", "field13"),
new SimpleEntry<>("field14", "field14"),
new SimpleEntry<>("field15", "field15"),
new SimpleEntry<>("field16", "field16"),
new SimpleEntry<>("field17", "field17"),
new SimpleEntry<>("field18", "field18"),
new SimpleEntry<>("localpictrueurl", "localpictrueurl")
)
.collect(Collectors.toMap(SimpleEntry::getKey, SimpleEntry::getValue));
@Override
public String getQueryFiled(String filedname){
public String getQueryFiled(String filedname) {
String obj = null;
if(null != query && query.size() > 0){
if (null != query && query.size() > 0) {
obj = query.get(filedname);
}
return obj;

@ -96,4 +96,6 @@ public interface OcrPictureService extends BaseService<OcrPicture> {
* @return
*/
int savePictures(List<OcrPicture> ocrPictureList);
ResultVo createPackageTask(List<OcrPicture> pageList, String tenantId, UserToken userToken, String searchMonth, HttpServletRequest req, String buessinessno);
}

@ -13,12 +13,15 @@ import cn.jyjz.xiaoyao.oa.from.service.CategoryService;
import cn.jyjz.xiaoyao.ocr.dataDao.OcrPictureMybatisDao;
import cn.jyjz.xiaoyao.ocr.dataobject.*;
import cn.jyjz.xiaoyao.ocr.service.*;
import cn.jyjz.xiaoyao.ocr.thread.TaskQueue;
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
import cn.jyjz.xiaoyao.ocr.util.DataDictionaryUtil;
import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil;
import cn.jyjz.xiaoyao.ocr.util.SearchEnum;
import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -48,6 +51,9 @@ import java.util.List;
@Service("ocrPictureService")
@Slf4j
public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao, OcrPicture> implements OcrPictureService {
@Value("${ocr.api.wly.localImagePath}")
private String localImagePath;
@Resource
private OcrPictureMybatisDao ocrpicturemybatisdao;
@ -273,79 +279,175 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
}
return ResultVoUtil.error("失败。");
}
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId) {
public ResultVo createPackageTask(List<OcrPicture> ocrPictureList, String tenantId, UserToken sysUser, String search_month, HttpServletRequest request, String buessinessno) {
//图片错误信息
StringBuffer error = new StringBuffer();
//项目错误信息
StringBuffer errorProject = new StringBuffer();
//流程错误信息
StringBuffer errorFlow = new StringBuffer();
//记录任务相似度为百分百的任务主键
List<Long> pointsList = new ArrayList<>();
//图片信息不能为空
if (null != ocrPictureList && !ocrPictureList.isEmpty()) {
//生成任务包
//String packageName = seqManageService.getSeqNextNo("AI任务包");
//创建任务包
OcrPackagetask ocrPackagetask = this.ocrPackagetaskService.create(buessinessno, tenantId, sysUser);
if (null == ocrPackagetask) {
return ResultVoUtil.error("失败。");
}
//用于标记相似度是否存在百分百的情况
List<OcrPicture> newList = new ArrayList<>();
for (OcrPicture ocrPicture : ocrPictureList) {
//如果当前图片已经生成任务包,直接跳过
if (ocrPicture.getTaskstatus().equals("1")) {
continue;
}
//图片查重的比对图片集合
List<OcrPicture> compareList = new ArrayList<>();
//非历史图片主键集合
List<String> picturecompareList = new ArrayList<>();
boolean havePoint = false;
//二次遍历进行比对
for (OcrPicture ocrPictureNext : ocrPictureList) {
if (ocrPictureNext.getId().longValue() == ocrPicture.getId().longValue()) {
continue;
}
//TODO 接口请求判断重复情况
JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(ocrPicture.getImgurl(),
ocrPictureNext.getImgurl(),
logService.addLog(103, "AI获取图片相似度接口", sysUser, "sendParams");
JSONObject jsonObjectSimi = ImageClassUtil.getSimilarity(StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPicture.getImgurl() : ocrPicture.getLocalpictrueurl(),
StringUtils.isBlank(ocrPicture.getLocalpictrueurl()) ? ocrPictureNext.getImgurl() : ocrPicture.getLocalpictrueurl(),
null);
System.out.println("responseDataXs--code = [" + jsonObjectSimi.get("code") + "]");
System.out.println("responseDataXs--similarity = [" + jsonObjectSimi.get("similarity") + "]");
String resultValue = "";
//返回内容为零,表示成功,否则表示失败
if (null != jsonObjectSimi && jsonObjectSimi.getString("code").equals("0")) {
resultValue = jsonObjectSimi.getString("similarity");
ocrPictureNext.setResult(resultValue);
} else {
resultValue = "0";
ocrPictureNext.setResult(resultValue);
}
BigDecimal b1 = new BigDecimal(resultValue);
BigDecimal b2 = new BigDecimal("100");
int val = b1.compareTo(b2);
if (val == 0) {
havePoint = true;
}
//如果当前图片未生成任务需要临时保存
if (ocrPictureNext.getTaskstatus().equals("0")) {
picturecompareList.add(ocrPictureNext.getId().toString());
}
compareList.add(ocrPictureNext);
}
bubbleSortOpt(compareList);
//从大到小进行排序
ocrPicture.setListCom(compareList);
//非历史图片主键集合
ocrPicture.setPicturecompareList(picturecompareList);
//查询项目对象
if (null == ocrPicture.getCategoryid()) {
//TODO 没有对应项目,返回提示信息
if (null != error && error.length() > 1) {
error.append("," + ocrPicture.getImgname());
} else {
error.append(ocrPicture.getImgname());
}
continue;
}
Category category = categoryService.getById(ocrPicture.getCategoryid());
if (null == category) {
if (null != errorProject && errorProject.length() > 1) {
errorProject.append("," + ocrPicture.getImgname());
} else {
errorProject.append(ocrPicture.getImgname());
}
continue;
} else if (StringUtils.isBlank(category.getProcessdefinitionid())) {
if (null != errorFlow && errorFlow.length() > 1) {
errorFlow.append("," + category.getCategoryname());
} else {
errorFlow.append(category.getCategoryname());
}
continue;
}
//创建工单,如果创建成功,增加标志,用于过滤条件使用
OcrTaskchildPicture ocrTaskchildPicture = this.updateTaskChild(ocrPicture, ocrPackagetask.getId(), buessinessno);
if (null != ocrTaskchildPicture) {
if (havePoint) {
pointsList.add(ocrTaskchildPicture.getId());
}
}
newList.add(ocrPicture);
}
//批量更新 pointsList 主键相似度为百分百的数据
if (null != pointsList && !pointsList.isEmpty()) {
this.ocrTaskchildPictureService.markPoint(pointsList);
}
if (StringUtils.isNotBlank(search_month)) {
if (StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) <= 12 && Integer.parseInt(search_month) > 0) {
ocrPackagetask.setSearchtimes(SearchEnum.getName(Integer.parseInt(search_month)));
} else if (StringUtils.isNotBlank(search_month) && Integer.parseInt(search_month) > 20) {
ocrPackagetask.setSearchtimes(SearchEnum.getName((Integer.parseInt(search_month) - 20)));
}
}
ocrPackagetask.setPictureno(ocrPictureList.size());
this.ocrPackagetaskService.updateById(ocrPackagetask);
//原主图设置为任务包已经生成
for (OcrPicture ocrPicture : newList) {
ocrPicture.setTaskstatus("1");
this.updateById(ocrPicture);
}
if (StringUtils.isBlank(error) && StringUtils.isBlank(errorProject) && StringUtils.isBlank(errorFlow)) {
return ResultVoUtil.success();
} else {
String msg = (StringUtils.isBlank(error)) ? "" : error.toString() + ",图片没有对应项目,无法查重。";
msg = msg + ((StringUtils.isBlank(errorProject)) ? "" : errorProject.toString() + ",图片没有对应项目,无法查重。");
msg = msg + ((StringUtils.isBlank(errorFlow)) ? "" : errorFlow.toString() + ",项目没有配置审批流程,无法查重。");
return ResultVoUtil.success(msg);
}
}
return ResultVoUtil.error("失败。");
}
public OcrTaskchildPicture updateTaskChild(OcrPicture ocrPicture, Long packageid, String buessinessno) {
OcrTaskchildPicture ocrTaskchildPicture = ocrTaskchildPictureService.getOne(new LambdaQueryWrapper<OcrTaskchildPicture>().eq(OcrTaskchildPicture::getPictureid, ocrPicture.getId()));
ocrTaskchildPicture.setBuessinessno(buessinessno);
ocrTaskchildPicture.setPackageid(packageid);
StringBuffer pcid = new StringBuffer();
StringBuffer result = new StringBuffer();
for (OcrPicture comp : ocrPicture.getListCom()) {
if (null == pcid || pcid.toString().length() < 1) {
pcid.append(comp.getId());
result.append(comp.getResult());
} else {
pcid.append("," + comp.getId());
result.append("," + comp.getResult());
}
}
ocrTaskchildPicture.setOcpictureid(pcid.toString());
ocrTaskchildPicture.setPictureresult(result.toString());
ocrTaskchildPicture.setPicturecompare(String.join(",", ocrPicture.getPicturecompareList()));
return ocrTaskchildPictureService.updateById(ocrTaskchildPicture) ? ocrTaskchildPicture : null;
}
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId) {
//图片错误信息
StringBuffer error = new StringBuffer();
//项目错误信息
StringBuffer errorProject = new StringBuffer();
//流程错误信息
StringBuffer errorFlow = new StringBuffer();
//图片信息不能为空
if (null != ocrPictureList && !ocrPictureList.isEmpty()) {
//用于标记相似度是否存在百分百的情况
List<OcrPicture> newList = new ArrayList<>();
for (OcrPicture ocrPicture : ocrPictureList) {
boolean havePoint = false;
//查询项目对象
if (null == ocrPicture.getCategoryid()) {
//TODO 没有对应项目,返回提示信息
@ -388,41 +490,19 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
ocrTaskchildPicture.getId().toString(),
category.getServicename()
);
if (havePoint) {
pointsList.add(ocrTaskchildPicture.getId());
}
//TODO 需要测试
ocrPicture.setTaskchildpictureid(ocrTaskchildPicture.getId().toString());
ocrPicture.setWorkStatus("1");
this.updateById(ocrPicture);
}
newList.add(ocrPicture);
}
//批量更新 pointsList 主键相似度为百分百的数据
if (null != pointsList && !pointsList.isEmpty()) {
this.ocrTaskchildPictureService.markPoint(pointsList);
}
//原主图设置为任务包已经生成
for (OcrPicture ocrPicture : newList) {
ocrPicture.setTaskstatus("1");
this.updateById(ocrPicture);
}
if (StringUtils.isBlank(error) && StringUtils.isBlank(errorProject) && StringUtils.isBlank(errorFlow)) {
return ResultVoUtil.success();
} else {
String msg = (StringUtils.isBlank(error)) ? "" : error.toString() + ",图片没有对应项目,无法查重。";
msg = msg + ((StringUtils.isBlank(errorProject)) ? "" : errorProject.toString() + ",图片没有对应项目,无法查重。");
msg = msg + ((StringUtils.isBlank(errorFlow)) ? "" : errorFlow.toString() + ",项目没有配置审批流程,无法查重。");
return ResultVoUtil.success(msg);
}
}
return ResultVoUtil.error("失败。");
}
@ -675,7 +755,6 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
}
@Override
@Transactional(rollbackFor = Exception.class)
public int savePictures(List<OcrPicture> ocrPictureList) {
//1.字典数据 解析入库
boolean b = dataDictionaryUtil.pictureDataDictionarySaveArray(ocrPictureList);
@ -687,18 +766,27 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
picture.setImgurl(interfaceDomain + picture.getImgurl());
}
boolean saveBatch = this.saveBatch(ocrPictureList);
//3.添加图片信息
if (this.saveBatch(ocrPictureList)) {
if (saveBatch) {
this.convertImage(ocrPictureList);
this.createTaskChild(ocrPictureList, ocrPictureList.get(0).getTenantId().toString());
return ocrPictureList.size();
}
return 0;
}
private void convertImage(List<OcrPicture> list) {
for (OcrPicture ocrPicture : list) {
PictureImgToLocalEntity entity = new PictureImgToLocalEntity();
entity.setPictureId(ocrPicture.getId());
entity.setImgUrl(ocrPicture.getImgurl());
String imgurl = ocrPicture.getImgurl();
entity.setLocalPath(localImagePath + imgurl.substring(imgurl.lastIndexOf("/")));
TaskQueue.pictureImgToLocalPushData(entity);
}
}
/**
*
*

@ -455,21 +455,21 @@ public class OcrTaskchildPictureServiceImpl extends BaseServiceImpl<OcrTaskchild
ocrTaskchildPicture.setFromprojectid(ocrPicture.getProjectid());
ocrTaskchildPicture.setFromuserid(ocrPicture.getUpuserid());
StringBuffer pcid = new StringBuffer();
StringBuffer result = new StringBuffer();
for(OcrPicture comp:ocrPicture.getListCom()){
if(null == pcid || pcid.toString().length() < 1){
pcid.append(comp.getId());
result.append(comp.getResult());
}else{
pcid.append("," + comp.getId());
result.append("," + comp.getResult());
}
}
ocrTaskchildPicture.setOcpictureid(pcid.toString());
ocrTaskchildPicture.setPictureresult(result.toString());
ocrTaskchildPicture.setPicturecompare(String.join(",",ocrPicture.getPicturecompareList()));
// StringBuffer pcid = new StringBuffer();
// StringBuffer result = new StringBuffer();
// for(OcrPicture comp:ocrPicture.getListCom()){
// if(null == pcid || pcid.toString().length() < 1){
// pcid.append(comp.getId());
// result.append(comp.getResult());
// }else{
// pcid.append("," + comp.getId());
// result.append("," + comp.getResult());
// }
// }
//
// ocrTaskchildPicture.setOcpictureid(pcid.toString());
// ocrTaskchildPicture.setPictureresult(result.toString());
// ocrTaskchildPicture.setPicturecompare(String.join(",",ocrPicture.getPicturecompareList()));
return this.save(ocrTaskchildPicture)?ocrTaskchildPicture:null;
}

@ -68,10 +68,10 @@ public class TaskQueue {
}
/**
*
*
* @return
*/
public static PictureImgToLocalEntity pictureImgToLocalPullData(){
return (PictureImgToLocalEntity) pictureDisposeQueue.poll();
return (PictureImgToLocalEntity) pictureImgToLocalQueue.poll();
}
}

@ -1,4 +1,5 @@
package cn.jyjz.xiaoyao.ocr.thread;
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
import cn.jyjz.xiaoyao.ocr.thread.tasks.PictureDisposeTask;
@ -21,8 +22,8 @@ public class TaskThreadPool {
private static Logger logger = LoggerFactory.getLogger(TaskQueue.class);
ExecutorService threadPool = null;
public TaskThreadPool(){
if(threadPool ==null){
public TaskThreadPool() {
if (threadPool == null) {
threadPool = new ThreadPoolExecutor(
10,
40,
@ -36,50 +37,59 @@ public class TaskThreadPool {
/**
*
*
* @return
*/
public boolean startPictureDisposePull(){
public boolean startPictureDisposePull() {
Runnable runnable = new Runnable() {
@SneakyThrows
@Override
public void run() {
logger.debug("无量云接口数据处理消费线程检测中...");
while (true){
while (true) {
PictureSourceResult pictureSourceResult = TaskQueue.pictureDisposePullData();
if(pictureSourceResult!=null){
if (pictureSourceResult != null) {
threadPool.execute(new PictureDisposeTask(pictureSourceResult));
}else{
} else {
Thread.sleep(5000);
}
}
}
};
Thread thread=new Thread(runnable);
Thread thread = new Thread(runnable);
thread.start();
return true;
}
/**
*
*
* @return
*/
public boolean startPictureImgToLocalPull(){
public boolean startPictureImgToLocalPull() {
Runnable runnable = new Runnable() {
@SneakyThrows
@Override
public void run() {
logger.debug("图片下载消费线程检测中...");
while (true){
while (true) {
try {
PictureImgToLocalEntity pictureImgToLocalEntity = TaskQueue.pictureImgToLocalPullData();
if(pictureImgToLocalEntity!=null){
if (pictureImgToLocalEntity != null) {
threadPool.execute(new PictureImgToLocalTask(pictureImgToLocalEntity));
}else{
} else {
Thread.sleep(5000);
}
} catch (Exception e) {
logger.error("图片下载消费线程报错{}", e.getMessage());
Thread.sleep(5000);
}
}
}
};
Thread thread=new Thread(runnable);
Thread thread = new Thread(runnable);
thread.start();
return true;
}

@ -1,5 +1,7 @@
package cn.jyjz.xiaoyao.ocr.thread.tasks;
import cn.hutool.core.util.ObjectUtil;
import cn.jyjz.xiaoyao.common.base.util.ObjectUtils;
import cn.jyjz.xiaoyao.common.base.util.SpringUtils;
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
@ -21,19 +23,28 @@ import java.util.Map;
* @version 1.0
* @date 2024/3/14 11:15
*/
public class PictureImgToLocalTask implements Runnable{
public class PictureImgToLocalTask implements Runnable {
protected Logger logger = LoggerFactory.getLogger(getClass());
private PictureImgToLocalEntity pictureImgToLocal;
public PictureImgToLocalTask(PictureImgToLocalEntity pictureImgToLocal){
public PictureImgToLocalTask(PictureImgToLocalEntity pictureImgToLocal) {
this.pictureImgToLocal = pictureImgToLocal;
}
@Override
public void run() {
OcrPictureService ocrPictureService = SpringUtils.getBean("ocrPictureService");
OcrPicture picture = ocrPictureService.getById(pictureImgToLocal.getPictureId());
//1.开始转储图片
DownloadImgUtil.downloadImage(pictureImgToLocal.getImgUrl(), pictureImgToLocal.getLocalPath());
Boolean result = DownloadImgUtil.downloadImage(pictureImgToLocal.getImgUrl(), pictureImgToLocal.getLocalPath());
if (Boolean.TRUE.equals(result)) {
if (ObjectUtil.isNotEmpty(picture)) {
picture.setLocalpictrueurl(pictureImgToLocal.getLocalPath());
picture.setIsdownload(1);
ocrPictureService.updateById(picture);
}
}
}

@ -19,10 +19,11 @@ public class DownloadImgUtil {
/**
*
*
* @param imageUrl
* @param destinationFile
*/
public static void downloadImage(String imageUrl, String destinationFile) {
public static Boolean downloadImage(String imageUrl, String destinationFile) {
try (InputStream in = new URL(imageUrl).openStream();
FileOutputStream out = new FileOutputStream(destinationFile)) {
@ -33,7 +34,9 @@ public class DownloadImgUtil {
}
} catch (Exception e) {
logger.error(e.getMessage());
return false;
}
return true;
}

@ -28,10 +28,10 @@ spring:
password: ysltest2024.
type: com.alibaba.druid.pool.DruidDataSource
slave:
url: jdbc:mysql://127.0.0.1:3306/ocr?useUnicode=true&nullCatalogMeansCurrent=true&characterEncoding=UTF-8&characterSetResults=utf8&serverTimezone=Asia/Shanghai&useSSL=false
url: jdbc:mysql://47.93.59.251:3306/ocrnew?useUnicode=true&nullCatalogMeansCurrent=true&characterEncoding=UTF-8&characterSetResults=utf8&serverTimezone=Asia/Shanghai&useSSL=false
driver-class-name: com.mysql.cj.jdbc.Driver
username: jyjz
password: jyjz
username: ysltest
password: ysltest2024.
type: com.alibaba.druid.pool.DruidDataSource
druid:
# 初始连接数
@ -190,15 +190,15 @@ mybatis-plus:
xiaoyao:
web:
#上传文件路径
uploadPath: D:/ideaWork/jeecg/ocrproject/htmlweb/upload
uploadPath: /Users/sunchenliang/IdeaProjects/ocr/htmlweb/upload
#页面根路径
frontPath: D:/ideaWork/jeecg/ocrproject/htmlweb
frontPath: /Users/sunchenliang/IdeaProjects/ocr/htmlweb
#js、css、图片存放路径
staticPath: D:/ideaWork/jeecg/ocrproject/htmlweb/static
staticPath: /Users/sunchenliang/IdeaProjects/ocr/htmlweb/static
#页面模版路径
webPath: D:/ideaWork/jeecg/ocrproject/htmlweb/web
webPath: /Users/sunchenliang/IdeaProjects/ocr/htmlweb/web
#Lucene索引路径
lucenePath: D:/ideaWork/jeecg/ocrproject/htmlweb/lucene/indexDir
lucenePath: /Users/sunchenliang/IdeaProjects/ocr/htmlweb/lucene/indexDir
#是否开启flowable
haveFlowable: true
webconfig:
@ -312,3 +312,4 @@ ocr:
accessCode: ED6F7B39768AF95E87AEA8ACCCC71A6F #秘钥编码
connectTimeout: 5000 #请求超时时间 毫秒
readTimeout: 60000 #接收超时时间 毫秒
localImagePath: /server/data/images #图片本地存储地址

@ -285,5 +285,5 @@ ocr:
accessCode: ED6F7B39768AF95E87AEA8ACCCC71A6F #秘钥编码
connectTimeout: 5000 #请求超时时间 毫秒
readTimeout: 60000 #接收超时时间 毫秒
localImagePath: /server/data/images #图片本地存储地址

Loading…
Cancel
Save