|
@@ -5,10 +5,11 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
|
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.api.RemoteConfigService;
|
|
|
-import com.ruoyi.system.api.domain.SysUser;
|
|
|
-import com.ruoyi.system.api.model.LoginUser;
|
|
|
+import com.ruoyi.system.api.RemoteDeptService;
|
|
|
+import com.sooka.sponest.lawenforcement.base.service.impl.BaseServiceImpl;
|
|
|
import com.sooka.sponest.lawenforcement.device.service.IDeviceService;
|
|
|
import com.sooka.sponest.lawenforcement.person.domain.LawenforcementPerson;
|
|
|
import com.sooka.sponest.lawenforcement.person.mapper.LawenforcementPersonMapper;
|
|
@@ -31,10 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -45,7 +43,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class LawenforcementRecordServiceImpl implements ILawenforcementRecordService {
|
|
|
+public class LawenforcementRecordServiceImpl extends BaseServiceImpl implements ILawenforcementRecordService {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@@ -69,6 +67,9 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
*/
|
|
|
@Override
|
|
|
public int insertEnforceLawInfoByList(JSONArray records) {
|
|
|
+ //存储原始报文
|
|
|
+ insertJsonData(records);
|
|
|
+
|
|
|
//创建转换结果集合
|
|
|
List<LawenforcementRecordDetailVO> remoteRecordList = JSONArray.parseArray(records.toJSONString(), LawenforcementRecordDetailVO.class);
|
|
|
//创建新增集合
|
|
@@ -87,6 +88,10 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
recordMapper.removeStandardInfoById(remoteRecord.getId());
|
|
|
recordMapper.removeSubitemInfoById(remoteRecord.getId());
|
|
|
recordMapper.removePersonInfoById(remoteRecord.getId());
|
|
|
+ recordMapper.updateRecord(remoteRecord);
|
|
|
+ } else {
|
|
|
+ remoteRecord.setRecordStatus("lawenforcement_type_1");
|
|
|
+ recordAddList.add(remoteRecord);
|
|
|
}
|
|
|
//将工单子表信息整理
|
|
|
JSONObject dataList = addRecordByRemote(remoteRecord);
|
|
@@ -94,15 +99,25 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
standardAddList.addAll(JSONArray.parseArray(dataList.getJSONArray("standardAddList").toJSONString(), LawenforcementStandardDetailVO.class));
|
|
|
subitemAddList.addAll(JSONArray.parseArray(dataList.getJSONArray("subitemAddList").toJSONString(), LawenforcementSubitemDetailVO.class));
|
|
|
personAddList.addAll(JSONArray.parseArray(dataList.getJSONArray("personAddList").toJSONString(), LawenforcementPersonDetailVO.class));
|
|
|
- recordAddList.add(remoteRecord);
|
|
|
+
|
|
|
|
|
|
});
|
|
|
//新增子表信息
|
|
|
- recordMapper.insertStandardByList(standardAddList);
|
|
|
- recordMapper.insertSubitemByList(subitemAddList);
|
|
|
- recordMapper.insertPersonByList(personAddList);
|
|
|
+ if (StringUtils.isNotEmpty(standardAddList)) {
|
|
|
+ recordMapper.insertStandardByList(standardAddList);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(subitemAddList)) {
|
|
|
+ recordMapper.insertSubitemByList(subitemAddList);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(personAddList)) {
|
|
|
+ recordMapper.insertPersonByList(personAddList);
|
|
|
+ }
|
|
|
+ int i = 0;
|
|
|
//执行批量写入操作
|
|
|
- return recordMapper.insertRecordByList(recordAddList);
|
|
|
+ if (StringUtils.isNotEmpty(recordAddList)) {
|
|
|
+ i = recordMapper.insertRecordByList(recordAddList);
|
|
|
+ }
|
|
|
+ return i;
|
|
|
}
|
|
|
log.error("数据转换后为空");
|
|
|
return 0;
|
|
@@ -110,6 +125,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
/**
|
|
|
* 查询任务数据列表
|
|
|
+ *
|
|
|
* @param lawenforcementRecord 任务数据
|
|
|
* @return 任务数据
|
|
|
*/
|
|
@@ -120,6 +136,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
/**
|
|
|
* 查询详情
|
|
|
+ *
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
@@ -142,6 +159,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
/**
|
|
|
* 新增任务数据:平台创建
|
|
|
* 暂定没有子级信息
|
|
|
+ *
|
|
|
* @param record 任务数据
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -160,23 +178,27 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
/**
|
|
|
* 查询任务数据
|
|
|
+ *
|
|
|
* @param id 任务数据主键
|
|
|
* @return 任务数据
|
|
|
*/
|
|
|
@Override
|
|
|
public LawenforcementRecord selectLawenforcementRecordById(String id) {
|
|
|
LawenforcementRecord record = recordMapper.selectLawenforcementRecordById(id);
|
|
|
- List<LawenforcementUser> personList = record.getPersonList();
|
|
|
- personList.forEach(person -> {
|
|
|
- if ("1".equals(person.getIsMainPerson())) {
|
|
|
- record.setMainPerson(person.getCertificateNumber());
|
|
|
- }
|
|
|
- });
|
|
|
+ if (null != record && null != record.getPersonList()) {
|
|
|
+ List<LawenforcementUser> personList = record.getPersonList();
|
|
|
+ personList.forEach(person -> {
|
|
|
+ if ("1".equals(person.getIsMainPerson())) {
|
|
|
+ record.setMainPerson(person.getCertificateNumber());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return record;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改任务数据
|
|
|
+ *
|
|
|
* @param lawenforcementRecord 任务数据
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -187,16 +209,17 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
/**
|
|
|
* 工单执行日志
|
|
|
+ *
|
|
|
* @param record
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public int addRecordLog(LawenforcementBindDeviceBO record) {
|
|
|
- if(null == record.getUserId() || record.getUserId().isEmpty()){
|
|
|
+ if (null == record.getUserId() || record.getUserId().isEmpty()) {
|
|
|
record.setUserId(SecurityUtils.getLoginUser().getSysUser().getUserId().toString());
|
|
|
}
|
|
|
Map<String, Object> userCodeByUserId = userMapper.getUserCodeByUserId(record.getUserId());
|
|
|
- record.setPersonCode(MapUtils.getString(userCodeByUserId,"personCode"));
|
|
|
+ record.setPersonCode(MapUtils.getString(userCodeByUserId, "personCode"));
|
|
|
|
|
|
//检查当前绑定设备的执法人是否为主办人
|
|
|
Map<String, Object> isMainPerson = recordMapper.getIsMainPerson(record);
|
|
@@ -207,7 +230,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
//将工单执行记录,写入到日志表中:数据id、任务id、执法人编号、设备编号、开始时间
|
|
|
recordMapper.addRecordLog(lawenforcementRecordLog);
|
|
|
//判断是否为主办人,如果是主办人则开始工单
|
|
|
- if("1".equals(MapUtils.getString(isMainPerson,"mainPerson"))){
|
|
|
+ if ("1".equals(MapUtils.getString(isMainPerson, "mainPerson"))) {
|
|
|
recordMapper.startRecord(record);
|
|
|
//绑定设备后关闭定时任务
|
|
|
deviceService.cancelTask(lawenforcementRecordLog.getDeviceId());
|
|
@@ -246,6 +269,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
/**
|
|
|
* 工单填报
|
|
|
+ *
|
|
|
* @param bo
|
|
|
* @return
|
|
|
*/
|
|
@@ -261,6 +285,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
/**
|
|
|
* 批量删除任务数据
|
|
|
+ *
|
|
|
* @param ids 需要删除的任务数据主键
|
|
|
* @return 结果
|
|
|
*/
|
|
@@ -277,15 +302,15 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateRecordLogEndTime(LawenforcementBindDeviceBO record) {
|
|
|
- if(null == record.getUserId() || record.getUserId().isEmpty()){
|
|
|
+ if (null == record.getUserId() || record.getUserId().isEmpty()) {
|
|
|
record.setUserId(SecurityUtils.getLoginUser().getSysUser().getUserId().toString());
|
|
|
}
|
|
|
Map<String, Object> userCodeByUserId = userMapper.getUserCodeByUserId(record.getUserId());
|
|
|
- record.setPersonCode(MapUtils.getString(userCodeByUserId,"personCode"));
|
|
|
+ record.setPersonCode(MapUtils.getString(userCodeByUserId, "personCode"));
|
|
|
|
|
|
//检查当前绑定设备的执法人是否为主办人
|
|
|
Map<String, Object> isMainPerson = recordMapper.getIsMainPerson(record);
|
|
|
- if("1".equals(MapUtils.getString(isMainPerson,"mainPerson"))){
|
|
|
+ if ("1".equals(MapUtils.getString(isMainPerson, "mainPerson"))) {
|
|
|
//设置任务完成状态
|
|
|
recordMapper.updateRecordStatus(record);
|
|
|
}
|
|
@@ -294,7 +319,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
int i = recordMapper.updateRecordLogEndTime(record);
|
|
|
|
|
|
Boolean isOpen = Boolean.valueOf(SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey("lawenforcement_open").getData());
|
|
|
- if(isOpen){
|
|
|
+ if (isOpen) {
|
|
|
//从正在执行任务的设备集合中移除信息
|
|
|
deviceService.removeOpenedDevice(record.getDeviceId());
|
|
|
}
|
|
@@ -303,7 +328,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
|
|
|
@Override
|
|
|
public List<LawenforcementRecord> getRecordList(LawenforcementRecord record) {
|
|
|
- if(null == record.getCreatorId() || record.getCreatorId().isEmpty()){
|
|
|
+ if (null == record.getCreatorId() || record.getCreatorId().isEmpty()) {
|
|
|
record.setCreatorId(SecurityUtils.getLoginUser().getSysUser().getUserId().toString());
|
|
|
}
|
|
|
|
|
@@ -343,6 +368,7 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
List<LawenforcementPersonDetailVO> persons = record.getPersons();
|
|
|
if (StringUtils.isNotEmpty(persons)) {
|
|
|
setRecordIdToItems(record.getId(), persons);
|
|
|
+ setDeptId(persons);
|
|
|
log.info("放入persons =》 {}", persons);
|
|
|
personAddList.addAll(persons);
|
|
|
}
|
|
@@ -362,13 +388,66 @@ public class LawenforcementRecordServiceImpl implements ILawenforcementRecordSer
|
|
|
* @param standards
|
|
|
*/
|
|
|
private void setSubItemId(String subItemId, List<LawenforcementStandardDetailVO> standards) {
|
|
|
- standards.forEach(standard -> {
|
|
|
- standard.setSubitemId(subItemId);
|
|
|
- });
|
|
|
+ standards.forEach(standard -> standard.setSubitemId(subItemId));
|
|
|
}
|
|
|
|
|
|
// 对工单子级设置父id
|
|
|
private <T extends RecordIdSetter> void setRecordIdToItems(String recordId, List<T> items) {
|
|
|
items.forEach(item -> item.setRecordId(recordId));
|
|
|
}
|
|
|
+
|
|
|
+ private void setDeptId(List<LawenforcementPersonDetailVO> persons) {
|
|
|
+ //获取persons中的deptName放入到deptNames中
|
|
|
+ Set<String> deptNameSet = new HashSet<>();
|
|
|
+ for (LawenforcementPersonDetailVO person : persons) {
|
|
|
+ deptNameSet.add(person.getDeptName());
|
|
|
+ }
|
|
|
+// deptNameSet.add("四平市");
|
|
|
+ String[] deptNames = deptNameSet.toArray(new String[0]);
|
|
|
+
|
|
|
+ //根据部门名称查询部门id
|
|
|
+ AjaxResult ajaxResult = SpringUtils.getBean(RemoteDeptService.class).selectDeptListByDeptNames(deptNames);
|
|
|
+ //取出部门集合
|
|
|
+ List<Map<String, Object>> deptList = (List<Map<String, Object>>) ajaxResult.get("data");
|
|
|
+ //如果部门集合不为空,则转换为key-value 部门名称-部门id
|
|
|
+ if (StringUtils.isNotEmpty(deptList)) {
|
|
|
+ HashMap<String, Object> deptMap = new HashMap<>();
|
|
|
+ deptList.forEach(dept -> {
|
|
|
+ deptMap.put(MapUtils.getString(dept, "deptName"), MapUtils.getString(dept, "deptId"));
|
|
|
+ });
|
|
|
+
|
|
|
+ //设置部门id,如果deptMap不存在key,则设置deptId为null
|
|
|
+ persons.forEach(person -> {
|
|
|
+ person.setDeptId(deptMap.containsKey(person.getDeptName()) ? MapUtils.getString(deptMap, person.getDeptName()) : null);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void insertJsonData(JSONArray array) {
|
|
|
+ List<Map<String, Object>> listToInsert = new ArrayList<>();
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
+ JSONObject jsonObject = array.getJSONObject(i);
|
|
|
+ String id = jsonObject.getString("id");
|
|
|
+ int count = recordMapper.selectJsonDataById(id);
|
|
|
+ if (count > 0) {
|
|
|
+ //更新
|
|
|
+ recordMapper.updateJsonData(id, jsonObject.toString(), new Date());
|
|
|
+ } else {
|
|
|
+ // id 不存在,放入 List<Map>
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", id);
|
|
|
+ map.put("jsonData", jsonObject.toString());
|
|
|
+ map.put("createTime", new Date());
|
|
|
+
|
|
|
+ listToInsert.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(listToInsert)) {
|
|
|
+ recordMapper.batchInsert(listToInsert);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|