fix:十二分制-移动端接口;PC端接口补充
This commit is contained in:
@@ -28,7 +28,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class DictService {
|
||||
private final SysDictColumnDAO columnDAO;
|
||||
private final Map<Class<?>, List<Pair<Field, Field>>> dictFieldCache = new ConcurrentHashMap<>();
|
||||
private final Map<Class<?>, Field[]> fieldCache = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 填充字典字段
|
||||
*/
|
||||
public <T> void fillDictField(T obj) {
|
||||
fillDictField(Collections.singletonList(obj));
|
||||
}
|
||||
@@ -41,12 +45,20 @@ public class DictService {
|
||||
return;
|
||||
}
|
||||
Class<?> clazz = objs.get(0).getClass();
|
||||
fillDictField(objs, clazz, new HashSet<>());
|
||||
}
|
||||
|
||||
private <T> void fillDictField(List<T> objs, Class<?> clazz, Set<Object> processedObjects) {
|
||||
List<Pair<Field, Field>> dictFields = getDictField(clazz);
|
||||
if (CollectionUtils.isEmpty(dictFields)) {
|
||||
return;
|
||||
}
|
||||
Set<String> columnCodes = new HashSet<>();
|
||||
List<T> validObjs = new ArrayList<>();
|
||||
for (T obj : objs) {
|
||||
if (obj == null || processedObjects.contains(obj)) continue;
|
||||
processedObjects.add(obj);
|
||||
validObjs.add(obj);
|
||||
for (Pair<Field, Field> dictField : dictFields) {
|
||||
try {
|
||||
Object value = dictField.getValue().get(obj);
|
||||
@@ -58,19 +70,71 @@ public class DictService {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (columnCodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<String, String> nameMap = columnDAO.getNameMapByCodes(new ArrayList<>(columnCodes));
|
||||
for (T obj : objs) {
|
||||
for (Pair<Field, Field> dictField : dictFields) {
|
||||
try {
|
||||
dictField.getKey().set(obj, nameMap.get((String) dictField.getValue().get(obj)));
|
||||
} catch (IllegalAccessException e) {
|
||||
log.info("字典字段值填充失败", e);
|
||||
if (!columnCodes.isEmpty()) {
|
||||
Map<String, String> nameMap = columnDAO.getNameMapByCodes(new ArrayList<>(columnCodes));
|
||||
for (T obj : objs) {
|
||||
for (Pair<Field, Field> dictField : dictFields) {
|
||||
try {
|
||||
dictField.getKey().set(obj, nameMap.get((String) dictField.getValue().get(obj)));
|
||||
} catch (IllegalAccessException e) {
|
||||
log.info("字典字段值填充失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
processNestedObjects(validObjs, clazz, processedObjects);
|
||||
}
|
||||
|
||||
private <T> void processNestedObjects(List<T> objs, Class<?> clazz, Set<Object> processedObjects) {
|
||||
Field[] fields = getFieldCache(clazz);
|
||||
for (Field field : fields) {
|
||||
if (isComplexObjectField(field)) {
|
||||
field.setAccessible(true);
|
||||
|
||||
for (T obj : objs) {
|
||||
if (obj == null) continue;
|
||||
|
||||
try {
|
||||
Object fieldValue = field.get(obj);
|
||||
if (fieldValue != null) {
|
||||
if (fieldValue instanceof Collection) {
|
||||
// 处理集合类型字段
|
||||
Collection<?> collection = (Collection<?>) fieldValue;
|
||||
List<Object> nestedObjs = new ArrayList<>();
|
||||
for (Object item : collection) {
|
||||
if (item != null && isComplexObject(item.getClass())) {
|
||||
nestedObjs.add(item);
|
||||
}
|
||||
}
|
||||
if (!nestedObjs.isEmpty()) {
|
||||
fillDictField(nestedObjs, nestedObjs.get(0).getClass(), new HashSet<>(processedObjects));
|
||||
}
|
||||
} else if (isComplexObject(fieldValue.getClass())) {
|
||||
// 处理单一对象类型字段
|
||||
fillDictField(Collections.singletonList(fieldValue), fieldValue.getClass(), processedObjects);
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.info("嵌套对象字段获取失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isComplexObjectField(Field field) {
|
||||
Class<?> fieldType = field.getType();
|
||||
return isComplexObject(fieldType);
|
||||
}
|
||||
|
||||
private boolean isComplexObject(Class<?> clazz) {
|
||||
return !clazz.isPrimitive() &&
|
||||
!clazz.getName().startsWith("java") &&
|
||||
!clazz.equals(String.class);
|
||||
}
|
||||
|
||||
private Field[] getFieldCache(Class<?> clazz) {
|
||||
return fieldCache.computeIfAbsent(clazz, Class::getDeclaredFields);
|
||||
}
|
||||
|
||||
private <T> List<Pair<Field, Field>> getDictField(Class<T> clazz) {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.cool.store.service.tp;
|
||||
|
||||
import com.cool.store.request.tp.TpAppealApplyRequest;
|
||||
import com.cool.store.request.tp.TpApplyAuditRequest;
|
||||
import com.cool.store.request.tp.TpApplyQueryRequest;
|
||||
import com.cool.store.request.tp.TpApplyRequest;
|
||||
import com.cool.store.request.tp.*;
|
||||
import com.cool.store.response.AuditInfoResponse;
|
||||
import com.cool.store.vo.tp.*;
|
||||
import com.cool.store.vo.tp.mini.MiniTpApplyListVO;
|
||||
import com.cool.store.vo.tp.mini.MiniTpPenaltyApplyVO;
|
||||
import com.cool.store.vo.tp.mini.MiniTpRewardApplyVO;
|
||||
import com.cool.store.vo.tp.mini.MiniTpRuleListVO;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 十二分制-申请单 服务类
|
||||
@@ -100,4 +104,60 @@ public interface TpApplyService {
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean appealAudit(TpApplyAuditRequest request);
|
||||
|
||||
/**
|
||||
* 批量删除申请单
|
||||
* @param applyIds 申请单id列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean deleteBatch(List<Long> applyIds);
|
||||
|
||||
/**
|
||||
* 获取审批列表
|
||||
* @param applyId 申请单id
|
||||
* @return 审批记录列表
|
||||
*/
|
||||
List<AuditInfoResponse> getAuditRecordList(Long applyId);
|
||||
|
||||
/**
|
||||
* Mini获取申请单列表
|
||||
* @param request 申请单查询Request
|
||||
* @return Mini申请单列表VO列表
|
||||
*/
|
||||
PageInfo<MiniTpApplyListVO> getMiniApplyList(TpApplyQueryRequest request);
|
||||
|
||||
/**
|
||||
* Mini获取加分申请单详情
|
||||
* @param applyId 申请单id
|
||||
* @return Mini加分申请单详情VO
|
||||
*/
|
||||
MiniTpRewardApplyVO getMiniRewardApplyDetail(Long applyId);
|
||||
|
||||
/**
|
||||
* Mini获取惩处申请单详情
|
||||
* @param applyId 申请单id
|
||||
* @return Mini惩处申请单详情VO
|
||||
*/
|
||||
MiniTpPenaltyApplyVO getMiniPenaltyApplyDetail(Long applyId);
|
||||
|
||||
/**
|
||||
* Mini规则分页查询
|
||||
* @param request 规则查询Request
|
||||
* @return Mini奖惩规则列表VO列表
|
||||
*/
|
||||
PageInfo<MiniTpRuleListVO> getMiniRulePage(TpRuleQueryRequest request);
|
||||
|
||||
/**
|
||||
* 认罚缴款
|
||||
* @param applyId 惩处申请单id
|
||||
* @return java.lang.Boolean
|
||||
*/
|
||||
Boolean acceptPenalty(Long applyId);
|
||||
|
||||
/**
|
||||
* 完成缴费
|
||||
* @param applyId 惩处申请单id
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean completePayment(Long applyId);
|
||||
}
|
||||
|
||||
@@ -16,15 +16,14 @@ import com.cool.store.enums.tp.TpFormStatusEnum;
|
||||
import com.cool.store.enums.tp.TpFormTypeEnum;
|
||||
import com.cool.store.enums.tp.TpPayStatusEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.request.tp.TpAppealApplyRequest;
|
||||
import com.cool.store.request.tp.TpApplyAuditRequest;
|
||||
import com.cool.store.request.tp.TpApplyQueryRequest;
|
||||
import com.cool.store.request.tp.TpApplyRequest;
|
||||
import com.cool.store.request.tp.*;
|
||||
import com.cool.store.response.AuditInfoResponse;
|
||||
import com.cool.store.service.dict.impl.DictService;
|
||||
import com.cool.store.service.tp.TpApplyService;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.utils.TpHelper;
|
||||
import com.cool.store.vo.tp.*;
|
||||
import com.cool.store.vo.tp.mini.*;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -198,20 +197,31 @@ public class TpApplyServiceImpl implements TpApplyService {
|
||||
public Boolean appealApplySubmit(TpAppealApplyRequest request) {
|
||||
TpApplyFormDO formDO = BeanUtil.toBean(request, TpApplyFormDO.class);
|
||||
boolean isDraft = CommonConstants.INDEX_ONE.equals(request.getIsDraft());
|
||||
TpApplyFormDO punishFormDO = tpApplyFormDAO.getByPenaltyId(request.getPenaltyId());
|
||||
if (Objects.nonNull(punishFormDO) && !isDraft) {
|
||||
if (TpFormStatusEnum.PENDING.getStatus().equals(punishFormDO.getStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_EXISTS_PENDING_APPLY);
|
||||
TpApplyFormDO penaltyFormDO = tpApplyFormDAO.getEffectiveById(request.getPenaltyId());
|
||||
if (Objects.isNull(penaltyFormDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_NOT_EXIST_APPLY_FORM);
|
||||
}
|
||||
if (!isDraft) {
|
||||
TpApplyFormDO appealFormDO = tpApplyFormDAO.getAppealByPenaltyId(request.getPenaltyId());
|
||||
// 存在待审批或已审批的复议申请单
|
||||
if (Objects.nonNull(appealFormDO)) {
|
||||
if (TpFormStatusEnum.PENDING.getStatus().equals(appealFormDO.getStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_EXISTS_PENDING_APPLY);
|
||||
}
|
||||
if (TpFormStatusEnum.PASS.getStatus().equals(appealFormDO.getStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_PENALTY_APPLY_APPEAL_COMPLETED);
|
||||
}
|
||||
}
|
||||
if (TpFormStatusEnum.PASS.getStatus().equals(punishFormDO.getStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_PENALTY_APPLY_APPEAL_COMPLETED);
|
||||
// 已生效的无法复议
|
||||
if (TpFormStatusEnum.EFFECTIVE.getStatus().equals(penaltyFormDO.getStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_PENALTY_APPLY_EFFECTIVE);
|
||||
}
|
||||
}
|
||||
boolean isInsert = Objects.isNull(request.getId());
|
||||
formDO.setApplyNo(isInsert ? TpHelper.generateAppealNo() : null);
|
||||
formDO.setRuleId(punishFormDO.getRuleId());
|
||||
formDO.setRuleId(penaltyFormDO.getRuleId());
|
||||
formDO.setType(TpFormTypeEnum.APPEAL.getType());
|
||||
formDO.setStoreId(punishFormDO.getStoreId());
|
||||
formDO.setStoreId(penaltyFormDO.getStoreId());
|
||||
fillRuleFields(formDO);
|
||||
tpApplyFormDAO.insertOrUpdate(formDO);
|
||||
// 第一次提交后添加审批记录
|
||||
@@ -267,6 +277,95 @@ public class TpApplyServiceImpl implements TpApplyService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean deleteBatch(List<Long> applyIds) {
|
||||
tpApplyFormDAO.deleteByIds(applyIds);
|
||||
// 删除审批记录
|
||||
tpAuditRecordDAO.deleteByApplyIds(applyIds);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuditInfoResponse> getAuditRecordList(Long applyId) {
|
||||
return tpAuditRecordDAO.getAuditRecordList(applyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<MiniTpApplyListVO> getMiniApplyList(TpApplyQueryRequest request) {
|
||||
PageHelper.startPage(request.getPageNum(), request.getPageSize());
|
||||
List<TpApplyFormDO> list = tpApplyFormDAO.getEffectiveList(request);
|
||||
PageInfo<TpApplyFormDO> page = new PageInfo<>(list);
|
||||
PageInfo<MiniTpApplyListVO> newPage = BeanUtil.toPage(page, MiniTpApplyListVO.class);
|
||||
List<MiniTpApplyListVO> applyList = newPage.getList();
|
||||
if (Boolean.TRUE.equals(request.getIsPenalty()) && CollectionUtils.isNotEmpty(applyList)) {
|
||||
List<Long> applyIds = CollStreamUtil.toList(applyList, MiniTpApplyListVO::getId);
|
||||
Set<Long> existAppealSet = tpApplyFormDAO.filterExistAppeal(applyIds);
|
||||
applyList.forEach(v -> v.setIsAppeal(existAppealSet.contains(v.getId()) ? 1 : 0));
|
||||
}
|
||||
return newPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniTpRewardApplyVO getMiniRewardApplyDetail(Long applyId) {
|
||||
TpApplyFormDO formDO = tpApplyFormDAO.getEffectiveById(applyId);
|
||||
return BeanUtil.toBean(formDO, MiniTpRewardApplyVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MiniTpPenaltyApplyVO getMiniPenaltyApplyDetail(Long applyId) {
|
||||
TpApplyFormDO formDO = tpApplyFormDAO.getEffectiveById(applyId);
|
||||
if (Objects.nonNull(formDO)) {
|
||||
MiniTpPenaltyApplyVO vo = BeanUtil.toBean(formDO, MiniTpPenaltyApplyVO.class);
|
||||
TpApplyFormDO appealForm = tpApplyFormDAO.getAppealByPenaltyId(formDO.getPenaltyId());
|
||||
vo.setAppeal(BeanUtil.toBean(appealForm, MiniTpAppealVO.class));
|
||||
dictService.fillDictField(vo);
|
||||
return vo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<MiniTpRuleListVO> getMiniRulePage(TpRuleQueryRequest request) {
|
||||
PageHelper.startPage(request.getPageNum(), request.getPageSize());
|
||||
List<TpRuleDO> list = tpRuleDAO.getEffectiveList(request);
|
||||
PageInfo<TpRuleDO> page = new PageInfo<>(list);
|
||||
PageInfo<MiniTpRuleListVO> newPage = BeanUtil.toPage(page, MiniTpRuleListVO.class);
|
||||
dictService.fillDictField(newPage.getList());
|
||||
return newPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean acceptPenalty(Long applyId) {
|
||||
// 校验申请单状态是否为审批通过
|
||||
TpApplyFormDO formDO = tpApplyFormDAO.getEffectiveById(applyId);
|
||||
if (Objects.isNull(formDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_NOT_EXIST_APPLY_FORM);
|
||||
}
|
||||
if (!TpFormStatusEnum.PASS.getStatus().equals(formDO.getStatus())) {
|
||||
log.info("非审批通过状态无法认缴");
|
||||
throw new ServiceException(ErrorCodeEnum.TP_PENALTY_APPLY_UNABLE_ACCEPT);
|
||||
}
|
||||
tpApplyFormDAO.updateStatus(applyId, TpFormStatusEnum.EFFECTIVE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean completePayment(Long applyId) {
|
||||
TpApplyFormDO formDO = tpApplyFormDAO.getEffectiveById(applyId);
|
||||
if (Objects.isNull(formDO)) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_NOT_EXIST_APPLY_FORM);
|
||||
}
|
||||
if (!TpFormStatusEnum.EFFECTIVE.getStatus().equals(formDO.getStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_PENALTY_APPLY_INEFFECTIVE);
|
||||
}
|
||||
if (TpPayStatusEnum.NO_NEED_PAY.getStatus().equals(formDO.getPayStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.TP_PENALTY_APPLY_NO_NEED_PAY);
|
||||
}
|
||||
tpApplyFormDAO.updatePayStatus(applyId, TpPayStatusEnum.PAID);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批通用方法
|
||||
*/
|
||||
@@ -293,7 +392,7 @@ public class TpApplyServiceImpl implements TpApplyService {
|
||||
private void appealPassResolve(TpApplyFormDO formDO) {
|
||||
if (TpFormStatusEnum.PASS.getStatus().equals(formDO.getStatus())) {
|
||||
// 申诉通过后,处罚单失效
|
||||
tpApplyFormDAO.cancelApply(formDO.getPenaltyId());
|
||||
tpApplyFormDAO.updateStatus(formDO.getPenaltyId(), TpFormStatusEnum.CANCEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user