| | |
| | | import com.moon.server.entity.all.StaticData; |
| | | import com.moon.server.entity.ctrl.PubEntity; |
| | | import com.moon.server.entity.data.MetaEntity; |
| | | import com.moon.server.entity.data.MetaPubEntity; |
| | | import com.moon.server.entity.data.PublishEntity; |
| | | import com.moon.server.helper.PathHelper; |
| | | import com.moon.server.helper.RestHelper; |
| | | import com.moon.server.helper.StringHelper; |
| | | import com.moon.server.helper.WebHelper; |
| | | import com.moon.server.mapper.data.PublishMapper; |
| | | import com.moon.server.service.sys.TokenService; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.lang.reflect.Field; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 数据发布 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | @SuppressWarnings("ALL") |
| | | public class PublishService implements PublishMapper { |
| | | @Value("${sys.exportServer}") |
| | | private String exportServer; |
| | | |
| | | @Value("${sys.iisHost}") |
| | | private String iisHost; |
| | | |
| | | @Resource |
| | | PublishMapper publishMapper; |
| | | |
| | | @Resource |
| | | PathHelper pathHelper; |
| | | |
| | | private final static Log log = LogFactory.getLog(PublishService.class); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<MetaEntity> selectMetasByPubid(Integer pubid) { |
| | | return publishMapper.selectMetasByPubid(pubid); |
| | | } |
| | | |
| | | @Override |
| | | public List<PublishEntity> selectRaster() { |
| | | return publishMapper.selectRaster(); |
| | | } |
| | | |
| | | @Override |
| | | public PublishEntity selectByLayerId(Integer layerId) { |
| | | return publishMapper.selectByLayerId(layerId); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> selectCodesForDir(String dircode, Integer isDom) { |
| | | return publishMapper.selectCodesForDir(dircode, isDom); |
| | | } |
| | |
| | | @Override |
| | | public Integer insertPubDown(Integer pubid, Integer downid, Integer createUser) { |
| | | return publishMapper.insertPubDown(pubid, downid, createUser); |
| | | } |
| | | |
| | | @Override |
| | | public Integer insertMetaPub(MetaPubEntity mp) { |
| | | return publishMapper.insertMetaPub(mp); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return publishMapper.selectMetasByPage(depcode, dircode, verid, types, name, limit, offset); |
| | | } |
| | | |
| | | public List<Integer> selectLasCs(PubEntity entity, String method, HttpServletRequest req) { |
| | | Map<String, Object> map = getMapData(entity); |
| | | |
| | | String str = RestHelper.postForRest(exportServer + method, map); |
| | | if (StringHelper.isEmpty(str)) { |
| | | return null; |
| | | } |
| | | |
| | | ResponseMsg<String> msg = JSON.parseObject(str, ResponseMsg.class); |
| | | if (msg == null || msg.getCode() != StaticData.TWO_HUNDRED) { |
| | | return null; |
| | | } |
| | | |
| | | String rs = msg.getResult(); |
| | | if (StringHelper.isEmpty(rs)) { |
| | | return null; |
| | | } |
| | | |
| | | return StringHelper.strToIntegers(rs); |
| | | } |
| | | |
| | | /** |
| | | * 发送发布请求 |
| | | */ |
| | | public long postForPub(PubEntity entity, String method, HttpServletRequest req) { |
| | | Map<String, Object> map = getMapData(entity); |
| | | |
| | |
| | | return msg.getCount(); |
| | | } |
| | | |
| | | /** |
| | | * 获取Map数据 |
| | | */ |
| | | private Map<String, Object> getMapData(PubEntity entity) { |
| | | Map<String, Object> map = new HashMap<>(3); |
| | | |
| | |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 获取服务类型 |
| | | */ |
| | | private String getServerType(PublishEntity entity) { |
| | | switch (entity.getType()) { |
| | | case "DOM": |
| | | return "TMS服务"; |
| | | case "DEM": |
| | | return "三维地形服务"; |
| | | case "mpt": |
| | | return "三维场景服务"; |
| | | case "las": |
| | | case "laz": |
| | | case "cpt": |
| | | return "三维点云服务"; |
| | | default: |
| | | return "三维模型服务"; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除多条 |
| | | */ |
| | | public Integer deletes(List<Integer> idList, HttpServletRequest req) { |
| | | String ids = StringHelper.join(idList, ","); |
| | | |
| | | return deletes(ids); |
| | | } |
| | | |
| | | /** |
| | | * 删除发布文件 |
| | | */ |
| | | public void deleteFiles(List<PublishEntity> list) { |
| | | String lfData = pathHelper.getConfig().getLfData(); |
| | | for (PublishEntity pub : list) { |
| | | if (null != pub.getUrl() && pub.getUrl().contains("/SG/")) { |
| | | continue; |
| | | } |
| | | |
| | | String path = lfData + pub.getPath().replace("\\tileset.json", ""); |
| | | File file = new File(path); |
| | | if (!file.exists() || !file.isDirectory()) { |
| | | continue; |
| | | } |
| | | |
| | | String cmd = String.format("cmd /c rd \"%s\" /s /q", path); |
| | | WebHelper.exec(cmd); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 发送发布请求 |
| | | */ |
| | | public long postForPub(PubEntity entity, String method) { |
| | | Map<String, Object> map = getMapData(entity); |
| | | |