| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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<BisInspQaScoreSd, BisInspQaScoreSdParam> 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<String,Object> map = new HashMap<>(4);
- map.put("rgstrId",bisInspQaScoreSd.getRgstrId());
- map.put("param","qa");
- map.put("total",bisInspQaScoreSd.getTotal());
- bisInspQaSdService.updateState(map);
- }
- }
|