101captain
2022-05-07 6e9db07a768f2f5d64ea85c537d50111cf0a4f3f
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActAcidRecordServiceImpl.java
@@ -5,18 +5,23 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.dtos.community.acid.ComActAcidRecordDTO;
import com.panzhihua.common.model.dtos.property.CommonPage;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.acid.*;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.DateUtils;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.dao.ComActAcidDangerMemberDao;
import com.panzhihua.service_community.dao.ComActDAO;
import com.panzhihua.service_community.entity.ComActAcidDangerMember;
import com.panzhihua.service_community.entity.ComActAcidRecord;
import com.panzhihua.service_community.dao.ComActAcidRecordDao;
import com.panzhihua.service_community.model.dos.ComActDO;
import com.panzhihua.service_community.service.ComActAcidRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
@@ -48,6 +53,10 @@
    private RabbitTemplate rabbitTemplate;
    @Resource
    private ComActAcidDangerMemberDao comActAcidDangerMemberDao;
    @Resource
    private UserService userService;
    @Resource
    private ComActDAO comActDAO;
    @Override
    public R pageList(ComActAcidRecordDTO comActAcidRecordDTO) {
@@ -56,7 +65,7 @@
    @Override
    public R export(ComActAcidRecordDTO comActAcidRecordDTO) {
        List<ComActAcidRecordExcelVO> comActAcidRecordExcelVOS=this.baseMapper.export(comActAcidRecordDTO);
        List<ComActAcidRecordExcelReturn> comActAcidRecordExcelVOS=this.baseMapper.export(comActAcidRecordDTO);
        comActAcidRecordExcelVOS.forEach(comActAcidRecordExcelVO -> {
            if(StringUtils.isNotEmpty(comActAcidRecordExcelVO.getTouristCity())&&comActAcidRecordExcelVO.getTouristCity().contains("[")){
                JSONArray jsonArray = JSON.parseArray(comActAcidRecordExcelVO.getTouristCity());
@@ -88,9 +97,12 @@
        }
        if(StringUtils.isEmpty(comActAcidRecordVO.getLocalCity())){
            rabbitTemplate.convertAndSend("huacheng.acid.exchange", "huacheng.acid.key", comActAcidRecordVO, message -> {
                message.getMessageProperties().setHeader("x-delay", 24*60*60*1000);
                message.getMessageProperties().setHeader("x-delay", 2*60*60*1000);
                return message;
            });
        }
        else {
            rabbitTemplate.convertAndSend("huacheng.acid.direct.exchange", "huacheng.acid.direct.key", comActAcidRecordVO);
        }
        ComActAcidRecord comActAcidRecord=new ComActAcidRecord();
        BeanUtils.copyProperties(comActAcidRecordVO,comActAcidRecord);
@@ -204,10 +216,16 @@
        BeanUtils.copyProperties(comActAcidRecordVO,comActAcidRecord);
        if(StringUtils.isNotEmpty(comActAcidRecord.getLocalCity())){
            ComActAcidDangerMember comActAcidDangerMember= comActAcidDangerMemberDao.selectOne(new QueryWrapper<ComActAcidDangerMember>().lambda().eq(ComActAcidDangerMember::getRecordId,comActAcidRecordVO.getId()));
            comActAcidDangerMember.setRelationName(comActAcidRecord.getLocalCity());
            this.comActAcidDangerMemberDao.updateById(comActAcidDangerMember);
            this.baseMapper.updateById(comActAcidRecord);
            if(comActAcidDangerMember!=null){
                if(comActAcidDangerMember.getType()==2){
                    this.comActAcidDangerMemberDao.deleteById(comActAcidDangerMember.getId());
                }
                else {
                    comActAcidDangerMember.setRelationName(comActAcidRecord.getLocalCity());
                    this.comActAcidDangerMemberDao.updateById(comActAcidDangerMember);
                }
            }
        }
        return R.ok();
        return R.ok(this.baseMapper.updateById(comActAcidRecord));
    }
}