|
@@ -0,0 +1,113 @@
|
|
|
+package com.huimv.production.service.impl;
|
|
|
+
|
|
|
+import com.huimv.production.domain.MSowAnimalHeatEntity;
|
|
|
+import com.huimv.production.repo.MSowAnimalHeatEntityRepo;
|
|
|
+import com.huimv.production.repo.MSowAnimalHeatEntityRepo;
|
|
|
+import com.huimv.production.result.Result;
|
|
|
+import com.huimv.production.service.MSowAnimalHeatService;
|
|
|
+import com.huimv.production.service.MTransferFattentService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Project : huimv.shiwan
|
|
|
+ * @Package : com.huimv.production.service.impl
|
|
|
+ * @Description : TODO
|
|
|
+ * @Author : yuxuexuan
|
|
|
+ * @Create : 2021/3/9 0009 17:43
|
|
|
+ **/
|
|
|
+@Service
|
|
|
+public class MSowAnimalHeatServiceImpl implements MSowAnimalHeatService {
|
|
|
+ @Autowired
|
|
|
+ private MSowAnimalHeatEntityRepo fattenEntityRepo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result add(MSowAnimalHeatEntity childcareEntity) {
|
|
|
+ if (childcareEntity == null){
|
|
|
+ return new Result(10002,"请输入参数");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String measureDatetime = childcareEntity.getMeasureDatetime();
|
|
|
+ //2021-03-03 00:00:00
|
|
|
+ childcareEntity.setMeasureDate(measureDatetime.substring(0,10));
|
|
|
+ childcareEntity.setMeasureTime(measureDatetime.substring(11));
|
|
|
+ fattenEntityRepo.save(childcareEntity);
|
|
|
+ return new Result(10000,"添加成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(10001,"添加失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result remove(Integer[] ids) {
|
|
|
+ if (ids == null || ids.length==0){
|
|
|
+ return new Result(10002,"请选择要删除的数据");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ for (Integer id : ids) {
|
|
|
+ fattenEntityRepo.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new Result(10000,"删除成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(10001,"删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result update(MSowAnimalHeatEntity childcareEntity) {
|
|
|
+ if (childcareEntity == null){
|
|
|
+ return new Result(10002,"请选择要修改的值");
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ fattenEntityRepo.save(childcareEntity);
|
|
|
+ return new Result(10000,"修改成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(10001,"修改失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result findAll() {
|
|
|
+ try {
|
|
|
+ List<MSowAnimalHeatEntity> all = fattenEntityRepo.findAll();
|
|
|
+ return new Result(10000,"查询成功",all);
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(10001,"查询失败",null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result findAllById(Integer locationId) {
|
|
|
+
|
|
|
+ List list = new ArrayList();
|
|
|
+
|
|
|
+ List<MSowAnimalHeatEntity> allByLocationId = fattenEntityRepo.findAllByLocationId(locationId);
|
|
|
+ for (MSowAnimalHeatEntity o : allByLocationId) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("heat",o.getHeat());
|
|
|
+ map.put("time",o.getMeasureTime());
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ List list2 = new ArrayList();
|
|
|
+ List<List> allBy = fattenEntityRepo.findAllBy();
|
|
|
+ for (List list1 : allBy) {
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("heat",list1.get(0));
|
|
|
+ map.put("time",list1.get(1));
|
|
|
+ list2.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("groupHeat",list);
|
|
|
+ map.put("unitHeat",list2);
|
|
|
+ return new Result(10000,"查询成功",map);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|