package cn.com.goldenwater.dcproj.service.impl.fjpjlgl; import cn.com.goldenwater.dcproj.dao.BisInspFjpjlglDao; import cn.com.goldenwater.dcproj.dao.BisInspFjpjlglTvetDao; import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl; import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTrgt; import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTvet; import cn.com.goldenwater.dcproj.param.BisInspFjpjlglTvetParam; import cn.com.goldenwater.dcproj.service.BisInspFjpjlglTvetService; 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-7 */ @Service @Transactional public class BisInspFjpjlglTvetServiceImpl extends AbstractCrudService implements BisInspFjpjlglTvetService { @Autowired private BisInspFjpjlglTvetDao bisInspFjpjlglTvetDao; @Autowired private BisInspFjpjlglDao bisInspFjpjlglDao; public BisInspFjpjlglTvetServiceImpl(BisInspFjpjlglTvetDao bisInspFjpjlglTvetDao) { super(bisInspFjpjlglTvetDao); this.bisInspFjpjlglTvetDao = bisInspFjpjlglTvetDao; } @Override public int insert(BisInspFjpjlglTvet bisInspFjpjlglTvet) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspFjpjlglTvet.setId(uuid); bisInspFjpjlglTvet.setIntm(new Date()); bisInspFjpjlglTvet.setUptm(new Date()); bisInspFjpjlglTvet.setDataStat("0"); int insert = bisInspFjpjlglTvetDao.insert(bisInspFjpjlglTvet); scoreProcessing(bisInspFjpjlglTvet); return insert; } @Override public int update(BisInspFjpjlglTvet bisInspFjpjlglTvet) { bisInspFjpjlglTvet.setUptm(new Date()); scoreProcessing(bisInspFjpjlglTvet); return this.bisInspFjpjlglTvetDao.update(bisInspFjpjlglTvet); } @Override public int delete(String id) { return this.bisInspFjpjlglTvetDao.delete(id); } /** * 分数处理 * * @param obj 对象 */ private void scoreProcessing(BisInspFjpjlglTvet obj) { Double total1 = 0.0;//合计 Double lac1 = 0.0;//缺项合计 if(obj.getF311()==null){ lac1 = lac1 + 5.0; }else{ total1= total1+obj.getF311(); } if(obj.getF312()==null){ lac1 = lac1 + 5.0; }else{ total1= total1+obj.getF312(); } if(obj.getF321()==null){ lac1 = lac1 + 15.0; }else{ total1= total1+obj.getF321(); } if(obj.getF322()==null){ lac1 = lac1 + 8.0; }else{ total1= total1+obj.getF322(); } if(obj.getF323()==null){ lac1 = lac1 + 10.0; }else{ total1= total1+obj.getF323(); } if(obj.getF324()==null){ lac1 = lac1 + 7.0; }else{ total1= total1+obj.getF324(); } if(obj.getF325()==null){ lac1 = lac1 + 5.0; }else{ total1= total1+obj.getF325(); } if(obj.getF326()==null){ lac1 = lac1 + 5.0; }else{ total1= total1+obj.getF326(); } BisInspFjpjlgl rgstr = bisInspFjpjlglDao.get(obj.getRgstrId()); if (rgstr == null) { throw new CheckException("未找到此登记表"); } //算总分和缺项、评分率 Double tatl = judge(total1)+ judge(rgstr.getSystemTatl())+judge(rgstr.getTrgtTatl())+judge(rgstr.getImgrTatl()) + judge(rgstr.getSafdlTatl())+judge(rgstr.getEmTatl())+judge(rgstr.getAmTatl())+judge(rgstr.getCimtTatl()); Double lacSoc = judge(lac1)+ judge(rgstr.getSystemLac())+judge(rgstr.getTrgtLac())+judge(rgstr.getImgrLac()) + judge(rgstr.getSafdlLac())+judge(rgstr.getEmLac())+judge(rgstr.getAmLac())+judge(rgstr.getCimtLac()); BisInspFjpjlgl bisInspFjpjlgl = new BisInspFjpjlgl(); bisInspFjpjlgl.setId(rgstr.getId()); bisInspFjpjlgl.setTvetTatl(total1); bisInspFjpjlgl.setTvetLac(lac1); bisInspFjpjlgl.setTvetStat(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()); bisInspFjpjlglDao.update(bisInspFjpjlgl); } private Double judge(Double value) { if (Objects.isNull(value)) { return 0.0; } return value; } }