|
@@ -4,9 +4,12 @@ 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.DataSource;
|
|
|
import com.huimv.cattle.pojo.IndustryOutput;
|
|
|
import com.huimv.cattle.mapper.IndustryOutputMapper;
|
|
|
+import com.huimv.cattle.pojo.OnlineService;
|
|
|
import com.huimv.cattle.pojo.SubsidyCount;
|
|
|
+import com.huimv.cattle.service.DataSourceService;
|
|
|
import com.huimv.cattle.service.IndustryOutputService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.huimv.cattle.token.TokenSign;
|
|
@@ -17,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -32,7 +36,8 @@ import java.util.*;
|
|
|
public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper, IndustryOutput> implements IndustryOutputService {
|
|
|
@Autowired
|
|
|
private IndustryOutputMapper industryOutputMapper;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private DataSourceService dataSourceService;
|
|
|
@Autowired
|
|
|
private DateUtil dateUtil;
|
|
|
|
|
@@ -67,6 +72,7 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
|
|
|
|
|
|
@Override
|
|
|
public Result saveIndustryOutput(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
+
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
if (StringUtils.isBlank(farmCode)) {
|
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
@@ -90,6 +96,41 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
|
|
|
return new Result(ResultCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result getIndustryOutputScreen(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
+ DataSource dataSource = dataSourceService.getDataSourceStatus();
|
|
|
+ if (dataSource.getDsStatus() == 1 && dataSource.getViewType() ==2) {
|
|
|
+ List<IndustryOutput> industryOutputs = industryOutputMapper.getIndustryOutputScreen();
|
|
|
+ return new Result(ResultCode.SUCCESS,industryOutputs);
|
|
|
+ }
|
|
|
+
|
|
|
+ String farmCode = paramsMap.get("farmCode");
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
|
+ farmCode = TokenSign.getFarmCode(request);
|
|
|
+ }
|
|
|
+ String yearNum = paramsMap.get("yearNum");
|
|
|
+// if (StringUtils.isBlank(yearNum)){
|
|
|
+// yearNum = "0";
|
|
|
+// }
|
|
|
+ QueryWrapper<IndustryOutput> queryWrapper = new QueryWrapper<IndustryOutput>();
|
|
|
+ if (StringUtils.isNotBlank(yearNum)) {
|
|
|
+ queryWrapper.between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()));
|
|
|
+ // queryWrapper.last("LIMIT "+yearNum);
|
|
|
+ }
|
|
|
+ queryWrapper.eq("farm_code", farmCode);
|
|
|
+ queryWrapper.orderByDesc("year");
|
|
|
+
|
|
|
+ List<IndustryOutput> industryOutputs = industryOutputMapper.selectList(queryWrapper);
|
|
|
+ if (industryOutputs.isEmpty()) {
|
|
|
+ IndustryOutput industryOutput = new IndustryOutput();
|
|
|
+ industryOutput.setYear(dateUtil.getThisYear());
|
|
|
+ industryOutput.setFarmCode(farmCode);
|
|
|
+ industryOutputMapper.insert(industryOutput);
|
|
|
+ industryOutputs.add(industryOutput);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS, industryOutputs);
|
|
|
+ }
|
|
|
+
|
|
|
private Boolean checkRepeat(List<IndustryOutput> list) {
|
|
|
List<String> collectionOptionList = new ArrayList<>();
|
|
|
for (IndustryOutput a : list) {
|