package cn.com.goldenwater.dcproj.service.impl.fjpjmgdp; import cn.com.goldenwater.dcproj.dao.BisInspFjpjmgdpDao; import cn.com.goldenwater.dcproj.dao.BisInspFjpjmgdpSystemDao; import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl; import cn.com.goldenwater.dcproj.model.BisInspFjpjlglSystem; import cn.com.goldenwater.dcproj.model.BisInspFjpjmgdp; import cn.com.goldenwater.dcproj.model.BisInspFjpjmgdpSystem; import cn.com.goldenwater.dcproj.param.BisInspFjpjmgdpSystemParam; import cn.com.goldenwater.dcproj.service.BisInspFjpjmgdpSystemService; import cn.com.goldenwater.core.service.AbstractCrudService; 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.List; import java.util.Date; import java.util.Objects; /** * @author lhc * @date 2023-11-8 */ @Service @Transactional public class BisInspFjpjmgdpSystemServiceImpl extends AbstractCrudService implements BisInspFjpjmgdpSystemService { @Autowired private BisInspFjpjmgdpSystemDao bisInspFjpjmgdpSystemDao; @Autowired private BisInspFjpjmgdpDao bisInspFjpjmgdpDao; public BisInspFjpjmgdpSystemServiceImpl(BisInspFjpjmgdpSystemDao bisInspFjpjmgdpSystemDao) { super(bisInspFjpjmgdpSystemDao); this.bisInspFjpjmgdpSystemDao = bisInspFjpjmgdpSystemDao; } @Override public int insert(BisInspFjpjmgdpSystem bisInspFjpjmgdpSystem) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspFjpjmgdpSystem.setId(uuid); bisInspFjpjmgdpSystem.setIntm(new Date()); bisInspFjpjmgdpSystem.setUptm(new Date()); bisInspFjpjmgdpSystem.setDataStat("0"); int insert = this.bisInspFjpjmgdpSystemDao.insert(bisInspFjpjmgdpSystem); scoreProcessing(bisInspFjpjmgdpSystem); return insert; } @Override public int update(BisInspFjpjmgdpSystem bisInspFjpjmgdpSystem) { bisInspFjpjmgdpSystem.setUptm(new Date()); scoreProcessing(bisInspFjpjmgdpSystem); return this.bisInspFjpjmgdpSystemDao.update(bisInspFjpjmgdpSystem); } @Override public int delete(String id) { return this.bisInspFjpjmgdpSystemDao.delete(id); } /** * 分数处理 * * @param obj 对象 */ private void scoreProcessing(BisInspFjpjmgdpSystem obj) { Double total1 = 0.0;//合计 Double lac1 = 0.0;//缺项合计 if(obj.getF211()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF211(); } if(obj.getF212()==null){ lac1 = lac1 + 5.0; }else{ total1= total1+obj.getF212(); } if(obj.getF213()==null){ lac1 = lac1 + 7.0; }else{ total1= total1+obj.getF213(); } if(obj.getF221()==null){ lac1 = lac1 + 15.0; }else{ total1= total1+obj.getF221(); } if(obj.getF222()==null){ lac1 = lac1 + 10.0; }else{ total1= total1+obj.getF222(); } if(obj.getF231()==null){ lac1 = lac1 + 10.0; }else{ total1= total1+obj.getF231(); } if(obj.getF232()==null){ lac1 = lac1 + 5.0; }else{ total1= total1+obj.getF232(); } if(obj.getF233()==null){ lac1 = lac1 + 10.0; }else{ total1= total1+obj.getF233(); } if(obj.getF241()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF241(); } if(obj.getF242()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF242(); } if(obj.getF243()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF243(); } if(obj.getF244()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF244(); } if(obj.getF245()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF245(); } BisInspFjpjmgdp rgstr = bisInspFjpjmgdpDao.get(obj.getRgstrId()); if (rgstr == null) { throw new CheckException("未找到此登记表"); } //算总分和缺项、评分率 Double tatl = judge(total1)+judge(rgstr.getTrgtTatl())+judge(rgstr.getTvetTatl())+judge(rgstr.getImgrTatl()) + judge(rgstr.getSafdlTatl())+judge(rgstr.getEmTatl())+judge(rgstr.getAmTatl())+judge(rgstr.getCimtTatl()); Double lacSoc = judge(lac1)+judge(rgstr.getTrgtLac())+judge(rgstr.getTvetLac())+judge(rgstr.getImgrLac()) + judge(rgstr.getSafdlLac())+judge(rgstr.getEmLac())+judge(rgstr.getAmLac())+judge(rgstr.getCimtLac()); BisInspFjpjmgdp bisInspFjpjlgl = new BisInspFjpjmgdp(); bisInspFjpjlgl.setId(rgstr.getId()); bisInspFjpjlgl.setSystemTatl(total1); bisInspFjpjlgl.setSystemLac(lac1); bisInspFjpjlgl.setSystemStat(obj.getState()); //设置总分和评定得分 if(tatl!=null || tatl != 0){ bisInspFjpjlgl.setTatl(Math.round(tatl*10.0)/10.0); Double soc = 1000-lacSoc; if(soc!=null && soc != 0){ Double ratSoc = tatl/(1000-lacSoc)*100; bisInspFjpjlgl.setRatSoc(Math.round(ratSoc*10.0)/10.0); } } bisInspFjpjlgl.setState("1"); bisInspFjpjlgl.setUptm(new Date()); bisInspFjpjmgdpDao.update(bisInspFjpjlgl); } private Double judge(Double value) { if (Objects.isNull(value)) { return 0.0; } return value; } }