|
|
|
|
@ -1,13 +1,25 @@
|
|
|
|
|
package com.da.dangan.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.da.common.core.domain.entity.DaCatalog;
|
|
|
|
|
import com.da.common.utils.DateUtils;
|
|
|
|
|
import com.da.dangan.domain.DaPicturesRecard;
|
|
|
|
|
import com.da.dangan.domain.DaQuanwen;
|
|
|
|
|
import com.da.dangan.domain.DaTask;
|
|
|
|
|
import com.da.dangan.mapper.DaCatalogMapper;
|
|
|
|
|
import com.da.dangan.mapper.DaPicturesRecardMapper;
|
|
|
|
|
import com.da.dangan.mapper.DaQuanwenMapper;
|
|
|
|
|
import com.da.dangan.mapper.DaTaskMapper;
|
|
|
|
|
import com.da.dangan.service.IDaQuanwenService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 全文识别Service业务层处理
|
|
|
|
|
@ -20,7 +32,12 @@ public class DaQuanwenServiceImpl implements IDaQuanwenService
|
|
|
|
|
{
|
|
|
|
|
@Resource
|
|
|
|
|
private DaQuanwenMapper daQuanwenMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DaCatalogMapper daCatalogMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private DaPicturesRecardMapper daPicturesRecardMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private DaTaskMapper daTaskMapper;
|
|
|
|
|
/**
|
|
|
|
|
* 查询全文识别
|
|
|
|
|
*
|
|
|
|
|
@ -54,8 +71,55 @@ public class DaQuanwenServiceImpl implements IDaQuanwenService
|
|
|
|
|
@Override
|
|
|
|
|
public int insertDaQuanwen(DaQuanwen daQuanwen)
|
|
|
|
|
{
|
|
|
|
|
//识别图片状态改为已识别
|
|
|
|
|
List<Long> picIds = Stream.of(daQuanwen.getPicIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
|
if (picIds != null && picIds.size() > 0) {
|
|
|
|
|
for (Long picid : picIds) {
|
|
|
|
|
DaPicturesRecard picRecard = new DaPicturesRecard();
|
|
|
|
|
picRecard.setId(picid);
|
|
|
|
|
picRecard.setRecognize("1");
|
|
|
|
|
daPicturesRecardMapper.updateDaPicturesRecard(picRecard);
|
|
|
|
|
}
|
|
|
|
|
//手动识别且图片来自于任务,修改任务成功、失败图片
|
|
|
|
|
if (daQuanwen.getTaskId() != null&&daQuanwen.getErrorCorrect().equals("2")) {
|
|
|
|
|
DaTask daTask = daTaskMapper.selectDaTaskById(daQuanwen.getTaskId());
|
|
|
|
|
List<Long> failIds ;
|
|
|
|
|
List<Long> successIds = new ArrayList<>();
|
|
|
|
|
String failId = daTask.getFailIds();
|
|
|
|
|
String successId = daTask.getSuccessIds();
|
|
|
|
|
if(failId!=null&&!failId.trim().equals("")){
|
|
|
|
|
failIds = Stream.of(daTask.getFailIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
|
if(successId!=null&&!successId.trim().equals("")){
|
|
|
|
|
successIds = Stream.of(daTask.getSuccessIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//失败减少、成功增加
|
|
|
|
|
for(Long picId:picIds){
|
|
|
|
|
if (failIds.remove(picId) && successIds.add(picId)) {
|
|
|
|
|
daTask.setSuccessNum(daTask.getSuccessNum() + 1);
|
|
|
|
|
daTask.setFailNum(daTask.getFailNum() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
daTask.setFailIds(StringUtils.join(failIds, ","));
|
|
|
|
|
daTask.setSuccessIds(StringUtils.join(successIds, ","));
|
|
|
|
|
daTaskMapper.updateDaTask(daTask);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
daQuanwen.setCreateTime(DateUtils.getNowDate());
|
|
|
|
|
return daQuanwenMapper.insertDaQuanwen(daQuanwen);
|
|
|
|
|
int i = daQuanwenMapper.insertDaQuanwen(daQuanwen);
|
|
|
|
|
|
|
|
|
|
//1-根据muId 查询该muId的所有父级集合,当数据添加成功后-----修改该muId及父级catalog中的countNum值
|
|
|
|
|
DaCatalog catalog = daCatalogMapper.selectDaCatalogById(daQuanwen.getMuId());
|
|
|
|
|
List<Long> ancestors = Arrays.stream(
|
|
|
|
|
catalog.getAncestors().split(",")).map(s->Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
|
|
ancestors.add(daQuanwen.getMuId());
|
|
|
|
|
ancestors.remove(0L);
|
|
|
|
|
//1-修改该muId及父级catalog id中的countNum值
|
|
|
|
|
for(Long id :ancestors ){
|
|
|
|
|
daCatalogMapper.addDaCatalogCountNumById(id,1L);
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -67,6 +131,17 @@ public class DaQuanwenServiceImpl implements IDaQuanwenService
|
|
|
|
|
@Override
|
|
|
|
|
public int updateDaQuanwen(DaQuanwen daQuanwen)
|
|
|
|
|
{
|
|
|
|
|
if (daQuanwen.getErrorCorrect().equals("1")) {
|
|
|
|
|
String picIds = daQuanwen.getPicIds();
|
|
|
|
|
String[] split = picIds.split(",");
|
|
|
|
|
for (String picId : split) {
|
|
|
|
|
Long picid = Long.parseLong(picId);
|
|
|
|
|
DaPicturesRecard picturesRecard = new DaPicturesRecard();
|
|
|
|
|
picturesRecard.setId(picid);
|
|
|
|
|
picturesRecard.setErrorCorrect("1");
|
|
|
|
|
daPicturesRecardMapper.updateDaPicturesRecard(picturesRecard);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
daQuanwen.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
|
return daQuanwenMapper.updateDaQuanwen(daQuanwen);
|
|
|
|
|
}
|
|
|
|
|
@ -80,7 +155,36 @@ public class DaQuanwenServiceImpl implements IDaQuanwenService
|
|
|
|
|
@Override
|
|
|
|
|
public int deleteDaQuanwenByIds(Long[] ids)
|
|
|
|
|
{
|
|
|
|
|
return daQuanwenMapper.deleteDaQuanwenByIds(ids);
|
|
|
|
|
if(ids.length>0){
|
|
|
|
|
//1-根据muId 查询该muId的所有父级集合,当数据添加成功后-----修改该muId及父级catalog中的countNum值
|
|
|
|
|
DaQuanwen daQuanwen = daQuanwenMapper.selectDaQuanwenById(ids[0]);
|
|
|
|
|
DaCatalog catalog = daCatalogMapper.selectDaCatalogById(daQuanwen.getMuId());
|
|
|
|
|
List<Long> ancestors = Arrays.stream(
|
|
|
|
|
catalog.getAncestors().split(",")).map(s->Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
|
|
ancestors.add(daQuanwen.getMuId());
|
|
|
|
|
ancestors.remove(0L);
|
|
|
|
|
//1-修改该muId及父级catalog id中的countNum值
|
|
|
|
|
for(Long muId :ancestors ){
|
|
|
|
|
daCatalogMapper.minusDaCatalogCountNumById(muId,((Integer)ids.length).longValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改对应的图片为未识别 ----前端已设置只能单条删除
|
|
|
|
|
List<Long> picIds = Stream.of(daQuanwen.getPicIds().split(",")).map(Long::parseLong).collect(Collectors.toList());
|
|
|
|
|
DaQuanwen daQuanwen1= new DaQuanwen();
|
|
|
|
|
daQuanwen1.setPicIds(daQuanwen.getPicIds());
|
|
|
|
|
List<DaQuanwen> daQuanwens = daQuanwenMapper.selectDaQuanwenList(daQuanwen1);
|
|
|
|
|
if(daQuanwens.size()<=1){ //当前需删除图片id不止存在一条记录时 不修改图片识别状态
|
|
|
|
|
for(Long picId :picIds){
|
|
|
|
|
DaPicturesRecard pic = new DaPicturesRecard();
|
|
|
|
|
pic.setId(picId);
|
|
|
|
|
pic.setRecognize("0");//未识别
|
|
|
|
|
pic.setErrorCorrect("0");
|
|
|
|
|
daPicturesRecardMapper.updateDaPicturesRecard(pic);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int i = daQuanwenMapper.deleteDaQuanwenByIds(ids);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -94,4 +198,33 @@ public class DaQuanwenServiceImpl implements IDaQuanwenService
|
|
|
|
|
{
|
|
|
|
|
return daQuanwenMapper.deleteDaQuanwenById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 从任务删除的时候 使用这个方法
|
|
|
|
|
* @param ids
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Transactional
|
|
|
|
|
public int deleteDaQuanwenByIds1(Long[] ids) {
|
|
|
|
|
if(ids.length>0){
|
|
|
|
|
//1-根据muId 查询该muId的所有父级集合,当数据删除成功后-----修改该muId及父级catalog中的countNum值
|
|
|
|
|
DaQuanwen daqw = daQuanwenMapper.selectDaQuanwenById(ids[0]);
|
|
|
|
|
DaCatalog catalog = daCatalogMapper.selectDaCatalogById(daqw.getMuId());
|
|
|
|
|
List<Long> ancestors = Arrays.stream(
|
|
|
|
|
catalog.getAncestors().split(",")).map(s->Long.parseLong(s.trim())).collect(Collectors.toList());
|
|
|
|
|
ancestors.add(daqw.getMuId());
|
|
|
|
|
ancestors.remove(0L);
|
|
|
|
|
//1-修改该muId及父级catalog id中的countNum值
|
|
|
|
|
for(Long muId :ancestors ){
|
|
|
|
|
daCatalogMapper.minusDaCatalogCountNumById(muId,((Integer)ids.length).longValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int i = daQuanwenMapper.deleteDaQuanwenByIds(ids);
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<DaQuanwen> searchDaQuanwenList1(DaQuanwen daqw) {
|
|
|
|
|
return daQuanwenMapper.searchDaQuanwenList1(daqw);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|