| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- package cn.com.goldenwater.dcproj.service.impl.fjaccp;
- import cn.com.goldenwater.dcproj.dao.BisInspFjaccpDao;
- import cn.com.goldenwater.dcproj.dao.BisInspFjaccpTrgtDao;
- import cn.com.goldenwater.dcproj.model.BisInspFjaccp;
- import cn.com.goldenwater.dcproj.model.BisInspFjaccpTrgt;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjlgl;
- import cn.com.goldenwater.dcproj.model.BisInspFjpjlglTrgt;
- import cn.com.goldenwater.dcproj.param.BisInspFjaccpTrgtParam;
- import cn.com.goldenwater.dcproj.service.BisInspFjaccpTrgtService;
- 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 BisInspFjaccpTrgtServiceImpl extends AbstractCrudService<BisInspFjaccpTrgt, BisInspFjaccpTrgtParam> implements BisInspFjaccpTrgtService {
- @Autowired
- private BisInspFjaccpTrgtDao bisInspFjaccpTrgtDao;
- @Autowired
- private BisInspFjaccpDao bisInspFjaccpDao;
- public BisInspFjaccpTrgtServiceImpl(BisInspFjaccpTrgtDao bisInspFjaccpTrgtDao) {
- super(bisInspFjaccpTrgtDao);
- this.bisInspFjaccpTrgtDao = bisInspFjaccpTrgtDao;
- }
- @Override
- public int insert(BisInspFjaccpTrgt bisInspFjaccpTrgt) {
- String uuid = UuidUtil.uuid(); // 生成uuid
- bisInspFjaccpTrgt.setId(uuid);
- bisInspFjaccpTrgt.setIntm(new Date());
- bisInspFjaccpTrgt.setUptm(new Date());
- bisInspFjaccpTrgt.setDataStat("0");
- int insert = bisInspFjaccpTrgtDao.insert(bisInspFjaccpTrgt);
- scoreProcessing(bisInspFjaccpTrgt);
- return insert;
- }
- @Override
- public int update(BisInspFjaccpTrgt bisInspFjaccpTrgt) {
- bisInspFjaccpTrgt.setUptm(new Date());
- scoreProcessing(bisInspFjaccpTrgt);
- return this.bisInspFjaccpTrgtDao.update(bisInspFjaccpTrgt);
- }
- @Override
- public int delete(String id) {
- return this.bisInspFjaccpTrgtDao.delete(id);
- }
- /**
- * 分数处理
- *
- * @param obj 对象
- */
- private void scoreProcessing(BisInspFjaccpTrgt obj) {
- Double total1 = 0.0;//合计
- Double lac1 = 0.0;//缺项合计
- if(obj.getF111()==null){
- lac1 = lac1 + 2.0;
- }else{
- total1= total1+obj.getF111();
- }
- if(obj.getF112()==null){
- lac1 = lac1 + 3.0;
- }else{
- total1= total1+obj.getF112();
- }
- if(obj.getF113()==null){
- lac1 = lac1 + 4.0;
- }else{
- total1= total1+obj.getF113();
- }
- if(obj.getF114()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF114();
- }
- if(obj.getF115()==null){
- lac1 = lac1 + 6.0;
- }else{
- total1= total1+obj.getF115();
- }
- if(obj.getF116()==null){
- lac1 = lac1 + 10.0;
- }else{
- total1= total1+obj.getF116();
- }
- if(obj.getF121()==null){
- lac1 = lac1 + 4.0;
- }else{
- total1= total1+obj.getF121();
- }
- if(obj.getF122()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF122();
- }
- if(obj.getF123()==null){
- lac1 = lac1 + 6.0;
- }else{
- total1= total1+obj.getF123();
- }
- if(obj.getF124()==null){
- lac1 = lac1 + 9.0;
- }else{
- total1= total1+obj.getF124();
- }
- if(obj.getF125()==null){
- lac1 = lac1 + 4.0;
- }else{
- total1= total1+obj.getF125();
- }
- if(obj.getF131()==null){
- lac1 = lac1 + 8.0;
- }else{
- total1= total1+obj.getF131();
- }
- if(obj.getF132()==null){
- lac1 = lac1 + 6.0;
- }else{
- total1= total1+obj.getF132();
- }
- if(obj.getF141()==null){
- lac1 = lac1 + 2.0;
- }else{
- total1= total1+obj.getF141();
- }
- if(obj.getF142()==null){
- lac1 = lac1 + 15.0;
- }else{
- total1= total1+obj.getF142();
- }
- if(obj.getF143()==null){
- lac1 = lac1 + 8.0;
- }else{
- total1= total1+obj.getF143();
- }
- if(obj.getF144()==null){
- lac1 = lac1 + 18.0;
- }else{
- total1= total1+obj.getF144();
- }
- if(obj.getF145()==null){
- lac1 = lac1 + 7.0;
- }else{
- total1= total1+obj.getF145();
- }
- if(obj.getF146()==null){
- lac1 = lac1 + 8.0;
- }else{
- total1= total1+obj.getF146();
- }
- if(obj.getF151()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF151();
- }
- if(obj.getF152()==null){
- lac1 = lac1 + 5.0;
- }else{
- total1= total1+obj.getF152();
- }
- if(obj.getF161()==null){
- lac1 = lac1 + 10.0;
- }else{
- total1= total1+obj.getF161();
- }
- BisInspFjaccp rgstr = bisInspFjaccpDao.get(obj.getRgstrId());
- if (rgstr == null) {
- throw new CheckException("未找到此登记表");
- }
- //算总分和缺项、评分率
- Double tatl = judge(total1)+judge(rgstr.getSystemTatl())+judge(rgstr.getTvetTatl())+judge(rgstr.getImgrTatl())
- + judge(rgstr.getSafdlTatl())+judge(rgstr.getEmTatl())+judge(rgstr.getAmTatl())+judge(rgstr.getCimtTatl());
- Double lacSoc = judge(lac1)+judge(rgstr.getSystemLac())+judge(rgstr.getTvetLac())+judge(rgstr.getImgrLac())
- + judge(rgstr.getSafdlLac())+judge(rgstr.getEmLac())+judge(rgstr.getAmLac())+judge(rgstr.getCimtLac());
- BisInspFjaccp bisInspFj = new BisInspFjaccp();
- bisInspFj.setId(rgstr.getId());
- bisInspFj.setTrgtTatl(total1);
- bisInspFj.setTrgtLac(lac1);
- bisInspFj.setTrgtStat(obj.getState());
- //设置总分和评定得分
- if(tatl!=null || tatl != 0){
- bisInspFj.setTatl(Math.round(tatl*10.0)/10.0);
- Double soc = 1000-lacSoc;
- if(soc!=null && soc != 0){
- Double ratSoc = tatl/(1000-lacSoc)*100;
- bisInspFj.setRatSoc(Math.round(ratSoc*10.0)/10.0);
- }
- }
- bisInspFj.setState("1");
- bisInspFj.setUptm(new Date());
- bisInspFjaccpDao.update(bisInspFj);
- }
- private Double judge(Double value) {
- if (Objects.isNull(value)) {
- return 0.0;
- }
- return value;
- }
- }
|