package com.nanometer.smartlab.service;
|
|
import com.nanometer.smartlab.dao.OpeApplyDao;
|
import com.nanometer.smartlab.entity.OpeApply;
|
import com.nanometer.smartlab.entity.OpeApplyReserve;
|
import com.nanometer.smartlab.entity.SysUser;
|
import com.nanometer.smartlab.entity.enumtype.ApplyStatus;
|
import com.nanometer.smartlab.entity.enumtype.SeeFlag;
|
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.commons.lang.StringUtils;
|
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 org.springframework.util.CollectionUtils;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.sql.Timestamp;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* Created by johnny on 17/12/12.
|
*/
|
@Service("opeApplyService")
|
public class OpeApplyServiceImpl implements OpeApplyService {
|
|
private static Logger logger = Logger.getLogger(OpeApplyService.class);
|
|
@Resource(name = "opeApplyDao")
|
OpeApplyDao opeApplyDao;
|
|
@Resource
|
private SysUserService sysUserService;
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public List<OpeApply> getOpeApplyList(String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status,
|
String applyUserId, String approveUserId, String queryCas,
|
Integer first, Integer pageSize,String applyCode,String applyUserName) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
if (StringUtils.isNotBlank(reagentName)) {
|
params.put("reagentName", "%" + reagentName + "%");
|
}
|
params.put("startDeadline", startDeadline);
|
params.put("endDeadline", endDeadline);
|
params.put("status", status);
|
|
if (StringUtils.isNotBlank(applyUserId)) {
|
SysUser sysUser = sysUserService.getSysUser(applyUserId);
|
// 不是管理员时,加入applyUserId
|
if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) {
|
params.put("applyUserId", applyUserId);
|
}
|
|
if("连悦".equals(sysUser.getName())){
|
params.remove("applyUserId");
|
}
|
}
|
|
params.put("approveUserId", approveUserId);
|
if (StringUtils.isNotBlank(queryCas)) {
|
params.put("cas", "%" + queryCas + "%");
|
}
|
params.put("first", first);
|
params.put("pageSize", pageSize);
|
params.put("applyCode", applyCode);
|
params.put("applyUserName", applyUserName);
|
return this.opeApplyDao.getOpeApplyList(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public List<OpeApply> getOpeApplyListForApproval(String applyUserName,String approvaUserName,String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status,
|
String applyUserId, String approveUserId, String queryCas,
|
Integer first, Integer pageSize,String applyCode,String searchApproval) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
if (StringUtils.isNotBlank(reagentName)) {
|
params.put("reagentName", "%" + reagentName + "%");
|
}
|
params.put("startDeadline", startDeadline);
|
params.put("endDeadline", endDeadline);
|
params.put("status", status);
|
params.put("searchApproval",searchApproval);
|
|
if (StringUtils.isNotBlank(approveUserId)) {
|
SysUser sysUser = sysUserService.getSysUser(approveUserId);
|
// 不是管理员时,加入applyUserId
|
if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) {
|
params.put("approveUserId", approveUserId);
|
}
|
}
|
|
params.put("applyUserId", applyUserId);
|
if (StringUtils.isNotBlank(queryCas)) {
|
params.put("cas", "%" + queryCas + "%");
|
}
|
if (StringUtils.isNotBlank(approvaUserName)) {
|
params.put("approvaUserName", "%" + approvaUserName + "%");
|
}
|
if (StringUtils.isNotBlank(applyUserName)) {
|
params.put("applyUserName", "%" + applyUserName + "%");
|
}
|
params.put("first", first);
|
params.put("pageSize", pageSize);
|
params.put("applyCode", applyCode);
|
return this.opeApplyDao.getOpeApplyList(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
@Transactional(propagation = Propagation.REQUIRED)
|
public int getOpeApplyTotalCountForApproval(String applyUserName,String approvaUserName,String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status,
|
String applyUserId, String approveUserId, String queryCas,String applyCode,String searchApproval) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
if (StringUtils.isNotBlank(reagentName)) {
|
params.put("reagentName", "%" + reagentName + "%");
|
}
|
params.put("startDeadline", startDeadline);
|
params.put("endDeadline", endDeadline);
|
params.put("status", status);
|
params.put("searchApproval",searchApproval);
|
if (StringUtils.isNotBlank(approveUserId)) {
|
SysUser sysUser = sysUserService.getSysUser(approveUserId);
|
// 不是管理员时,加入applyUserId
|
if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) {
|
params.put("approveUserId", approveUserId);
|
}
|
}
|
if (StringUtils.isNotBlank(approvaUserName)) {
|
params.put("approvaUserName", "%" + approvaUserName + "%");
|
}
|
if (StringUtils.isNotBlank(applyUserName)) {
|
params.put("applyUserName", "%" + applyUserName + "%");
|
}
|
params.put("applyUserId", applyUserId);
|
|
if (StringUtils.isNotBlank(queryCas)) {
|
params.put("cas", "%" + queryCas + "%");
|
}
|
params.put("applyCode", applyCode);
|
return this.opeApplyDao.getOpeApplyTotalCount(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public int getOpeApplyTotalCount(String reagentName, Timestamp startDeadline, Timestamp endDeadline, Integer status,
|
String applyUserId, String approveUserId, String queryCas,String applyCode,String applyUserName) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
if (StringUtils.isNotBlank(reagentName)) {
|
params.put("reagentName", "%" + reagentName + "%");
|
}
|
params.put("startDeadline", startDeadline);
|
params.put("endDeadline", endDeadline);
|
params.put("status", status);
|
|
if (StringUtils.isNotBlank(applyUserId)) {
|
SysUser sysUser = sysUserService.getSysUser(applyUserId);
|
// 不是管理员时,加入applyUserId
|
if (sysUser.getSeeFlag().getKey() != SeeFlag.MANAGE.getKey()) {
|
params.put("applyUserId", applyUserId);
|
}
|
|
if("连悦".equals(sysUser.getName())){
|
params.remove("applyUserId");
|
}
|
}
|
|
params.put("approveUserId", approveUserId);
|
params.put("applyUserName", applyUserName);
|
if (StringUtils.isNotBlank(queryCas)) {
|
params.put("cas", "%" + queryCas + "%");
|
}
|
params.put("applyCode", applyCode);
|
return this.opeApplyDao.getOpeApplyTotalCount(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public OpeApply getOpeApply(String id) {
|
try {
|
return this.opeApplyDao.getOpeApply(id);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR, MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public OpeApply insertOpeApply(OpeApply opeApply) {
|
try {
|
opeApply.setId(IDUtils.uuid());
|
this.opeApplyDao.insertOpeApply(opeApply);
|
return opeApply;
|
} 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);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public List<OpeApply> insertOpeApplyList(List<OpeApply> opeApplyList) {
|
try {
|
this.opeApplyDao.insertOpeApplyList(opeApplyList);
|
return opeApplyList;
|
} 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);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateOpeApply(OpeApply opeApply) {
|
try {
|
int row = this.opeApplyDao.updateOpeApply(opeApply);
|
|
if (row == 0) {
|
return false;
|
}
|
return true;
|
} 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);
|
}
|
}
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateFirst(String id) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("id",id);
|
int row = this.opeApplyDao.updateFirst(params);
|
|
if (row == 0) {
|
return false;
|
}
|
return true;
|
} 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);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateFirst2(String id) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("id",id);
|
int row = this.opeApplyDao.updateFirst2(params);
|
|
if (row == 0) {
|
return false;
|
}
|
return true;
|
} 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);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateOpeApplyProject(String newObjective,String oldObjective) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("newObjective", newObjective);
|
params.put("oldObjective", oldObjective);
|
int row = this.opeApplyDao.updateOpeApplyProject(params);
|
|
return true;
|
} 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 boolean updateSelectedOpeApplyStatus(String memo, List<String> applyIds, String adminUserId, List<String> adminApplyIds,List<String> firstUserIds) {
|
boolean apply = false, adminApply = false;
|
if (!CollectionUtils.isEmpty(applyIds)) {
|
apply = this.updateOpeApplyStatus(ApplyStatus.APPROVED, memo, applyIds);
|
}
|
if (!CollectionUtils.isEmpty(adminApplyIds)) {
|
adminApply = this.updateOpeApplyAdminStatus2(memo, adminApplyIds, adminUserId,firstUserIds);
|
}
|
return apply || adminApply;
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateOpeApplyStatus(ApplyStatus status, String memo, List<String> applyIds) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("status", status.getKey());
|
params.put("memo", memo);
|
params.put("applyIds", applyIds);
|
|
int row = this.opeApplyDao.updateOpeApplyStatus(params);
|
|
if (row == 0) {
|
return false;
|
}
|
|
return true;
|
} 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);
|
}
|
}
|
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateOpeApplyAdminStatus2(String memo, List<String> applyIds, String adminUserId,List<String> firstUserIds) {
|
try {
|
for(int i=0;i<applyIds.size();i++){
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("userId", adminUserId);
|
params.put("memo", memo);
|
params.put("id", applyIds.get(i));
|
params.put("beforeUserId",firstUserIds.get(i));
|
int row = this.opeApplyDao.updateOpeApplyAdmin2(params);
|
if (row == 0) {
|
return false;
|
}
|
}
|
|
|
return true;
|
} 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);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updateOpeApplyAdminStatus(String memo, List<String> applyIds, String adminUserId,List<String> firstUserIds) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("userId", adminUserId);
|
params.put("memo", memo);
|
params.put("applyIds", applyIds);
|
params.put("firstUserIds",firstUserIds);
|
int row = this.opeApplyDao.updateOpeApplyAdmin(params);
|
|
if (row == 0) {
|
return false;
|
}
|
|
return true;
|
} 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);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean deleteOpeApply(List<OpeApply> opeApplyList) {
|
try {
|
if (opeApplyList == null || opeApplyList.size() == 0) {
|
return false;
|
}
|
|
List<String> ids = new ArrayList<String>();
|
for (OpeApply opeApply : opeApplyList) {
|
ids.add(opeApply.getId());
|
}
|
|
int row = this.opeApplyDao.deleteOpeApply(ids);
|
if (row == 0) {
|
return false;
|
}
|
|
return true;
|
} 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);
|
}
|
}
|
|
public boolean isApplyPendingApproval(OpeApply opeApply) {
|
if (opeApply != null
|
&& opeApply.getStatus() != null
|
&& opeApply.getStatus().getKey() == ApplyStatus.PENDING_APPROVAL.getKey()) {
|
return true;
|
}
|
|
return false;
|
}
|
|
public boolean isApplyApproved(OpeApply opeApply) {
|
if (opeApply != null
|
&& opeApply.getStatus() != null
|
&& opeApply.getStatus().getKey() == ApplyStatus.APPROVED.getKey()) {
|
return true;
|
}
|
|
return false;
|
}
|
|
public boolean isAllowApplyCancel(OpeApply opeApply) {
|
if (this.isApplyPendingApproval(opeApply)
|
|| this.isApplyApproved(opeApply)) {
|
return true;
|
}
|
|
return false;
|
}
|
|
@Override
|
public OpeApply selectOpeApplyByPrimaryKey(String id) {
|
try {
|
OpeApply info = this.opeApplyDao.selectOpeApplyByPrimaryKey(id);
|
return info;
|
} 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 int getOpeApplyReserveTotalCountByName(String id,String reagentName, String personName) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("reagentName", reagentName);
|
params.put("personName", personName);
|
params.put("userId",id);
|
return this.opeApplyDao.getOpeApplyReserveTotalCount(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Override
|
public int getOpeApplyReserveTotalCountByNameFor(String id,String reagentName, String personName,String productSn,String applyCode,Integer status) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("reagentName", reagentName);
|
params.put("personName", personName);
|
params.put("userId",id);
|
params.put("productSn",productSn);
|
params.put("applyCode",applyCode);
|
params.put("status",status);
|
return this.opeApplyDao.getOpeApplyReserveTotalCountFor(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
@Override
|
public List<OpeApplyReserve> getOpeApplyReserveListByNameFor(String id,String reagentName, String personName, Integer first,
|
Integer pageSize,String productSn,String applyCode,Integer status) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("reagentName", reagentName);
|
params.put("personName", personName);
|
params.put("userId",id);
|
params.put("first", first);
|
params.put("pageSize", pageSize);
|
params.put("productSn",productSn);
|
params.put("applyCode",applyCode);
|
params.put("status",status);
|
return this.opeApplyDao.getOpeApplyReserveListFor(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
@Override
|
public List<OpeApplyReserve> getOpeApplyReserveListByName(String id,String reagentName, String personName, Integer first,
|
Integer pageSize) {
|
try {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("reagentName", reagentName);
|
params.put("personName", personName);
|
params.put("userId",id);
|
params.put("first", first);
|
params.put("pageSize", pageSize);
|
return this.opeApplyDao.getOpeApplyReserveList(params);
|
} catch (DataAccessException e) {
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updaetOpeApplyPrice(BigDecimal applyPrice, String id){
|
try{
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("applyPrice", applyPrice);
|
params.put("id", id);
|
int row = this.opeApplyDao.updaetOpeApplyPrice(params);
|
if (row == 0) {
|
return false;
|
}
|
return true;
|
}catch (DataAccessException e){
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean updaetOpeApplyStockFlag(int stockFlag, String id){
|
try{
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("stockFlag", stockFlag);
|
params.put("id", id);
|
int row = this.opeApplyDao.updaetOpeApplyStockFlag(params);
|
if (row == 0) {
|
return false;
|
}
|
return true;
|
}catch (DataAccessException e){
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public boolean cancelApply(ApplyStatus status,String id){
|
try{
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("status", status.getKey());
|
params.put("id", id);
|
int row = this.opeApplyDao.cancelApply(params);
|
if (row == 0) {
|
return false;
|
}
|
return true;
|
}catch (DataAccessException e){
|
logger.error(e.getMessage(), e);
|
throw new BusinessException(ExceptionEnumCode.DB_ERR,
|
MessageUtil.getMessageByCode(ExceptionEnumCode.DB_ERR.getCode()), e);
|
}
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public List<OpeApply>selectByReId(String id){
|
return this.opeApplyDao.selectByReId(id);
|
}
|
|
@Transactional(propagation = Propagation.REQUIRED)
|
public void updateByReId(String newReId,String oldReId){
|
Map<String, Object> params=new HashMap();
|
params.put("newReId",newReId);
|
params.put("oldReId",oldReId);
|
this.opeApplyDao.updateByReId(params);
|
}
|
}
|