kongzy
2024-07-01 47a751cb301d05276ae5d75145d57b2d090fe4e1
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
package com.nanometer.smartlab.service;
 
import com.nanometer.smartlab.dao.OpeLaboratoryReserveDao;
import com.nanometer.smartlab.dao.SysLaboratoryDao;
import com.nanometer.smartlab.entity.*;
import com.nanometer.smartlab.entity.enumtype.ValidFlag;
import com.nanometer.smartlab.exception.AlarmCode;
import com.nanometer.smartlab.exception.AlarmException;
import com.nanometer.smartlab.exception.BusinessException;
import com.nanometer.smartlab.exception.ExceptionEnumCode;
import com.nanometer.smartlab.util.IDUtils;
import com.nanometer.smartlab.util.MessageUtil;
import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
/**
 * Created by johnny on 17/12/14.
 */
@Service("opeLaboratoryReserveService")
public class OpeLaboratoryReserveServiceImpl implements OpeLaboratoryReserveService {
 
    private static Logger logger = Logger.getLogger(OpeOrderService.class);
 
    @Resource
    OpeLaboratoryReserveDao opeLaboratoryReserveDao;
 
    @Transactional(propagation = Propagation.REQUIRED)
    public void insert(OpeLaboratoryReserve opeLaboratoryReserve) {
        try {
          //  opeLaboratoryReserve.setId(IDUtils.uuid());
            this.opeLaboratoryReserveDao.insertOpeLaboratoryReserve(opeLaboratoryReserve);
        } catch (DuplicateKeyException ex) {
            logger.warn(ex.getMessage(), ex);
            throw new AlarmException(AlarmCode.DATA_DUPLICATE, MessageUtil.getMessage(AlarmCode.DATA_DUPLICATE.getCode()));
        } catch (DataIntegrityViolationException ex) {
            logger.warn(ex.getMessage(), ex);
            throw new AlarmException(AlarmCode.DATA_CONFICT, MessageUtil.getMessage(AlarmCode.DATA_CONFICT.getCode()));
        } catch (DataAccessException ex) {
            logger.error(ex.getMessage(), ex);
            throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), ex);
        }
    }
 
    @Override
    public List<OpeLaboratoryReserve> selectByReId(Long id) {
        return this.opeLaboratoryReserveDao.selectByReId(id);
    }
 
    @Override
    public void updateByReId(Long newReId, Long oldReId) {
        Map<String, Object> params=new HashMap();
        params.put("newReId",newReId);
        params.put("oldReId",oldReId);
        this.opeLaboratoryReserveDao.updateByReId(params);
    }
 
    @Override
    public void updateByReagent(Long reagentId, Long houseId, Long containerId, Long userId) {
        Map<String, Object> params=new HashMap();
        params.put("reagentId",reagentId);
        params.put("houseId",houseId);
        params.put("containerId",containerId);
        params.put("userId",userId);
        this.opeLaboratoryReserveDao.updateByReagent(params);
    }
 
 
}