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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.repairsorder.service.impl;
 
import org.springblade.common.constant.NoConstant;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.eventgm.entity.EventgmRecordEntity;
import org.springblade.modules.eventgm.service.IEventgmRecordService;
import org.springblade.modules.repairsorder.entity.RepairsorderEntity;
import org.springblade.modules.repairsorder.entity.RepairsorderRecordEntity;
import org.springblade.modules.repairsorder.service.IRepairsorderRecordService;
import org.springblade.modules.repairsorder.vo.RepairsorderVO;
import org.springblade.modules.repairsorder.mapper.RepairsorderMapper;
import org.springblade.modules.repairsorder.service.IRepairsorderService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.utils.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
 
/**
 * 维修工单 服务实现类
 *
 * @author aix
 * @since 2022-09-14
 */
@Service
@Transactional
public class RepairsorderServiceImpl extends BaseServiceImpl<RepairsorderMapper, RepairsorderEntity> implements IRepairsorderService {
 
    @Autowired
    private IRepairsorderRecordService repairsorderRecordService;
 
    @Override
    public IPage<RepairsorderVO> selectRepairsorderPage(IPage<RepairsorderVO> page, RepairsorderVO repairsorder) {
        return page.setRecords(baseMapper.selectRepairsorderPage(page, repairsorder));
    }
 
    @Override
    public boolean save(RepairsorderEntity entity) {
        RepairsorderVO vo = this.getRepairsorderMaxNo();
        String str = "";
        if (vo != null) {
            str = vo.getNo();
        }
        entity.setNo(NumberUtils.autoCreateNumber(NoConstant.WXGL_PREFIX_NO,str));
        RepairsorderRecordEntity rrentity = new RepairsorderRecordEntity();
        rrentity.setState("0");
        rrentity.setRemark("工单提交");
        BladeUser user = AuthUtil.getUser();
        rrentity.setRepairPerson(user.getNickName());
        rrentity.setNo(entity.getNo());
        repairsorderRecordService.save(rrentity);
        return super.save(entity);
    }
 
    @Override
    public boolean saveOrUpdate(RepairsorderEntity entity) {
        return entity.getId() == null ? this.save(entity) : this.updateById(entity);
    }
 
    @Override
    public RepairsorderVO getRepairsorderMaxNo() {
        return baseMapper.getRepairsorderMaxNo();
    }
 
    @Override
    public Boolean updateState(RepairsorderEntity repairsorder) {
        //更新维修表状态
        boolean updateRepairsorder = this.updateById(repairsorder);
        //维修记录表数据插入
        RepairsorderRecordEntity repairsorderRecord = new RepairsorderRecordEntity();
        repairsorderRecord.setNo(repairsorder.getNo());
        BladeUser user = AuthUtil.getUser();
        repairsorderRecord.setRepairPerson(user.getNickName());
        if (repairsorder.getState().equals("2")){
            repairsorderRecord.setRemark("工单处理中");
            repairsorderRecord.setState("2");
        }else if (repairsorder.getState().equals("3")){
            repairsorderRecord.setRemark("工单已完成");
            repairsorderRecord.setState("3");
        }
        boolean saveRecord = repairsorderRecordService.save(repairsorderRecord);
        return updateRepairsorder&&saveRecord;
    }
 
 
}