From e547993a3c78d0bd75f3fdef4a9878e180d73d36 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期一, 29 四月 2024 17:52:26 +0800
Subject: [PATCH] 合同考核结果定时任务、详情、查询、导出

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/CheckResultServiceImpl.java |  247 +++++++++++++++++++++----------------------------
 1 files changed, 105 insertions(+), 142 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckResultServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckResultServiceImpl.java
index b8cf58c..cdd747c 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckResultServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CheckResultServiceImpl.java
@@ -1,166 +1,129 @@
 package com.ycl.platform.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.ycl.exception.ServiceException;
-import com.ycl.platform.domain.entity.CheckResult;
-import com.ycl.platform.domain.form.ManualScoreForm;
-import com.ycl.platform.mapper.CheckResultMapper;
-import com.ycl.platform.service.CheckResultService;
-import com.ycl.system.Result;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ycl.platform.domain.form.CheckResultForm;
+import com.ycl.platform.domain.entity.CheckResult;
+import com.ycl.platform.domain.entity.ContractResultRecord;
 import com.ycl.platform.domain.vo.CheckResultVO;
-import com.ycl.platform.domain.query.CheckResultQuery;
+import com.ycl.platform.mapper.CheckResultMapper;
+import com.ycl.platform.mapper.ContractResultRecordMapper;
+import com.ycl.platform.service.ICheckResultService;
+import com.ycl.platform.service.ITContractService;
+import com.ycl.platform.service.YwUnitService;
+import com.ycl.utils.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import utils.DateUtils;
+
+import java.util.Arrays;
 import java.util.List;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.ycl.system.page.PageUtil;
-import org.springframework.stereotype.Service;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.beans.BeanUtils;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.Assert;
-import java.util.ArrayList;
-import java.util.Objects;
-import java.util.stream.Collectors;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
-import lombok.RequiredArgsConstructor;
-import org.springframework.util.StringUtils;
-
 /**
- * 鑰冩牳缁撴灉 鏈嶅姟瀹炵幇绫�
+ * 鑰冩牳缁撴灉Service涓氬姟灞傚鐞�
  *
- * @author xp
- * @since 2024-03-07
+ * @author ruoyi
+ * @date 2024-04-01
  */
 @Service
