|
@@ -1,13 +1,11 @@
|
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
-import com.qmth.sop.business.entity.TBViolationDetail;
|
|
|
import com.qmth.sop.business.entity.SysUser;
|
|
|
+import com.qmth.sop.business.entity.TBViolationDetail;
|
|
|
import com.qmth.sop.business.mapper.TBViolationDetailMapper;
|
|
|
import com.qmth.sop.business.service.TBViolationDetailService;
|
|
|
-import com.qmth.sop.common.contant.SystemConstant;
|
|
|
import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.sop.common.enums.FieldUniqueEnum;
|
|
|
import com.qmth.sop.common.util.ResultUtil;
|
|
@@ -15,9 +13,8 @@ import com.qmth.sop.common.util.ServletUtil;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import javax.annotation.Resource;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
@@ -30,50 +27,55 @@ import java.util.Objects;
|
|
|
* @Company: www.qmth.com.cn
|
|
|
*/
|
|
|
@Service
|
|
|
-public class TBViolationDetailServiceImpl extends ServiceImpl<TBViolationDetailMapper, TBViolationDetail> implements TBViolationDetailService{
|
|
|
+public class TBViolationDetailServiceImpl extends ServiceImpl<TBViolationDetailMapper, TBViolationDetail> implements TBViolationDetailService {
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 新增修改违规明细表
|
|
|
- *
|
|
|
- * @param tBViolationDetail
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Boolean saveTBViolationDetail(TBViolationDetail tBViolationDetail) {
|
|
|
- try {
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- if (Objects.isNull(tBViolationDetail.getId())) {// 新增
|
|
|
- tBViolationDetail.setCreateId(sysUser.getId());
|
|
|
- tBViolationDetail.setCreateTime(System.currentTimeMillis());
|
|
|
- } else { // 修改
|
|
|
+ /**
|
|
|
+ * 新增修改违规明细表
|
|
|
+ *
|
|
|
+ * @param tBViolationDetail
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean saveTBViolationDetail(TBViolationDetail tBViolationDetail) {
|
|
|
+ try {
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ if (Objects.isNull(tBViolationDetail.getId())) {// 新增
|
|
|
+ tBViolationDetail.setCreateId(sysUser.getId());
|
|
|
+ tBViolationDetail.setCreateTime(System.currentTimeMillis());
|
|
|
+ } else { // 修改
|
|
|
// tBViolationDetail.updateInfo(sysUser.getId());
|
|
|
- }
|
|
|
- return saveOrUpdate(tBViolationDetail);
|
|
|
- } catch (Exception e) {
|
|
|
- if (e instanceof DuplicateKeyException) {
|
|
|
- String errorColumn = e.getCause().toString();
|
|
|
- String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
- throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
|
|
|
- } else if (e instanceof ApiException) {
|
|
|
- ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
- } else {
|
|
|
- ResultUtil.error(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
+ }
|
|
|
+ return saveOrUpdate(tBViolationDetail);
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
+ String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
+ throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
|
|
|
+ } else if (e instanceof ApiException) {
|
|
|
+ ResultUtil.error((ApiException) e, e.getMessage());
|
|
|
+ } else {
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 删除违规明细表
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean delete(Long id) {
|
|
|
+ return this.removeById(id);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 删除违规明细表
|
|
|
- *
|
|
|
- * @param id
|
|
|
- */
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
- public Boolean delete(Long id) {
|
|
|
- return this.removeById(id);
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public List<TBViolationDetail> listByViolationId(long id) {
|
|
|
+ return this.baseMapper.listByViolationId(id);
|
|
|
+ }
|
|
|
|
|
|
}
|