|
@@ -1,6 +1,7 @@
|
|
|
package com.huimv.cattle.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.huimv.cattle.mapper.SysRegionCounTownVillMapper;
|
|
|
import com.huimv.cattle.pojo.DataSource;
|
|
|
import com.huimv.cattle.pojo.OnlineService;
|
|
|
import com.huimv.cattle.mapper.OnlineServiceMapper;
|
|
@@ -16,6 +17,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -32,25 +35,47 @@ public class OnlineServiceServiceImpl extends ServiceImpl<OnlineServiceMapper, O
|
|
|
private OnlineServiceMapper onlineServiceMapper;
|
|
|
@Resource
|
|
|
private DataSourceService dataSourceService;
|
|
|
+ @Autowired
|
|
|
+ private SysRegionCounTownVillMapper sysRegionCounTownVillMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Result getOnlineServiceScreen(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
- DataSource dataSource = dataSourceService.getDataSourceStatus();
|
|
|
- if (dataSource.getDsStatus() == 1 && dataSource.getViewType() ==2) {
|
|
|
- OnlineService onlineService = onlineServiceMapper.getOnlineServiceScreen();
|
|
|
- return new Result(ResultCode.SUCCESS,onlineService);
|
|
|
- }
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
if (StringUtils.isBlank(farmCode)){
|
|
|
farmCode = TokenSign.getFarmCode(request);
|
|
|
}
|
|
|
- OnlineService onlineService = onlineServiceMapper.getOnlineService(farmCode);
|
|
|
- if (ObjectUtil.isEmpty(onlineService)){
|
|
|
- onlineService = new OnlineService();
|
|
|
- onlineService.setTreatCount(0);
|
|
|
- onlineService.setDoctorCount(0);
|
|
|
- onlineService.setFarmerCount(0);
|
|
|
- onlineService.setFarmCode(farmCode);
|
|
|
- onlineServiceMapper.insert(onlineService);
|
|
|
+ OnlineService onlineService = new OnlineService();
|
|
|
+ String cityCode;
|
|
|
+ List<String> subCityList = new ArrayList<>();
|
|
|
+ DataSource dataSource = dataSourceService.getDataSourceStatus();
|
|
|
+ if (dataSource.getDsStatus() == 1 && dataSource.getViewType() ==2) {
|
|
|
+ if (farmCode == null || farmCode.equals("0")){
|
|
|
+ cityCode = sysRegionCounTownVillMapper.listSub(farmCode);
|
|
|
+ String[] city = cityCode.split(",");
|
|
|
+ onlineService = onlineServiceMapper.getOnlineServiceScreen(city);
|
|
|
+ }
|
|
|
+ }else if (dataSource.getDsStatus() == 1 && dataSource.getViewType() ==3){
|
|
|
+ cityCode = sysRegionCounTownVillMapper.listSub(farmCode);
|
|
|
+ String[] city = cityCode.split(",");
|
|
|
+ for (String s : city) {
|
|
|
+ String subCityCode = sysRegionCounTownVillMapper.listSub(s);
|
|
|
+ String[] strings = subCityCode.split(",");
|
|
|
+ for (String string : strings) {
|
|
|
+ subCityList.add(string);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String[] subCity = subCityList.toArray(new String[subCityList.size()]);
|
|
|
+ onlineService = onlineServiceMapper.getOnlineServiceScreen(subCity);
|
|
|
+ }else{
|
|
|
+ onlineService = onlineServiceMapper.getOnlineService(farmCode);
|
|
|
+ if (ObjectUtil.isEmpty(onlineService)){
|
|
|
+ onlineService = new OnlineService();
|
|
|
+ onlineService.setTreatCount(0);
|
|
|
+ onlineService.setDoctorCount(0);
|
|
|
+ onlineService.setFarmerCount(0);
|
|
|
+ onlineService.setFarmCode(farmCode);
|
|
|
+ onlineServiceMapper.insert(onlineService);
|
|
|
+ }
|
|
|
}
|
|
|
return new Result(ResultCode.SUCCESS,onlineService);
|
|
|
}
|