Commit ea2fab46 authored by gaoyingwei's avatar gaoyingwei

修改 隔离点、方舱与用户对应关系

parent 8f302d33
......@@ -85,7 +85,7 @@ public class SysDictData extends BaseEntity
}
@NotBlank(message = "字典键值不能为空")
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
@Size(min = 0, max = 1000, message = "字典键值长度不能超过1000个字符")
public String getDictValue()
{
return dictValue;
......
......@@ -3,8 +3,11 @@ package com.ruoyi.common.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.domain.entity.SysDictData;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
* 数据工具类
......@@ -15,9 +18,7 @@ public class DataUtils {
public static String dateMap = "{\"area\":{ \"1\":\"123\",\"2\":\"124\",\"3\":\"124\",\"4\":\"124\",\"5\":\"124\",\"6\":\"124\",\"7\":\"124\",\"8\":\"124\",\"9\":\"124\",\"10\":\"124\",\"11\":\"124\",\"12\":\"124\",\"13\":\"124\",\"14\":\"124\",\"15\":\"124\",\"16\":\"124\",\"17\":\"124\",\"18\":\"124\",\"19\":\"124\",\"20\":\"124\",\"21\":\"124\",\"22\":\"124\",\"23\":\"124\",\"24\":\"124\"}," +
"\"street\":{\"1\":\"101\",\"2\":\"103\", \"3\":\"102\", \"4\":\"104\",\"5\":\"105\", \"6\":\"106\", \"7\":\"121\", \"8\":\"120\", \"9\":\"117\", \"10\":\"119\", \"11\":\"118\"}," +
"\"community\":{\"1\":\"125\",\"2\":\"126\", \"3\":\"127\",\"4\":\"128\", \"5\":\"129\", \"6\":\"130\", \"7\":\"131\", \"17\":\"132\", \"18\":\"133\", \"19\":\"134\", \"20\":\"135\", \"21\":\"136\", \"22\":\"137\", \"23\":\"138\", \"24\":\"139\", \"34\":\"140\", \"35\":\"141\", \"36\":\"142\", \"37\":\"143\", \"38\":\"144\", \"39\":\"145\", \"40\":\"146\", \"41\":\"147\", \"42\":\"148\", \"43\":\"149\",\"44\":\"150\",\"45\":\"151\",\"46\":\"152\",\"47\":\"153\",\"48\":\"154\",\"49\":\"155\",\"50\":\"156\", \"60\":\"157\", \"61\":\"158\", \"62\":\"159\", \"63\":\"160\", \"64\":\"161\", \"65\":\"162\", \"66\":\"163\", \"67\":\"164\", \"68\":\"181\", \"69\":\"165\", \"70\":\"166\", \"71\":\"167\", \"72\":\"168\", \"73\":\"169\", \"74\":\"170\", \"75\":\"171\", \"76\":\"172\"}," +
"\"shelters\":{\"1\":\"107\",\"2\":\"108\", \"3\":\"109\", \"4\":\"110\",\"5\":\"111\", \"6\":\"112\", \"7\":\"113\", \"8\":\"114\", \"9\":\"115\", \"10\":\"116\", \"11\":\"182\"}," +
"\"isolation\":{\"01\":\"173\",\"02\":\"174\", \"03\":\"175\", \"04\":\"176\",\"05\":\"177\", \"06\":\"178\", \"07\":\"179\", \"08\":\"180\"}}";
"\"community\":{\"1\":\"125\",\"2\":\"126\", \"3\":\"127\",\"4\":\"128\", \"5\":\"129\", \"6\":\"130\", \"7\":\"131\", \"17\":\"132\", \"18\":\"133\", \"19\":\"134\", \"20\":\"135\", \"21\":\"136\", \"22\":\"137\", \"23\":\"138\", \"24\":\"139\", \"34\":\"140\", \"35\":\"141\", \"36\":\"142\", \"37\":\"143\", \"38\":\"144\", \"39\":\"145\", \"40\":\"146\", \"41\":\"147\", \"42\":\"148\", \"43\":\"149\",\"44\":\"150\",\"45\":\"151\",\"46\":\"152\",\"47\":\"153\",\"48\":\"154\",\"49\":\"155\",\"50\":\"156\", \"60\":\"157\", \"61\":\"158\", \"62\":\"159\", \"63\":\"160\", \"64\":\"161\", \"65\":\"162\", \"66\":\"163\", \"67\":\"164\", \"68\":\"181\", \"69\":\"165\", \"70\":\"166\", \"71\":\"167\", \"72\":\"168\", \"73\":\"169\", \"74\":\"170\", \"75\":\"171\", \"76\":\"172\"}}";
public static String getValue(String area, String street, String community) {
JSONObject map = JSON.parseObject(dateMap);
......@@ -36,6 +37,19 @@ public class DataUtils {
public static String getKey(String area, String street, String community, String shelters, String isolation) {
JSONObject map = JSON.parseObject(dateMap);
JSONObject sheltersJson = null;
JSONObject isolationJson = null;
List<SysDictData> corresponding= DictUtils.getDictCache("corresponding_user");
if (corresponding!=null){
List<String> labels = corresponding.stream().filter(i -> "shelters".equals(i.getDictLabel()))
.map(SysDictData::getDictValue).collect(Collectors.toList());
if (!labels.isEmpty())
sheltersJson = JSON.parseObject(labels.get(0));
List<String> isolations = corresponding.stream().filter(i -> "isolation".equals(i.getDictLabel()))
.map(SysDictData::getDictValue).collect(Collectors.toList());
if (!isolations.isEmpty())
isolationJson = JSON.parseObject(isolations.get(0));
}
if (StringUtils.isNotEmpty(community)) {
JSONObject com = map.getJSONObject("community");
return getKey(com,community);
......@@ -46,11 +60,17 @@ public class DataUtils {
JSONObject a = map.getJSONObject("area");
return getKey(a,area);
} else if (StringUtils.isNotEmpty(shelters)) {
JSONObject a = map.getJSONObject("shelters");
return getKey(a,shelters);
// JSONObject a = map.getJSONObject("shelters");
if (sheltersJson!=null)
return getKey(sheltersJson,shelters);
else
return "";
} else if (StringUtils.isNotEmpty(isolation)) {
JSONObject a = map.getJSONObject("isolation");
return getKey(a,isolation);
if (isolationJson!=null)
return getKey(isolationJson,isolation);
else
return "";
// JSONObject a = map.getJSONObject("isolation");
} else
return "null";
}
......
......@@ -85,4 +85,6 @@ public interface FcryMapper
List<Fcry> selectAll();
int updateBatch(@Param("list") List<Fcry> list);
int updateFcryByCreateBy(@Param("newUserId")String newUserId, @Param("oldUserId")String oldUserId);
}
......@@ -84,4 +84,6 @@ public interface GldryMapper
List<Gldry> selectAll();
int updateBatch(@Param("list") List<Gldry> list);
int updateGldryByCreateBy(@Param("newUserId")String newUserId, @Param("oldUserId")String oldUserId);
}
package com.ruoyi.system.service.impl;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.system.mapper.FcryMapper;
import com.ruoyi.system.mapper.GldryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.domain.entity.SysDictData;
......@@ -18,6 +25,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService
{
@Autowired
private SysDictDataMapper dictDataMapper;
@Autowired
private FcryMapper fcryMapper;
@Autowired
private GldryMapper gldryMapper;
/**
* 根据条件分页查询字典数据
......@@ -100,6 +111,36 @@ public class SysDictDataServiceImpl implements ISysDictDataService
@Override
public int updateDictData(SysDictData data)
{
if ("corresponding_user".equals(data.getDictType())){
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
List<String> values = dictDatas.stream().filter(i -> "shelters".equals(i.getDictLabel()))
.map(SysDictData::getDictValue).collect(Collectors.toList());
JSONObject sheltersJson = null;
if (!values.isEmpty())
sheltersJson = JSON.parseObject(values.get(0));
List<String> isolations = dictDatas.stream().filter(i -> "isolation".equals(i.getDictLabel()))
.map(SysDictData::getDictValue).collect(Collectors.toList());
JSONObject isolationJson = null;
if (!isolations.isEmpty())
isolationJson = JSON.parseObject(isolations.get(0));
JSONObject dateValue = JSON.parseObject(data.getDictValue());
Iterator<String> keys = dateValue.keySet().iterator();
if ("shelters".equals(data.getDictLabel())) {
while (keys.hasNext()) {
String key = keys.next();
if (!((String) dateValue.get(key)).equals(sheltersJson.get(key))) {
fcryMapper.updateFcryByCreateBy((String) dateValue.get(key),(String)sheltersJson.get(key));
}
}
}else {
while (keys.hasNext()) {
String key = keys.next();
if (!((String) dateValue.get(key)).equals(isolationJson.get(key))) {
gldryMapper.updateGldryByCreateBy((String)dateValue.get(key),(String)isolationJson.get(key));
}
}
}
}
int row = dictDataMapper.updateDictData(data);
if (row > 0)
{
......
......@@ -324,6 +324,11 @@
</foreach>
</update>
<update id="updateFcryByCreateBy">
update fcry set create_by = #{newUserId}
where create_by = #{oldUserId}
</update>
<insert id="updateBatchFcry" parameterType="com.ruoyi.system.domain.Fcry">
<foreach item="item" index="index" collection="list" separator=";">
update fcry
......
......@@ -242,6 +242,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{item.id}
</foreach>
</update>
<update id="updateGldryByCreateBy">
update gldry set create_by = #{newUserId}
where create_by = #{oldUserId}
</update>
<delete id="deleteGldryById" parameterType="Long">
delete from gldry where id = #{id}
......
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