-@RequiredArgsConstructor
-public class CheckResultServiceImpl extends ServiceImpl<CheckResultMapper, CheckResult> implements CheckResultService {
+public class CheckResultServiceImpl extends ServiceImpl<CheckResultMapper, CheckResult> implements ICheckResultService {
+    @Autowired
+    private CheckResultMapper checkResultMapper;
+    @Autowired
+    private ContractResultRecordMapper contractResultRecordMapper;
+    @Autowired
+    private YwUnitService unitService;
+    @Autowired
+    private ITContractService contractService;
 
-    private final CheckResultMapper checkResultMapper;
 
     /**
-     * 娣诲姞
-     * @param form
-     * @return
+     * 鏌ヨ鑰冩牳缁撴灉
+     *
+     * @param id 鑰冩牳缁撴灉涓婚敭
+     * @return 鑰冩牳缁撴灉
      */
     @Override
-    public Result add(CheckResultForm form) {
-        CheckResult entity = CheckResultForm.getEntityByForm(form, null);
-        if(baseMapper.insert(entity) > 0) {
-            return Result.ok("娣诲姞鎴愬姛");
+    public CheckResult selectCheckResultById(Long id) {
+        return checkResultMapper.selectById(id);
+    }
+
+    /**
+     * 鏌ヨ鑰冩牳缁撴灉鍒楄〃
+     *
+     * @param checkResult 鑰冩牳缁撴灉
+     * @return 鑰冩牳缁撴灉
+     */
+    @Override
+    public List<CheckResultVO> selectCheckResultList(CheckResultVO checkResult) {
+        return checkResultMapper.selectCheckResultList(checkResult);
+    }
+
+    /**
+     * 鏂板鑰冩牳缁撴灉
+     *
+     * @param checkResult 鑰冩牳缁撴灉
+     * @return 缁撴灉
+     */
+    @Override
+    public int insertCheckResult(CheckResult checkResult) {
+        return checkResultMapper.insert(checkResult);
+    }
+
+    /**
+     * 淇敼鑰冩牳缁撴灉
+     *
+     * @param checkResult 鑰冩牳缁撴灉
+     * @return 缁撴灉
+     */
+    @Override
+    public int updateCheckResult(CheckResult checkResult) {
+        checkResult.setUpdateTime(DateUtils.getNowDate());
+        return checkResultMapper.updateById(checkResult);
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎鑰冩牳缁撴灉
+     *
+     * @param ids 闇�瑕佸垹闄ょ殑鑰冩牳缁撴灉涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteCheckResultByIds(Long[] ids) {
+        return checkResultMapper.deleteBatchIds(Arrays.asList(ids));
+    }
+
+    /**
+     * 鍒犻櫎鑰冩牳缁撴灉淇℃伅
+     *
+     * @param id 鑰冩牳缁撴灉涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deleteCheckResultById(Long id) {
+        return checkResultMapper.deleteById(id);
+    }
+
+    @Override
+    public void saveBatchRecord(List<ContractResultRecord> contractResultRecord) {
+        if (!contractResultRecord.isEmpty()) {
+            contractResultRecordMapper.saveBatch(contractResultRecord);
         }
-        return Result.error("娣诲姞澶辫触");
-    }
-
-    /**
-     * 淇敼
-     * @param form
-     * @return
-     */
-    @Override
-    public Result update(CheckResultForm form) {
-
-        CheckResult entity = baseMapper.selectById(form.getId());
-
-        // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
-        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
-        BeanUtils.copyProperties(form, entity);
-        if (baseMapper.updateById(entity) > 0) {
-            return Result.ok("淇敼鎴愬姛");
-        }
-        return Result.error("淇敼澶辫触");
-    }
-
-    /**
-     * 鎵归噺鍒犻櫎
-     * @param ids
-     * @return
-     */
-    @Override
-    public Result remove(List<String> ids) {
-        if(baseMapper.deleteBatchIds(ids) > 0) {
-            return Result.ok("鍒犻櫎鎴愬姛");
-        }
-        return Result.error("鍒犻櫎澶辫触");
-    }
-
-    /**
-     * id鍒犻櫎
-     * @param id
-     * @return
-     */
-    @Override
-    public Result removeById(String id) {
-        if(baseMapper.deleteById(id) > 0) {
-            return Result.ok("鍒犻櫎鎴愬姛");
-        }
-        return Result.error("鍒犻櫎澶辫触");
-    }
-
-    /**
-     * 鍒嗛〉鏌ヨ
-     * @param query
-     * @return
-     */
-    @Override
-    public Result page(CheckResultQuery query) {
-        query.setTime();
-        IPage page = PageUtil.getPage(query, CheckResult.class);
-        baseMapper.page(page, query);
-        return Result.ok().data(page.getRecords()).total(page.getTotal());
-    }
-
-    /**
-     * 鏍规嵁id鏌ユ壘
-     * @param id
-     * @return
-     */
-    @Override
-    public Result detail(String id) {
-
-        CheckResult entity = baseMapper.selectById(id);
-        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
-        CheckResultVO vo = CheckResultVO.getVoByEntity(entity, null);
-        return Result.ok().data(vo);
-    }
-
-    /**
-     * 鍒楄〃
-     * @return
-     */
-    @Override
-    public Result all() {
-        List<CheckResult> entities = baseMapper.selectList(null);
-        List<CheckResultVO> vos = entities.stream()
-                .map(
-                        entity -> CheckResultVO.getVoByEntity(entity, null)
-                )
-                .collect(Collectors.toList());
-        return Result.ok().data(vos);
     }
 
     @Override
-    public Result manualScore(ManualScoreForm form) {
-        CheckResult checkResult = baseMapper.selectById(form.getId());
-        if (Objects.isNull(checkResult)) {
-            throw new ServiceException("鑰冩牳缁撴灉涓嶅瓨鍦�");
-        }
-        checkResult.setManualScore(form.getManualScore());
-        checkResult.setCheckScore(form.getManualScore().add(checkResult.getSystemScore()));
-        baseMapper.updateById(checkResult);
-        return Result.ok();
+    public List<ContractResultRecord> selectCheckResultRecordList(Long resultId) {
+        return new LambdaQueryChainWrapper<>(contractResultRecordMapper)
+                .eq(ContractResultRecord::getResultId, resultId)
+                .list();
     }
 
     @Override
-    public Result publishById(String id) {
-        CheckResult checkResult = new CheckResult();
-        checkResult.setId(Integer.valueOf(id));
-        checkResult.setPublish(1);
-        if(baseMapper.updateById(checkResult) > 0) {
-            return Result.ok("鍙戝竷鎴愬姛");
-        }
-        return Result.error("鍙戝竷澶辫触");
+    public Boolean publish(Long id) {
+        return new LambdaUpdateChainWrapper<>(checkResultMapper)
+                .eq(CheckResult::getId, id)
+                .set(CheckResult::getPublish, 1)
+                .set(CheckResult::getPublishId, SecurityUtils.getLoginUser().getUserId())
+                .update();
     }
 }

--
Gitblit v1.8.0