Commit 7c32611a authored by maoying's avatar maoying

合并developer分支代码优化设备消息处理代码

parents beb9f47e 66a7ad19
...@@ -774,6 +774,34 @@ public class DateUtils { ...@@ -774,6 +774,34 @@ public class DateUtils {
} }
/** /**
* 获得本天的开始时间,即2012-01-01 00:00:00
*
* @return
*/
public static Date getCurrentDayStartTime(Date date) {
try {
date = shortSdf.parse(shortSdf.format(date) + " 00:00:00");
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 获得本天的结束时间,即2012-01-01 23:59:59
*
* @return
*/
public static Date getCurrentDayEndTime(Date date) {
try {
date = longSdf.parse(shortSdf.format(date) + " 23:59:59");
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 获取指定时间所在周的第一天日期 * 获取指定时间所在周的第一天日期
* *
* @param date * @param date
......
package com.yeejoin.amos.boot.module.jcs.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.entity.SourceFile;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Map;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("jc_situation_detail")
@ApiModel(value="AlertCalled对象", description="警情接警记录")
public class JcSituationDetail extends BaseEntity {
@ApiModelProperty(value = "报送内容")
private String info;
@ApiModelProperty(value = "类型")
private String infoType = "指令下发";
@ApiModelProperty(value = "警情ID")
private Long alertCalledId;
}
package com.yeejoin.amos.boot.module.jcs.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jcs.api.entity.JcSituationDetail;
public interface JcSituationDetailMapper extends BaseMapper<JcSituationDetail> {
}
...@@ -181,7 +181,7 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> { ...@@ -181,7 +181,7 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
* *
* @param indexs * @param indexs
*/ */
void updateEquipmentSpecIndexRealtimeData(List<EquipmentSpecificIndex> indexs); void updateEquipmentSpecIndexRealtimeData(EquipmentSpecificIndex index);
List<EquipmentSpecificVo> getEquipAndCarIotcodeByIotcode(String iotCode); List<EquipmentSpecificVo> getEquipAndCarIotcodeByIotcode(String iotCode);
......
...@@ -1631,10 +1631,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1631,10 +1631,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
@Override @Override
public void updateEquipmentSpecIndexRealtimeData(List<EquipmentSpecificIndex> indexs) { public void updateEquipmentSpecIndexRealtimeData(EquipmentSpecificIndex index) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (!ObjectUtils.isEmpty(indexs)) { if (!ObjectUtils.isEmpty(index)) {
EquipmentSpecificIndex index = indexs.get(0);
EquipmentSpecific es = equipmentSpecificMapper.selectById(index.getEquipmentSpecificId()); EquipmentSpecific es = equipmentSpecificMapper.selectById(index.getEquipmentSpecificId());
es.setRealtimeIotEsIndexId(index.getId()); es.setRealtimeIotEsIndexId(index.getId());
es.setRealtimeIotIndexKey(index.getNameKey()); es.setRealtimeIotIndexKey(index.getNameKey());
......
package com.yeejoin.amos.boot.module.jcs.biz.controller; package com.yeejoin.amos.boot.module.jcs.biz.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.entity.JcSituationDetail;
import com.yeejoin.amos.boot.module.jcs.api.mapper.JcSituationDetailMapper;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; 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.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -22,6 +30,9 @@ import com.yeejoin.amos.boot.module.jcs.biz.service.impl.PowerTransferCompanySer ...@@ -22,6 +30,9 @@ import com.yeejoin.amos.boot.module.jcs.biz.service.impl.PowerTransferCompanySer
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
/** /**
...@@ -38,6 +49,18 @@ public class PowerTransferCompanyController extends BaseController { ...@@ -38,6 +49,18 @@ public class PowerTransferCompanyController extends BaseController {
@Autowired @Autowired
PowerTransferCompanyServiceImpl powerTransferCompanyService; PowerTransferCompanyServiceImpl powerTransferCompanyService;
@Autowired
SourceFileServiceImpl sourceFileService;
@Autowired
JcSituationDetailMapper jcSituationDetailMapper;
@Autowired
private EmqKeeper emqKeeper;
@Value("${mqtt.topic.command.power.deployment}")
private String topic;
/** /**
* 新增调派单位 * 新增调派单位
* *
...@@ -139,5 +162,29 @@ public class PowerTransferCompanyController extends BaseController { ...@@ -139,5 +162,29 @@ public class PowerTransferCompanyController extends BaseController {
page = powerTransferCompanyService.page(pageBean, powerTransferCompanyQueryWrapper); page = powerTransferCompanyService.page(pageBean, powerTransferCompanyQueryWrapper);
return page; return page;
} }
/**
* 新增文字信息图片信息
*
* @return 返回结果
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/jcSituationDetail/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增文字信息图片信息", notes = "新增文字信息图片信息")
public ResponseModel<Boolean> saveJcSituationDetail(@RequestBody JcSituationDetail jcSituationDetail) throws MqttException {
if (Objects.isNull(jcSituationDetail.getAlertCalledId())) {
throw new BadRequest("警情ID不能为空");
}
jcSituationDetailMapper.insert(jcSituationDetail);
// if (ObjectUtils.isNotEmpty(jcSituationDetail.getAttachments())) {
// sourceFileService.saveAttachments(jcSituationDetail.getSequenceNbr(), jcSituationDetail.getAttachments());
// }
// 自定义指令信息消息推送
// 定义指令信息消息推送 页面发送mqtt 默认发送 String 类型 0, 新警情 1 警情状态变化
emqKeeper.getMqttClient().publish(topic, "0".getBytes(), RuleConfig.DEFAULT_QOS, false);
return ResponseHelper.buildResponse(Boolean.TRUE);
}
} }
...@@ -32,6 +32,9 @@ import java.util.stream.IntStream; ...@@ -32,6 +32,9 @@ import java.util.stream.IntStream;
import com.yeejoin.amos.boot.module.command.api.dto.FrontlineLiaisonDto; import com.yeejoin.amos.boot.module.command.api.dto.FrontlineLiaisonDto;
import com.yeejoin.amos.boot.module.command.biz.service.impl.FrontlineLiaisonServiceImpl; import com.yeejoin.amos.boot.module.command.biz.service.impl.FrontlineLiaisonServiceImpl;
import com.yeejoin.amos.boot.module.common.api.service.ISourceFileService;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
import com.yeejoin.amos.boot.module.jcs.api.mapper.JcSituationDetailMapper;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTable;
...@@ -113,10 +116,6 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.SchedulingReportingDto; ...@@ -113,10 +116,6 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.SchedulingReportingDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateDto; import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto; import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto; import com.yeejoin.amos.boot.module.jcs.api.dto.VoiceRecordFileDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmitted;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmittedObject;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums;
...@@ -214,6 +213,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -214,6 +213,9 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
private FrontlineLiaisonServiceImpl frontlineLiaisonServiceImpl; private FrontlineLiaisonServiceImpl frontlineLiaisonServiceImpl;
@Autowired
JcSituationDetailMapper jcSituationDetailMapper;
@Value("${mqtt.topic.command.alert.noticeJa}") @Value("${mqtt.topic.command.alert.noticeJa}")
private String topicJa; private String topicJa;
...@@ -1434,6 +1436,20 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -1434,6 +1436,20 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
listInstructionsZHDto.add(instruct); listInstructionsZHDto.add(instruct);
}); });
//增加自定义指令信息:实战指挥需求【1575】
LambdaQueryWrapper<JcSituationDetail> qw = new LambdaQueryWrapper();
qw.eq(JcSituationDetail::getAlertCalledId, id);
List<JcSituationDetail> jcSituationDetailList = jcSituationDetailMapper.selectList(qw);
jcSituationDetailList.stream().forEach(item -> {
InstructionsZHDto instructionsZHDto = new InstructionsZHDto();
instructionsZHDto.setSequenceNbr(item.getSequenceNbr());
instructionsZHDto.setType(item.getInfoType());
instructionsZHDto.setContent(item.getInfo());
instructionsZHDto.setSubmissionTime(item.getRecDate());
listInstructionsZHDto.add(instructionsZHDto);
});
// ;
//排序时间倒序 //排序时间倒序
/* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 开始*/ /* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 开始*/
Collections.sort(listInstructionsZHDto, new Comparator<InstructionsZHDto>() { Collections.sort(listInstructionsZHDto, new Comparator<InstructionsZHDto>() {
......
...@@ -378,22 +378,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -378,22 +378,9 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
continue; continue;
paramMap.clear(); paramMap.clear();
paramMap.put("id", plan.getId()); paramMap.put("id", plan.getId());
// 2.1计划数据合法性校验
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
if (!fileFlag) {
paramMap.put("next_gen_date", tomorrow);
planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
continue;
}
// 2.2.计算生成数据的日期区间 // 2.2.计算生成数据的日期区间
CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, tomorrow, tomorrow); CalDateVo vo = PlanTaskUtil.reGenPlanTaskData(plan, tomorrow, tomorrow);
// 计划未开始,则更新生成时间为明天
if (null == vo) {
paramMap.put("next_gen_date", tomorrow);
planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
continue;
}
// 计划已过期,则更新status = 7,已完成 // 计划已过期,则更新status = 7,已完成
if (!vo.getIsGenData()) { if (!vo.getIsGenData()) {
int num = 0; int num = 0;
...@@ -413,9 +400,28 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -413,9 +400,28 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap.put("status", PlanStatusEnum.COMPLETED.getValue()); paramMap.put("status", PlanStatusEnum.COMPLETED.getValue());
} }
} }
if (plan.getIsFixedDate().equals("2")){
paramMap.put("status", PlanStatusEnum.OUT_TIME.getValue());
planMapper.updPlanStatusOrGenDate(paramMap);
continue;
}
planMapper.updPlanStatusOrGenDate(paramMap); planMapper.updPlanStatusOrGenDate(paramMap);
continue; continue;
} }
// 2.1计划数据合法性校验
Boolean fileFlag = PlanTaskUtil.checkMustFile(plan);
if (!fileFlag) {
paramMap.put("next_gen_date", tomorrow);
planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
continue;
}
// 计划未开始,则更新生成时间为明天
if (null == vo) {
paramMap.put("next_gen_date", tomorrow);
planMapper.updPlanStatusOrGenDate(paramMap);// 更新为明天
continue;
}
// 2.3.执行数据生成(具体时间 + 人员) // 2.3.执行数据生成(具体时间 + 人员)
List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.SCHED_FLAG); List<HashMap<String, Object>> list = genAllExeDate(plan, vo, XJConstant.SCHED_FLAG);
...@@ -757,7 +763,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -757,7 +763,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
ReginParams reginParam = JSON.parseObject(redisUtils ReginParams reginParam = JSON.parseObject(redisUtils
.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), .get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(),
ReginParams.class); ReginParams.class);
params.put("loginUserId", reginParam.getPersonIdentity().getPersonSeq()); // params.put("loginUserId", reginParam.getPersonIdentity().getPersonSeq());
long total = planTaskMapper.getPlanTasksCount(params); long total = planTaskMapper.getPlanTasksCount(params);
if (total == 0) { if (total == 0) {
return new PageImpl<>(content, pageParam, total); return new PageImpl<>(content, pageParam, total);
......
...@@ -3122,5 +3122,27 @@ ...@@ -3122,5 +3122,27 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="zs" id="2022-05-31-01">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="jc_situation_detail"/>
</not>
</preConditions>
<comment>增加自定义指令表</comment>
<sql>
CREATE TABLE `jc_situation_detail` (
`sequence_nbr` bigint(20) NOT NULL AUTO_INCREMENT,
`info` longtext COMMENT '内容图片信息',
`alert_called_id` bigint(20) DEFAULT NULL COMMENT '警情ID',
`rec_date` datetime DEFAULT NULL COMMENT '时间',
`rec_user_id` varchar(19) DEFAULT NULL COMMENT '发送人',
`rec_user_name` varchar(15) DEFAULT NULL COMMENT '发送人名称',
`is_delete` bit(1) NOT NULL COMMENT '是否删除',
`info_type` varchar(255) DEFAULT NULL COMMENT '消息类型',
PRIMARY KEY (`sequence_nbr`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
...@@ -1041,8 +1041,8 @@ ...@@ -1041,8 +1041,8 @@
<if test="key == 'endDeadline' and value != null and value != ''"> <if test="key == 'endDeadline' and value != null and value != ''">
and a.reform_limit_date <![CDATA[ <= ]]> #{value} and a.reform_limit_date <![CDATA[ <= ]]> #{value}
</if> </if>
<if test="key == 'pointName' and value != null and value != ''"> <if test="key == 'pointId' and value != null and value != ''">
and a.biz_info like concat('%"pointName":"', #{value}, '"%') and a.biz_info like concat('%"pointId":"', #{value}, '"%')
</if> </if>
</foreach> </foreach>
</where> </where>
......
package com.yeejoin.amos.boot.module.tzs.flc.api.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 任务表
*
* @author system_generator
* @date 2022-05-31
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="TaskDto", description="任务表")
public class TaskDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "任务名称")
private String name;
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "描述")
private String description;
@ApiModelProperty(value = "状态【0:待填报,1:待签收,2:已完成】")
private Integer status = 0;
@ApiModelProperty(value = "用户ID")
private String userId;
@ApiModelProperty(value = "创建时间")
private Date createDate;
@ApiModelProperty(value = "对接公司编码")
private String appId;
@ApiModelProperty(value = "单位ID")
private String deptId;
@ApiModelProperty(value = "单位名称")
private String deptName;
}
package com.yeejoin.amos.boot.module.tzs.flc.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 任务表
*
* @author system_generator
* @date 2022-05-31
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tz_task")
public class Task extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 任务名称
*/
@TableField("name")
private String name;
/**
* 内容
*/
@TableField("content")
private String content;
/**
* 描述
*/
@TableField("description")
private String description;
/**
* 状态【0:待填报,1:待签收,2:已完成】
*/
@TableField("status")
private Integer status;
/**
* 用户ID
*/
@TableField("user_id")
private String userId;
/**
* 创建时间
*/
@TableField("create_date")
private Date createDate;
/**
* 对接公司编码
*/
@TableField("app_id")
private String appId;
/**
* 单位ID
*/
@TableField("dept_id")
private String deptId;
/**
* 单位名称
*/
@TableField("dept_name")
private String deptName;
}
package com.yeejoin.amos.boot.module.tzs.flc.api.enums;
import lombok.Getter;
/**
* 任务状态枚举
*/
@Getter
public enum TaskStatusEnum {
待填报(0, "待填报"),
待签收(1, "待签收"),
已完成(2, "已完成");
private Integer key;
private String desc;
TaskStatusEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
}
package com.yeejoin.amos.boot.module.tzs.flc.api.mapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.Task;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 任务表 Mapper 接口
*
* @author system_generator
* @date 2022-05-31
*/
public interface TaskMapper extends BaseMapper<Task> {
}
package com.yeejoin.amos.boot.module.tzs.flc.api.service;
/**
* 任务表接口类
*
* @author system_generator
* @date 2022-05-31
*/
public interface ITaskService {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.tzs.flc.api.mapper.TaskMapper">
</mapper>
package com.yeejoin.amos.boot.module.tzs.flc.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.module.tzs.flc.api.enums.TaskStatusEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl.TaskServiceImpl;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.TaskDto;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
/**
* 任务表
*
* @author system_generator
* @date 2022-05-31
*/
@RestController
@Api(tags = "任务表Api")
@RequestMapping(value = "/task")
public class TaskController extends BaseController {
@Autowired
TaskServiceImpl taskServiceImpl;
/**
* 新增任务表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增任务表", notes = "新增任务表")
public ResponseModel<TaskDto> save(@RequestBody TaskDto model) {
model.setCreateDate(new Date());
model.setUserId(RequestContext.getExeUserId());
model = taskServiceImpl.createWithModel(model);
return ResponseHelper.buildResponse(model);
}
/**
* 根据sequenceNbr更新
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新任务表", notes = "根据sequenceNbr更新任务表")
public ResponseModel<TaskDto> updateBySequenceNbrTask(@RequestBody TaskDto model, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
model.setSequenceNbr(sequenceNbr);
return ResponseHelper.buildResponse(taskServiceImpl.updateWithModel(model));
}
/**
* 根据sequenceNbr删除
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "DELETE", value = "根据sequenceNbr删除任务表", notes = "根据sequenceNbr删除任务表")
public ResponseModel deleteBySequenceNbr(HttpServletRequest request, @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
taskServiceImpl.deleteById(sequenceNbr);
return ResponseHelper.buildResponse(null);
}
/**
* 根据sequenceNbr查询
*
* @param sequenceNbr 主键
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "根据sequenceNbr查询单个任务表", notes = "根据sequenceNbr查询单个任务表")
public ResponseModel<TaskDto> selectOne(@PathVariable Long sequenceNbr) {
return ResponseHelper.buildResponse(taskServiceImpl.queryBySeq(sequenceNbr));
}
/**
* 列表分页查询
*
* @param current 当前页
* @param current 每页大小
* @param status TODO(uncomplete: 待办,complete:已办)
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET", value = "任务表分页查询", notes = "任务表分页查询")
public ResponseModel<Page<TaskDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "status", required = false) String status) {
Page<TaskDto> page = new Page<TaskDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(taskServiceImpl.queryForTaskPageByStatus(page, RequestContext.getExeUserId(), status));
}
/**
* 统计任务数量
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "任务数量查询", notes = "任务数量查询")
@GetMapping(value = "/queryCount")
public ResponseModel<JSONObject> queryCountForMap() {
return ResponseHelper.buildResponse(taskServiceImpl.queryCountForMap(RequestContext.getExeUserId()));
}
/**
* 列表全部数据查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "任务表列表全部数据查询", notes = "任务表列表全部数据查询")
@GetMapping(value = "/list")
public ResponseModel<List<TaskDto>> selectForList() {
return ResponseHelper.buildResponse(taskServiceImpl.queryForTaskList());
}
}
package com.yeejoin.amos.boot.module.tzs.flc.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.TaskDto;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.Task;
import com.yeejoin.amos.boot.module.tzs.flc.api.enums.TaskStatusEnum;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.TaskMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ITaskService;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 任务表服务实现类
*
* @author system_generator
* @date 2022-05-31
*/
@Component
public class TaskServiceImpl extends BaseService<TaskDto, Task, TaskMapper> implements ITaskService {
public void deleteById(Long sequenceNbr) {
TaskDto taskDto = this.queryBySeq(sequenceNbr);
taskDto.setIsDelete(true);
this.updateWithModel(taskDto);
}
public Page<TaskDto> queryForTaskPageByStatus(Page<TaskDto> page, String userId, String status) {
List<Integer> statusList = getStatus(status);
return this.queryForTaskPage(page, userId, statusList);
}
public JSONObject queryCountForMap(String userId){
Date[] recDate = new Date[2];
Date now = DateUtils.getDateNow();
recDate[0] = DateUtils.getCurrentDayStartTime(now);
recDate[1] = DateUtils.getCurrentDayEndTime(now);
// 我的任务
Integer myTaskCount = this.queryForCount(userId, null, null);
// 今日待办
List<Integer> statusList = getStatus("uncomplete");
Integer todyUnCompletedTaskCount = this.queryForCount(userId, recDate, statusList);
// 未完结业务
Integer unCompletedTaskCount = this.queryForCount(userId, null, statusList);
JSONObject jsonObject = new JSONObject();
jsonObject.put("myTask", myTaskCount);
jsonObject.put("todyUnCompletedTask", todyUnCompletedTaskCount);
jsonObject.put("unCompletedTask", unCompletedTaskCount);
return jsonObject;
}
/**
* 分页查询
*/
public Page<TaskDto> queryForTaskPage(Page<TaskDto> page, String userId, @Condition(Operator.in) List<Integer> status) {
return this.queryForPage(page, null, false, userId, status);
}
/**
* 列表查询 示例
*/
public List<TaskDto> queryForTaskList() {
return this.queryForList("", false);
}
/**
* 列表查询 示例
*/
public Integer queryForCount(String userId, @Condition(Operator.between) Date[] recDate, @Condition(Operator.in) List<Integer> status) {
return this.queryCount(userId, recDate, status);
}
private List<Integer> getStatus (String status) {
List<Integer> statusList = new ArrayList<>();
if ("uncomplete".equals(status)) {
statusList.add(TaskStatusEnum.待填报.getKey());
statusList.add(TaskStatusEnum.待签收.getKey());
} else if ("complete".equals(status)) {
statusList.add(TaskStatusEnum.已完成.getKey());
}
return statusList;
}
}
\ 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