|
@@ -23,7 +23,7 @@ import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
- * 服务实现类
|
|
|
|
|
|
+ * 服务实现类
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @author zn
|
|
* @author zn
|
|
@@ -40,42 +40,45 @@ public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacit
|
|
@Override
|
|
@Override
|
|
public Result getProductionCapacity(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
public Result getProductionCapacity(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
String farmCode = paramsMap.get("farmCode");
|
|
String farmCode = paramsMap.get("farmCode");
|
|
- if (StringUtils.isBlank(farmCode)){
|
|
|
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
}
|
|
}
|
|
String yearNum = paramsMap.get("yearNum");
|
|
String yearNum = paramsMap.get("yearNum");
|
|
- if (StringUtils.isBlank(yearNum)){
|
|
|
|
- yearNum = "0";
|
|
|
|
|
|
+// if (StringUtils.isBlank(yearNum)){
|
|
|
|
+// yearNum = "0";
|
|
|
|
+// }
|
|
|
|
+ QueryWrapper<ProductionCapacity> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ if (StringUtils.isNotBlank(yearNum)) {
|
|
|
|
+ queryWrapper.between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()));
|
|
}
|
|
}
|
|
- List<ProductionCapacity> productionCapacities = productionCapacityMapper.selectList(new QueryWrapper<ProductionCapacity>()
|
|
|
|
-// .between("year", Integer.valueOf(dateUtil.getThisYear()) - Integer.valueOf(yearNum), Integer.valueOf(dateUtil.getThisYear()))
|
|
|
|
- .eq("farm_code",farmCode)
|
|
|
|
- .orderByDesc("year"));
|
|
|
|
- if (ObjectUtil.isEmpty(productionCapacities)){
|
|
|
|
|
|
+ queryWrapper.eq("farm_code", farmCode);
|
|
|
|
+ queryWrapper.orderByDesc("year");
|
|
|
|
+ List<ProductionCapacity> productionCapacities = productionCapacityMapper.selectList(queryWrapper);
|
|
|
|
+ if (ObjectUtil.isEmpty(productionCapacities)) {
|
|
ProductionCapacity productionCapacity1 = new ProductionCapacity();
|
|
ProductionCapacity productionCapacity1 = new ProductionCapacity();
|
|
productionCapacity1.setYear(Integer.valueOf(dateUtil.getThisYear()));
|
|
productionCapacity1.setYear(Integer.valueOf(dateUtil.getThisYear()));
|
|
productionCapacity1.setFarmCode(farmCode);
|
|
productionCapacity1.setFarmCode(farmCode);
|
|
productionCapacities.add(productionCapacity1);
|
|
productionCapacities.add(productionCapacity1);
|
|
productionCapacityMapper.insert(productionCapacity1);
|
|
productionCapacityMapper.insert(productionCapacity1);
|
|
}
|
|
}
|
|
- return new Result(ResultCode.SUCCESS,productionCapacities);
|
|
|
|
|
|
+ return new Result(ResultCode.SUCCESS, productionCapacities);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result saveProductionCapacity(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
public Result saveProductionCapacity(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
String farmCode = paramsMap.get("farmCode");
|
|
String farmCode = paramsMap.get("farmCode");
|
|
- if (StringUtils.isBlank(farmCode)){
|
|
|
|
|
|
+ if (StringUtils.isBlank(farmCode)) {
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
}
|
|
}
|
|
String list = paramsMap.get("list");
|
|
String list = paramsMap.get("list");
|
|
JSONArray listJa = JSONArray.parseArray(list);
|
|
JSONArray listJa = JSONArray.parseArray(list);
|
|
List<ProductionCapacity> productionCapacityList = listJa.toJavaList(ProductionCapacity.class);
|
|
List<ProductionCapacity> productionCapacityList = listJa.toJavaList(ProductionCapacity.class);
|
|
if (checkRepeat(productionCapacityList)) {
|
|
if (checkRepeat(productionCapacityList)) {
|
|
- return new Result(10001,"有重复年份",false);
|
|
|
|
- }else {
|
|
|
|
|
|
+ return new Result(10001, "有重复年份", false);
|
|
|
|
+ } else {
|
|
productionCapacityMapper.deleteAll(farmCode);
|
|
productionCapacityMapper.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);
|
|
JSONObject jsonObject = listJa.getJSONObject(a);
|
|
Integer year = jsonObject.getInteger("year");
|
|
Integer year = jsonObject.getInteger("year");
|
|
ProductionCapacity productionCapacity = new ProductionCapacity();
|
|
ProductionCapacity productionCapacity = new ProductionCapacity();
|
|
@@ -87,12 +90,12 @@ public class ProductionCapacityServiceImpl extends ServiceImpl<ProductionCapacit
|
|
return new Result(ResultCode.SUCCESS);
|
|
return new Result(ResultCode.SUCCESS);
|
|
}
|
|
}
|
|
|
|
|
|
- private Boolean checkRepeat(List<ProductionCapacity> list){
|
|
|
|
|
|
+ private Boolean checkRepeat(List<ProductionCapacity> list) {
|
|
List<Integer> collectionOptionList = new ArrayList<>();
|
|
List<Integer> collectionOptionList = new ArrayList<>();
|
|
- for (ProductionCapacity a : list){
|
|
|
|
|
|
+ for (ProductionCapacity a : list) {
|
|
collectionOptionList.add(a.getYear());
|
|
collectionOptionList.add(a.getYear());
|
|
}
|
|
}
|
|
Set<Integer> set = new HashSet<>(collectionOptionList);
|
|
Set<Integer> set = new HashSet<>(collectionOptionList);
|
|
- return collectionOptionList.size()!= set.size();
|
|
|
|
|
|
+ return collectionOptionList.size() != set.size();
|
|
}
|
|
}
|
|
}
|
|
}
|