package cn.com.goldenwater.dcproj.service.impl; import cn.com.goldenwater.dcproj.dao.BisInspQaScoreSdDao; import cn.com.goldenwater.dcproj.model.BisInspQaScore; import cn.com.goldenwater.dcproj.model.BisInspQaScoreSd; import cn.com.goldenwater.dcproj.param.BisInspQaScoreSdParam; import cn.com.goldenwater.dcproj.service.BisInspQaScoreSdService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.service.BisInspQaSdService; import cn.com.goldenwater.target.CheckException; import com.github.pagehelper.PageHelper; 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.*; import java.util.concurrent.atomic.LongAdder; /** * @author lhc * @date 2024-4-7 */ @Service @Transactional(rollbackFor = Exception.class) public class BisInspQaScoreSdServiceImpl extends AbstractCrudService implements BisInspQaScoreSdService { @Autowired private BisInspQaScoreSdDao bisInspQaScoreSdDao; @Autowired private BisInspQaSdService bisInspQaSdService; public BisInspQaScoreSdServiceImpl(BisInspQaScoreSdDao bisInspQaScoreSdDao) { super(bisInspQaScoreSdDao); this.bisInspQaScoreSdDao = bisInspQaScoreSdDao; } @Override public int insert(BisInspQaScoreSd bisInspQaScoreSd) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspQaScoreSd.setId(uuid); bisInspQaScoreSd.setIntm(new Date()); bisInspQaScoreSd.setUptm(new Date()); bisInspQaScoreSd.setDataStat("0"); return this.bisInspQaScoreSdDao.insert(bisInspQaScoreSd); } @Override public int update(BisInspQaScoreSd bisInspQaScoreSd) { BisInspQaScoreSd score = get(bisInspQaScoreSd.getRgstrId()); if (score == null) { throw new CheckException("未找到此登记表下的子表"); } bisInspQaScoreSd.setId(score.getId()); bisInspQaScoreSd.setUptm(new Date()); //分数处理 scoreProcessing(bisInspQaScoreSd); return this.bisInspQaScoreSdDao.update(bisInspQaScoreSd); } @Override public int delete(String id) { return this.bisInspQaScoreSdDao.delete(id); } /** * 分数处理 * * @param obj 对象 */ private void scoreProcessing(BisInspQaScoreSd 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.getQaZrr())); empSub.add(judge(obj.getQaGzyd())); empSub.add(judge(obj.getQaZgls())); empSub.add(judge(obj.getQaJdsq())); empSub.add(judge(obj.getQaGzjh())); empSub.add(judge(obj.getQaXmhf())); empSub.add(judge(obj.getQaPdbz())); empSub.add(judge(obj.getQaZzqk())); empSub.add(judge(obj.getQaJlqk())); empSub.add(judge(obj.getQaYxqk())); empSub.add(judge(obj.getQaJdjc())); empSub.add(judge(obj.getQaZljl())); empSub.add(judge(obj.getQaWtcl())); empSub.add(judge(obj.getQaZszrz())); empSub.add(judge(obj.getQaZdbg())); empSub.add(judge(obj.getQaJdda())); empSub.add(judge(obj.getQaJbts())); empSub.add(judge(obj.getQaFwxw())); //加分合计 LongAdder empAdd = new LongAdder(); empAdd.add(judge(obj.getQaSpts())); empAdd.add(judge(obj.getQaGlxxh())); //总分值 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(BisInspQaScoreSd bisInspQaScoreSd) { Map map = new HashMap<>(4); map.put("rgstrId",bisInspQaScoreSd.getRgstrId()); map.put("param","qa"); map.put("total",bisInspQaScoreSd.getTotal()); bisInspQaSdService.updateState(map); } }