|
@@ -22,7 +22,7 @@ import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author zn
|
|
@@ -39,7 +39,7 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
|
|
|
@Override
|
|
|
public Result getIndustryOutput(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
- if (StringUtils.isBlank(farmCode)){
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
|
}
|
|
|
String yearNum = paramsMap.get("yearNum");
|
|
@@ -47,13 +47,13 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
|
|
|
// yearNum = "0";
|
|
|
// }
|
|
|
QueryWrapper<IndustryOutput> queryWrapper = new QueryWrapper<IndustryOutput>();
|
|
|
-// queryWrapper.between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()));
|
|
|
- if(StringUtils.isNotBlank(yearNum)) {
|
|
|
+ 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.eq("farm_code", farmCode);
|
|
|
queryWrapper.orderByDesc("year");
|
|
|
-// queryWrapper.last("LIMIT "+yearNum);
|
|
|
+
|
|
|
List<IndustryOutput> industryOutputs = industryOutputMapper.selectList(queryWrapper);
|
|
|
if (industryOutputs.isEmpty()) {
|
|
|
IndustryOutput industryOutput = new IndustryOutput();
|
|
@@ -62,24 +62,24 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
|
|
|
industryOutputMapper.insert(industryOutput);
|
|
|
industryOutputs.add(industryOutput);
|
|
|
}
|
|
|
- return new Result(ResultCode.SUCCESS,industryOutputs);
|
|
|
+ return new Result(ResultCode.SUCCESS, industryOutputs);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result saveIndustryOutput(HttpServletRequest request,Map<String, String> paramsMap) {
|
|
|
+ public Result saveIndustryOutput(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
- if (StringUtils.isBlank(farmCode)){
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
|
}
|
|
|
String list = paramsMap.get("list");
|
|
|
JSONArray listJa = JSONArray.parseArray(list);
|
|
|
List<IndustryOutput> industryOutputList = listJa.toJavaList(IndustryOutput.class);
|
|
|
if (checkRepeat(industryOutputList)) {
|
|
|
- return new Result(10001,"有重复年份",false);
|
|
|
- }else {
|
|
|
+ return new Result(10001, "有重复年份", false);
|
|
|
+ } else {
|
|
|
industryOutputMapper.deleteAll(farmCode);
|
|
|
}
|
|
|
- for (int a = listJa.size()-1; a >= 0 ; a--){
|
|
|
+ for (int a = listJa.size() - 1; a >= 0; a--) {
|
|
|
JSONObject jsonObject = listJa.getJSONObject(a);
|
|
|
IndustryOutput industryOutput = new IndustryOutput();
|
|
|
industryOutput.setYear(jsonObject.getString("year"));
|
|
@@ -90,12 +90,12 @@ public class IndustryOutputServiceImpl extends ServiceImpl<IndustryOutputMapper,
|
|
|
return new Result(ResultCode.SUCCESS);
|
|
|
}
|
|
|
|
|
|
- private Boolean checkRepeat(List<IndustryOutput> list){
|
|
|
+ private Boolean checkRepeat(List<IndustryOutput> list) {
|
|
|
List<String> collectionOptionList = new ArrayList<>();
|
|
|
- for (IndustryOutput a : list){
|
|
|
+ for (IndustryOutput a : list) {
|
|
|
collectionOptionList.add(a.getYear());
|
|
|
}
|
|
|
Set<String> set = new HashSet<>(collectionOptionList);
|
|
|
- return collectionOptionList.size()!= set.size();
|
|
|
+ return collectionOptionList.size() != set.size();
|
|
|
}
|
|
|
}
|