指令计划删除和新增时,删除和生成对应指令数据池
This commit is contained in:
parent
98a569b174
commit
31413271bd
|
|
@ -8,6 +8,8 @@ import com.nu.modules.NuBizNuCustomerServer.mapper.NuBizNuCustomerServerMapper;
|
|||
import com.nu.modules.NuBizNuCustomerServer.service.INuBizNuCustomerElderTagService;
|
||||
import com.nu.modules.NuBizNuCustomerServer.service.INuBizNuCustomerServerInstantService;
|
||||
import com.nu.modules.NuBizNuCustomerServer.service.INuBizNuCustomerServerService;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import com.nu.modules.directive.datapool.service.impl.DataPoolServiceImpl;
|
||||
import com.nu.modules.nuApiServiceCategory.entity.NuConfigServiceCategory;
|
||||
import com.nu.modules.nuApiServiceCategory.entity.NuConfigServiceDirective;
|
||||
import com.nu.modules.nuApiServiceCategory.entity.NuConfigServiceType;
|
||||
|
|
@ -43,6 +45,8 @@ public class NuBizNuCustomerServerServiceImpl extends ServiceImpl<NuBizNuCustome
|
|||
private INuBizNuCustomerElderTagService nuBizNuCustomerElderTagService;
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
@Autowired
|
||||
private DataPoolServiceImpl dataPoolServiceImpl;
|
||||
|
||||
private String serverNetUrl;
|
||||
|
||||
|
|
@ -356,6 +360,10 @@ public class NuBizNuCustomerServerServiceImpl extends ServiceImpl<NuBizNuCustome
|
|||
public NuBizNuCustomerServer addDirective(NuBizNuCustomerServer nuBizNuCustomerServer) {
|
||||
baseMapper.insert(nuBizNuCustomerServer);
|
||||
//TODO 增加日志
|
||||
|
||||
//单一指令生成到数据池
|
||||
dataPoolServiceImpl.generateDataPool(nuBizNuCustomerServer);
|
||||
|
||||
return nuBizNuCustomerServer;
|
||||
}
|
||||
|
||||
|
|
@ -363,6 +371,18 @@ public class NuBizNuCustomerServerServiceImpl extends ServiceImpl<NuBizNuCustome
|
|||
public NuBizNuCustomerServerInstant addInstant(NuBizNuCustomerServerInstant customerServerInstant) {
|
||||
nuBizNuCustomerServerInstantService.save(customerServerInstant);
|
||||
//TODO 增加日志
|
||||
|
||||
//生成即时指令到数据池,测试
|
||||
// DataPool dataPool = new DataPool();
|
||||
// dataPool.setBizId(customerServerInstant.getId());
|
||||
// dataPool.setNuId(customerServerInstant.getNuId());
|
||||
// dataPool.setNuName(customerServerInstant.getNuName());
|
||||
// dataPool.setCustomerId(customerServerInstant.getCustomerId());
|
||||
// dataPool.setCustomerName(customerServerInstant.getCustomerName());
|
||||
// dataPool.setDirectiveId(customerServerInstant.getDirectiveId());
|
||||
// dataPool.setDirectiveName(customerServerInstant.getDirectiveName());
|
||||
// dataPool.setServiceDuration(customerServerInstant.getServiceDuration());
|
||||
// dataPoolServiceImpl.addInstant(dataPool);
|
||||
return customerServerInstant;
|
||||
}
|
||||
|
||||
|
|
@ -375,6 +395,10 @@ public class NuBizNuCustomerServerServiceImpl extends ServiceImpl<NuBizNuCustome
|
|||
|
||||
@Override
|
||||
public void deleteDirective(NuBizNuCustomerServer nuBizNuCustomerServer) {
|
||||
|
||||
//调用方法删除数据池中的数据
|
||||
dataPoolServiceImpl.deleteDataPool(nuBizNuCustomerServer.getId());
|
||||
|
||||
baseMapper.deleteByIdPhysic(nuBizNuCustomerServer.getId());
|
||||
//TODO 增加日志
|
||||
}
|
||||
|
|
@ -395,6 +419,9 @@ public class NuBizNuCustomerServerServiceImpl extends ServiceImpl<NuBizNuCustome
|
|||
public void editDirective(NuBizNuCustomerServer nuBizNuCustomerServer) {
|
||||
baseMapper.updateById(nuBizNuCustomerServer);
|
||||
//TODO 增加日志
|
||||
|
||||
//调用方法先删除数据池中的数据,在生成数据池中的数据
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ public class DataPool implements Serializable {
|
|||
/**id*/
|
||||
private String id;
|
||||
|
||||
/**服务指令计划id*/
|
||||
private String planId;
|
||||
/**业务id,服务指令计划id,即时指令计划id*/
|
||||
private String bizId;
|
||||
|
||||
/**护理单元id*/
|
||||
private String nuId;
|
||||
|
|
@ -112,4 +112,10 @@ public class DataPool implements Serializable {
|
|||
|
||||
/**是否删除 0未删除 1删除*/
|
||||
private String delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String tableName;//表名字
|
||||
|
||||
@TableField(exist = false)
|
||||
private String operationFlag;//操作标记 1正常删除入库 2撤回删除入库
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nu.modules.directive.datapool.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import com.nu.modules.directive.datapool.entity.DataPoolSub;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -13,6 +14,16 @@ import java.util.List;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
public interface DataPoolMapper extends BaseMapper<DataPool> {
|
||||
List<DataPool> queryList(DataPool dataPool);
|
||||
DataPool queryOne(DataPool dataPool);
|
||||
List<DataPool> queryPlanList(DataPool dataPool);
|
||||
DataPool queryPlanById(@Param("id") String id);
|
||||
DataPool queryPoolOne(DataPool dataPool);
|
||||
|
||||
void createDataPoolLog(DataPool dataPool);
|
||||
void createDataPoolLogSub(DataPool dataPool);
|
||||
|
||||
void addDataPoolLog(DataPool dataPool);
|
||||
void addDataPoolSubLog(DataPool dataPool);
|
||||
|
||||
void deleteDataPool(DataPool dataPool);
|
||||
void deleteDataPoolSub(DataPool dataPool);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
<!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="queryPlanList" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id as planId,
|
||||
id as bizId,
|
||||
nu_id as nuId,
|
||||
nu_name as nuName,
|
||||
customer_id as customerId,
|
||||
|
|
@ -42,10 +42,31 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryOne" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
<select id="queryPlanById" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id as bizId,
|
||||
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_care_server
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryPoolOne" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id,
|
||||
plan_id,
|
||||
biz_id,
|
||||
nu_id,
|
||||
nu_name,
|
||||
customer_id,
|
||||
|
|
@ -61,6 +82,9 @@
|
|||
iz_send
|
||||
from nu_biz_nu_directive_data_pool
|
||||
<where>
|
||||
<if test="bizId != null and bizId != ''">
|
||||
AND biz_id = #{bizId}
|
||||
</if>
|
||||
<if test="nuId != null and nuId != ''">
|
||||
AND nu_id = #{nuId}
|
||||
</if>
|
||||
|
|
@ -76,13 +100,16 @@
|
|||
<if test="startTime != null">
|
||||
AND start_time = #{startTime}
|
||||
</if>
|
||||
<if test="izSend != null and izSend != ''">
|
||||
AND iz_send = #{izSend}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="queryInstantOne" resultType="com.nu.modules.directive.datapool.entity.DataPool">
|
||||
select
|
||||
id,
|
||||
plan_id,
|
||||
biz_id,
|
||||
nu_id,
|
||||
nu_name,
|
||||
customer_id,
|
||||
|
|
@ -119,4 +146,131 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="existsTable" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_NAME = #{tableName}
|
||||
AND TABLE_SCHEMA = (SELECT DATABASE())
|
||||
</select>
|
||||
|
||||
<update id="createDataPoolLog">
|
||||
CREATE TABLE IF NOT EXISTS ${tableName} (
|
||||
id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
|
||||
biz_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令计划ID,nu_biz_nu_customer_server.id;即时指令计划ID,nu_biz_nu_customer_care_server_instant.id',
|
||||
nu_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '护理单元ID,nu_base_info.id',
|
||||
nu_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '护理单元名称',
|
||||
customer_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户ID,nu_biz_customer_info.id',
|
||||
customer_name varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户名称',
|
||||
directive_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令ID,nu_config_service_directive.id',
|
||||
directive_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令名称',
|
||||
cycle_type_id varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '周期类型ID',
|
||||
package_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令包ID',
|
||||
package_name varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令包名称',
|
||||
iz_package varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否是服务指令包 0否 1是',
|
||||
start_time datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
|
||||
end_time datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
|
||||
iz_send varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '是否派发 0否 1是',
|
||||
create_by varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime(0) NULL DEFAULT NULL COMMENT '创建日期',
|
||||
update_by varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
|
||||
update_time datetime(0) NULL DEFAULT NULL COMMENT '更新日期',
|
||||
del_flag varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '是否删除 0未删除 1删除',
|
||||
operation_flag varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作标记 1正常删除入库 2撤回删除入库',
|
||||
PRIMARY KEY (id) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '护理单元-服务指令-数据池日志主表' ROW_FORMAT = Dynamic;
|
||||
</update>
|
||||
|
||||
<update id="createDataPoolLogSub">
|
||||
CREATE TABLE IF NOT EXISTS ${tableName} (
|
||||
id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ID',
|
||||
main_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '主表ID,nu_biz_nu_directive_data_pool.id',
|
||||
nu_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '护理单元ID,nu_base_info.id',
|
||||
nu_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '护理单元名称',
|
||||
instruction_tag_id varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类标签',
|
||||
instruction_tag_name varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '分类标签名称',
|
||||
customer_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户ID,nu_biz_customer_info.id',
|
||||
customer_name varchar(150) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户名称',
|
||||
category_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务类别ID,nu_config_service_category.id',
|
||||
category_name varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务类别名称',
|
||||
type_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务类型ID,nu_config_service_type.id',
|
||||
type_name varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务类型名称',
|
||||
directive_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令ID,nu_config_service_directive.id',
|
||||
directive_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令名称',
|
||||
cycle_type_id varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '周期类型ID',
|
||||
cycle_type varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '周期类型',
|
||||
cycle_value varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '周期值',
|
||||
preview_file varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令图片大图',
|
||||
preview_file_small varchar(300) CHARACTER SET utf32 COLLATE utf32_general_ci NULL DEFAULT NULL COMMENT '服务指令图片小图',
|
||||
mp3_file varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '语音文件',
|
||||
mp4_file varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '视频文件',
|
||||
service_duration varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务时长(分钟)',
|
||||
service_content varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务说明',
|
||||
package_id varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令包ID',
|
||||
package_name varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '服务指令包名称',
|
||||
iz_package varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否是服务指令包 0否 1是',
|
||||
start_time datetime(0) NULL DEFAULT NULL COMMENT '开始时间',
|
||||
end_time datetime(0) NULL DEFAULT NULL COMMENT '结束时间',
|
||||
create_by varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime(0) NULL DEFAULT NULL COMMENT '创建日期',
|
||||
update_by varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人',
|
||||
update_time datetime(0) NULL DEFAULT NULL COMMENT '更新日期',
|
||||
del_flag varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '是否删除 0未删除 1删除',
|
||||
operation_flag varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作标记 1正常删除入库 2撤回删除入库',
|
||||
PRIMARY KEY (id) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '护理单元-服务指令-数据池日志子表' ROW_FORMAT = Dynamic;
|
||||
</update>
|
||||
|
||||
<update id="addDataPoolLog">
|
||||
insert into ${tableName}
|
||||
select a.*,#{operationFlag}
|
||||
from nu_biz_nu_directive_data_pool a
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND a.create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<update id="addDataPoolSubLog">
|
||||
insert into ${tableName}
|
||||
select a.*,#{operationFlag}
|
||||
from nu_biz_nu_directive_data_pool_sub a
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
AND main_id = #{id}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND a.create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<update id="deleteDataPool">
|
||||
delete from nu_biz_nu_directive_data_pool a
|
||||
where a.create_time <= #{endTime}
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
AND id = #{id}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND a.create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<update id="deleteDataPoolSub">
|
||||
delete from nu_biz_nu_directive_data_pool_sub a
|
||||
<where>
|
||||
<if test="id != null and id != ''">
|
||||
AND main_id = #{id}
|
||||
</if>
|
||||
<if test="endTime != null">
|
||||
AND a.create_time <= #{endTime}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nu.modules.directive.datapool.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.NuBizNuCustomerServer.entity.NuBizNuCustomerServer;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
|
||||
|
|
@ -19,15 +20,15 @@ public interface IDataPoolService extends IService<DataPool> {
|
|||
|
||||
/**
|
||||
* 单一生成
|
||||
* @param dataPool
|
||||
* @param nuBizNuCustomerServer
|
||||
*/
|
||||
void generateDataPool(DataPool dataPool);
|
||||
void generateDataPool(NuBizNuCustomerServer nuBizNuCustomerServer);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param dataPool
|
||||
* @param id
|
||||
*/
|
||||
void deleteDataPool(DataPool dataPool);
|
||||
void deleteDataPool(String id);
|
||||
|
||||
/**
|
||||
* 清理
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
package com.nu.modules.directive.datapool.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.NuBizNuCustomerServer.entity.NuBizNuCustomerServer;
|
||||
import com.nu.modules.directive.datapool.entity.DataPool;
|
||||
import com.nu.modules.directive.datapool.entity.DataPoolSub;
|
||||
import com.nu.modules.directive.datapool.mapper.DataPoolMapper;
|
||||
import com.nu.modules.directive.datapool.mapper.DataPoolSubMapper;
|
||||
import com.nu.modules.directive.datapool.service.IDataPoolService;
|
||||
import com.nu.modules.directive.datapool.service.IDataPoolSubService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -30,26 +28,24 @@ import java.util.List;
|
|||
@Slf4j
|
||||
public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> implements IDataPoolService {
|
||||
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
@Autowired
|
||||
IDataPoolSubService dataPoolSubService;
|
||||
|
||||
/**
|
||||
* 批量生成
|
||||
* 批量生成数据池
|
||||
*/
|
||||
@Override
|
||||
public Result<?> generateDataPoolBatch() {
|
||||
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);//获取计划
|
||||
List<DataPool> planList = baseMapper.queryPlanList(entity);//获取计划
|
||||
if(planList.size()>0){
|
||||
for(DataPool plan : planList){
|
||||
DataPool pool = baseMapper.queryOne(plan);
|
||||
DataPool pool = baseMapper.queryPoolOne(plan);
|
||||
if(pool!=null){
|
||||
continue;
|
||||
}
|
||||
|
|
@ -63,6 +59,9 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
return Result.OK("计划批量生成指令池成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 指令生成数据池
|
||||
*/
|
||||
private void addDataPool(DataPool dataPool){
|
||||
dataPool.setIzSend("0");
|
||||
dataPool.setDelFlag("0");
|
||||
|
|
@ -90,7 +89,9 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
}
|
||||
}
|
||||
|
||||
//生成日常
|
||||
/**
|
||||
* 日常指令生成数据池子表(非包)
|
||||
*/
|
||||
private void addDaily(DataPool dataPool){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
|
|
@ -98,7 +99,9 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
addSub(dataPool);
|
||||
}
|
||||
|
||||
//生成星期周期
|
||||
/**
|
||||
* 星期周期指令生成数据池子表(非包)
|
||||
*/
|
||||
private void addWeekDay(DataPool dataPool){
|
||||
String cycleValue = dataPool.getCycleValue();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
|
@ -119,7 +122,9 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
}
|
||||
}
|
||||
|
||||
//生成月周期
|
||||
/**
|
||||
* 月周期指令生成数据池子表(非包)
|
||||
*/
|
||||
private void addMonthDay(DataPool dataPool){
|
||||
String cycleValue = dataPool.getCycleValue();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
|
@ -134,15 +139,9 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
}
|
||||
}
|
||||
|
||||
//生成指令包
|
||||
private void addPackage(DataPool dataPool){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
//入指令池子表
|
||||
addPackageSubs(dataPool);
|
||||
}
|
||||
|
||||
//生成数据池子表
|
||||
/**
|
||||
* 指令生成数据池子表(非包)
|
||||
*/
|
||||
private void addSub(DataPool dataPool){
|
||||
DataPoolSub entity = new DataPoolSub();
|
||||
entity.setDirectiveId(dataPool.getDirectiveId());
|
||||
|
|
@ -160,7 +159,19 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
dataPoolSubService.save(dataPoolSub);
|
||||
}
|
||||
|
||||
//生成数据池子表
|
||||
/**
|
||||
* 指令包生成数据池
|
||||
*/
|
||||
private void addPackage(DataPool dataPool){
|
||||
//入指令池主表
|
||||
this.save(dataPool);
|
||||
//入指令池子表
|
||||
addPackageSubs(dataPool);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指令包中指令进行规则判断,并生成到数据池子表
|
||||
*/
|
||||
private void addPackageSubs(DataPool dataPool){
|
||||
DataPoolSub entity = new DataPoolSub();
|
||||
entity.setPackageId(dataPool.getPackageId());
|
||||
|
|
@ -169,11 +180,11 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
DataPoolSub dataPoolSub = subList.get(i);
|
||||
String cycleValue = dataPoolSub.getCycleValue();
|
||||
if(cycleValue==null || cycleValue.equals("")){
|
||||
//日常
|
||||
//指令包中日常指令
|
||||
addPackageSub(dataPool,dataPoolSub);
|
||||
}else{
|
||||
if(cycleValue.length()>1){
|
||||
//月周期
|
||||
//指令包中月周期指令
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
Integer cv = Integer.valueOf(cycleValue);
|
||||
|
|
@ -182,7 +193,7 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
addPackageSub(dataPool,dataPoolSub);
|
||||
}
|
||||
}else{
|
||||
//星期周期
|
||||
//指令包中星期周期指令
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
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 %
|
||||
|
|
@ -201,6 +212,9 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指令生成到数据池子表
|
||||
*/
|
||||
private void addPackageSub(DataPool dataPool,DataPoolSub dataPoolSub){
|
||||
dataPoolSub.setNuId(dataPool.getNuId());
|
||||
dataPoolSub.setNuName(dataPool.getNuName());
|
||||
|
|
@ -217,46 +231,148 @@ public class DataPoolServiceImpl extends ServiceImpl<DataPoolMapper, DataPool> i
|
|||
}
|
||||
|
||||
/**
|
||||
* 单一生成
|
||||
* @param directiveDataPool
|
||||
* 单一指令生成到数据池
|
||||
* @param nuBizNuCustomerServer
|
||||
*/
|
||||
@Override
|
||||
public void generateDataPool(DataPool directiveDataPool){
|
||||
|
||||
public void generateDataPool(NuBizNuCustomerServer nuBizNuCustomerServer){
|
||||
DataPool dataPool = new DataPool();
|
||||
dataPool.setBizId(nuBizNuCustomerServer.getId());
|
||||
dataPool.setNuId(nuBizNuCustomerServer.getNuId());
|
||||
dataPool.setNuName(nuBizNuCustomerServer.getNuName());
|
||||
dataPool.setCustomerId(nuBizNuCustomerServer.getCustomerId());
|
||||
dataPool.setCustomerName(nuBizNuCustomerServer.getCustomerName());
|
||||
dataPool.setDirectiveId(nuBizNuCustomerServer.getDirectiveId());
|
||||
dataPool.setDirectiveName(nuBizNuCustomerServer.getDirectiveName());
|
||||
dataPool.setServiceDuration(nuBizNuCustomerServer.getServiceDuration());
|
||||
dataPool.setCycleTypeId(nuBizNuCustomerServer.getCycleTypeId());
|
||||
dataPool.setIzPackage(nuBizNuCustomerServer.getIzPackage());
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.SECOND,0);
|
||||
c.add(Calendar.MINUTE,1);
|
||||
dataPool.setStartTime(c.getTime());
|
||||
String serviceDuration = dataPool.getServiceDuration();
|
||||
c.add(Calendar.MINUTE,Integer.valueOf(serviceDuration));
|
||||
dataPool.setEndTime(c.getTime());
|
||||
addDataPool(dataPool);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param directiveDataPool
|
||||
* 删除数据池
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void deleteDataPool(DataPool directiveDataPool) {
|
||||
|
||||
public void deleteDataPool(String id) {
|
||||
DataPool entity = baseMapper.queryPlanById(id);
|
||||
entity.setIzSend("0");
|
||||
DataPool dataPool = baseMapper.queryPoolOne(entity);
|
||||
if(dataPool!=null){
|
||||
Calendar c = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = sdf.format(c.getTime());
|
||||
addDataPoolLog(dateStr,dataPool.getId());
|
||||
addDataPoolSubLog(dateStr,dataPool.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理
|
||||
* 创建日志表
|
||||
*/
|
||||
private void addDataPoolLog(String dateStr,String id){
|
||||
String tableName = "nu_biz_nu_directive_data_pool_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
DataPool dataPool = new DataPool();
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createDataPoolLog(dataPool);//创建日志主表
|
||||
dataPool.setId(id);
|
||||
dataPool.setOperationFlag("2");
|
||||
baseMapper.addDataPoolLog(dataPool);//保存数据池数据到日志主表
|
||||
baseMapper.deleteDataPool(dataPool);//删除昨天及之前的数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建日志表
|
||||
*/
|
||||
private void addDataPoolSubLog(String dateStr,String id){
|
||||
String tableName = "nu_biz_nu_directive_data_pool_sub_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
DataPool dataPool = new DataPool();
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createDataPoolLogSub(dataPool);//创建日志子表
|
||||
dataPool.setId(id);
|
||||
dataPool.setOperationFlag("2");
|
||||
baseMapper.addDataPoolSubLog(dataPool);//保存数据池数据到日志子表
|
||||
baseMapper.deleteDataPoolSub(dataPool);//删除昨天及之前的数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理数据池数据
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void cleanDataPool() {
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.add(Calendar.DAY_OF_MONTH,-1);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String dateStr = sdf.format(c.getTime());
|
||||
//创建日志表,保存数据池数据到日志表,删除昨天及之前的数据
|
||||
addDataPoolLogByClean(dateStr);
|
||||
addDataPoolSubLogByClean(dateStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建日志表
|
||||
*/
|
||||
private void addDataPoolLogByClean(String dateStr){
|
||||
String tableName = "nu_biz_nu_directive_data_pool_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
DataPool dataPool = new DataPool();
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createDataPoolLog(dataPool);//创建日志主表
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.HOUR,0);
|
||||
c.set(Calendar.MINUTE,0);
|
||||
c.set(Calendar.SECOND,0);
|
||||
dataPool.setEndTime(c.getTime());
|
||||
dataPool.setOperationFlag("1");
|
||||
baseMapper.addDataPoolLog(dataPool);//保存数据池数据到日志主表
|
||||
baseMapper.deleteDataPool(dataPool);//删除昨天及之前的数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建日志表
|
||||
*/
|
||||
private void addDataPoolSubLogByClean(String dateStr){
|
||||
String tableName = "nu_biz_nu_directive_data_pool_sub_log_"+dateStr.substring(2, 4)+dateStr.substring(5, 7);
|
||||
DataPool dataPool = new DataPool();
|
||||
dataPool.setTableName(tableName);
|
||||
baseMapper.createDataPoolLogSub(dataPool);//创建日志子表
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.HOUR,0);
|
||||
c.set(Calendar.MINUTE,0);
|
||||
c.set(Calendar.SECOND,0);
|
||||
dataPool.setEndTime(c.getTime());
|
||||
dataPool.setOperationFlag("1");
|
||||
baseMapper.addDataPoolSubLog(dataPool);//保存数据池数据到日志子表
|
||||
baseMapper.deleteDataPoolSub(dataPool);//删除昨天及之前的数据
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成即时指令到数据池
|
||||
* @param dataPool
|
||||
* @return
|
||||
*/
|
||||
@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());
|
||||
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
JSONObject sysUser = sysBaseAPI.queryUserById(user.getId());
|
||||
String employessId = sysUser.getString("employessId");
|
||||
dataPool.setCreateBy(employessId);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.SECOND,0);
|
||||
c.add(Calendar.MINUTE,1);
|
||||
dataPool.setStartTime(c.getTime());
|
||||
String serviceDuration = dataPool.getServiceDuration();
|
||||
c.add(Calendar.MINUTE,Integer.valueOf(serviceDuration));
|
||||
dataPool.setEndTime(c.getTime());
|
||||
dataPool.setCycleTypeId("3");
|
||||
this.save(dataPool);
|
||||
dataPool.setIzPackage("0");
|
||||
dataPool.setIzSend("0");
|
||||
dataPool.setDelFlag("0");
|
||||
addDaily(dataPool);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue