Commit 6d6c51e0 authored by 廖旭伟's avatar 廖旭伟

综窗事项管理等

parent 29d06970
package com.mortals.xhx.daemon.task;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 同步综窗事项
*/
@Slf4j
@Service("SyncImplementationTask")
public class SyncImplementationTaskImpl implements ITaskExcuteService {
@Override
public void excuteTask(ITask task) throws AppException {
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
package com.mortals.xhx.module.matter.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import java.util.List;
/**
* 申报事项列表Dao
* 申报事项列表 DAO接口
*
* @author zxfei
* @date 2024-06-20
*/
public interface ApplyMatterDao extends ICRUDDao<ApplyMatterEntity,Long>{
}
package com.mortals.xhx.module.matter.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import java.util.List;
/**
* 综窗事项列表Dao
* 综窗事项列表 DAO接口
*
* @author zxfei
* @date 2024-06-20
*/
public interface EventImplementationDao extends ICRUDDao<EventImplementationEntity,Long>{
}
package com.mortals.xhx.module.matter.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.matter.dao.ApplyMatterDao;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 申报事项列表DaoImpl DAO接口
*
* @author zxfei
* @date 2024-06-20
*/
@Repository("applyMatterDao")
public class ApplyMatterDaoImpl extends BaseCRUDDaoMybatis<ApplyMatterEntity,Long> implements ApplyMatterDao {
}
package com.mortals.xhx.module.matter.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.matter.dao.EventImplementationDao;
import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 综窗事项列表DaoImpl DAO接口
*
* @author zxfei
* @date 2024-06-20
*/
@Repository("eventImplementationDao")
public class EventImplementationDaoImpl extends BaseCRUDDaoMybatis<EventImplementationEntity,Long> implements EventImplementationDao {
}
package com.mortals.xhx.module.matter.model;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.matter.model.vo.ApplyMatterVo;
import lombok.Data;
/**
* 申报事项列表实体对象
*
* @author zxfei
* @date 2024-06-20
*/
@Data
public class ApplyMatterEntity extends ApplyMatterVo {
private static final long serialVersionUID = 1L;
/**
* 可申报类型
*/
private Integer applyType;
/**
* 实施清单事项ID
*/
private String eventId;
/**
* 事项类型
*/
private String eventType;
/**
* 实施编码
*/
private String implementCoding;
/**
* 业务办理项编码
*/
private String handlingItemCode;
/**
* 实施清单名称
*/
private String implementName;
/**
* 事项面向对象分类
*/
private String eventObjectType;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof ApplyMatterEntity) {
ApplyMatterEntity tmp = (ApplyMatterEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.applyType = 0;
this.eventId = "";
this.eventType = "";
this.implementCoding = "";
this.handlingItemCode = "";
this.implementName = "";
this.eventObjectType = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.model;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.matter.model.vo.EventImplementationVo;
import lombok.Data;
/**
* 综窗事项列表实体对象
*
* @author zxfei
* @date 2024-06-20
*/
@Data
public class EventImplementationEntity extends EventImplementationVo {
private static final long serialVersionUID = 1L;
/**
* 实施清单事项ID
*/
private String eventId;
/**
* 事项类型
*/
private String eventType;
/**
* 实施编码
*/
private String implementCoding;
/**
* 业务办理项编码
*/
private String handlingItemCode;
/**
* 实施清单名称
*/
private String implementName;
/**
* 事项面向对象分类
*/
private String eventObjectType;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof EventImplementationEntity) {
EventImplementationEntity tmp = (EventImplementationEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.eventId = "";
this.eventType = "";
this.implementCoding = "";
this.handlingItemCode = "";
this.implementName = "";
this.eventObjectType = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.mortals.framework.annotation.Excel;
import java.math.BigDecimal;
import java.util.Date;
/**
* 申报事项列表视图对象
*
* @author zxfei
* @date 2024-06-20
*/
@Data
public class ApplyMatterVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private List <Long> idList;
}
\ No newline at end of file
package com.mortals.xhx.module.matter.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.mortals.framework.annotation.Excel;
import java.math.BigDecimal;
import java.util.Date;
/**
* 综窗事项列表视图对象
*
* @author zxfei
* @date 2024-06-20
*/
@Data
public class EventImplementationVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private List <Long> idList;
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import com.mortals.xhx.module.matter.dao.ApplyMatterDao;
/**
* ApplyMatterService
*
* 申报事项列表 service接口
*
* @author zxfei
* @date 2024-06-20
*/
public interface ApplyMatterService extends ICRUDService<ApplyMatterEntity,Long>{
ApplyMatterDao getDao();
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import com.mortals.xhx.module.matter.dao.EventImplementationDao;
import java.util.List;
/**
* EventImplementationService
*
* 综窗事项列表 service接口
*
* @author zxfei
* @date 2024-06-20
*/
public interface EventImplementationService extends ICRUDService<EventImplementationEntity,Long>{
EventImplementationDao getDao();
/**
* 同步综窗事项到本地库
*/
void syncEventImplementation();
/**
* 新增或者修改
*/
void saveOrUpdate(List<EventImplementationEntity> list);
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service.impl;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.matter.dao.ApplyMatterDao;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import com.mortals.xhx.module.matter.service.ApplyMatterService;
import lombok.extern.slf4j.Slf4j;
/**
* ApplyMatterService
* 申报事项列表 service实现
*
* @author zxfei
* @date 2024-06-20
*/
@Service("applyMatterService")
@Slf4j
public class ApplyMatterServiceImpl extends AbstractCRUDServiceImpl<ApplyMatterDao, ApplyMatterEntity, Long> implements ApplyMatterService {
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.xhx.busiz.req.ComplexImplementationReq;
import com.mortals.xhx.busiz.rsp.ApiResp;
import com.mortals.xhx.busiz.rsp.ImplementEventInfo;
import com.mortals.xhx.busiz.rsp.RecordsItem;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.module.matter.model.EventImplementationQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.matter.dao.EventImplementationDao;
import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import com.mortals.xhx.module.matter.service.EventImplementationService;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
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.RedisKey.KEY_COMPLEX_REQ;
import static com.mortals.xhx.common.key.RedisKey.KEY_EVENT_IMPLEMENTATION_RESP;
/**
* EventImplementationService
* 综窗事项列表 service实现
*
* @author zxfei
* @date 2024-06-20
*/
@Service("eventImplementationService")
@Slf4j
public class EventImplementationServiceImpl extends AbstractCRUDServiceImpl<EventImplementationDao, EventImplementationEntity, Long> implements EventImplementationService {
@Autowired
private ICacheService cacheService;
@Override
public void syncEventImplementation() {
int currentPage = 1;
int pageSize = 20;
ComplexImplementationReq req = new ComplexImplementationReq();
req.setUrlPath("eventImplementation/list");
req.setPageSize(pageSize);
req.setCurrentPage(currentPage);
try {
req.setNonce(RandomUtil.randomNumbers(6));
cacheService.lpush(KEY_COMPLEX_REQ, JSONObject.toJSONString(req));
String rest = cacheService.blpop(KEY_EVENT_IMPLEMENTATION_RESP + req.getNonce(), HTTP_TIMEOUT, String.class);
if (ObjectUtil.isEmpty(rest)) {
throw new AppException("请求访问超时");
}
Rest<ImplementEventInfo> eventListRest = JSON.parseObject(rest, new TypeReference<Rest<ImplementEventInfo>>() {
});
if(eventListRest.getCode()==ApiRespCodeEnum.SUCCESS.getValue()){
List<EventImplementationEntity> list = convertEventImplementation(eventListRest.getData().getRecords());
this.saveOrUpdate(list);
int total = eventListRest.getData().getTotal();
int pages = total/pageSize + 1;
if(pages > 1){
while (currentPage < pages){
currentPage++;
req.setCurrentPage(currentPage);
req.setNonce(RandomUtil.randomNumbers(6));
cacheService.lpush(KEY_COMPLEX_REQ, JSONObject.toJSONString(req));
String restTemp = cacheService.blpop(KEY_EVENT_IMPLEMENTATION_RESP + req.getNonce(), HTTP_TIMEOUT, String.class);
if (ObjectUtil.isEmpty(restTemp)) {
throw new AppException("请求访问超时");
}
Rest<ImplementEventInfo> eventListTemp = JSON.parseObject(rest, new TypeReference<Rest<ImplementEventInfo>>() {
});
if(eventListTemp.getCode()==ApiRespCodeEnum.SUCCESS.getValue()){
List<EventImplementationEntity> listTemp = convertEventImplementation(eventListTemp.getData().getRecords());
this.saveOrUpdate(listTemp);
}
}
}
}
} catch (Exception e) {
log.error("同步数据失败", e);
}
}
@Override
public void saveOrUpdate(List<EventImplementationEntity> list) {
if(CollectionUtils.isNotEmpty(list)){
List<EventImplementationEntity> saveList = new ArrayList<>();
List<EventImplementationEntity> updateList = new ArrayList<>();
for(EventImplementationEntity entity:list){
EventImplementationEntity temp = this.selectOne(new EventImplementationQuery().eventId(entity.getEventId()));
if(temp!=null){
entity.setId(temp.getId());
entity.setUpdateTime(new Date());
updateList.add(entity);
}else {
entity.setCreateTime(new Date());
saveList.add(entity);
}
}
if(CollectionUtils.isNotEmpty(saveList)){
this.save(saveList);
}
if(CollectionUtils.isNotEmpty(updateList)){
this.update(updateList);
}
}
}
private List<EventImplementationEntity> convertEventImplementation(List<RecordsItem> records){
List<EventImplementationEntity> list = new ArrayList<>();
if(CollectionUtils.isNotEmpty(records)){
for (RecordsItem item:records){
EventImplementationEntity entity = new EventImplementationEntity();
entity.initAttrValue();
entity.setEventId(item.getEventId());
entity.setEventObjectType(item.getEventObjectType());
entity.setEventType(item.getEventType());
entity.setHandlingItemCode(item.getHandlingItemCode());
entity.setImplementName(item.getImplementName());
entity.setImplementCoding(item.getImplementCoding());
list.add(entity);
}
}
return list;
}
public static void main(String[] args) {
int total = 175;
int pageSize = 50;
int currentPage = 1;
System.out.println("当前页数:"+currentPage);
int pages = total/pageSize + 1;
System.out.println("总页数:"+pages);
while (currentPage < pages){
currentPage++;
System.out.println("当前页数:"+currentPage);
}
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.web;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.matter.model.ApplyMatterEntity;
import com.mortals.xhx.module.matter.service.ApplyMatterService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
/**
*
* 申报事项列表
*
* @author zxfei
* @date 2024-06-20
*/
@RestController
@RequestMapping("apply/matter")
public class ApplyMatterController extends BaseCRUDJsonBodyMappingController<ApplyMatterService,ApplyMatterEntity,Long> {
@Autowired
private ParamService paramService;
public ApplyMatterController(){
super.setModuleDesc( "申报事项列表");
}
@Override
protected void init(Map<String, Object> model, Context context) {
//this.addDict(model, "applyType", ApplyTypeEnum.getEnumMap());
super.init(model, context);
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.matter.model.EventImplementationEntity;
import com.mortals.xhx.module.matter.service.EventImplementationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
*
* 综窗事项列表
*
* @author zxfei
* @date 2024-06-20
*/
@RestController
@RequestMapping("event/implementation")
public class EventImplementationController extends BaseCRUDJsonBodyMappingController<EventImplementationService,EventImplementationEntity,Long> {
@Autowired
private ParamService paramService;
@Autowired
private ICacheService cacheService;
private ExecutorService executorService = Executors.newCachedThreadPool();
private static String SYNC_TASK_KEY ="syncEventImplementation:run";
public EventImplementationController(){
super.setModuleDesc( "综窗事项列表");
}
@Override
protected void init(Map<String, Object> model, Context context) {
super.init(model, context);
}
@PostMapping({"sync"})
@UnAuth
public Rest<Object> syncEventImplementation() {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
String busiDesc = "同步综窗事项";
int code = 1;
try {
String verify = cacheService.get(SYNC_TASK_KEY);
if(StringUtils.isNotEmpty(verify)&&verify.equals("true")){
throw new AppException("同步任务正在执行,请勿重复操作");
}
executorService.submit(new Runnable() {
@Override
public void run() {
cacheService.setnx(SYNC_TASK_KEY,"true",3600);
service.syncEventImplementation();
}
});
cacheService.setnx(SYNC_TASK_KEY,"false",60);
model.put("message_info","开始执行同步,请稍后查看");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
ret.setCode(code);
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
\ No newline at end of file
...@@ -51,3 +51,45 @@ INSERT INTO `mortals_xhx_menu` VALUES (null, '员工离职信息', '/staff/leave ...@@ -51,3 +51,45 @@ INSERT INTO `mortals_xhx_menu` VALUES (null, '员工离职信息', '/staff/leave
INSERT INTO `mortals_xhx_resource` VALUES (null, '员工离职信息-菜单管理-查看', '/staff/leave/list,/staff/leave/view,/staff/leave/info,/staff/leave/export,/staff/leave/exportExcel,/staff/leave/downloadTemplate,/staff/leave/download', 3, 0, NULL, NULL, NULL, 0); INSERT INTO `mortals_xhx_resource` VALUES (null, '员工离职信息-菜单管理-查看', '/staff/leave/list,/staff/leave/view,/staff/leave/info,/staff/leave/export,/staff/leave/exportExcel,/staff/leave/downloadTemplate,/staff/leave/download', 3, 0, NULL, NULL, NULL, 0);
INSERT INTO `mortals_xhx_resource` VALUES (null, '员工离职信息-菜单管理-维护', '/staff/leave/add,/staff/leave/edit,/staff/leave/delete,/staff/leave/logicDelete,/staff/leave/save,/staff/leave/importData', 3, 0, NULL, NULL, NULL, 0); INSERT INTO `mortals_xhx_resource` VALUES (null, '员工离职信息-菜单管理-维护', '/staff/leave/add,/staff/leave/edit,/staff/leave/delete,/staff/leave/logicDelete,/staff/leave/save,/staff/leave/importData', 3, 0, NULL, NULL, NULL, 0);
-- ----------------------------
-- 2024-06-20
-- 综窗事项列表表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_event_implementation`;
CREATE TABLE mortals_xhx_event_implementation(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`eventId` varchar(128) NOT NULL COMMENT '实施清单事项ID',
`eventType` varchar(128) NOT NULL COMMENT '事项类型',
`implementCoding` varchar(128) NOT NULL COMMENT '实施编码',
`handlingItemCode` varchar(128) NOT NULL COMMENT '业务办理项编码',
`implementName` varchar(128) NOT NULL COMMENT '实施清单名称',
`eventObjectType` varchar(32) NOT NULL COMMENT '事项面向对象分类',
`createUserId` bigint(20) COMMENT '更新用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
,KEY `eventType` (`eventType`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='综窗事项列表';
-- ----------------------------
-- 申报事项列表表
-- ----------------------------
DROP TABLE IF EXISTS `mortals_xhx_apply_matter`;
CREATE TABLE mortals_xhx_apply_matter(
`id` bigint(20) AUTO_INCREMENT COMMENT '序号,主键,自增长',
`applyType` tinyint(2) NOT NULL COMMENT '可申报类型',
`eventId` varchar(128) NOT NULL COMMENT '实施清单事项ID',
`eventType` varchar(128) NOT NULL COMMENT '事项类型',
`implementCoding` varchar(128) NOT NULL COMMENT '实施编码',
`handlingItemCode` varchar(128) NOT NULL COMMENT '业务办理项编码',
`implementName` varchar(128) NOT NULL COMMENT '实施清单名称',
`eventObjectType` varchar(32) NOT NULL COMMENT '事项面向对象分类',
`createUserId` bigint(20) COMMENT '更新用户',
`createTime` datetime NOT NULL COMMENT '创建时间',
`updateUserId` bigint(20) COMMENT '更新用户',
`updateTime` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
,KEY `eventType` (`eventType`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='申报事项列表';
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