| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 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<BisInspFjpjlglTvet, BisInspFjpjlglTvetParam> 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;
- }
- }
|