|
|
@ -27,9 +27,15 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.UserResiInfoResultDTO; |
|
|
@ -68,6 +74,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
@ -127,6 +134,15 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
@Autowired |
|
|
|
private GroupEditSubmitRecordDao groupEditSubmitRecordDao; |
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
private String scanApiUrl; |
|
|
|
|
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
private String textSyncScanMethod; |
|
|
|
|
|
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiGroupDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ResiGroupEntity> page = baseDao.selectPage( |
|
|
@ -980,7 +996,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
public GroupDetailResultDTO getGroupDetail(String groupId) { |
|
|
|
GroupDetailResultDTO groupDetail = new GroupDetailResultDTO(); |
|
|
|
|
|
|
|
// 组基本信息
|
|
|
|
// 1.拼装组基本信息
|
|
|
|
GroupEditSubmitRecordEntity ler = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId); |
|
|
|
|
|
|
|
if (ler != null) { |
|
|
@ -988,7 +1004,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
groupDetail.setRemark(ler.getRemark()); |
|
|
|
} |
|
|
|
|
|
|
|
if (GroupAuditStatusConstant.UNDER_AUDITING.equals(ler.getAuditStatus())) { |
|
|
|
if (ler != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(ler.getAuditStatus())) { |
|
|
|
// 审核中,显示待审核内容
|
|
|
|
groupDetail.setGroupHeadPhoto(ler.getGroupHeadPhoto()); |
|
|
|
groupDetail.setGroupName(ler.getGroupName()); |
|
|
@ -1005,7 +1021,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
groupDetail.setGroupIntroduction(resiGroupEntity.getGroupIntroduction()); |
|
|
|
} |
|
|
|
|
|
|
|
// 编辑次数及其限制
|
|
|
|
// 2.编辑次数及其限制
|
|
|
|
groupDetail.setEditNumLimit(GroupLimitConstant.EDIT_NUM_LIMIT_MONTH); |
|
|
|
Date now = new Date(); |
|
|
|
int usedEditNum = groupEditSubmitRecordDao.countEditNum(groupId, DateUtils.getMonthStart(now), DateUtils.getMonthEnd(now)); |
|
|
@ -1026,7 +1042,79 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
} |
|
|
|
|
|
|
|
groupDetail.setEditable(editable); |
|
|
|
|
|
|
|
return groupDetail; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void submitGroupEdit(String groupId, String groupName, String groupHeadPhoto, String groupIntroduction) { |
|
|
|
// 1.判断小组是否存在,判断是否已经在"待审核"状态
|
|
|
|
ResiGroupEntity group = resiGroupDao.selectById(groupId); |
|
|
|
if (group == null) { |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "组信息不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
GroupEditSubmitRecordEntity lre = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId); |
|
|
|
if (lre != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(lre.getAuditStatus())) { |
|
|
|
// 在待审核状态,不允许再次提交编辑
|
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "该组已提交编辑待审核,完成审核前不可再次提交"); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.内容检查
|
|
|
|
//scanGroupEditContent(groupName, groupIntroduction, groupHeadPhoto);
|
|
|
|
|
|
|
|
// 3.创建编辑提交记录
|
|
|
|
GroupEditSubmitRecordEntity editRecord = new GroupEditSubmitRecordEntity(); |
|
|
|
editRecord.setAuditStatus(GroupAuditStatusConstant.UNDER_AUDITING); |
|
|
|
editRecord.setCustomerId(group.getCustomerId()); |
|
|
|
editRecord.setGridId(group.getGridId()); |
|
|
|
editRecord.setGroupHeadPhoto(groupHeadPhoto); |
|
|
|
editRecord.setGroupIntroduction(groupIntroduction); |
|
|
|
editRecord.setGroupId(groupId); |
|
|
|
editRecord.setGroupName(groupName); |
|
|
|
|
|
|
|
if (groupEditSubmitRecordDao.insert(editRecord) == 0) { |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), EpmetErrorCode.GROUP_EDIT_ERROR.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 内容检查 |
|
|
|
* @param groupName |
|
|
|
* @param groupIntroduction |
|
|
|
* @param groupHeadPhoto |
|
|
|
*/ |
|
|
|
private void scanGroupEditContent(String groupName, String groupIntroduction, String groupHeadPhoto) { |
|
|
|
|
|
|
|
// 文本内容审核
|
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
String content = groupName.concat("-").concat(groupIntroduction); |
|
|
|
taskDTO.setContent(content); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
logger.error("调用内容审核服务审核文本发生错误:{}", textSyncScanResult.getInternalMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 图片内容审核
|
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
task.setUrl(groupHeadPhoto); |
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
|
|
|
|
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
if (!imgScanResult.success()){ |
|
|
|
logger.error("调用内容审核服务审核图片发生错误:{}", textSyncScanResult.getInternalMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode(), EpmetErrorCode.IMG_SCAN_FAILED.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|