xieb
2024-03-11 3be630d678dd60603e557514a203a1f544034a4d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package cn.gistack.sm.sjztmd.service.impl;
 
import cn.gistack.sm.sjztmd.entity.TbResGeneralInvestigation;
import cn.gistack.sm.sjztmd.entity.TbResGeneralInvestigationState;
import cn.gistack.sm.sjztmd.mapper.TbResGeneralInvestigationMapper;
import cn.gistack.sm.sjztmd.service.ITbResGeneralInvestigationService;
import cn.gistack.sm.sjztmd.service.ITbResGeneralInvestigationStateService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
/**
 * @PROJECT_NAME: skjcmanager
 * @DESCRIPTION:
 * @USER: aix
 * @DATE: 2024/1/3 14:36
 */
@Service
@DS("zt")
@Transactional(rollbackFor = Exception.class)
public class TbResGeneralInvestigationServiceImpl extends ServiceImpl<TbResGeneralInvestigationMapper, TbResGeneralInvestigation> implements ITbResGeneralInvestigationService {
 
    @Autowired
    private ITbResGeneralInvestigationStateService tbResGeneralInvestigationStateService;
 
    @Override
    @Transactional
    public R saveOrUpdateBy(TbResGeneralInvestigation entity) {
 
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("\"res_guid\"",entity.getResGuid());
        queryWrapper.eq("\"tb_year\"",entity.getTbYear());
        queryWrapper.eq("\"tb_quarter\"",entity.getTbQuarter());
        TbResGeneralInvestigationState state = tbResGeneralInvestigationStateService.getOne(queryWrapper);
        if (null == state) {
            state = new TbResGeneralInvestigationState();
            state.setResGuid(entity.getResGuid());
            state.setTbQuarter(entity.getTbQuarter());
            state.setTbYear(entity.getTbYear());
            state.setCreateTime(entity.getCreateTime());
            state.setCreateUser(entity.getCreateUser());
        } else {
            if (state.getCheckState() == 1 || state.getCheckState() == 2) {
                return R.fail(entity.getResName() + "本年度已经普查完成,不能在提交了。");
            }
        }
 
        // 是否普查完成 1是 0否
        if (entity.getCheckState() != 0) {
            state.setCheckState(entity.getIsInvCom());
        }
 
        tbResGeneralInvestigationStateService.saveOrUpdate(state);
 
        entity.setTbStateId(state.getGuid());
        return R.status(this.saveOrUpdate(entity));
    }
}