|
@@ -0,0 +1,111 @@
|
|
|
+package cn.cslg.pas.service.business;
|
|
|
+
|
|
|
+import cn.cslg.pas.common.dto.customAnalyse.SelectCustomAnalyseDTO;
|
|
|
+import cn.cslg.pas.common.dto.customAnalyse.SelectCustomAnalyseListDTO;
|
|
|
+import cn.cslg.pas.common.model.cronModel.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
+import cn.cslg.pas.common.vo.customAnalyse.CustomAnalyseIdVO;
|
|
|
+import cn.cslg.pas.common.vo.customAnalyse.CustomAnalyseVO;
|
|
|
+import cn.cslg.pas.common.vo.customAnalyse.SelectCustomAnalyseVO;
|
|
|
+import cn.cslg.pas.domain.business.CustomAnalysisItem;
|
|
|
+import cn.cslg.pas.exception.UnLoginException;
|
|
|
+import cn.cslg.pas.mapper.CustomAnalysisItemMapper;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 自定义分析项目Service层
|
|
|
+ *
|
|
|
+ * @Author zero
|
|
|
+ * @Date 2024/01/12
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CustomAnalyseService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CacheUtils cacheUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LoginUtils loginUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CustomAnalysisItemMapper customAnalysisItemMapper;
|
|
|
+
|
|
|
+ public List<SelectCustomAnalyseListDTO> queryAnalyseGroup(SelectCustomAnalyseVO vo) {
|
|
|
+ List<SelectCustomAnalyseListDTO> list = new ArrayList<>();
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public SelectCustomAnalyseDTO queryAnalyseGroupDetail(CustomAnalyseIdVO vo) {
|
|
|
+ SelectCustomAnalyseDTO dto = new SelectCustomAnalyseDTO();
|
|
|
+ CustomAnalysisItem item = customAnalysisItemMapper.selectById(vo.getId());
|
|
|
+ if (ObjectUtil.isNotEmpty(item)) {
|
|
|
+ BeanUtils.copyProperties(item, dto);
|
|
|
+ }
|
|
|
+ return dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer addAnalyseGroup(CustomAnalyseVO vo) {
|
|
|
+
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ CustomAnalysisItem item = new CustomAnalysisItem();
|
|
|
+ BeanUtils.copyProperties(vo, item);
|
|
|
+ item.setTenantId(personnelVO.getTenantId());
|
|
|
+ item.setCreatorId(personnelVO.getId());
|
|
|
+ item.setCreator(personnelVO.getName());
|
|
|
+ item.setCreateTime(new Date());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.insert();
|
|
|
+ return item.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer editAnalyseGroup(CustomAnalyseVO vo) {
|
|
|
+
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+
|
|
|
+ CustomAnalysisItem item = customAnalysisItemMapper.selectById(vo.getId());
|
|
|
+ BeanUtils.copyProperties(vo, item);
|
|
|
+ item.setTenantId(personnelVO.getTenantId());
|
|
|
+ item.setCreatorId(personnelVO.getId());
|
|
|
+ item.setCreator(personnelVO.getName());
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.insert();
|
|
|
+ return item.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer delAnalyseGroup(CustomAnalyseIdVO vo) {
|
|
|
+ CustomAnalysisItem item = customAnalysisItemMapper.selectById(vo.getId());
|
|
|
+ customAnalysisItemMapper.deleteById(vo.getId());
|
|
|
+ return item.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|