package cn.com.goldenwater.dcproj.service.impl; import cn.com.goldenwater.dcproj.dao.BisInspQymtenMsrDao; import cn.com.goldenwater.dcproj.model.BisInspQymtenMsr; import cn.com.goldenwater.dcproj.model.BisInspStstnScene; import cn.com.goldenwater.dcproj.param.BisInspQymtenMsrParam; import cn.com.goldenwater.dcproj.service.BisInspQymtenMsrService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.service.BisInspQymtenService; import cn.com.goldenwater.dcproj.utils.Constant; 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.HashMap; import java.util.List; import java.util.Date; import java.util.Map; /** * @author lhc * @date 2021-7-19 */ @Service @Transactional public class BisInspQymtenMsrServiceImpl extends AbstractCrudService implements BisInspQymtenMsrService { @Autowired private BisInspQymtenMsrDao bisInspQymtenMsrDao; @Autowired private BisInspQymtenService bisInspQymtenService; public BisInspQymtenMsrServiceImpl(BisInspQymtenMsrDao bisInspQymtenMsrDao) { super(bisInspQymtenMsrDao); this.bisInspQymtenMsrDao = bisInspQymtenMsrDao; } @Override public int insert(BisInspQymtenMsr bisInspQymtenMsr) { BisInspQymtenMsr msr = get(bisInspQymtenMsr.getRgstrId()); if (msr != null){ bisInspQymtenMsr.setId(msr.getId()); return update(bisInspQymtenMsr); } String uuid = UuidUtil.uuid(); // 生成uuid bisInspQymtenMsr.setId(uuid); bisInspQymtenMsr.setIntm(new Date()); bisInspQymtenMsr.setUptm(new Date()); bisInspQymtenMsr.setDataStat("0"); // bisInspQymtenMsr.setScore(score(bisInspQymtenMsr)); return this.bisInspQymtenMsrDao.insert(bisInspQymtenMsr); } @Override public int update(BisInspQymtenMsr bisInspQymtenMsr) { BisInspQymtenMsr msr = get(bisInspQymtenMsr.getRgstrId()); if(msr == null){ throw new CheckException("未找到此登记表下的子表"); } bisInspQymtenMsr.setId(msr.getId()); bisInspQymtenMsr.setUptm(new Date()); updateRgstrState(bisInspQymtenMsr); return bisInspQymtenMsrDao.update(bisInspQymtenMsr); } private void updateRgstrState(BisInspQymtenMsr bisInspQymtenMsr) { Map map = new HashMap<>(4); map.put("rgstrId",bisInspQymtenMsr.getRgstrId()); map.put("param","msr"); map.put("state",bisInspQymtenMsr.getState()); map.put("score",bisInspQymtenMsr.getScore()); bisInspQymtenService.updateState(map); } @Override public int delete(String id) { return this.bisInspQymtenMsrDao.delete(id); } private double judge(Double value){ if (value == null){ return 0; } return value; } private Double score(BisInspQymtenMsr bisInspQymtenMsr){ Double score = 100.0; score=score-judge(bisInspQymtenMsr.getQyPrgNum())- judge(bisInspQymtenMsr.getQyMeritNum())- judge(bisInspQymtenMsr.getCmpNum())- judge(bisInspQymtenMsr.getSysNum())- judge(bisInspQymtenMsr.getQyDutyNum())- judge(bisInspQymtenMsr.getQySprNum())- judge(bisInspQymtenMsr.getMrtDutyNum())- judge(bisInspQymtenMsr.getCrdSysNum())- judge(bisInspQymtenMsr.getQyMendNum())- judge(bisInspQymtenMsr.getQyUpNum())- judge(bisInspQymtenMsr.getNewMendNum())- judge(bisInspQymtenMsr.getQyDtctNum())- judge(bisInspQymtenMsr.getQyChkNum())- judge(bisInspQymtenMsr.getQyInfoNum())- judge(bisInspQymtenMsr.getMrtMendNum())- judge(bisInspQymtenMsr.getBuldSysNum())- judge(bisInspQymtenMsr.getQyPubNum())- judge(bisInspQymtenMsr.getQyPerformDutyNum())+ judge(bisInspQymtenMsr.getOtherNum())+ judge(bisInspQymtenMsr.getHghNum())+ judge(bisInspQymtenMsr.getQySysNum()); return score; } }