package cn.com.goldenwater.dcproj.service.impl.fjaccp; import cn.com.goldenwater.dcproj.dao.BisInspFjaccpDao; import cn.com.goldenwater.dcproj.dao.BisInspFjaccpTvetDao; import cn.com.goldenwater.dcproj.model.BisInspFjaccp; import cn.com.goldenwater.dcproj.model.BisInspFjaccpTvet; import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl; import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTvet; import cn.com.goldenwater.dcproj.param.BisInspFjaccpTvetParam; import cn.com.goldenwater.dcproj.service.BisInspFjaccpTvetService; 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 BisInspFjaccpTvetServiceImpl extends AbstractCrudService implements BisInspFjaccpTvetService { @Autowired private BisInspFjaccpTvetDao bisInspFjaccpTvetDao; @Autowired private BisInspFjaccpDao bisInspFjaccpDao; public BisInspFjaccpTvetServiceImpl(BisInspFjaccpTvetDao bisInspFjaccpTvetDao) { super(bisInspFjaccpTvetDao); this.bisInspFjaccpTvetDao = bisInspFjaccpTvetDao; } @Override public int insert(BisInspFjaccpTvet bisInspFjaccpTvet) { String uuid = UuidUtil.uuid(); // 生成uuid bisInspFjaccpTvet.setId(uuid); bisInspFjaccpTvet.setIntm(new Date()); bisInspFjaccpTvet.setUptm(new Date()); bisInspFjaccpTvet.setDataStat("0"); int insert = this.bisInspFjaccpTvetDao.insert(bisInspFjaccpTvet); scoreProcessing(bisInspFjaccpTvet); return insert; } @Override public int update(BisInspFjaccpTvet bisInspFjaccpTvet) { bisInspFjaccpTvet.setUptm(new Date()); scoreProcessing(bisInspFjaccpTvet); return this.bisInspFjaccpTvetDao.update(bisInspFjaccpTvet); } @Override public int delete(String id) { return this.bisInspFjaccpTvetDao.delete(id); } /** * 分数处理 * * @param obj 对象 */ private void scoreProcessing(BisInspFjaccpTvet obj) { Double total1 = 0.0;//合计 Double lac1 = 0.0;//缺项合计 if(obj.getF311()==null){ lac1 = lac1 + 2.0; }else{ total1= total1+obj.getF311(); } if(obj.getF312()==null){ lac1 = lac1 + 8.0; }else{ total1= total1+obj.getF312(); } if(obj.getF321()==null){ lac1 = lac1 + 8.0; }else{ total1= total1+obj.getF321(); } if(obj.getF322()==null){ lac1 = lac1 + 15.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 + 5.0; }else{ total1= total1+obj.getF324(); } if(obj.getF325()==null){ lac1 = lac1 + 9.0; }else{ total1= total1+obj.getF325(); } if(obj.getF326()==null){ lac1 = lac1 + 3.0; }else{ total1= total1+obj.getF326(); } BisInspFjaccp rgstr = bisInspFjaccpDao.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()); BisInspFjaccp bisInspFjpjlgl = new BisInspFjaccp(); 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()); bisInspFjaccpDao.update(bisInspFjpjlgl); } private Double judge(Double value) { if (Objects.isNull(value)) { return 0.0; } return value; } }