| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package cn.com.goldenwater.dcproj.service.impl;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.dao.BisInspStstnScoreDao;
- import cn.com.goldenwater.dcproj.model.BisInspStstnScore;
- import cn.com.goldenwater.dcproj.model.GwComFile;
- import cn.com.goldenwater.dcproj.param.BisInspStstnScoreParam;
- import cn.com.goldenwater.dcproj.service.BisInspStstnScoreService;
- import cn.com.goldenwater.dcproj.service.GwComFileService;
- import cn.com.goldenwater.id.util.UuidUtil;
- import cn.com.goldenwater.target.CheckException;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.Date;
- import java.util.List;
- import java.util.Optional;
- /**
- * @author lhc
- * @date 2021-7-14
- */
- @Service
- @Transactional
- public class BisInspStstnScoreServiceImpl extends AbstractCrudService<BisInspStstnScore, BisInspStstnScoreParam> implements BisInspStstnScoreService {
- @Autowired
- private BisInspStstnScoreDao bisInspStstnScoreDao;
- @Autowired
- private GwComFileService gwComFileService;
- public BisInspStstnScoreServiceImpl(BisInspStstnScoreDao bisInspStstnScoreDao) {
- super(bisInspStstnScoreDao);
- this.bisInspStstnScoreDao = bisInspStstnScoreDao;
- }
- @Override
- public BisInspStstnScore get(String key) {
- BisInspStstnScore score = super.get(key);
- Optional.ofNullable(score).ifPresent(s -> {
- List<GwComFile> gwComFileList = gwComFileService.findFileByBiz(s.getId());
- s.setGwComFileList(gwComFileList);
- });
- return score;
- }
- @Override
- public int insert(BisInspStstnScore bisInspStstnScore) {
- if (StringUtils.isBlank(bisInspStstnScore.getCaseId())) {
- throw new CheckException("caseId为空");
- }
- if (StringUtils.isBlank(bisInspStstnScore.getScoreName())) {
- throw new CheckException("scoreName为空");
- }
- BisInspStstnScore score = getByCaseScore(bisInspStstnScore.getCaseId(), bisInspStstnScore.getScoreName());
- if (score != null) {
- return update(bisInspStstnScore);
- }
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspStstnScore.setId(uuid);
- bisInspStstnScore.setIntm(new Date());
- bisInspStstnScore.setUptm(new Date());
- bisInspStstnScore.setDataStat("0");
- int ret = this.bisInspStstnScoreDao.insert(bisInspStstnScore);
- gwComFileService.updateBiz(bisInspStstnScore.getGwComFileList(), bisInspStstnScore.getId());
- return ret;
- }
- @Override
- public BisInspStstnScore getByCaseScore(String caseId, String scoreName) {
- BisInspStstnScore score = bisInspStstnScoreDao.getByCaseScore(caseId, scoreName);
- Optional.ofNullable(score).ifPresent(s -> {
- List<GwComFile> gwComFileList = gwComFileService.findFileByBiz(s.getId());
- s.setGwComFileList(gwComFileList);
- });
- return score;
- }
- @Override
- public int update(BisInspStstnScore bisInspStstnScore) {
- BisInspStstnScore score = getByCaseScore(bisInspStstnScore.getCaseId(), bisInspStstnScore.getScoreName());
- if (score == null) {
- throw new CheckException("未找到指定修改数据");
- }
- bisInspStstnScore.setId(score.getId());
- bisInspStstnScore.setUptm(new Date());
- int ret = this.bisInspStstnScoreDao.update(bisInspStstnScore);
- gwComFileService.updateBiz(bisInspStstnScore.getGwComFileList(), bisInspStstnScore.getId());
- return ret;
- }
- @Override
- public int delete(String id) {
- return this.bisInspStstnScoreDao.delete(id);
- }
- }
|