|
@@ -4,13 +4,12 @@ import com.dderp.business.dao.PlatformDao;
|
|
|
import com.dderp.common.api.NoSqlKeysService;
|
|
import com.dderp.common.api.NoSqlKeysService;
|
|
|
import com.dderp.common.api.PlatformService;
|
|
import com.dderp.common.api.PlatformService;
|
|
|
import com.dderp.common.base.BaseService;
|
|
import com.dderp.common.base.BaseService;
|
|
|
-import com.dderp.common.datas.ESKeys;
|
|
|
|
|
|
|
+import com.dderp.common.datas.RedisKeys;
|
|
|
import com.dderp.common.datas.business.PlatformType;
|
|
import com.dderp.common.datas.business.PlatformType;
|
|
|
import com.dderp.common.entity.platform.PlatformInfo;
|
|
import com.dderp.common.entity.platform.PlatformInfo;
|
|
|
import com.dderp.common.entity.platform.PlatformRequire;
|
|
import com.dderp.common.entity.platform.PlatformRequire;
|
|
|
import com.dderp.common.entity.site.ERPTokenUser;
|
|
import com.dderp.common.entity.site.ERPTokenUser;
|
|
|
-import com.dderp.common.tool.ERPUtils;
|
|
|
|
|
-import com.dySweetFishPlugin.elasticsearch.ESClient;
|
|
|
|
|
|
|
+import com.dySweetFishPlugin.redis.RedisService;
|
|
|
import com.dySweetFishPlugin.sql.TableIdService;
|
|
import com.dySweetFishPlugin.sql.TableIdService;
|
|
|
import com.dySweetFishPlugin.sql.dao.TunaService;
|
|
import com.dySweetFishPlugin.sql.dao.TunaService;
|
|
|
import com.sweetfish.convert.json.JsonConvert;
|
|
import com.sweetfish.convert.json.JsonConvert;
|
|
@@ -21,29 +20,21 @@ import com.sweetfish.util.AnyValue;
|
|
|
import com.sweetfish.util.AutoLoad;
|
|
import com.sweetfish.util.AutoLoad;
|
|
|
import com.sweetfish.util.ResourceType;
|
|
import com.sweetfish.util.ResourceType;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.elasticsearch.action.DocWriteResponse;
|
|
|
|
|
-import org.elasticsearch.action.index.IndexResponse;
|
|
|
|
|
-import org.elasticsearch.action.support.WriteRequest;
|
|
|
|
|
-import org.elasticsearch.common.xcontent.XContentType;
|
|
|
|
|
-import org.elasticsearch.index.query.BoolQueryBuilder;
|
|
|
|
|
-import org.elasticsearch.index.query.Operator;
|
|
|
|
|
-import org.elasticsearch.index.query.QueryBuilders;
|
|
|
|
|
-import org.elasticsearch.search.sort.SortBuilders;
|
|
|
|
|
-import org.elasticsearch.search.sort.SortOrder;
|
|
|
|
|
import org.rex.RMap;
|
|
import org.rex.RMap;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.IOException;
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-
|
|
|
|
|
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
@AutoLoad(value = false)
|
|
@AutoLoad(value = false)
|
|
|
@Local
|
|
@Local
|
|
|
@ResourceType(PlatformService.class)
|
|
@ResourceType(PlatformService.class)
|
|
|
public class PlatformServiceImpl extends BaseService implements PlatformService {
|
|
public class PlatformServiceImpl extends BaseService implements PlatformService {
|
|
|
|
|
+
|
|
|
@Resource
|
|
@Resource
|
|
|
- private ESClient esClient;
|
|
|
|
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private JsonConvert jsonConvert;
|
|
private JsonConvert jsonConvert;
|
|
@@ -66,60 +57,59 @@ public class PlatformServiceImpl extends BaseService implements PlatformService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<PlatformInfo> queryPlatformList(RMap params, PageFlipper pageFlipper, long supplierCode) {
|
|
|
|
|
- List<PlatformInfo> platformInfoList = searchESList(esClient, jsonConvert,
|
|
|
|
|
- PlatformInfo.class,
|
|
|
|
|
- null,
|
|
|
|
|
- ((sd) -> {
|
|
|
|
|
- BoolQueryBuilder qb = QueryBuilders.boolQuery();
|
|
|
|
|
- qb = qb.must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE));
|
|
|
|
|
-
|
|
|
|
|
- if (ERPUtils.mapContainKey(params, "platformType")) {
|
|
|
|
|
- qb = qb.must(QueryBuilders.termQuery("platformType", params.getInt("platformType")));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (ERPUtils.mapContainKey(params, "platformName")) {
|
|
|
|
|
- String platformName = params.getString("platformName");
|
|
|
|
|
- BoolQueryBuilder qbPlatformName = QueryBuilders.boolQuery()
|
|
|
|
|
- .should(QueryBuilders.matchQuery("platformName", platformName).analyzer("query_ansj").operator(Operator.AND))
|
|
|
|
|
- .should(QueryBuilders.termQuery("platformName.number", platformName.toLowerCase()))
|
|
|
|
|
- .should(QueryBuilders.matchQuery("platformName.letter", platformName.toLowerCase()).operator(Operator.AND));
|
|
|
|
|
- qb = qb.must(qbPlatformName);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (ERPUtils.mapContainKey(params, "voidFlag")) {
|
|
|
|
|
- qb = qb.must(QueryBuilders.termQuery("voidFlag", params.getInt("voidFlag")));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return qb;
|
|
|
|
|
- }),
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
|
|
|
|
|
- pageFlipper,
|
|
|
|
|
- (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC)));
|
|
|
|
|
-
|
|
|
|
|
- return platformInfoList;
|
|
|
|
|
|
|
+ @SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
|
|
+ public RetResult<List<PlatformInfo>> queryPlatformList(RMap params, PageFlipper pageFlipper, String dataSourceId, long supplierCode) {
|
|
|
|
|
+ RMap searchData = new RMap();
|
|
|
|
|
+ if (params != null) {
|
|
|
|
|
+ searchData.putAll(params);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<PlatformInfo> platformInfoList = platformDao.queryPlatformInfoList(searchData, pageFlipper, dataSourceId, supplierCode);
|
|
|
|
|
+ return RetResult.<List<PlatformInfo>>successT().result(platformInfoList).page(pageFlipper);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public PlatformInfo getPlatformInfo(long idPlatformInfo, long supplierCode) {
|
|
|
|
|
- return this.getESOneInfo(esClient, jsonConvert,
|
|
|
|
|
- PlatformInfo.class,
|
|
|
|
|
- String.valueOf(idPlatformInfo),
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
|
|
|
|
|
- ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE,
|
|
|
|
|
- null);
|
|
|
|
|
|
|
+ public PlatformInfo getPlatformInfo(long idPlatformInfo, boolean withDetail, long supplierCode) {
|
|
|
|
|
+ PlatformInfo platformInfo = getRedisDocInfo(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode), String.valueOf(idPlatformInfo), PlatformInfo.class);
|
|
|
|
|
+
|
|
|
|
|
+ if ((platformInfo != null) && (withDetail)) {
|
|
|
|
|
+ String detailKey = keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + platformInfo.getId();
|
|
|
|
|
+ List<PlatformRequire> requireList = getRedisDocInfos(detailKey, PlatformRequire.class);
|
|
|
|
|
+ requireList.sort(Comparator.comparingLong(PlatformRequire::getId));
|
|
|
|
|
+ platformInfo.setRequireList(requireList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return platformInfo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public PlatformInfo getPlatformInfoByCode(String platformCode, long supplierCode) {
|
|
|
|
|
- return this.getESOneInfo(esClient, jsonConvert,
|
|
|
|
|
- PlatformInfo.class,
|
|
|
|
|
- (a) -> {
|
|
|
|
|
- return QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE))
|
|
|
|
|
- .must(QueryBuilders.termQuery("platformCode.raw", platformCode));
|
|
|
|
|
- },
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
|
|
|
|
|
- null);
|
|
|
|
|
|
|
+ public PlatformInfo getPlatformInfoByCode(String platformCode, boolean withDetail, long supplierCode) {
|
|
|
|
|
+ Map<String, String> platformMap = redisService.hgetAll(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode));
|
|
|
|
|
+
|
|
|
|
|
+ for (String v : platformMap.values()) {
|
|
|
|
|
+ PlatformInfo platformInfo = jsonConvert.convertFrom(PlatformInfo.class, v);
|
|
|
|
|
+ if (platformCode.equalsIgnoreCase(platformInfo.getPlatformCode())) {
|
|
|
|
|
+ if (withDetail) {
|
|
|
|
|
+ String detailKey = keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + platformInfo.getId();
|
|
|
|
|
+ List<PlatformRequire> requireList = getRedisDocInfos(detailKey, PlatformRequire.class);
|
|
|
|
|
+ requireList.sort(Comparator.comparingLong(PlatformRequire::getId));
|
|
|
|
|
+ platformInfo.setRequireList(requireList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return platformInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private PlatformInfo getPlatformInfoByName(String platformName, long supplierCode) {
|
|
|
|
|
+ Map<String, String> platformMap = redisService.hgetAll(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode));
|
|
|
|
|
+
|
|
|
|
|
+ for (String v : platformMap.values()) {
|
|
|
|
|
+ PlatformInfo platformInfo = jsonConvert.convertFrom(PlatformInfo.class, v);
|
|
|
|
|
+ if (platformName.equalsIgnoreCase(platformInfo.getPlatformName())) {
|
|
|
|
|
+ return platformInfo;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -130,76 +120,49 @@ public class PlatformServiceImpl extends BaseService implements PlatformService
|
|
|
if (StringUtils.isBlank(platformInfo.getPlatformCode()))
|
|
if (StringUtils.isBlank(platformInfo.getPlatformCode()))
|
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台编号不可为空");
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台编号不可为空");
|
|
|
|
|
|
|
|
|
|
+ if (StringUtils.isEmpty(platformInfo.getPlatformCode())) {
|
|
|
|
|
+ return RetResult.<PlatformInfo>errorT().retinfo("请选择平台编号");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (PlatformType.getName(platformInfo.getPlatformType()) == null)
|
|
if (PlatformType.getName(platformInfo.getPlatformType()) == null)
|
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台类型非法");
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台类型非法");
|
|
|
|
|
|
|
|
//先查一下有没有重名的平台信息
|
|
//先查一下有没有重名的平台信息
|
|
|
- PlatformInfo esInfo = this.getESOneInfo(esClient, jsonConvert,
|
|
|
|
|
- PlatformInfo.class,
|
|
|
|
|
- (a) -> {
|
|
|
|
|
- BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE));
|
|
|
|
|
- qb.must(QueryBuilders.termQuery("platformName.raw", platformInfo.getPlatformName()));
|
|
|
|
|
- qb.must(QueryBuilders.termQuery("platformType", platformInfo.getPlatformType()));
|
|
|
|
|
-
|
|
|
|
|
- return qb;
|
|
|
|
|
- },
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
|
|
|
|
|
- null);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ PlatformInfo esInfo = getPlatformInfoByName(platformInfo.getPlatformName(), supplierCode);
|
|
|
if (esInfo != null) return RetResult.<PlatformInfo>errorT().retinfo("已存在同名的平台");
|
|
if (esInfo != null) return RetResult.<PlatformInfo>errorT().retinfo("已存在同名的平台");
|
|
|
|
|
|
|
|
- esInfo = this.getPlatformInfoByCode(platformInfo.getPlatformCode(), supplierCode);
|
|
|
|
|
|
|
+ esInfo = this.getPlatformInfoByCode(platformInfo.getPlatformCode(), false, supplierCode);
|
|
|
if (esInfo != null) return RetResult.<PlatformInfo>errorT().retinfo("已存在同编号的平台");
|
|
if (esInfo != null) return RetResult.<PlatformInfo>errorT().retinfo("已存在同编号的平台");
|
|
|
|
|
|
|
|
platformInfo.setId(tableIdService.getTableIdMulti("tbPlatformInfo.id", 1, dataSourceId, String.valueOf(supplierCode)));
|
|
platformInfo.setId(tableIdService.getTableIdMulti("tbPlatformInfo.id", 1, dataSourceId, String.valueOf(supplierCode)));
|
|
|
//前端传进来的是平台需求的list,由于获取平台信息的时候几乎必带需求信息而且一般不会很多,所以不做子表直接序列化进主表
|
|
//前端传进来的是平台需求的list,由于获取平台信息的时候几乎必带需求信息而且一般不会很多,所以不做子表直接序列化进主表
|
|
|
- platformInfo.setRequireListSerial(jsonConvert.convertTo(platformInfo.getRequireList()));
|
|
|
|
|
|
|
+ platformInfo.setRequireList(null);
|
|
|
PlatformInfo.create(platformInfo, currentUser.getId());
|
|
PlatformInfo.create(platformInfo, currentUser.getId());
|
|
|
|
|
|
|
|
- IndexResponse itemResponse = esClient.getClient()
|
|
|
|
|
- .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode), ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE)
|
|
|
|
|
- .setId(String.valueOf(platformInfo.getId()))
|
|
|
|
|
- .setSource(jsonConvert.convertTo(platformInfo), XContentType.JSON)
|
|
|
|
|
- .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
|
|
- .get();
|
|
|
|
|
-
|
|
|
|
|
- if (itemResponse.getResult() == DocWriteResponse.Result.CREATED) {
|
|
|
|
|
- platformDao.addPlatformInfo(platformInfo, dataSourceId, supplierCode);
|
|
|
|
|
- } else {
|
|
|
|
|
- return RetResult.<PlatformInfo>errorT().retinfo("创建平台档案失败");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode), String.valueOf(platformInfo.getId()), jsonConvert.convertTo(platformInfo));
|
|
|
|
|
+
|
|
|
|
|
+ platformDao.addPlatformInfo(platformInfo, dataSourceId, supplierCode);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
- return RetResult.<PlatformInfo>successT().result(platformInfo);
|
|
|
|
|
|
|
+ return RetResult.successT();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public RetResult<PlatformInfo> updatePlatformInfo(PlatformInfo platformInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
public RetResult<PlatformInfo> updatePlatformInfo(PlatformInfo platformInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
|
- PlatformInfo esInfo = this.getPlatformInfo(platformInfo.getId(), supplierCode);
|
|
|
|
|
|
|
+ PlatformInfo esInfo = this.getPlatformInfo(platformInfo.getId(), false, supplierCode);
|
|
|
if (esInfo == null)
|
|
if (esInfo == null)
|
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台信息不存在");
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台信息不存在");
|
|
|
|
|
|
|
|
|
|
+ esInfo.setPlatformCode(platformInfo.getPlatformCode());
|
|
|
esInfo.setPlatformName(platformInfo.getPlatformName());
|
|
esInfo.setPlatformName(platformInfo.getPlatformName());
|
|
|
esInfo.setPlatformType(platformInfo.getPlatformType());
|
|
esInfo.setPlatformType(platformInfo.getPlatformType());
|
|
|
- esInfo.setRequireListSerial(jsonConvert.convertTo(platformInfo.getRequireList()));
|
|
|
|
|
|
|
+ esInfo.setRequireList(null);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
PlatformInfo.update(esInfo, currentUser.getId());
|
|
PlatformInfo.update(esInfo, currentUser.getId());
|
|
|
- try {
|
|
|
|
|
- esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
|
|
|
|
|
- ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE, String.valueOf(esInfo.getId()))
|
|
|
|
|
- .setDoc(jsonBuilder()
|
|
|
|
|
- .startObject()
|
|
|
|
|
- .field("platformName", esInfo.getPlatformName())
|
|
|
|
|
- .field("platformType", esInfo.getPlatformType())
|
|
|
|
|
- .field("requireListSerial", esInfo.getRequireListSerial())
|
|
|
|
|
- .field("updateBy", esInfo.getUpdateBy())
|
|
|
|
|
- .field("updateTimeLong", esInfo.getUpdateTimeLong())
|
|
|
|
|
- .endObject())
|
|
|
|
|
- .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
|
|
- .get();
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode), String.valueOf(esInfo.getId()), jsonConvert.convertTo(esInfo));
|
|
|
|
|
|
|
|
platformDao.updatePlatformInfo(esInfo, dataSourceId, supplierCode);
|
|
platformDao.updatePlatformInfo(esInfo, dataSourceId, supplierCode);
|
|
|
|
|
|
|
@@ -208,27 +171,14 @@ public class PlatformServiceImpl extends BaseService implements PlatformService
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public RetResult<PlatformInfo> voidPlatformInfo(PlatformInfo platformInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
public RetResult<PlatformInfo> voidPlatformInfo(PlatformInfo platformInfo, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
|
- PlatformInfo esInfo = this.getPlatformInfo(platformInfo.getId(), supplierCode);
|
|
|
|
|
|
|
+ PlatformInfo esInfo = this.getPlatformInfo(platformInfo.getId(), false, supplierCode);
|
|
|
if (esInfo == null)
|
|
if (esInfo == null)
|
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台信息不存在");
|
|
return RetResult.<PlatformInfo>errorT().retinfo("平台信息不存在");
|
|
|
|
|
|
|
|
esInfo.setVoidFlag(platformInfo.getVoidFlag());
|
|
esInfo.setVoidFlag(platformInfo.getVoidFlag());
|
|
|
-
|
|
|
|
|
PlatformInfo.update(esInfo, currentUser.getId());
|
|
PlatformInfo.update(esInfo, currentUser.getId());
|
|
|
- try {
|
|
|
|
|
- esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_INFO_INDEX, supplierCode),
|
|
|
|
|
- ESKeys.ES_DELIVER_PLATFORM_INFO_TYPE, String.valueOf(esInfo.getId()))
|
|
|
|
|
- .setDoc(jsonBuilder()
|
|
|
|
|
- .startObject()
|
|
|
|
|
- .field("voidFlag", esInfo.getVoidFlag())
|
|
|
|
|
- .field("updateBy", esInfo.getUpdateBy())
|
|
|
|
|
- .field("updateTimeLong", esInfo.getUpdateTimeLong())
|
|
|
|
|
- .endObject())
|
|
|
|
|
- .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
|
|
- .get();
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_INFO, supplierCode), String.valueOf(esInfo.getId()), jsonConvert.convertTo(esInfo));
|
|
|
|
|
|
|
|
platformDao.voidPlatformInfo(esInfo, dataSourceId, supplierCode);
|
|
platformDao.voidPlatformInfo(esInfo, dataSourceId, supplierCode);
|
|
|
|
|
|
|
@@ -236,71 +186,66 @@ public class PlatformServiceImpl extends BaseService implements PlatformService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<PlatformRequire> queryPlatformRequireList(RMap params, PageFlipper pageFlipper, long supplierCode) {
|
|
|
|
|
- return this.searchESList(esClient, jsonConvert, PlatformRequire.class,
|
|
|
|
|
- params,
|
|
|
|
|
- (a) -> {
|
|
|
|
|
- BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_TYPE));
|
|
|
|
|
-
|
|
|
|
|
- if (ERPUtils.mapContainKey(params, "requireName")) {
|
|
|
|
|
- String requireName = params.getString("requireName");
|
|
|
|
|
- BoolQueryBuilder qbRequireName = QueryBuilders.boolQuery()
|
|
|
|
|
- .should(QueryBuilders.matchQuery("requireName", requireName).analyzer("query_ansj").operator(Operator.AND))
|
|
|
|
|
- .should(QueryBuilders.termQuery("requireName.number", requireName.toLowerCase()))
|
|
|
|
|
- .should(QueryBuilders.matchQuery("requireName.letter", requireName.toLowerCase()).operator(Operator.AND));
|
|
|
|
|
- qb = qb.must(qbRequireName);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return qb;
|
|
|
|
|
- },
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_INDEX, supplierCode),
|
|
|
|
|
- (() -> SortBuilders.fieldSort("id").order(SortOrder.DESC)));
|
|
|
|
|
|
|
+ @SuppressWarnings({"rawtypes", "unchecked"})
|
|
|
|
|
+ public RetResult<List<PlatformRequire>> queryPlatformRequireList(RMap params, PageFlipper pageFlipper, String dataSourceId, long supplierCode) {
|
|
|
|
|
+ RMap searchData = new RMap();
|
|
|
|
|
+ if (params != null) {
|
|
|
|
|
+ searchData.putAll(params);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<PlatformRequire> requireList = platformDao.queryPlatformRequireList(searchData, pageFlipper, dataSourceId, supplierCode);
|
|
|
|
|
+ return RetResult.<List<PlatformRequire>>successT().result(requireList).page(pageFlipper);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public RetResult<List<PlatformRequire>> selectPlatformRequireList(long idPlatform, long supplierCode) {
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> platformRequireMap = redisService.hgetAll(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + idPlatform);
|
|
|
|
|
+ List<PlatformRequire> dataList = new ArrayList<>();
|
|
|
|
|
+ platformRequireMap.forEach((k, v) -> {
|
|
|
|
|
+ PlatformRequire data = jsonConvert.convertFrom(PlatformRequire.class, v);
|
|
|
|
|
+
|
|
|
|
|
+ if (data.getVoidFlag() == 0) {
|
|
|
|
|
+ dataList.add(data);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ //排序
|
|
|
|
|
+ dataList.sort(Comparator.comparingLong(PlatformRequire::getId));
|
|
|
|
|
+
|
|
|
|
|
+ return RetResult.<List<PlatformRequire>>successT().result(dataList);
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public PlatformRequire getPlatformRequire(long id, long supplierCode) {
|
|
|
|
|
- return this.getESOneInfo(esClient, jsonConvert, PlatformRequire.class, String.valueOf(id),
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_INDEX, supplierCode),
|
|
|
|
|
- ESKeys.ES_DELIVER_PLATFORM_REQUIRE_TYPE, null);
|
|
|
|
|
|
|
+ public PlatformRequire getPlatformRequire(long idPlatform, long id, long supplierCode) {
|
|
|
|
|
+ String key = keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + idPlatform;
|
|
|
|
|
+ return getRedisDocInfo(key, String.valueOf(id), PlatformRequire.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public RetResult<PlatformRequire> addPlatformRequire(PlatformRequire platformRequire, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
public RetResult<PlatformRequire> addPlatformRequire(PlatformRequire platformRequire, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
|
- PlatformRequire esInfo = this.getESOneInfo(esClient, jsonConvert,
|
|
|
|
|
- PlatformRequire.class,
|
|
|
|
|
- (a) -> {
|
|
|
|
|
- BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_TYPE));
|
|
|
|
|
- qb.must(QueryBuilders.termQuery("requireCode.raw", platformRequire.getRequireCode()));
|
|
|
|
|
-
|
|
|
|
|
- return qb;
|
|
|
|
|
- },
|
|
|
|
|
- keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_INDEX, supplierCode),
|
|
|
|
|
- null);
|
|
|
|
|
-
|
|
|
|
|
- if (esInfo != null) return RetResult.<PlatformRequire>errorT().retinfo("已存在相同CODE的平台接入需求档案");
|
|
|
|
|
|
|
+ if (platformRequire.getIdPlatform() <= 0L) {
|
|
|
|
|
+ return RetResult.<PlatformRequire>errorT().retinfo("请设置需求属性的平台id");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
platformRequire.setId(tableIdService.getTableIdMulti("tbPlatformRequire.id", 1, dataSourceId, String.valueOf(supplierCode)));
|
|
platformRequire.setId(tableIdService.getTableIdMulti("tbPlatformRequire.id", 1, dataSourceId, String.valueOf(supplierCode)));
|
|
|
|
|
+ platformRequire.setVoidFlag(0);
|
|
|
PlatformRequire.create(platformRequire, currentUser.getId());
|
|
PlatformRequire.create(platformRequire, currentUser.getId());
|
|
|
|
|
|
|
|
- IndexResponse itemResponse = esClient.getClient()
|
|
|
|
|
- .prepareIndex(keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_INDEX, supplierCode), ESKeys.ES_DELIVER_PLATFORM_REQUIRE_TYPE)
|
|
|
|
|
- .setId(String.valueOf(platformRequire.getId()))
|
|
|
|
|
- .setSource(jsonConvert.convertTo(platformRequire), XContentType.JSON)
|
|
|
|
|
- .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
|
|
- .get();
|
|
|
|
|
-
|
|
|
|
|
- if (itemResponse.getResult() == DocWriteResponse.Result.CREATED) {
|
|
|
|
|
- platformDao.addPlatformRequire(platformRequire, dataSourceId, supplierCode);
|
|
|
|
|
- } else {
|
|
|
|
|
- return RetResult.<PlatformRequire>errorT().retinfo("创建平台接入需求档案失败");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + platformRequire.getIdPlatform(), String.valueOf(platformRequire.getId()), jsonConvert.convertTo(platformRequire));
|
|
|
|
|
+
|
|
|
|
|
+ platformDao.addPlatformRequire(platformRequire, dataSourceId, supplierCode);
|
|
|
|
|
|
|
|
- return RetResult.<PlatformRequire>successT().result(platformRequire);
|
|
|
|
|
|
|
+ return RetResult.successT();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public RetResult<PlatformRequire> updatePlatformRequire(PlatformRequire platformRequire, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
public RetResult<PlatformRequire> updatePlatformRequire(PlatformRequire platformRequire, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
|
- PlatformRequire esInfo = this.getPlatformRequire(platformRequire.getId(), supplierCode);
|
|
|
|
|
|
|
+ if (platformRequire.getIdPlatform() <= 0L) {
|
|
|
|
|
+ return RetResult.<PlatformRequire>errorT().retinfo("请设置需求属性的平台id");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PlatformRequire esInfo = this.getPlatformRequire(platformRequire.getIdPlatform(), platformRequire.getId(), supplierCode);
|
|
|
if (esInfo == null)
|
|
if (esInfo == null)
|
|
|
return RetResult.<PlatformRequire>errorT().retinfo("平台接入需求档案不存在");
|
|
return RetResult.<PlatformRequire>errorT().retinfo("平台接入需求档案不存在");
|
|
|
|
|
|
|
@@ -308,52 +253,29 @@ public class PlatformServiceImpl extends BaseService implements PlatformService
|
|
|
esInfo.setValueType(platformRequire.getValueType());
|
|
esInfo.setValueType(platformRequire.getValueType());
|
|
|
|
|
|
|
|
PlatformRequire.update(esInfo, currentUser.getId());
|
|
PlatformRequire.update(esInfo, currentUser.getId());
|
|
|
- try {
|
|
|
|
|
- esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_INDEX, supplierCode),
|
|
|
|
|
- ESKeys.ES_DELIVER_PLATFORM_REQUIRE_TYPE, String.valueOf(esInfo.getId()))
|
|
|
|
|
- .setDoc(jsonBuilder()
|
|
|
|
|
- .startObject()
|
|
|
|
|
- .field("requireName", esInfo.getRequireName())
|
|
|
|
|
- .field("valueType", esInfo.getValueType())
|
|
|
|
|
- .field("updateBy", esInfo.getUpdateBy())
|
|
|
|
|
- .field("updateTimeLong", esInfo.getUpdateTimeLong())
|
|
|
|
|
- .endObject())
|
|
|
|
|
- .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
|
|
- .get();
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + esInfo.getIdPlatform(), String.valueOf(esInfo.getId()), jsonConvert.convertTo(esInfo));
|
|
|
platformDao.updatePlatformRequire(esInfo, dataSourceId, supplierCode);
|
|
platformDao.updatePlatformRequire(esInfo, dataSourceId, supplierCode);
|
|
|
|
|
|
|
|
- return RetResult.<PlatformRequire>successT().result(esInfo);
|
|
|
|
|
|
|
+ return RetResult.successT();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public RetResult<PlatformRequire> voidPlatformRequire(PlatformRequire platformRequire, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
public RetResult<PlatformRequire> voidPlatformRequire(PlatformRequire platformRequire, ERPTokenUser currentUser, String dataSourceId, long supplierCode) {
|
|
|
- PlatformRequire esInfo = this.getPlatformRequire(platformRequire.getId(), supplierCode);
|
|
|
|
|
|
|
+ if (platformRequire.getIdPlatform() <= 0L) {
|
|
|
|
|
+ return RetResult.<PlatformRequire>errorT().retinfo("请设置需求属性的平台id");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PlatformRequire esInfo = this.getPlatformRequire(platformRequire.getIdPlatform(), platformRequire.getId(), supplierCode);
|
|
|
if (esInfo == null)
|
|
if (esInfo == null)
|
|
|
return RetResult.<PlatformRequire>errorT().retinfo("平台接入需求档案不存在");
|
|
return RetResult.<PlatformRequire>errorT().retinfo("平台接入需求档案不存在");
|
|
|
|
|
|
|
|
esInfo.setVoidFlag(platformRequire.getVoidFlag());
|
|
esInfo.setVoidFlag(platformRequire.getVoidFlag());
|
|
|
-
|
|
|
|
|
PlatformInfo.update(esInfo, currentUser.getId());
|
|
PlatformInfo.update(esInfo, currentUser.getId());
|
|
|
- try {
|
|
|
|
|
- esClient.getClient().prepareUpdate(keysService.getESKey(ESKeys.ES_DELIVER_PLATFORM_REQUIRE_INDEX, supplierCode),
|
|
|
|
|
- ESKeys.ES_DELIVER_PLATFORM_REQUIRE_TYPE, String.valueOf(esInfo.getId()))
|
|
|
|
|
- .setDoc(jsonBuilder()
|
|
|
|
|
- .startObject()
|
|
|
|
|
- .field("voidFlag", esInfo.getVoidFlag())
|
|
|
|
|
- .field("updateBy", esInfo.getUpdateBy())
|
|
|
|
|
- .field("updateTimeLong", esInfo.getUpdateTimeLong())
|
|
|
|
|
- .endObject())
|
|
|
|
|
- .setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
|
|
|
|
|
- .get();
|
|
|
|
|
- } catch (IOException e) {
|
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ redisService.hset(keysService.getRedisKey(RedisKeys.KEY_DELIVER_PLATFORM_REQUIRE, supplierCode, true) + esInfo.getIdPlatform(), String.valueOf(esInfo.getId()), jsonConvert.convertTo(esInfo));
|
|
|
|
|
|
|
|
platformDao.voidPlatformRequire(esInfo, dataSourceId, supplierCode);
|
|
platformDao.voidPlatformRequire(esInfo, dataSourceId, supplierCode);
|
|
|
- return RetResult.<PlatformRequire>successT().result(esInfo);
|
|
|
|
|
|
|
+ return RetResult.successT();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|