| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.pro.packaged.P; |
| | | import liquibase.pro.packaged.W; |
| | | import liquibase.repackaged.org.apache.commons.lang3.StringUtils; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.IdUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | |
| | | import org.springblade.modules.grid.mapper.GridMapper; |
| | | import org.springblade.modules.grid.service.IGridRangeService; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | | import org.springblade.modules.label.entity.LabelEntity; |
| | | import org.springblade.modules.partyOrganization.vo.PartyOrganizationVO; |
| | | import org.springblade.modules.place.entity.*; |
| | | import org.springblade.modules.place.excel.ExportPlaceExcel; |
| | | import org.springblade.modules.place.excel.NinePlaceExcel; |
| | | import org.springblade.modules.place.excel.PlaceAndRelExcel; |
| | | import org.springblade.modules.place.excel.PlaceExcel; |
| | | import org.springblade.modules.place.excel.ImportPlaceExcel; |
| | | import org.springblade.modules.place.service.*; |
| | | import org.springblade.modules.place.vo.PlaceCheckVO; |
| | | import org.springblade.modules.place.vo.PlacePoiLabelVO; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.place.mapper.PlaceMapper; |
| | | import org.springblade.modules.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.DictBiz; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IDictBizService; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springblade.modules.task.vo.TaskLabelReportingEventVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | public void importPlace(List<PlaceExcel> data, Boolean isCovered) { |
| | | for (PlaceExcel placeExcel : data) { |
| | | public String importPlace(List<ImportPlaceExcel> data, Boolean isCovered) { |
| | | int totalNum = data.size(); |
| | | int importNum = 0; |
| | | int updateNum = 0; |
| | | int errorNum = 0; |
| | | for (ImportPlaceExcel placeExcel : data) { |
| | | if (Strings.isBlank(placeExcel.getPlaceName()) || Strings.isBlank(placeExcel.getHouseCode())){ |
| | | errorNum++; |
| | | continue; |
| | | } |
| | | PlaceEntity placeEntity = Objects.requireNonNull(BeanUtil.copy(placeExcel, PlaceEntity.class)); |
| | | Long userId = updateUser(placeExcel); |
| | | // 九小场所类型处理 |
| | | if (!Strings.isBlank(placeExcel.getNineType())) { |
| | | placeEntity.setIsNine(1); |
| | | placeEntity.setNineType(Integer.parseInt(placeExcel.getNineType())); |
| | | } |
| | | // 阵地类型处理 |
| | | if (!Strings.isBlank(placeExcel.getFrontType())) { |
| | | placeEntity.setIsFront(1); |
| | | placeEntity.setFrontType(Integer.parseInt(placeExcel.getFrontType())); |
| | | } |
| | | // 无诈类别 |
| | | if (!Strings.isBlank(placeExcel.getNoExplosionCategory())){ |
| | | placeEntity.setNoExplosionCategory(Integer.parseInt(placeExcel.getNoExplosionCategory())); |
| | | } |
| | | // 三级单位 |
| | | if (!Strings.isBlank(placeExcel.getThreeFireProtection())){ |
| | | if (placeExcel.getThreeFireProtection().equals("是")){ |
| | | placeEntity.setThreeFireProtection(1); |
| | | } |
| | | if (placeExcel.getThreeFireProtection().equals("否")){ |
| | | placeEntity.setThreeFireProtection(2); |
| | | } |
| | | } |
| | | String[] split = placeExcel.getHouseCode().split(","); |
| | | placeEntity.setHouseCode(split[0]); |
| | | placeEntity.setHouseCodeBinds(placeExcel.getHouseCode()); |
| | | placeEntity.setPrincipalUserId(userId); |
| | | // houseCode 关联处理 来源 1:地址总表 2:国控采集 3:商超 |
| | | houseCodeHandle(placeExcel, placeEntity); |
| | | // 网格绑定处理 |
| | | importGridHandle(placeExcel, placeEntity); |
| | | // 判断是否存在,不存在则插入,否则不操作 |
| | | QueryWrapper<PlaceEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("house_code", placeExcel.getHouseCode()); |
| | | PlaceEntity one = getOne(wrapper); |
| | | Long userId = updateUser(placeExcel); |
| | | if (null == one) { |
| | | // 插入场所 |
| | | String[] split = placeExcel.getHouseCode().split(","); |
| | | placeEntity.setHouseCode(split[0]); |
| | | placeEntity.setHouseCodeBinds(placeExcel.getHouseCode()); |
| | | placeEntity.setPrincipalUserId(userId); |
| | | // 默认为未完善 |
| | | placeEntity.setStatus(1); |
| | | // 是否现场采集 1:是 2:否 |
| | | placeEntity.setIsScene(1); |
| | | // houseCode 关联处理 来源 1:地址总表 2:国控采集 3:商超 |
| | | houseCodeHandle(placeExcel, placeEntity); |
| | | // 九小场所类型处理 |
| | | if (!Strings.isBlank(placeExcel.getNineType())) { |
| | | placeEntity.setIsNine(1); |
| | | placeEntity.setNineType(Integer.parseInt(placeExcel.getNineType())); |
| | | } |
| | | // 网格绑定处理 |
| | | importGridHandle(placeExcel, placeEntity); |
| | | // 新增 |
| | | save(placeEntity); |
| | | importNum++; |
| | | // 保存详情 |
| | | savePlaceExt(placeEntity,placeExcel); |
| | | // 场所标签信息处理 |
| | |
| | | // 房屋编号绑定处理 |
| | | houseCodeBindHandle(placeEntity); |
| | | } else { |
| | | // 更新场所 |
| | | one.setPrincipalUserId(userId); |
| | | one.setPrincipal(placeExcel.getPrincipal()); |
| | | one.setPrincipalPhone(placeExcel.getPrincipalPhone()); |
| | | // 默认为未完善 |
| | | one.setStatus(1); |
| | | // 是否现场采集 1:是 2:否 |
| | | one.setIsScene(1); |
| | | // 来源 1:地址总表 2:国控采集 3:商超 |
| | | one.setSource(1); |
| | | // 九小场所类型处理 |
| | | if (!Strings.isBlank(placeExcel.getNineType())) { |
| | | one.setIsNine(1); |
| | | one.setNineType(Integer.parseInt(placeExcel.getNineType())); |
| | | } |
| | | // 网格绑定处理 |
| | | importGridHandle(placeExcel, one); |
| | | // 更新 |
| | | updateById(one); |
| | | // 场所标签信息处理 |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(one.getId()); |
| | | placeVO.setLabel(placeExcel.getLabelCode()); |
| | | // 处理 |
| | | placeLabelBind(placeVO); |
| | | updateNum++; |
| | | // 是否覆盖更新 |
| | | if (isCovered) { |
| | | // 更新场所 |
| | | placeEntity.setId(one.getId()); |
| | | // 更新 |
| | | updateById(placeEntity); |
| | | importNum++; |
| | | // 场所标签信息处理 |
| | | if (!Strings.isBlank(placeExcel.getLabelCode())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(one.getId()); |
| | | placeVO.setLabel(placeExcel.getLabelCode()); |
| | | // 处理 |
| | | placeLabelBind(placeVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | StringBuilder builder = new StringBuilder("导入完成!"); |
| | | builder.append("其中本次表格共有 ").append(totalNum).append(" 条数据,") |
| | | .append("成功导入 ").append(importNum).append(" 条数据。"); |
| | | if (updateNum>0) { |
| | | builder.append("其中有 ").append(updateNum).append(" 条数据已存在。"); |
| | | } |
| | | if (errorNum>0){ |
| | | builder.append("共有 ").append(errorNum).append(" 条数据由于无企业(店铺)名称信息或无地址编号未导入!"); |
| | | } |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param placeExcel |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void savePlaceExt(PlaceEntity placeEntity,PlaceExcel placeExcel) { |
| | | public void savePlaceExt(PlaceEntity placeEntity, ImportPlaceExcel placeExcel) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | | placeVO.setId(placeEntity.getId()); |
| | | PlaceExtEntity placeExtEntity = new PlaceExtEntity(); |
| | |
| | | * @param placeExcel |
| | | * @param placeEntity |
| | | */ |
| | | public void houseCodeHandle(PlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | public void houseCodeHandle(ImportPlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (!Strings.isBlank(placeExcel.getHouseCode())) { |
| | | placeEntity.setSource(1); |
| | | // 设置经纬度及地址 |
| | |
| | | * @param placeExcel |
| | | * @param placeEntity |
| | | */ |
| | | private void importGridHandle(PlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | private void importGridHandle(ImportPlaceExcel placeExcel, PlaceEntity placeEntity) { |
| | | if (!Strings.isBlank(placeExcel.getCommunityName()) && |
| | | !Strings.isBlank(placeExcel.getGridName())) { |
| | | // 查询对应的网格信息 |
| | |
| | | * @param placeExcel |
| | | * @return |
| | | */ |
| | | public Long updateUser(PlaceExcel placeExcel) { |
| | | public Long updateUser(ImportPlaceExcel placeExcel) { |
| | | if (!Strings.isBlank(placeExcel.getPrincipal()) && |
| | | !Strings.isBlank(placeExcel.getPrincipalPhone())) { |
| | | PlaceVO placeVO = new PlaceVO(); |
| | |
| | | public String getCommunityCode(Long id) { |
| | | return baseMapper.getCommunityCode(id); |
| | | } |
| | | |
| | | /** |
| | | * 导出场所信息 |
| | | * @param place |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ExportPlaceExcel> exportPlaceList(PlaceVO place) { |
| | | // 公共参数设置 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(PlaceVO.class, place); |
| | | return baseMapper.exportPlaceList(place, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator() |
| | | ); |
| | | } |
| | | } |