Commit 163d1597 authored by 廖旭伟's avatar 廖旭伟

综窗事项差集查询接口;事项配置接口

parent 1e182526
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum ApplyTypeEnum {
自助端申报(1, "自助端申报"),
移动端申报(2, "移动端申报"),
第三方申报(3, "第三方申报");
private Integer value;
private String desc;
ApplyTypeEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static ApplyTypeEnum getByValue(Integer value) {
for (ApplyTypeEnum applyTypeEnum : ApplyTypeEnum.values()) {
if (applyTypeEnum.getValue() == value) {
return applyTypeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (ApplyTypeEnum item : ApplyTypeEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
public enum EventObjectType {
个人("P", "个人"),
企业("O", "企业"),
个人以及企业("O", "个人以及企业");
private String value;
private String desc;
EventObjectType(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static EventObjectType getByValue(String value) {
for (EventObjectType eventObjectType : EventObjectType.values()) {
if (eventObjectType.getValue().equals(value)) {
return eventObjectType;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (EventObjectType item : EventObjectType.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue().equals(e)) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
...@@ -3,7 +3,9 @@ package com.mortals.xhx.daemon.task; ...@@ -3,7 +3,9 @@ package com.mortals.xhx.daemon.task;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.module.matter.service.EventImplementationService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -13,9 +15,12 @@ import org.springframework.stereotype.Service; ...@@ -13,9 +15,12 @@ import org.springframework.stereotype.Service;
@Service("SyncImplementationTask") @Service("SyncImplementationTask")
public class SyncImplementationTaskImpl implements ITaskExcuteService { public class SyncImplementationTaskImpl implements ITaskExcuteService {
@Autowired
private EventImplementationService eventImplementationService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
eventImplementationService.syncEventImplementation();
} }
@Override @Override
......
package com.mortals.xhx.daemon.task;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 同步门户用户
*/
@Slf4j
@Service("SyncPortalUserTask")
public class SyncPortalUserTaskImpl implements ITaskExcuteService {
@Autowired
private IUserFeign userFeign;
@Autowired
private UserService userService;
@Override
public void excuteTask(ITask task) throws AppException {
try {
log.info("同步门户用户");
syncPersons();
} catch (Exception e) {
log.error("同步门户异常", e);
}
}
private void syncPersons() {
UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> resp = userFeign.list(userPdu);
if (resp.getCode() == YesNoEnum.YES.getValue()) {
List<UserPdu> userPduList = resp.getData().getData();
log.info("用户总数量:{}", userPduList.size());
if (!ObjectUtils.isEmpty(userPduList)) {
List<UserEntity> newUserList = userPduList.stream().map(newUser -> {
UserEntity userEntity = new UserEntity();
userEntity.initAttrValue();
BeanUtils.copyProperties(newUser, userEntity, new String[]{"id", "lastLoginTime", "lastLoginAddress"});
return userEntity;
}).collect(Collectors.toList());
List<UserEntity> oldUserList = userService.find(new UserQuery());
log.info(" oldUserList size:{}", oldUserList.size());
//当前用户map
Map<String, UserEntity> oldUserMap = oldUserList.parallelStream().collect(Collectors.toMap(x -> x.getLoginName(), y -> y, (o, n) -> n));
List<UserEntity> saveUserList = newUserList.stream().map(item -> {
if (!oldUserMap.containsKey(item.getLoginName())) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
item.setCreateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(saveUserList)) {
log.info("用户新增,size:{}", saveUserList.size());
saveUserList.stream().forEach(item -> {
userService.getUserDao().insert(item);
});
}
}
}
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
...@@ -19,5 +19,8 @@ public class EventImplementationVo extends BaseEntityLong { ...@@ -19,5 +19,8 @@ public class EventImplementationVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */ /** 序号,主键,自增长列表 */
private List <Long> idList; private List <Long> idList;
/**
* 可申报类型
*/
private Integer applyType;
} }
\ No newline at end of file
package com.mortals.xhx.module.matter.service; package com.mortals.xhx.module.matter.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.EventImplementationEntity; import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import com.mortals.xhx.module.matter.dao.EventImplementationDao; import com.mortals.xhx.module.matter.dao.EventImplementationDao;
...@@ -26,4 +30,21 @@ public interface EventImplementationService extends ICRUDService<EventImplementa ...@@ -26,4 +30,21 @@ public interface EventImplementationService extends ICRUDService<EventImplementa
* 新增或者修改 * 新增或者修改
*/ */
void saveOrUpdate(List<EventImplementationEntity> list); void saveOrUpdate(List<EventImplementationEntity> list);
/**
* 获取差集
* @param params
* @param pageInfo
* @param context
* @return
* @throws AppException
*/
Result<EventImplementationEntity> findSubList(EventImplementationEntity params, PageInfo pageInfo, Context context) throws AppException;
/**
* 配置可申请事项
* @param entity
* @return
*/
int addToApplyMatter(EventImplementationEntity entity,Context context);
} }
\ No newline at end of file
...@@ -5,13 +5,20 @@ import com.alibaba.fastjson.JSON; ...@@ -5,13 +5,20 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.EntityUtil;
import com.mortals.xhx.busiz.req.ComplexImplementationReq; import com.mortals.xhx.busiz.req.ComplexImplementationReq;
import com.mortals.xhx.busiz.rsp.ApiResp; import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.busiz.rsp.ImplementEventInfo; import com.mortals.xhx.busiz.rsp.ImplementEventInfo;
import com.mortals.xhx.busiz.rsp.RecordsItem; import com.mortals.xhx.busiz.rsp.RecordsItem;
import com.mortals.xhx.common.code.ApiRespCodeEnum; import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import com.mortals.xhx.module.matter.model.EventImplementationQuery; import com.mortals.xhx.module.matter.model.EventImplementationQuery;
import com.mortals.xhx.module.matter.service.ApplyMatterService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -23,9 +30,7 @@ import com.mortals.xhx.module.matter.model.EventImplementationEntity; ...@@ -23,9 +30,7 @@ import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import com.mortals.xhx.module.matter.service.EventImplementationService; import com.mortals.xhx.module.matter.service.EventImplementationService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import static com.mortals.xhx.common.key.Constant.HTTP_TIMEOUT; import static com.mortals.xhx.common.key.Constant.HTTP_TIMEOUT;
import static com.mortals.xhx.common.key.RedisKey.KEY_COMPLEX_REQ; import static com.mortals.xhx.common.key.RedisKey.KEY_COMPLEX_REQ;
...@@ -44,9 +49,12 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even ...@@ -44,9 +49,12 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Autowired
private ApplyMatterService applyMatterService;
@Override @Override
public void syncEventImplementation() { public void syncEventImplementation() {
log.info("开始执行综窗事项同步任务....");
int currentPage = 1; int currentPage = 1;
int pageSize = 20; int pageSize = 20;
ComplexImplementationReq req = new ComplexImplementationReq(); ComplexImplementationReq req = new ComplexImplementationReq();
...@@ -96,6 +104,7 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even ...@@ -96,6 +104,7 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
} catch (Exception e) { } catch (Exception e) {
log.error("同步数据失败", e); log.error("同步数据失败", e);
} }
log.info("综窗事项同步任务执行完成....");
} }
@Override @Override
...@@ -124,6 +133,55 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even ...@@ -124,6 +133,55 @@ public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<Even
} }
} }
@Override
public Result<EventImplementationEntity> findSubList(EventImplementationEntity params, PageInfo pageInfo, Context context) throws AppException {
EventImplementationEntity newParams = this.findBefore(params, pageInfo, context);
Result<EventImplementationEntity> result = this.dao.getList(getQueryParam(newParams), pageInfo,"getSubList");
this.findAfter(params, pageInfo, context, result.getList());
return result;
}
protected ParamDto getQueryParam(EventImplementationEntity params) {
ParamDto paramDto = new ParamDto();
Map map = new HashMap();
EntityUtil.entityToMap(params, map);
paramDto.setCondition(map);
paramDto.setOrderCol(params.getOrderCols());
paramDto.setOrderColList(params.getOrderColList());
paramDto.setData(params.getTabColMap());
paramDto.setMatchMode(params.getMatchMode());
paramDto.setColPickMode(params.getColPickMode());
paramDto.setGroupList(params.getGroupList());
return paramDto;
}
@Override
public int addToApplyMatter(EventImplementationEntity entity,Context context) {
int result = 0;
if(CollectionUtils.isNotEmpty(entity.getIdList())){
List<EventImplementationEntity> list = this.find(new EventImplementationQuery().idList(entity.getIdList()));
if(CollectionUtils.isNotEmpty(list)){
List<ApplyMatterEntity> applyMatterList = new ArrayList<>();
Long userId = context == null?null:context.getUser().getId();
for (EventImplementationEntity item:list){
ApplyMatterEntity applyMatterEntity = new ApplyMatterEntity();
applyMatterEntity.initAttrValue();
applyMatterEntity.setEventId(item.getEventId());
applyMatterEntity.setEventObjectType(item.getEventObjectType());
applyMatterEntity.setEventType(item.getEventType());
applyMatterEntity.setHandlingItemCode(item.getHandlingItemCode());
applyMatterEntity.setImplementName(item.getImplementName());
applyMatterEntity.setImplementCoding(item.getImplementCoding());
applyMatterEntity.setApplyType(entity.getApplyType());
applyMatterEntity.setCreateTime(new Date());
applyMatterEntity.setCreateUserId(userId);
applyMatterList.add(applyMatterEntity);
}
}
}
return result;
}
private List<EventImplementationEntity> convertEventImplementation(List<RecordsItem> records){ private List<EventImplementationEntity> convertEventImplementation(List<RecordsItem> records){
List<EventImplementationEntity> list = new ArrayList<>(); List<EventImplementationEntity> list = new ArrayList<>();
if(CollectionUtils.isNotEmpty(records)){ if(CollectionUtils.isNotEmpty(records)){
......
...@@ -43,7 +43,8 @@ public class ApplyMatterController extends BaseCRUDJsonBodyMappingController<App ...@@ -43,7 +43,8 @@ public class ApplyMatterController extends BaseCRUDJsonBodyMappingController<App
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
//this.addDict(model, "applyType", ApplyTypeEnum.getEnumMap()); this.addDict(model, "applyType", ApplyTypeEnum.getEnumMap());
this.addDict(model, "eventObjectType", EventObjectType.getEnumMap());
super.init(model, context); super.init(model, context);
} }
......
...@@ -4,14 +4,18 @@ import com.mortals.framework.annotation.UnAuth; ...@@ -4,14 +4,18 @@ import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.EventObjectType;
import com.mortals.xhx.module.matter.model.EventImplementationEntity; import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import com.mortals.xhx.module.matter.service.EventImplementationService; import com.mortals.xhx.module.matter.service.EventImplementationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -46,6 +50,7 @@ public class EventImplementationController extends BaseCRUDJsonBodyMappingContro ...@@ -46,6 +50,7 @@ public class EventImplementationController extends BaseCRUDJsonBodyMappingContro
@Override @Override
protected void init(Map<String, Object> model, Context context) { protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "eventObjectType", EventObjectType.getEnumMap());
super.init(model, context); super.init(model, context);
} }
...@@ -79,4 +84,69 @@ public class EventImplementationController extends BaseCRUDJsonBodyMappingContro ...@@ -79,4 +84,69 @@ public class EventImplementationController extends BaseCRUDJsonBodyMappingContro
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString()); ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret; return ret;
} }
/***
* 获取差集
* @param query
* @return
*/
@PostMapping({"subList"})
public Rest<Object> subList(@RequestBody EventImplementationEntity query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
int code;
try {
this.doListBefore(query, model, context);
PageInfo pageInfo = this.buildPageInfo(query);
Result<EventImplementationEntity> result = this.getService().findSubList(query, pageInfo, context);
this.doListAfter(query, result.getList(), context);
model.put("data", result.getList());
model.put("pageInfo", result.getPageInfo());
this.parsePageInfo(model, result.getPageInfo());
code = this.doListAfter(query, (Map)model, context);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
/***
* 配置可申请事项
* @param entity
* @return
*/
@PostMapping({"addToApplyMatter"})
public Rest<Object> addToApplyMatter(@RequestBody EventImplementationEntity entity) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "配置可申请事项";
int code = 1;
try {
int result = this.getService().addToApplyMatter(entity,this.getContext());
model.put("data", result);
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.matter.dao.ibatis.EventImplementationDaoImpl">
<!-- 获取列表 -->
<select id="getSubList" parameterType="paramDto" resultMap="EventImplementationEntity-Map">
select <include refid="_columns"/>
from (SELECT * FROM mortals_xhx_event_implementation WHERE eventId not in (SELECT eventId FROM mortals_xhx_apply_matter WHERE applyType = #{condition.applyType})) as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
<include refid="_orderCols_"/>
</select>
<!-- 获取 -->
<select id="getSubListCount" parameterType="paramDto" resultType="int">
select count(1)
from (SELECT * FROM mortals_xhx_event_implementation WHERE eventId not in (SELECT eventId FROM mortals_xhx_apply_matter WHERE applyType = #{condition.applyType})) as a
<trim suffixOverrides="where" suffix="">
where
<trim prefixOverrides="and" prefix="">
<include refid="_condition_"/>
</trim>
</trim>
</select>
</mapper>
\ No newline at end of file
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