| | |
| | | package com.yuanchu.limslaboratory.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.limslaboratory.mapper.InstrumentMapper; |
| | | import com.yuanchu.limslaboratory.mapper.MetricalInformationMapper; |
| | | import com.yuanchu.limslaboratory.pojo.*; |
| | | import com.yuanchu.limslaboratory.mapper.MeteringPlanMapper; |
| | | import com.yuanchu.limslaboratory.pojo.dto.AddPlanDto; |
| | | import com.yuanchu.limslaboratory.pojo.dto.GetPlanMeasureInstrumentDto; |
| | | import com.yuanchu.limslaboratory.pojo.dto.SelectMeasurementLedgerDto; |
| | | import com.yuanchu.limslaboratory.pojo.dto.SelectMeteringPlanDto; |
| | | import com.yuanchu.limslaboratory.pojo.vo.UserAndInsVo; |
| | | import com.yuanchu.limslaboratory.service.MeteringPlanService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.yuanchu.limslaboratory.utils.MyUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | private MeteringPlanMapper meteringPlanMapper; |
| | | |
| | | @Resource |
| | | private InstrumentMapper instrumentMapper; |
| | | |
| | | @Resource |
| | | private MetricalInformationMapper metricalInformationMapper; |
| | | |
| | | @Override |
| | | public Integer addMeteringPlanInformation(MeteringPlan meteringPlan) { |
| | | String timeSixNumber = MyUtil.getTimeSixNumberCode("P","P"); |
| | |
| | | List<MeteringPlanAndInfo> page= meteringPlanMapper |
| | | .limitConditionMeteringPlan(dto,new LimitPage((dto.getCurrentPage()-1)*dto.getPageSize(), dto.getPageSize())); |
| | | page.forEach(l->{ |
| | | AtomicBoolean haveZero= new AtomicBoolean(false); |
| | | l.getResultList().forEach(r->{ |
| | | if (r.getResult() < 1) { |
| | | l.setStatus(0); |
| | | if (r.getResult()<1) { |
| | | haveZero.set(true); |
| | | }else { |
| | | l.setStatus(1); |
| | | } |
| | | }); |
| | | if(haveZero.get()){ |
| | | l.setStatus(0); |
| | | } |
| | | l.setResultList(null); |
| | | }); |
| | | Map<String, Object>all=new HashMap<>(2); |
| | |
| | | ,dto.getPageSize()),dto.getId())); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public UserAndInsVo getListUserAndListIns(List<Map<String, Object>> userNameAndId) { |
| | | QueryWrapper<Instrument>queryWrapper=new QueryWrapper<Instrument>(); |
| | | queryWrapper.lambda() |
| | | .select(Instrument::getEquipmentName,Instrument::getId,Instrument::getMeasuringRange,Instrument::getTermValidity) |
| | | .eq(Instrument::getState,true); |
| | | List<Instrument> instruments = instrumentMapper.selectList(queryWrapper); |
| | | return new UserAndInsVo(userNameAndId,instruments); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean addPlanAndMeasure(Map<String, Object> userInfo, AddPlanDto addPlanDto) { |
| | | //计划添加 |
| | | MeteringPlan meteringPlan=new MeteringPlan(); |
| | | String timeSixNumber = MyUtil.getTimeSixNumberCode("P","P"); |
| | | meteringPlan.setPlannedOrderNumber(timeSixNumber); |
| | | meteringPlan.setCreatePerson(Integer.parseInt(String.valueOf(userInfo.get("id")))); |
| | | meteringPlan.setUnit(String.valueOf(addPlanDto.getPlan().get("unit"))); |
| | | meteringPlan |
| | | .setBeginTime(DateUtil. |
| | | parseDate(String.valueOf(addPlanDto.getPlan().get("startTime")))); |
| | | meteringPlan.setEndTime(DateUtil. |
| | | parseDate(String.valueOf(addPlanDto.getPlan().get("endTime")))); |
| | | meteringPlan.setCreateTime(DateUtil.date()); |
| | | meteringPlan.setMeasurePerson(Integer.parseInt(String.valueOf(addPlanDto.getPlan().get("measurePerson")))); |
| | | meteringPlan.setUpdateTime(DateUtil.date()); |
| | | meteringPlan.setPlanningStatus(3); |
| | | boolean addPlan = meteringPlanMapper.insert(meteringPlan) > 0; |
| | | //新增计量 |
| | | List<MetricalInformation>informationList=new ArrayList<>(); |
| | | addPlanDto.getMeasureList().forEach(l->{ |
| | | MetricalInformation info=new MetricalInformation(); |
| | | info.setInstrumentId(Integer.parseInt(String.valueOf(l.get("equipmentPointName")))); |
| | | info.setUserId(Integer.parseInt(String.valueOf(userInfo.get("id")))); |
| | | info.setCreateTime(DateUtil.date()); |
| | | Date endDate=Objects.nonNull(l.get("endDate"))?DateUtil.parseDate(String.valueOf(l.get("endDate"))):null; |
| | | info.setEndDate(endDate); |
| | | Integer result=Objects.nonNull(l.get("result"))?Integer.parseInt(String.valueOf(l.get("result"))):null; |
| | | info.setResult(result); |
| | | info.setMeasurementUnit(meteringPlan.getUnit()); |
| | | info.setCode(MyUtil.getTimeSixNumberCode("METRICALCODE","METRICALCODE")); |
| | | info.setUpdateTime(DateUtil.date()); |
| | | info.setPlan(meteringPlan.getId()); |
| | | informationList.add(info); |
| | | }); |
| | | return addPlan&&metricalInformationMapper.insertBatchInformation(informationList)>0; |
| | | } |
| | | |
| | | |
| | | } |