|
@@ -1,10 +1,23 @@
|
|
package com.huimv.cattle.service.impl;
|
|
package com.huimv.cattle.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.huimv.cattle.pojo.ProductionCapacity;
|
|
import com.huimv.cattle.pojo.ProductionCapacity;
|
|
import com.huimv.cattle.mapper.ProductionCapacityMapper;
|
|
import com.huimv.cattle.mapper.ProductionCapacityMapper;
|
|
|
|
+import com.huimv.cattle.pojo.SubsidyCount;
|
|
import com.huimv.cattle.service.ProductionCapacityService;
|
|
import com.huimv.cattle.service.ProductionCapacityService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.huimv.cattle.utils.DateUtil;
|
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -16,5 +29,42 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacityMapper, ProductionCapacity> implements ProductionCapacityService {
|
|
public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacityMapper, ProductionCapacity> implements ProductionCapacityService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductionCapacityMapper productionCapacityMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DateUtil dateUtil;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result getProductionCapacity(Map<String, String> paramsMap) {
|
|
|
|
+ String yearNum = paramsMap.get("yearNum");
|
|
|
|
+ List<ProductionCapacity> productionCapacity = productionCapacityMapper.getProductionCapacity(yearNum);
|
|
|
|
+ if (ObjectUtil.isEmpty(productionCapacity)){
|
|
|
|
+ ProductionCapacity productionCapacity1 = new ProductionCapacity();
|
|
|
|
+ productionCapacity1.setYear(Integer.valueOf(dateUtil.getThisYear()));
|
|
|
|
+ productionCapacity.add(productionCapacity1);
|
|
|
|
+ productionCapacityMapper.insert(productionCapacity1);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS,productionCapacity);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ //目前没有判断重复年份
|
|
|
|
+ public Result saveProductionCapacity(Map<String, String> paramsMap) {
|
|
|
|
+ productionCapacityMapper.deleteAll();
|
|
|
|
+ String list = paramsMap.get("list");
|
|
|
|
+ JSONArray listJa = JSONArray.parseArray(list);
|
|
|
|
+ for (int a = listJa.size()-1; a >= 0 ; a--){
|
|
|
|
+ JSONObject jsonObject = listJa.getJSONObject(a);
|
|
|
|
+ Integer year = jsonObject.getInteger("year");
|
|
|
|
+ ProductionCapacity productionCapacity = new ProductionCapacity();
|
|
|
|
+ productionCapacity.setYear(year);
|
|
|
|
+// if (ObjectUtil.isNotEmpty(productionCapacityMapper.selectOne(new QueryWrapper<ProductionCapacity>().eq("year",year)))){
|
|
|
|
+// return new Result(10001,"存在重复年份",false);
|
|
|
|
+// }
|
|
|
|
+ productionCapacity.setProductionCount(jsonObject.getInteger("productionCount"));
|
|
|
|
+ productionCapacityMapper.insert(productionCapacity);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
|
+ }
|
|
}
|
|
}
|