| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package cn.com.goldenwater.dcproj.service.impl.fjpjmgdp;
- import cn.com.goldenwater.dcproj.dao.BisInspFjpjmgdpAmDao;
- import cn.com.goldenwater.dcproj.dao.BisInspFjpjmgdpDao;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjlglAm;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjmgdp;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjmgdpAm;
- import cn.com.goldenwater.dcproj.param.BisInspFjpjmgdpAmParam;
- import cn.com.goldenwater.dcproj.service.BisInspFjpjmgdpAmService;
- 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 BisInspFjpjmgdpAmServiceImpl extends AbstractCrudService<BisInspFjpjmgdpAm, BisInspFjpjmgdpAmParam> implements BisInspFjpjmgdpAmService {
- @Autowired
- private BisInspFjpjmgdpAmDao bisInspFjpjmgdpAmDao;
- @Autowired
- private BisInspFjpjmgdpDao bisInspFjpjmgdpDao;
- public BisInspFjpjmgdpAmServiceImpl(BisInspFjpjmgdpAmDao bisInspFjpjmgdpAmDao) {
- super(bisInspFjpjmgdpAmDao);
- this.bisInspFjpjmgdpAmDao = bisInspFjpjmgdpAmDao;
- }
- @Override
- public int insert(BisInspFjpjmgdpAm bisInspFjpjmgdpAm) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspFjpjmgdpAm.setId(uuid);
- bisInspFjpjmgdpAm.setIntm(new Date());
- bisInspFjpjmgdpAm.setUptm(new Date());
- bisInspFjpjmgdpAm.setDataStat("0");
- int insert = this.bisInspFjpjmgdpAmDao.insert(bisInspFjpjmgdpAm);
- scoreProcessing(bisInspFjpjmgdpAm);
- return insert;
- }
- @Override
- public int update(BisInspFjpjmgdpAm bisInspFjpjmgdpAm) {
- bisInspFjpjmgdpAm.setUptm(new Date());
- scoreProcessing(bisInspFjpjmgdpAm);
- return this.bisInspFjpjmgdpAmDao.update(bisInspFjpjmgdpAm);
- }
- @Override
- public int delete(String id) {
- return this.bisInspFjpjmgdpAmDao.delete(id);
- }
- /**
- * 分数处理
- *
- * @param obj 对象
- */
- private void scoreProcessing(BisInspFjpjmgdpAm obj) {
- Double total1 = 0.0;//合计
- Double lac1 = 0.0;//缺项合计
- if(obj.getF711()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF711();
- }
- if(obj.getF712()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF712();
- }
- if(obj.getF721()==null){
- lac1 = lac1 + 4.0;
- }else{
- total1= total1+obj.getF721();
- }
- if(obj.getF722()==null){
- lac1 = lac1 + 7.0;
- }else{
- total1= total1+obj.getF722();
- }
- if(obj.getF723()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF723();
- }
- if(obj.getF724()==null){
- lac1 = lac1 + 4.0;
- }else{
- total1= total1+obj.getF724();
- }
- if(obj.getF725()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF725();
- }
- if(obj.getF731()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF731();
- }
- 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.getEmTatl())+judge(rgstr.getCimtTatl());
- Double lacSoc = judge(lac1)+
- judge(rgstr.getSystemLac())+judge(rgstr.getTrgtLac())+judge(rgstr.getTvetLac())
- + judge(rgstr.getImgrLac())+judge(rgstr.getSafdlLac())+judge(rgstr.getEmLac())+judge(rgstr.getCimtLac());
- BisInspFjpjmgdp bisInspFjpjlgl = new BisInspFjpjmgdp();
- bisInspFjpjlgl.setId(rgstr.getId());
- bisInspFjpjlgl.setAmTatl(total1);
- bisInspFjpjlgl.setAmLac(lac1);
- bisInspFjpjlgl.setAmStat(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;
- }
- }
|