package cn.com.goldenwater.dcproj.service.impl; import cn.com.goldenwater.dcproj.dao.BisInspQaScore1Dao; import cn.com.goldenwater.dcproj.model.BisInspQaScore1; import cn.com.goldenwater.dcproj.model.GwComFile; import cn.com.goldenwater.dcproj.param.BisInspQaScore1Param; import cn.com.goldenwater.dcproj.service.BisInspQaScore1Service; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.service.GwComFileService; 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 cn.com.goldenwater.id.util.UuidUtil; import java.util.List; import java.util.Date; import java.util.Optional; /** * @author hjp * @date 2022-7-28 */ @Service @Transactional(rollbackFor = Exception.class) public class BisInspQaScore1ServiceImpl extends AbstractCrudService implements BisInspQaScore1Service { @Autowired private BisInspQaScore1Dao bisInspQaScore1Dao; @Autowired private GwComFileService gwComFileService; public BisInspQaScore1ServiceImpl(BisInspQaScore1Dao bisInspQaScore1Dao) { super(bisInspQaScore1Dao); this.bisInspQaScore1Dao = bisInspQaScore1Dao; } @Override public BisInspQaScore1 get(String key) { BisInspQaScore1 score = super.get(key); Optional.ofNullable(score).ifPresent(s -> { List gwComFileList = gwComFileService.findFileByBiz(s.getId()); s.setGwComFileList(gwComFileList); }); return score; } @Override public int insert(BisInspQaScore1 bisInspQaScore1) { if (StringUtils.isBlank(bisInspQaScore1.getCaseId())) { throw new CheckException("caseId为空"); } if (StringUtils.isBlank(bisInspQaScore1.getScoreName())) { throw new CheckException("scoreName为空"); } BisInspQaScore1 score = getByCaseScore(bisInspQaScore1.getCaseId(), bisInspQaScore1.getScoreName()); if (score != null) { return update(bisInspQaScore1); } // 生成uuid String uuid = UuidUtil.uuid(); bisInspQaScore1.setId(uuid); bisInspQaScore1.setIntm(new Date()); bisInspQaScore1.setUptm(new Date()); bisInspQaScore1.setDataStat("0"); int ret = this.bisInspQaScore1Dao.insert(bisInspQaScore1); gwComFileService.updateBiz(bisInspQaScore1.getGwComFileList(), bisInspQaScore1.getId()); return ret; } @Override public int update(BisInspQaScore1 bisInspQaScore1) { bisInspQaScore1.setUptm(new Date()); return this.bisInspQaScore1Dao.update(bisInspQaScore1); } @Override public int delete(String id) { return this.bisInspQaScore1Dao.delete(id); } @Override public BisInspQaScore1 getByCaseScore(String caseId, String scoreName) { BisInspQaScore1 score = bisInspQaScore1Dao.getByCaseScore(caseId, scoreName); Optional.ofNullable(score).ifPresent(s -> { List gwComFileList = gwComFileService.findFileByBiz(s.getId()); s.setGwComFileList(gwComFileList); }); return score; } }