|
@@ -1,11 +1,22 @@
|
|
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.IndustryOutput;
|
|
import com.huimv.cattle.pojo.IndustryOutput;
|
|
import com.huimv.cattle.mapper.IndustryOutputMapper;
|
|
import com.huimv.cattle.mapper.IndustryOutputMapper;
|
|
import com.huimv.cattle.service.IndustryOutputService;
|
|
import com.huimv.cattle.service.IndustryOutputService;
|
|
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 java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -16,5 +27,38 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper, IndustryOutput> implements IndustryOutputService {
|
|
public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper, IndustryOutput> implements IndustryOutputService {
|
|
|
|
+ @Autowired
|
|
|
|
+ private IndustryOutputMapper industryOutputMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private DateUtil dateUtil;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result getIndustryOutput() {
|
|
|
|
+ QueryWrapper<IndustryOutput> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.orderByAsc("year");
|
|
|
|
+ List<IndustryOutput> industryOutputs = industryOutputMapper.selectList(queryWrapper);
|
|
|
|
+ if (industryOutputs.isEmpty()) {
|
|
|
|
+ IndustryOutput industryOutput = new IndustryOutput();
|
|
|
|
+ industryOutput.setYear(Integer.valueOf(dateUtil.getThisYear()));
|
|
|
|
+ industryOutputMapper.insert(industryOutput);
|
|
|
|
+ industryOutputs.add(industryOutput);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS,industryOutputs);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Result saveIndustryOutput(Map<String, String> paramsMap) {
|
|
|
|
+ industryOutputMapper.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);
|
|
|
|
+ IndustryOutput industryOutput = new IndustryOutput();
|
|
|
|
+ industryOutput.setYear(jsonObject.getInteger("year"));
|
|
|
|
+ industryOutput.setSalesMoney(jsonObject.getBigDecimal("salesMoney"));
|
|
|
|
+ industryOutputMapper.insert(industryOutput);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
|
+ }
|
|
}
|
|
}
|