优化更新权限判断
This commit is contained in:
parent
54c4c54cc7
commit
5b3e09803e
@ -79,6 +79,8 @@ declare namespace Api {
|
||||
delFlag: string;
|
||||
/** 创建时间 */
|
||||
entryDate: string;
|
||||
/** 更新状态 */
|
||||
updateFlag: string;
|
||||
}>;
|
||||
|
||||
/** market search params */
|
||||
|
||||
@ -391,8 +391,8 @@ const {
|
||||
if (!hasAuth('mps:market:edit')) {
|
||||
return null;
|
||||
}
|
||||
// 只有当checkType为'9'时才显示编辑按钮
|
||||
if (row.checkFlag !== '9') {
|
||||
// 只有当updateFlag为'1'时才显示编辑按钮
|
||||
if (row.updateFlag !== '1') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ async function search() {
|
||||
<!-- <NInput v-model:value="model.heatingNo" placeholder="请输入取暖费户号" />-->
|
||||
<!-- </NFormItemGi>-->
|
||||
<NFormItemGi span="24 s:12 m:6" label="核对标志" path="checkFlag" class="pr-24px">
|
||||
<NSelect v-model:value="model.checkFlag" :options="mpsCheckStatusOptions" placeholder="请选择核对状态" />
|
||||
<NSelect v-model:value="model.checkFlag" :options="mpsCheckStatusOptions" clearable placeholder="请选择核对状态" />
|
||||
</NFormItemGi>
|
||||
<!-- <NFormItemGi span="24 s:12 m:6" label="核对时间" path="checkTime" class="pr-24px">-->
|
||||
<!-- <NDatePicker-->
|
||||
|
||||
@ -144,7 +144,7 @@ public class MpsMarketController extends BaseController {
|
||||
if(!"9".equals(bo.getCheckFlag())){//9-校验失败
|
||||
return R.fail("校验状态异常,不允许修改!");
|
||||
}
|
||||
bo.setCheckFlag("2");//2-修改完成
|
||||
// bo.setCheckFlag("2");//2-修改完成
|
||||
return toAjax(mpsMarketService.updateByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
@ -231,5 +231,7 @@ public class MpsMarketVo implements Serializable {
|
||||
@ExcelProperty(value = "创建时间")
|
||||
private String entryDate;
|
||||
|
||||
private String updateFlag;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,10 +2,10 @@ package org.dromara.mps.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.idev.excel.util.DateUtils;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
@ -16,13 +16,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.mps.domain.MpsBatch;
|
||||
import org.dromara.mps.domain.MpsMagneticcard;
|
||||
import org.dromara.mps.domain.MpsTraffic;
|
||||
import org.dromara.mps.domain.vo.MpsMagneticcardVo;
|
||||
import org.dromara.mps.domain.vo.MpsTrafficVo;
|
||||
import org.dromara.mps.mapper.MpsBatchMapper;
|
||||
import org.dromara.mps.mapper.MpsMagneticcardMapper;
|
||||
import org.dromara.mps.mapper.MpsTrafficMapper;
|
||||
import org.dromara.system.domain.SysDeptTransfer;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.mps.domain.bo.MpsMarketBo;
|
||||
import org.dromara.mps.domain.vo.MpsMarketVo;
|
||||
@ -33,7 +34,6 @@ import org.dromara.mps.service.IMpsMarketService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 营销数据管理Service业务层处理
|
||||
@ -50,6 +50,7 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
private final IdentifierGenerator identifierGenerator;
|
||||
private final MpsMagneticcardMapper magneticcardMapper;
|
||||
private final MpsTrafficMapper TrafficMapper;
|
||||
private final MpsBatchMapper batchMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@ -119,7 +120,17 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
));
|
||||
}
|
||||
});
|
||||
// result.getRecords().forEach(r -> r.setTrafficList(TrafficMapper.selectVoList(new LambdaQueryWrapper<MpsTraffic>().eq(MpsTraffic::getTrafficId, r.getTrafficId()))));
|
||||
//当MpsBatch表里有满足batch_code='formal' and batch_month=上月 and pre_batch_status=1 and check_status=0
|
||||
// 条件的记录时,将result中上个月的check_flg不为1的数据updateFlag设为1,表示该数据需要更新
|
||||
String lastMonth = DateUtil.format(DateUtil.lastMonth(), DatePattern.NORM_MONTH_PATTERN);
|
||||
if (isUpdateSupport()) {
|
||||
result.getRecords().forEach(r -> {
|
||||
//当在修改周期内时,对上月的失败记录更新状态设置为1
|
||||
if (lastMonth.equals(r.getEntryDate().substring( 0, 7)) && !"1".equals(r.getCheckFlag())) {
|
||||
r.setUpdateFlag("1");
|
||||
}
|
||||
});
|
||||
}
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@ -179,7 +190,7 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
@Override
|
||||
public Boolean insertByBo(MpsMarketBo bo) {
|
||||
MpsMarket add = MapstructUtils.convert(bo, MpsMarket.class);
|
||||
add.setEntryDate(DateUtils.format(new Date(), "yyyy-MM-dd"));
|
||||
add.setEntryDate(DateUtil.format(new Date(), "yyyy-MM-dd"));
|
||||
validEntityBefore(add);
|
||||
System.out.println("add:--->"+add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
@ -191,6 +202,25 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
private boolean isUpdateSupport() {
|
||||
// 获取上月日期
|
||||
String lastMonth = DateUtil.format(DateUtil.lastMonth(), "yyyy-MM");
|
||||
LambdaQueryWrapper<MpsBatch> batchQueryWrapper = Wrappers.lambdaQuery();
|
||||
batchQueryWrapper.eq(MpsBatch::getBatchCode, "formal")
|
||||
.eq(MpsBatch::getBatchMonth, lastMonth)
|
||||
.eq(MpsBatch::getAfterBatchStatus, 1)
|
||||
.eq(MpsBatch::getCheckStatus, 0);
|
||||
|
||||
// 这里需要注入MpsBatchMapper来查询MpsBatch表
|
||||
List<MpsBatch> batchList = batchMapper.selectList(batchQueryWrapper);
|
||||
if (CollUtil.isNotEmpty(batchList)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改营销数据管理
|
||||
*
|
||||
@ -199,6 +229,9 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(MpsMarketBo bo) {
|
||||
if (!isUpdateSupport() || "1".equals(bo.getCheckFlag())) {
|
||||
throw new ServiceException("当前数据已锁定,请勿修改");
|
||||
}
|
||||
MpsMarket update = MapstructUtils.convert(bo, MpsMarket.class);
|
||||
validEntityBefore(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
@ -478,107 +511,6 @@ public class MpsMarketServiceImpl implements IMpsMarketService {
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 新增前的数据校验
|
||||
*/
|
||||
// private void validEntityBeforeUpdate(MpsMarket entity){
|
||||
// //TODO 做一些数据校验,如唯一约束,非空校验
|
||||
// switch (entity.getSubcategoryName()) {
|
||||
// case "公积金缴纳账户":
|
||||
// if (StringUtils.isEmpty(entity.getSurplusAccountName())) {
|
||||
// throw new ServiceException("请填写公积金账户名称");
|
||||
// }
|
||||
// break;
|
||||
// case "磁条卡更换金融IC卡":
|
||||
// if (CollectionUtil.isEmpty(entity.getMagneticCardList())) {
|
||||
// throw new ServiceException("请填写磁条卡更换金融IC卡记录");
|
||||
// }
|
||||
// checkMagneticCardList(entity.getMagneticCardList());
|
||||
//
|
||||
// //id
|
||||
// Long magneticCardId = entity.getMagneticCardId();
|
||||
// if (magneticCardId == null) {
|
||||
// magneticCardId = identifierGenerator.nextId(entity).longValue();
|
||||
// entity.setMagneticCardId(magneticCardId);
|
||||
// }
|
||||
// //删除原记录
|
||||
// MpsMagneticcard bo = new MpsMagneticcard();
|
||||
// bo.setMagneticCardId(magneticCardId);
|
||||
// magneticcardMapper.delete( new LambdaQueryWrapper<>(bo));
|
||||
// //插入数据库
|
||||
// for (MpsMagneticcard mpsMagneticCard : entity.getMagneticCardList()) {
|
||||
// mpsMagneticCard.setMagneticCardId(magneticCardId);
|
||||
// }
|
||||
// magneticcardMapper.insertBatch(entity.getMagneticCardList());
|
||||
// break;
|
||||
// case "代收交警罚没款":
|
||||
// if (CollectionUtil.isEmpty(entity.getTrafficList())) {
|
||||
// throw new ServiceException("请填写磁条卡更换金融IC卡记录");
|
||||
// }
|
||||
// for (MpsTraffic mpsTraffic : entity.getTrafficList()) {
|
||||
//
|
||||
// if ( StringUtils.isEmpty(mpsTraffic.getTrafficNo())) {
|
||||
// throw new ServiceException("请填写代缴交警罚没款编号");
|
||||
// }
|
||||
// if (mpsTraffic.getTrafficAmt() == null) {
|
||||
// throw new ServiceException("请填写代缴交警罚没款金额");
|
||||
// }
|
||||
// //判重
|
||||
// MpsTraffic traffic = new MpsTraffic();
|
||||
// traffic.setTrafficNo(mpsTraffic.getTrafficNo());
|
||||
// LambdaQueryWrapper<MpsTraffic> lqw1 = new LambdaQueryWrapper<>(traffic);
|
||||
// lqw1.ne( ObjectUtil.isNotNull(mpsTraffic.getTrafficId()), MpsTraffic::getTrafficId, mpsTraffic.getTrafficId());
|
||||
// List<MpsTrafficVo> result1 = TrafficMapper.selectVoList(lqw1);
|
||||
// if (!result1.isEmpty()) {
|
||||
// throw new ServiceException("该代缴交警罚没款已存在,编号:"+mpsTraffic.getTrafficNo());
|
||||
// }
|
||||
// }
|
||||
// //id
|
||||
// Long TrafficId = entity.getTrafficId();
|
||||
// if (TrafficId == null) {
|
||||
// TrafficId = identifierGenerator.nextId(entity).longValue();
|
||||
// entity.setTrafficId(TrafficId);
|
||||
// }
|
||||
// //删除原记录
|
||||
// MpsTraffic trafficbo = new MpsTraffic();
|
||||
// trafficbo.setTrafficId(TrafficId);
|
||||
// TrafficMapper.delete( new LambdaQueryWrapper<>(trafficbo));
|
||||
// //插入数据库
|
||||
// List<MpsTraffic> trafficList = entity.getTrafficList();
|
||||
// for (MpsTraffic mpsTraffic : trafficList) {
|
||||
// mpsTraffic.setTrafficId(TrafficId);
|
||||
// }
|
||||
// TrafficMapper.insertBatch(entity.getTrafficList());
|
||||
// break;
|
||||
// case "新增综合收单商户(首月)":
|
||||
// if (entity.getAcquiringId() == null) {
|
||||
// throw new ServiceException("请填写收单机构ID");
|
||||
// }
|
||||
// if (entity.getAcquiringName() == null) {
|
||||
// throw new ServiceException("请填写收单机构名称");
|
||||
// }
|
||||
// break;
|
||||
// case "网上支付客户":
|
||||
// if (entity.getInternetChannel() == null) {
|
||||
// throw new ServiceException("请填写网上支付渠道");
|
||||
// }
|
||||
// break;
|
||||
// case "营销职工社保卡":
|
||||
// if (entity.getWorkplace() == null) {
|
||||
// throw new ServiceException("请填写营销职工社保卡工作单位");
|
||||
// }
|
||||
// break;
|
||||
// case "取暖费":
|
||||
// if (entity.getHeatingNo() == null) {
|
||||
// throw new ServiceException("请填写取暖费编号");
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
private void checkMagneticCardList(List<MpsMagneticcard> mpsMagneticCardList) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user