| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- package cn.com.goldenwater.dcproj.service.impl.fjpjmgdp;
- import cn.com.goldenwater.dcproj.dao.BisInspFjpjmgdpDao;
- import cn.com.goldenwater.dcproj.dao.BisInspFjpjmgdpEmDao;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjlglEm;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjmgdp;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjmgdpEm;
- import cn.com.goldenwater.dcproj.param.BisInspFjpjmgdpEmParam;
- import cn.com.goldenwater.dcproj.service.BisInspFjpjmgdpEmService;
- 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 BisInspFjpjmgdpEmServiceImpl extends AbstractCrudService<BisInspFjpjmgdpEm, BisInspFjpjmgdpEmParam> implements BisInspFjpjmgdpEmService {
- @Autowired
- private BisInspFjpjmgdpEmDao bisInspFjpjmgdpEmDao;
- @Autowired
- private BisInspFjpjmgdpDao bisInspFjpjmgdpDao;
- public BisInspFjpjmgdpEmServiceImpl(BisInspFjpjmgdpEmDao bisInspFjpjmgdpEmDao) {
- super(bisInspFjpjmgdpEmDao);
- this.bisInspFjpjmgdpEmDao = bisInspFjpjmgdpEmDao;
- }
- @Override
- public int insert(BisInspFjpjmgdpEm bisInspFjpjmgdpEm) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspFjpjmgdpEm.setId(uuid);
- bisInspFjpjmgdpEm.setIntm(new Date());
- bisInspFjpjmgdpEm.setUptm(new Date());
- bisInspFjpjmgdpEm.setDataStat("0");
- int insert = this.bisInspFjpjmgdpEmDao.insert(bisInspFjpjmgdpEm);
- scoreProcessing(bisInspFjpjmgdpEm);
- return insert;
- }
- @Override
- public int update(BisInspFjpjmgdpEm bisInspFjpjmgdpEm) {
- bisInspFjpjmgdpEm.setUptm(new Date());
- scoreProcessing(bisInspFjpjmgdpEm);
- return this.bisInspFjpjmgdpEmDao.update(bisInspFjpjmgdpEm);
- }
- @Override
- public int delete(String id) {
- return this.bisInspFjpjmgdpEmDao.delete(id);
- }
- /**
- * 分数处理
- *
- * @param obj 对象
- */
- private void scoreProcessing(BisInspFjpjmgdpEm obj) {
- Double total1 = 0.0;//合计
- Double lac1 = 0.0;//缺项合计
- if(obj.getF611()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF611();
- }
- if(obj.getF612()==null){
- lac1 = lac1 + 10.0;
- }else{
- total1= total1+obj.getF612();
- }
- if(obj.getF613()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF613();
- }
- if(obj.getF614()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF614();
- }
- if(obj.getF615()==null){
- lac1 = lac1 + 10.0;
- }else{
- total1= total1+obj.getF615();
- }
- if(obj.getF616()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF616();
- }
- if(obj.getF621()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF621();
- }
- if(obj.getF622()==null){
- lac1 = lac1 + 2.0;
- }else{
- total1= total1+obj.getF622();
- }
- if(obj.getF631()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF631();
- }
- BisInspFjpjmgdp rgstr = bisInspFjpjmgdpDao.get(obj.getRgstrId());
- if (rgstr == null) {
- throw new CheckException("未找到此登记表");
- }
- //算总分和缺项、评分率
- Double tatl = judge(total1)+
- judge(rgstr.getSystemTatl())+judge(rgstr.getTrgtTatl())+judge(rgstr.getTvetTatl())
- + judge(rgstr.getImgrTatl())+judge(rgstr.getSafdlTatl())+judge(rgstr.getAmTatl())+judge(rgstr.getCimtTatl());
- Double lacSoc = judge(lac1)+
- judge(rgstr.getSystemLac())+judge(rgstr.getTrgtLac())+judge(rgstr.getTvetLac())
- + judge(rgstr.getImgrLac())+judge(rgstr.getSafdlLac())+judge(rgstr.getAmLac())+judge(rgstr.getCimtLac());
- BisInspFjpjmgdp bisInspFjpjlgl = new BisInspFjpjmgdp();
- bisInspFjpjlgl.setId(rgstr.getId());
- bisInspFjpjlgl.setEmTatl(total1);
- bisInspFjpjlgl.setEmLac(lac1);
- bisInspFjpjlgl.setEmStat(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;
- }
- }
|