|
@@ -8,12 +8,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.huimv.cattle.pojo.DataSource;
|
|
import com.huimv.cattle.pojo.DataSource;
|
|
import com.huimv.cattle.pojo.PreventDetection;
|
|
import com.huimv.cattle.pojo.PreventDetection;
|
|
import com.huimv.cattle.pojo.SalesCattle;
|
|
import com.huimv.cattle.pojo.SalesCattle;
|
|
|
|
+import com.huimv.cattle.pojo.SysFarm;
|
|
import com.huimv.cattle.pojo.vo.SalesCattleVo;
|
|
import com.huimv.cattle.pojo.vo.SalesCattleVo;
|
|
import com.huimv.cattle.service.DataSourceService;
|
|
import com.huimv.cattle.service.DataSourceService;
|
|
import com.huimv.cattle.service.SalesCattleService;
|
|
import com.huimv.cattle.service.SalesCattleService;
|
|
|
|
+import com.huimv.cattle.service.SysFarmService;
|
|
import com.huimv.cattle.utils.FarmCodeUtils;
|
|
import com.huimv.cattle.utils.FarmCodeUtils;
|
|
import com.huimv.common.utils.Result;
|
|
import com.huimv.common.utils.Result;
|
|
import com.huimv.common.utils.ResultCode;
|
|
import com.huimv.common.utils.ResultCode;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpEntity;
|
|
import org.springframework.http.HttpEntity;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
@@ -44,6 +47,8 @@ import java.util.Map;
|
|
public class SalesCattleController {
|
|
public class SalesCattleController {
|
|
@Autowired
|
|
@Autowired
|
|
private SalesCattleService salesCattleService;
|
|
private SalesCattleService salesCattleService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysFarmService farmService;
|
|
@Resource
|
|
@Resource
|
|
private DataSourceService dataSourceService;
|
|
private DataSourceService dataSourceService;
|
|
@Resource
|
|
@Resource
|
|
@@ -88,23 +93,42 @@ public class SalesCattleController {
|
|
//view=2,显示镇汇总数据
|
|
//view=2,显示镇汇总数据
|
|
if (dataSource.getDsStatus() == 1) {
|
|
if (dataSource.getDsStatus() == 1) {
|
|
//status=1,显示镇汇总(手填)数据
|
|
//status=1,显示镇汇总(手填)数据
|
|
- return salesCattleService.getSalesCattle(farmCode);
|
|
|
|
|
|
+ return salesCattleService.getAllSaleCattle(farmCode);
|
|
} else {
|
|
} else {
|
|
//status=2,显示镇汇总(养殖云)数据
|
|
//status=2,显示镇汇总(养殖云)数据
|
|
System.out.println("status=2,显示镇汇总(养殖云)数据");
|
|
System.out.println("status=2,显示镇汇总(养殖云)数据");
|
|
- return getSalesByDivision(farmCode);
|
|
|
|
|
|
+ String farmCodes = getFarmCodeByAdcode(farmCode);
|
|
|
|
+ if (StringUtils.isBlank(farmCodes)){
|
|
|
|
+ return new Result(ResultCode.SUCCESS,new ArrayList<>());
|
|
|
|
+ }
|
|
|
|
+ return getSalesByDivision(farmCodes);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private String getFarmCodeByAdcode(String farmCode) {
|
|
|
|
+ String adcode = "620826";
|
|
|
|
+ if (!"0".equals(farmCode)){
|
|
|
|
+ SysFarm list = farmService.getOne(new QueryWrapper<SysFarm>().eq("farm_code", farmCode));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(list)){
|
|
|
|
+ String[] split = list.getAdcode().split(",");
|
|
|
|
+ adcode = split[split.length-1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ String remoteUrl = "http://123.60.134.84:10001/admin/v1.0.0/account/getFarmCodeByAdcode";
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("adcode",adcode);
|
|
|
|
+ ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity(remoteUrl, map, String.class);
|
|
|
|
+ return stringResponseEntity.getBody();
|
|
}
|
|
}
|
|
|
|
|
|
- private Result getSalesByDivision(String farmCode) {
|
|
|
|
|
|
+ private Result getSalesByDivision(String farmCodes) {
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
MediaType type = MediaType.parseMediaType("application/json;charset=UTF-8");
|
|
MediaType type = MediaType.parseMediaType("application/json;charset=UTF-8");
|
|
httpHeaders.setContentType(type);
|
|
httpHeaders.setContentType(type);
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
//这里提交的是区县编码或乡镇编码
|
|
//这里提交的是区县编码或乡镇编码
|
|
- map.put("farmCode", farmCode);
|
|
|
|
|
|
+ map.put("farmCodes", farmCodes);
|
|
HttpEntity<Map<String, Object>> objectHttpEntity = new HttpEntity<>(map, httpHeaders);
|
|
HttpEntity<Map<String, Object>> objectHttpEntity = new HttpEntity<>(map, httpHeaders);
|
|
//读取真实数据
|
|
//读取真实数据
|
|
String remoteUrl = "http://123.60.134.84:10001/breed/api/v1.0.0/cattle/getSalesByDivision";
|
|
String remoteUrl = "http://123.60.134.84:10001/breed/api/v1.0.0/cattle/getSalesByDivision";
|