定时服务指令计划批量生成到指令池
This commit is contained in:
parent
636d7bc884
commit
0397b79ed1
|
|
@ -0,0 +1,48 @@
|
|||
package com.nu.modules.directive.datapool.controller;
|
||||
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import com.nu.modules.directive.datapool.service.IDataPoolService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令数据池管理
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags = "服务指令数据池管理")
|
||||
@RestController
|
||||
@RequestMapping("/nuIpadApi/directive/dataPool")
|
||||
@Slf4j
|
||||
public class DataPoolController extends JeecgController<DataPool, IDataPoolService> {
|
||||
|
||||
@Autowired
|
||||
private IDataPoolService service;
|
||||
|
||||
/**
|
||||
* 批量
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/generateDataPoolBatch")
|
||||
public Result<?> generateDataPoolBatch() {
|
||||
return service.generateDataPoolBatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增即时指令
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/addInstant")
|
||||
public Result<?> addInstant(DataPool dataPool) {
|
||||
return service.addInstant(dataPool);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
package com.nu.modules.directive.datapool.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令数据池主表
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_biz_nu_directive_data_pool")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_biz_nu_directive_data_pool对象", description="服务指令数据池主表")
|
||||
public class DataPool implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
/**id*/
|
||||
private String id;
|
||||
|
||||
/**服务指令计划id*/
|
||||
private String planId;
|
||||
|
||||
/**护理单元id*/
|
||||
private String nuId;
|
||||
|
||||
/**护理单元名称*/
|
||||
private String nuName;
|
||||
|
||||
/**客户id*/
|
||||
private String customerId;
|
||||
|
||||
/**客户姓名*/
|
||||
private String customerName;
|
||||
|
||||
/**服务指令id*/
|
||||
private String directiveId;
|
||||
|
||||
/**服务指令名称*/
|
||||
private String directiveName;
|
||||
|
||||
/**指令包id*/
|
||||
private String packageId;
|
||||
|
||||
/**指令包名称*/
|
||||
private String packageName;
|
||||
|
||||
/**是否是服务指令包 0否 1是*/
|
||||
private String izPackage;
|
||||
|
||||
/**开始时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
|
||||
/**结束时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date endTime;
|
||||
|
||||
/**是否派发 0否 1是*/
|
||||
private String izSend;
|
||||
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/**周期类型ID 1日常护理 2周期护理 3即时护理*/
|
||||
private String cycleTypeId;
|
||||
|
||||
/**周期类型*/
|
||||
@TableField(exist = false)
|
||||
private String cycleType;
|
||||
|
||||
/**周期值*/
|
||||
@TableField(exist = false)
|
||||
private String cycleValue;
|
||||
|
||||
/**服务时长*/
|
||||
@TableField(exist = false)
|
||||
private String serviceDuration;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.nu.modules.directive.datapool.job;
|
||||
|
||||
import com.nu.modules.directive.datapool.service.IDataPoolService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 指令计划批量生成到指令池
|
||||
*/
|
||||
@Slf4j
|
||||
public class DataPoolJob implements Job {
|
||||
|
||||
@Autowired
|
||||
IDataPoolService service;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
log.error("DataPoolJob:{}-{}", DateUtils.now(),"指令计划批量生成到指令池开始");
|
||||
Result<?> result = service.generateDataPoolBatch();
|
||||
log.error("DataPoolJob:{}-{}", DateUtils.now(),result.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.directive.datapool.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令数据池管理
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface DataPoolMapper extends BaseMapper<DataPool> {
|
||||
List<DataPool> queryList(DataPool dataPool);
|
||||
DataPool queryOne(DataPool dataPool);
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
<?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.nu.modules.directive.datapool.mapper.DataPoolMapper">
|
||||
|
||||
<select id="queryList" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id as planId,
|
||||
nu_id as nuId,
|
||||
nu_name as nuName,
|
||||
customer_id as customerId,
|
||||
customer_name as customerName,
|
||||
(case when iz_package = '1' then '' else directive_id end) as directiveId,
|
||||
(case when iz_package = '1' then '' else directive_name end) as directiveName,
|
||||
(case when iz_package = '1' then directive_id else '' end) as packageId,
|
||||
(case when iz_package = '1' then directive_name else '' end) as packageName,
|
||||
iz_package as izPackage,
|
||||
CONCAT(CURDATE(), ' ',STR_TO_DATE(start_time, '%H:%i')) as startTime,
|
||||
CONCAT(CURDATE(), ' ',STR_TO_DATE(end_time, '%H:%i')) as endTime,
|
||||
cycle_type_id as cycleTypeId,
|
||||
cycle_type as cycleType,
|
||||
cycle_value as cycleValue
|
||||
from nu_biz_nu_customer_server
|
||||
<where>
|
||||
<if test="nuId != null and nuId != ''">
|
||||
AND nu_id = #{nuId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND customer_id = #{customerId}
|
||||
</if>
|
||||
<if test="directiveId != null and directiveId != ''">
|
||||
AND directive_id = #{directiveId}
|
||||
</if>
|
||||
<if test="packageId != null and packageId != ''">
|
||||
AND package_id = #{packageId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND CONCAT(CURDATE(), ' ',STR_TO_DATE(start_time, '%H:%i')) >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND CONCAT(CURDATE(), ' ',STR_TO_DATE(start_time, '%H:%i')) <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryOne" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id,
|
||||
plan_id,
|
||||
nu_id,
|
||||
nu_name,
|
||||
customer_id,
|
||||
customer_name,
|
||||
directive_id,
|
||||
directive_name,
|
||||
cycle_type_id,
|
||||
package_id,
|
||||
package_name,
|
||||
iz_package,
|
||||
start_time,
|
||||
end_time,
|
||||
iz_send
|
||||
from nu_biz_nu_directive_data_pool
|
||||
<where>
|
||||
<if test="nuId != null and nuId != ''">
|
||||
AND nu_id = #{nuId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND customer_id = #{customerId}
|
||||
</if>
|
||||
<if test="directiveId != null and directiveId != ''">
|
||||
AND directive_id = #{directiveId}
|
||||
</if>
|
||||
<if test="packageId != null and packageId != ''">
|
||||
AND package_id = #{packageId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND start_time = #{startTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryInstantOne" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id,
|
||||
plan_id,
|
||||
nu_id,
|
||||
nu_name,
|
||||
customer_id,
|
||||
customer_name,
|
||||
directive_id,
|
||||
directive_name,
|
||||
cycle_type_id,
|
||||
package_id,
|
||||
package_name,
|
||||
iz_package,
|
||||
start_time,
|
||||
end_time,
|
||||
iz_send
|
||||
from nu_biz_nu_directive_data_pool
|
||||
<where>
|
||||
<if test="nuId != null and nuId != ''">
|
||||
AND nu_id = #{nuId}
|
||||
</if>
|
||||
<if test="customerId != null and customerId != ''">
|
||||
AND customer_id = #{customerId}
|
||||
</if>
|
||||
<if test="directiveId != null and directiveId != ''">
|
||||
AND directive_id = #{directiveId}
|
||||
</if>
|
||||
<if test="cycleTypeId != null and cycleTypeId != ''">
|
||||
AND cycle_type_id = #{cycleTypeId}
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
AND start_time >= #{startTime}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND start_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.nu.modules.directive.datapool.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令数据池管理
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-06
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IDataPoolService extends IService<DataPool> {
|
||||
|
||||
/**
|
||||
* 批量生成
|
||||
*/
|
||||
Result<?> generateDataPoolBatch();
|
||||
|
||||
/**
|
||||
* 单一生成
|
||||
* @param dataPool
|
||||
*/
|
||||
void generateDataPool(DataPool dataPool);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param dataPool
|
||||
*/
|
||||
void deleteDataPool(DataPool dataPool);
|
||||
|
||||
/**
|
||||
* 清理
|
||||
*/
|
||||
void cleanDataPool();
|
||||
|
||||
Result<?> addInstant(DataPool dataPool);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
package com.nu.modules.directive.datapool.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import com.nu.modules.directive.datapool.mapper.DataPoolMapper;
|
||||
import com.nu.modules.directive.datapool.service.IDataPoolService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令数据池管理
|
||||
* @Author: caolei
|
||||
* @Date: 2025-11-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> implements IDataPoolService {
|
||||
|
||||
/**
|
||||
* 批量生成
|
||||
*/
|
||||
@Override
|
||||
public Result<?> generateDataPoolBatch() {
|
||||
DataPool entity = new DataPool();
|
||||
Calendar c = Calendar.getInstance();
|
||||
entity.setStartTime(c.getTime());
|
||||
c.add(Calendar.MINUTE,10);
|
||||
entity.setEndTime(c.getTime());
|
||||
try{
|
||||
List<DataPool> planList = baseMapper.queryList(entity);//获取计划
|
||||
if(planList.size()>0){
|
||||
for(DataPool plan : planList){
|
||||
DataPool pool = baseMapper.queryOne(plan);
|
||||
if(pool!=null){
|
||||
continue;
|
||||
}
|
||||
addDataPool(plan);
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error("计划批量生成指令池错误:{}-{}", DateUtils.now(),e.getMessage());
|
||||
return Result.error("计划批量生成指令池错误");
|
||||
}
|
||||
return Result.OK("计划批量生成指令池成功");
|
||||
}
|
||||
|
||||
private void addDataPool(DataPool dataPool){
|
||||
String izPackage = dataPool.getIzPackage();
|
||||
if(izPackage!=null&&izPackage.equals("1")){
|
||||
//指令包,入指令池
|
||||
dataPool.setIzSend("0");
|
||||
this.save(dataPool);
|
||||
}else{
|
||||
String typeId = dataPool.getCycleTypeId();
|
||||
if(typeId!=null){
|
||||
if(typeId.equals("1")){
|
||||
//常规,入指令池
|
||||
dataPool.setIzSend("0");
|
||||
this.save(dataPool);
|
||||
}
|
||||
if(typeId.equals("2")){
|
||||
//周期,先判断是星期还是月份,再判断当前时间是否命中周期
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
String cycleValue = dataPool.getCycleValue();
|
||||
if(cycleValue.length()>1){
|
||||
//月周期
|
||||
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
Integer cv = Integer.valueOf(cycleValue);
|
||||
if(dayOfMonth == cv){
|
||||
//计划执行月中的几号是当天,则入指令池
|
||||
this.save(dataPool);
|
||||
}
|
||||
}else{
|
||||
//星期周期
|
||||
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); //1周日 2周一 3周二 4周三 5周四 6周五 7周六
|
||||
// cycleValue 存js的星期 0周一 1周二 2周三 3周四 4周五 5周六 6周日 js +2 2 3 4 5 6 7 8 /7 %
|
||||
Integer cv = Integer.valueOf(cycleValue);
|
||||
//处理js星期,使其能和java的星期进行比较
|
||||
cv = cv + 2;
|
||||
if(cv-7>0){
|
||||
cv = cv -7;
|
||||
}
|
||||
if(dayOfWeek == cv){
|
||||
//计划执行星期几是当天,则入指令池
|
||||
this.save(dataPool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单一生成
|
||||
* @param directiveDataPool
|
||||
*/
|
||||
@Override
|
||||
public void generateDataPool(DataPool directiveDataPool){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param directiveDataPool
|
||||
*/
|
||||
@Override
|
||||
public void deleteDataPool(DataPool directiveDataPool) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理
|
||||
*/
|
||||
@Override
|
||||
public void cleanDataPool() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<?> addInstant(DataPool dataPool){
|
||||
// DataPool entity = new DataPool();
|
||||
// Calendar c = Calendar.getInstance();
|
||||
// c.add(Calendar.MINUTE,1);
|
||||
// entity.setEndTime(c.getTime());
|
||||
// c.add(Calendar.MINUTE,10);
|
||||
// entity.setStartTime(c.getTime());
|
||||
|
||||
|
||||
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -89,9 +89,9 @@ public class ShiroConfig {
|
|||
// filterChainDefinitionMap.put("/api/nuInfo/**", "anon");//绑定护理单元
|
||||
|
||||
}
|
||||
|
||||
filterChainDefinitionMap.put("/api/tplink/videoStorage/**", "anon"); //视频缓存存储接口
|
||||
// filterChainDefinitionMap.put("/api/pad/invoicing/**", "anon"); //测试进销存对应的接口
|
||||
// filterChainDefinitionMap.put("/nuIpadApi/nuBizNuCustomerServer/**", "anon"); //服务指令测试
|
||||
filterChainDefinitionMap.put("/iot/tq/api/electricityMeter/**", "anon"); //电表回调
|
||||
filterChainDefinitionMap.put("/api/pad/baseInfo/**", "anon"); //电表回调
|
||||
filterChainDefinitionMap.put("/iot/tq/api/waterMeter/**", "anon"); //水表回调
|
||||
|
|
|
|||
Loading…
Reference in New Issue