Commit a4424a24 by zxn

初始化刷新Redis约束关系

parent 3552ea3d
...@@ -25,10 +25,7 @@ package cn.com.uitech.authorization.controller; ...@@ -25,10 +25,7 @@ package cn.com.uitech.authorization.controller;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController @RestController
@RequestMapping("/integrate") @RequestMapping("/integrate")
...@@ -71,51 +68,48 @@ public class IntegrateController { ...@@ -71,51 +68,48 @@ public class IntegrateController {
public Object initializationData(@RequestBody SelectorEntity selectorEntity) { public Object initializationData(@RequestBody SelectorEntity selectorEntity) {
String redis = redisHelper.get(RedisKey.getVariantTableKey(selectorEntity.getSystem(), selectorEntity.getProductClassCode(), selectorEntity.getSuperBomCode())); String redis = redisHelper.get(RedisKey.getVariantTableKey(selectorEntity.getSystem(), selectorEntity.getProductClassCode(), selectorEntity.getSuperBomCode()));
if (ObjectUtils.isEmpty(redis)) { if (ObjectUtils.isEmpty(redis)) {
List<SuperTableInfoDto> superTableInfos = superTableInfoMapper.findBySuperBomCode(selectorEntity.getSuperBomCode()); // table信息
List<RedisEntity> redisEntities = new ArrayList<>(); List<Map<String, String>> superTableInfos = superTableInfoMapper.findBySuperBomCode(selectorEntity.getSuperBomCode());
superTableInfos.forEach(superTableInfo->{ // 拿table信息取所有的组
RedisEntity redisEntity = new RedisEntity(); List<Map<String, Object>> resultList = new ArrayList<>();
redisEntity.setTableName(superTableInfo.getTableName()); superTableInfos.forEach(item -> {
redisEntity.setTableId(superTableInfo.getTableId()); Map<String, Object> resultMap = new HashMap<>();
Map<String, Object> map = new HashMap<>(); Map<String, Object> data = new HashMap<>();
List<SuperTableInfoItemDto> data = superTableInfo.getData(); String tablenumber = item.get("tablenumber");
List<String> featureComponentNames = new ArrayList<>(); resultMap.put("tableName", item.get("tablename"));
resultMap.put("tableId", tablenumber);
// 根据tableNumber 查询所有的groupNumber
// constraintCharacteristicName
Set<String> characteristicnames = new HashSet<>();
List<Map<String, Object>> constraintCharacteristicValues = new ArrayList<>(); List<Map<String, Object>> constraintCharacteristicValues = new ArrayList<>();
data.forEach(item -> { List<String> groupNumbers = superTableInfoMapper.findGroupNumber(tablenumber);
groupNumbers.forEach(groupNumber -> {
Map<String, Object> constraintCharacteristicValue = new HashMap<>(); Map<String, Object> constraintCharacteristicValue = new HashMap<>();
List<Map<String, String>> constraintCharacteristicNames = superTableInfoMapper.findCName(tablenumber, groupNumber);
List<Map<String, Object>> characteristicValues = new ArrayList<>(); List<Map<String, Object>> characteristicValues = new ArrayList<>();
List<SuperTableInfo> infos = item.getSuperTableInfos(); constraintCharacteristicNames.forEach(constraintCharacteristicName -> {
infos.forEach(info -> {
Map<String, Object> characteristicValue = new HashMap<>(); Map<String, Object> characteristicValue = new HashMap<>();
List<String> values = new ArrayList<>(); String characteristicname = constraintCharacteristicName.get("characteristicname");
List<SuperTableItemInfo> itemInfos = info.getData(); characteristicnames.add(characteristicname);
itemInfos.forEach(itemInfo -> { String characteristiccode = constraintCharacteristicName.get("characteristiccode");
constraintCharacteristicValue.put("groupNumber", item.getGroupNumber()); // 拿code和groupnumber 查Vname
String characteristicCode = itemInfo.getCharacteristicCode(); List<String> values = superTableInfoMapper.findVName(tablenumber, characteristiccode, groupNumber);
String cName = integrateService.getNameByCode(characteristicCode,selectorEntity.getIsShow(), item.getGroupNumber());
if (!StringUtils.isEmpty(cName)) {
characteristicValue.put("characteristicName", cName);
String characteristicValueCode = itemInfo.getCharacteristicValueCode();
if (!StringUtils.isEmpty(characteristicValueCode)) {
String vName = integrateService.getVNameByCode(characteristicValueCode,characteristicCode);
values.add(vName);
}
featureComponentNames.add(cName);
}
});
characteristicValue.put("values", values); characteristicValue.put("values", values);
characteristicValue.put("characteristicName", characteristicname);
characteristicValues.add(characteristicValue); characteristicValues.add(characteristicValue);
constraintCharacteristicValue.put("characteristicValues", characteristicValues);
}); });
constraintCharacteristicValue.put("groupNumber", groupNumber);
constraintCharacteristicValues.add(constraintCharacteristicValue); constraintCharacteristicValues.add(constraintCharacteristicValue);
data.put("constraintCharacteristicName", characteristicnames);
data.put("constraintCharacteristicValues", constraintCharacteristicValues);
}); });
map.put("constraintCharacteristicValues", constraintCharacteristicValues); resultMap.put("data", data);
map.put("constraintCharacteristicName", featureComponentNames); resultList.add(resultMap);
redisEntity.setData(map);
redisEntities.add(redisEntity);
}); });
redisHelper.set(RedisKey.getVariantTableKey(selectorEntity.getSystem(), selectorEntity.getProductClassCode(), selectorEntity.getSuperBomCode()), JSONObject.toJSONString(redisEntities), 86400); redisHelper.set(RedisKey.getVariantTableKey(selectorEntity.getSystem(), selectorEntity.getProductClassCode(), selectorEntity.getSuperBomCode()), JSONObject.toJSONString(resultList), 86400);
} }
ConfigurableBom configurableBom = integrateService.getOdInfo(selectorEntity); ConfigurableBom configurableBom = integrateService.getOdInfo(selectorEntity);
// 查询用户对应的角色以及能够查询得所有C\V 组合之后调用initialization接口 // 查询用户对应的角色以及能够查询得所有C\V 组合之后调用initialization接口
// 返回得参数交互数据库查询对应的code返回 // 返回得参数交互数据库查询对应的code返回
......
...@@ -5,6 +5,7 @@ import cn.com.uitech.authorization.pojo.dto.SuperTableInfoDto; ...@@ -5,6 +5,7 @@ import cn.com.uitech.authorization.pojo.dto.SuperTableInfoDto;
import cn.com.uitech.authorization.pojo.dto.SuperTableInfoLog; import cn.com.uitech.authorization.pojo.dto.SuperTableInfoLog;
import cn.com.uitech.authorization.pojo.entity.SuperTableInfo; import cn.com.uitech.authorization.pojo.entity.SuperTableInfo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -21,5 +22,11 @@ public interface SuperTableInfoMapper extends IBaseMapper<SuperTableInfo>{ ...@@ -21,5 +22,11 @@ public interface SuperTableInfoMapper extends IBaseMapper<SuperTableInfo>{
void deleteBom(SuperTableInfo getOne); void deleteBom(SuperTableInfo getOne);
List<SuperTableInfoDto> findBySuperBomCode(String superBomCode); List<Map<String,String>> findBySuperBomCode(String superBomCode);
List<String> findGroupNumber(@Param("tablenumber") String tablenumber);
List<Map<String,String>> findCName(@Param("tablenumber") String tablenumber, @Param("groupNumber") String groupNumber);
List<String> findVName(@Param("tablenumber") String tablenumber, @Param("characteristiccode") String characteristiccode, @Param("groupNumber") String groupNumber);
} }
...@@ -17,5 +17,5 @@ import java.util.List; ...@@ -17,5 +17,5 @@ import java.util.List;
public class SuperTableInfoItemDto { public class SuperTableInfoItemDto {
private String tableId; private String tableId;
private String groupNumber; private String groupNumber;
private List<SuperTableInfo> superTableInfos; private List<SuperTableInfo> constraintCharacteristicValues;
} }
...@@ -5,6 +5,7 @@ import lombok.experimental.Accessors; ...@@ -5,6 +5,7 @@ import lombok.experimental.Accessors;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable; import java.io.Serializable;
import java.sql.Timestamp; import java.sql.Timestamp;
...@@ -41,12 +42,18 @@ public class SuperTableItemInfo implements Serializable { ...@@ -41,12 +42,18 @@ public class SuperTableItemInfo implements Serializable {
@Column(name = "characteristic_code") @Column(name = "characteristic_code")
private String characteristicCode; private String characteristicCode;
@Transient
private String characteristicName;
/** /**
* characteristic_value_code * characteristic_value_code
*/ */
@Column(name = "characteristic_value_code") @Column(name = "characteristic_value_code")
private String characteristicValueCode; private String characteristicValueCode;
@Transient
private String characteristicValueName;
/** /**
* create_time * create_time
*/ */
......
...@@ -50,25 +50,24 @@ ...@@ -50,25 +50,24 @@
<result property="superBomCode" column="super_bom_code"/> <result property="superBomCode" column="super_bom_code"/>
<collection property="data" ofType="cn.com.uitech.authorization.pojo.dto.SuperTableInfoItemDto"> <collection property="data" ofType="cn.com.uitech.authorization.pojo.dto.SuperTableInfoItemDto">
<result property="groupNumber" column="group_number"/> <result property="groupNumber" column="group_number"/>
<collection property="superTableInfos" ofType="cn.com.uitech.authorization.pojo.entity.SuperTableInfo"> <collection property="constraintCharacteristicValues"
<result property="superBomCode" column="super_bom_code"/> ofType="cn.com.uitech.authorization.pojo.entity.SuperTableItemInfo">
<result property="tableName" column="table_name"/> <result property="characteristicValueName" column="characteristic_value_name"/>
<result property="tableNumber" column="table_number"/> <result property="characteristicName" column="characteristic_name"/>
<collection property="data"
ofType="cn.com.uitech.authorization.pojo.entity.SuperTableItemInfo">
<result property="characteristicValueCode" column="characteristic_value_code"/>
<result property="characteristicCode" column="characteristic_code"/>
</collection>
</collection> </collection>
</collection> </collection>
</resultMap> </resultMap>
<select id="findBySuperBomCode" resultMap="baseResultMap"> <select id="findBySuperBomCode" resultType="map">
select * from super_table_info a select distinct table_name tablename,table_number tablenumber from super_table_info a where a.super_bom_code = #{superBomCode}
left join super_table_item_info b on a.table_number = b.table_number </select>
left join super_characteristic_info c on b.characteristic_code = c.characteristic_code <select id="findGroupNumber" resultType="java.lang.String">
left join super_characteristic_value_info d on b.characteristic_value_code = d.characteristic_value_code select distinct group_number groupnumber from super_table_item_info where table_number = #{tablenumber}
where a.super_bom_code = #{superBomCode} </select>
order by b.characteristic_code <select id="findCName" resultType="map">
select distinct c.characteristic_code characteristiccode,c.characteristic_name characteristicname from super_table_item_info b left join super_characteristic_info c on b.characteristic_code = c.characteristic_code where b.table_number =#{tablenumber} and b.group_number = #{groupNumber}
</select>
<select id="findVName" resultType="java.lang.String">
select distinct d.characteristic_value_name from super_table_item_info b left join super_characteristic_value_info d on b.characteristic_value_code = d.characteristic_value_code where b.table_number =#{tablenumber} and b.group_number = #{groupNumber} and b.characteristic_code = #{characteristiccode}
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment