package cn.com.goldenwater.dcproj.service.impl; import cn.com.goldenwater.dcproj.dao.BisInspQaScoreDao; import cn.com.goldenwater.dcproj.model.BisInspQaScore; import cn.com.goldenwater.dcproj.model.BisInspQymtenMsr; import cn.com.goldenwater.dcproj.param.BisInspQaScoreParam; import cn.com.goldenwater.dcproj.service.BisInspQaScoreService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.service.BisInspQaService; import cn.com.goldenwater.target.CheckException; 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.Date; import java.util.HashMap; import java.util.Map; import java.util.Objects; import java.util.concurrent.atomic.LongAdder; /** * @author hjp * @date 2022-7-28 */ @Service @Transactional(rollbackFor = Exception.class) public class BisInspQaScoreServiceImpl extends AbstractCrudService implements BisInspQaScoreService { @Autowired private BisInspQaScoreDao bisInspQaScoreDao; @Autowired private BisInspQaService bisInspQaService; public BisInspQaScoreServiceImpl(BisInspQaScoreDao bisInspQaScoreDao) { super(bisInspQaScoreDao); this.bisInspQaScoreDao = bisInspQaScoreDao; } @Override public int insert(BisInspQaScore bisInspQaScore) { // 生成uuid String uuid = UuidUtil.uuid(); bisInspQaScore.setId(uuid); bisInspQaScore.setIntm(new Date()); bisInspQaScore.setUptm(new Date()); bisInspQaScore.setDataStat("0"); return this.bisInspQaScoreDao.insert(bisInspQaScore); } @Override public int update(BisInspQaScore bisInspQaScore) { BisInspQaScore score = get(bisInspQaScore.getRgstrId()); if (score == null) { throw new CheckException("未找到此登记表下的子表"); } bisInspQaScore.setId(score.getId()); bisInspQaScore.setUptm(new Date()); //分数处理 scoreProcessing(bisInspQaScore); return this.bisInspQaScoreDao.update(bisInspQaScore); } @Override public int delete(String id) { return this.bisInspQaScoreDao.delete(id); } /** * 分数处理 * * @param obj 对象 */ private void scoreProcessing(BisInspQaScore obj) { //扣分合计 LongAdder empSub = new LongAdder(); empSub.add(judge(obj.getQaMgr())); empSub.add(judge(obj.getQaDst())); empSub.add(judge(obj.getQaNewEta())); empSub.add(judge(obj.getQaBuld())); empSub.add(judge(obj.getQaApply())); empSub.add(judge(obj.getQaPlan())); empSub.add(judge(obj.getQaPrjDiv())); empSub.add(judge(obj.getQaStan())); empSub.add(judge(obj.getQaRvqn())); empSub.add(judge(obj.getQaPrjBuld())); empSub.add(judge(obj.getQaChkRun())); empSub.add(judge(obj.getQaQaChk())); empSub.add(judge(obj.getQaChkCnl())); empSub.add(judge(obj.getQaPblmHnd())); empSub.add(judge(obj.getQaPrjDuty())); empSub.add(judge(obj.getQaPrjIdea())); empSub.add(judge(obj.getQaBuldJar())); empSub.add(judge(obj.getQaAccp())); //加分合计 LongAdder empAdd = new LongAdder(); empAdd.add(judge(obj.getQaSys())); empAdd.add(judge(obj.getQaMgrUp())); //总分值 long totalScore = 100L; long subTotal = empSub.longValue(); long addTotal = empAdd.longValue(); //得分=总分值-减分项+加分项 long total = totalScore - subTotal + addTotal; obj.setSubTotal(subTotal); obj.setAddTotal(addTotal); obj.setTotal(total); //赋值 updateRgstrState(obj); } private long judge(Long value) { if (Objects.isNull(value)) { return 0L; } return value; } private void updateRgstrState(BisInspQaScore bisInspQaScore) { Map map = new HashMap<>(4); map.put("rgstrId",bisInspQaScore.getRgstrId()); map.put("param","qa"); map.put("total",bisInspQaScore.getTotal()); bisInspQaService.updateState(map); } }