|
@@ -17,7 +17,9 @@ import com.usky.fire.service.BaseCompanyAttach1Service;
|
|
|
import com.usky.fire.service.BaseCompanyPersonService;
|
|
|
import com.usky.fire.service.BaseCompanyService;
|
|
|
import com.usky.fire.service.BaseUserCompanyService;
|
|
|
+import com.usky.fire.service.util.OnlineMethod;
|
|
|
import com.usky.fire.service.vo.CompanyDataVo;
|
|
|
+import com.usky.fire.service.vo.LocateInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -212,5 +214,111 @@ public class BaseCompanyServiceImpl extends AbstractCrudService<BaseCompanyMappe
|
|
|
this.updateById(baseCompany);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<Object> companyScatterer(String streetTown, String companyType) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<BaseCompany> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.select(BaseCompany::getId, BaseCompany::getCompanyId, BaseCompany::getCompanyName,
|
|
|
+ BaseCompany::getCompanyType, BaseCompany::getLinkPhone, BaseCompany::getAddress,BaseCompany::getStreetTown)
|
|
|
+ .eq(BaseCompany::getEnable, 0)
|
|
|
+ .eq(StringUtils.isNotBlank(streetTown), BaseCompany::getStreetTown, streetTown)
|
|
|
+ .eq(StringUtils.isNotBlank(companyType), BaseCompany::getCompanyType, companyType);
|
|
|
+ List<BaseCompany> list1 = this.list(queryWrapper);
|
|
|
+ if (CollectionUtils.isNotEmpty(list1)) {
|
|
|
+ List<String> companyIdList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ companyIdList.add(list1.get(i).getCompanyId());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<BaseCompanyAttach1> queryWrapper1 = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper1.select(BaseCompanyAttach1::getId,BaseCompanyAttach1::getCompanyId,BaseCompanyAttach1::getLongitude,
|
|
|
+ BaseCompanyAttach1::getLatitude)
|
|
|
+ .in(BaseCompanyAttach1::getCompanyId, companyIdList);
|
|
|
+ List<BaseCompanyAttach1> list2 = baseCompanyAttach1Service.list(queryWrapper1);
|
|
|
+ for (int i = 0; i < list1.size(); i++) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", list1.get(i).getId());
|
|
|
+ map.put("companyName", list1.get(i).getCompanyName());
|
|
|
+ String companyTyepName = null;
|
|
|
+ if (StringUtils.isNotBlank(list1.get(i).getCompanyType())) {
|
|
|
+ if (list1.get(i).getCompanyType().equals("1")) {
|
|
|
+ companyTyepName = "重点单位";
|
|
|
+ } else if (list1.get(i).getCompanyType().equals("2")) {
|
|
|
+ companyTyepName = "一般单位";
|
|
|
+ } else if (list1.get(i).getCompanyType().equals("3")) {
|
|
|
+ companyTyepName = "九小场所";
|
|
|
+ } else if (list1.get(i).getCompanyType().equals("9")) {
|
|
|
+ companyTyepName = "其他单位";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("companyTypeName", companyTyepName);
|
|
|
+ map.put("linkPhone", list1.get(i).getLinkPhone());
|
|
|
+ map.put("address", list1.get(i).getAddress());
|
|
|
+ map.put("longitude", null);
|
|
|
+ map.put("latitude", null);
|
|
|
+ map.put("streetTown", null);
|
|
|
+ for (int j = 0; j < list2.size(); j++) {
|
|
|
+ if (list1.get(i).getCompanyId().equals(list2.get(j).getCompanyId())) {
|
|
|
+ String longitude = null;
|
|
|
+ String latitude = null;
|
|
|
+ if ((StringUtils.isBlank(list2.get(j).getLongitude())&&StringUtils.isNotBlank(list1.get(i).getAddress()))) {
|
|
|
+ List<LocateInfo> lonLat = OnlineMethod.getLonLat(list1.get(i).getAddress());
|
|
|
+ if (CollectionUtils.isNotEmpty(lonLat)){
|
|
|
+ if (StringUtils.isBlank(list2.get(j).getLongitude())&&StringUtils.isBlank(list2.get(j).getLatitude())){
|
|
|
+ longitude = "" + lonLat.get(0).getLongitude();
|
|
|
+ latitude = "" + lonLat.get(0).getLatitude();
|
|
|
+ }else {
|
|
|
+ longitude = list2.get(j).getLongitude();
|
|
|
+ latitude = list2.get(j).getLatitude();
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(list1.get(i).getStreetTown())){
|
|
|
+ streetTown = lonLat.get(0).getStreet();
|
|
|
+ }else {
|
|
|
+ streetTown = list1.get(i).getStreetTown();
|
|
|
+ }
|
|
|
+ this.updateCompany1(list1.get(i).getId(), list2.get(j).getId(), longitude, latitude, streetTown);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ longitude = list2.get(j).getLongitude();
|
|
|
+ latitude = list2.get(j).getLatitude();
|
|
|
+ streetTown = list1.get(i).getStreetTown();
|
|
|
+ }
|
|
|
+ map.put("streetTown", streetTown);
|
|
|
+ map.put("longitude", longitude);
|
|
|
+ map.put("latitude", latitude);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (map.get("longitude") != null && map.get("latitude") != null) {
|
|
|
+ if (StringUtils.isNotBlank(streetTown)){
|
|
|
+ if (streetTown.equals(map.get("streetTown").toString())){
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void updateCompany1(Integer id1, Integer id2, String longitude, String latitude, String streetTown) {
|
|
|
+ BaseCompany baseCompany = new BaseCompany();
|
|
|
+ baseCompany.setId(id1);
|
|
|
+ baseCompany.setStreetTown(streetTown);
|
|
|
+ baseCompany.setUpdatePerson(SecurityUtils.getUsername());
|
|
|
+ baseCompany.setUpdateTime(LocalDateTime.now());
|
|
|
+ this.updateById(baseCompany);
|
|
|
+ BaseCompanyAttach1 baseCompanyAttach1 = new BaseCompanyAttach1();
|
|
|
+ baseCompanyAttach1.setId(id2);
|
|
|
+ baseCompanyAttach1.setLongitude(longitude);
|
|
|
+ baseCompanyAttach1.setLatitude(latitude);
|
|
|
+ baseCompanyAttach1.setUpdatePerson(SecurityUtils.getUsername());
|
|
|
+ baseCompanyAttach1.setUpdateTime(LocalDateTime.now());
|
|
|
+ baseCompanyAttach1Service.updateById(baseCompanyAttach1);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|