diff --git a/nursing-unit-api/src/main/java/com/nu/modules/NuBizNuCustomerServer/service/impl/NuBizNuCustomerServerServiceImpl.java b/nursing-unit-api/src/main/java/com/nu/modules/NuBizNuCustomerServer/service/impl/NuBizNuCustomerServerServiceImpl.java index a372c505..91da9dd4 100644 --- a/nursing-unit-api/src/main/java/com/nu/modules/NuBizNuCustomerServer/service/impl/NuBizNuCustomerServerServiceImpl.java +++ b/nursing-unit-api/src/main/java/com/nu/modules/NuBizNuCustomerServer/service/impl/NuBizNuCustomerServerServiceImpl.java @@ -395,11 +395,11 @@ public class NuBizNuCustomerServerServiceImpl extends ServiceImpl delete from nu_biz_nu_directive_data_pool a - where a.create_time <= #{endTime} AND id = #{id} diff --git a/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/IDataPoolService.java b/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/IDataPoolService.java index bca75a37..c5365110 100644 --- a/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/IDataPoolService.java +++ b/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/IDataPoolService.java @@ -28,7 +28,14 @@ public interface IDataPoolService extends IService { * 删除 * @param id */ - void deleteDataPool(String id); + void deleteDataPool(NuBizNuCustomerServer nuBizNuCustomerServer); + + /** + * 修改 + * @param nuBizNuCustomerServer + */ + void editDataPool(NuBizNuCustomerServer nuBizNuCustomerServer); + /** * 清理 diff --git a/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/impl/DataPoolServiceImpl.java b/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/impl/DataPoolServiceImpl.java index e1df031c..9a358d92 100644 --- a/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/impl/DataPoolServiceImpl.java +++ b/nursing-unit-api/src/main/java/com/nu/modules/directive/datapool/service/impl/DataPoolServiceImpl.java @@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Date; import java.util.List; /** @@ -38,6 +39,8 @@ public class DataPoolServiceImpl extends ServiceImpl i public Result generateDataPoolBatch() { DataPool entity = new DataPool(); Calendar c = Calendar.getInstance(); + c.set(Calendar.SECOND,0); + c.set(Calendar.MILLISECOND,0); entity.setStartTime(c.getTime()); c.add(Calendar.MINUTE,10); entity.setEndTime(c.getTime()); @@ -63,26 +66,37 @@ public class DataPoolServiceImpl extends ServiceImpl i * 指令生成数据池 */ private void addDataPool(DataPool dataPool){ - dataPool.setIzSend("0"); - dataPool.setDelFlag("0"); - String izPackage = dataPool.getIzPackage(); - if(izPackage!=null&&izPackage.equals("1")){ - addPackage(dataPool); - }else{ - String typeId = dataPool.getCycleTypeId(); - if(typeId!=null){ - if(typeId.equals("1")){ - addDaily(dataPool); - } - if(typeId.equals("2")){ - //周期,先判断是星期还是月份,再判断当前时间是否命中周期 - String cycleValue = dataPool.getCycleValue(); - if(cycleValue.length()>1){ - //月周期 - addMonthDay(dataPool); - }else{ - //星期周期 - addWeekDay(dataPool); + Date dataTime = dataPool.getStartTime(); + Calendar c = Calendar.getInstance(); + c.set(Calendar.SECOND,0); + c.set(Calendar.MILLISECOND,0); + Date startTime = c.getTime(); + c.add(Calendar.MINUTE,10); + Date endTime = c.getTime(); + if(dataTime.getTime()>=startTime.getTime()){ + if(dataTime.getTime()<=endTime.getTime()){ + dataPool.setIzSend("0"); + dataPool.setDelFlag("0"); + String izPackage = dataPool.getIzPackage(); + if(izPackage!=null&&izPackage.equals("1")){ + addPackage(dataPool); + }else{ + String typeId = dataPool.getCycleTypeId(); + if(typeId!=null){ + if(typeId.equals("1")){ + addDaily(dataPool); + } + if(typeId.equals("2")){ + //周期,先判断是星期还是月份,再判断当前时间是否命中周期 + String cycleValue = dataPool.getCycleValue(); + if(cycleValue.length()>1){ + //月周期 + addMonthDay(dataPool); + }else{ + //星期周期 + addWeekDay(dataPool); + } + } } } } @@ -242,36 +256,83 @@ public class DataPoolServiceImpl extends ServiceImpl i 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()); + if(nuBizNuCustomerServer.getIzPackage().equals("1")){ + dataPool.setPackageId(nuBizNuCustomerServer.getDirectiveId()); + dataPool.setPackageName(nuBizNuCustomerServer.getDirectiveName()); + }else{ + dataPool.setDirectiveId(nuBizNuCustomerServer.getDirectiveId()); + dataPool.setDirectiveName(nuBizNuCustomerServer.getDirectiveName()); + } + String startTime = nuBizNuCustomerServer.getStartTime(); + String hour = startTime.substring(0, 2); + String minute = startTime.substring(3, 5); Calendar c = Calendar.getInstance(); + c.set(Calendar.HOUR_OF_DAY,Integer.valueOf(hour)); + c.set(Calendar.MINUTE,Integer.valueOf(minute)); c.set(Calendar.SECOND,0); - c.add(Calendar.MINUTE,1); + c.set(Calendar.MILLISECOND,0); dataPool.setStartTime(c.getTime()); - String serviceDuration = dataPool.getServiceDuration(); - c.add(Calendar.MINUTE,Integer.valueOf(serviceDuration)); + String endTime = nuBizNuCustomerServer.getEndTime(); + hour = endTime.substring(0, 2); + minute = endTime.substring(3, 5); + c.set(Calendar.HOUR_OF_DAY,Integer.valueOf(hour)); + c.set(Calendar.MINUTE,Integer.valueOf(minute)); + c.set(Calendar.SECOND,0); + c.set(Calendar.MILLISECOND,0); dataPool.setEndTime(c.getTime()); addDataPool(dataPool); } /** * 删除数据池 - * @param id + * @param nuBizNuCustomerServer */ @Override - 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(); + public void deleteDataPool(NuBizNuCustomerServer nuBizNuCustomerServer) { + String startTime = nuBizNuCustomerServer.getStartTime(); + String hour = startTime.substring(0, 2); + String minute = startTime.substring(3, 5); + Calendar c = Calendar.getInstance(); + c.set(Calendar.HOUR_OF_DAY,Integer.valueOf(hour)); + c.set(Calendar.MINUTE,Integer.valueOf(minute)); + c.set(Calendar.SECOND,0); + c.set(Calendar.MILLISECOND,0); + DataPool dataPool = new DataPool(); + dataPool.setBizId(nuBizNuCustomerServer.getId()); + dataPool.setNuId(nuBizNuCustomerServer.getNuId()); + dataPool.setCustomerId(nuBizNuCustomerServer.getCustomerId()); + dataPool.setStartTime(c.getTime()); + dataPool.setIzSend("0"); + String izPackage = nuBizNuCustomerServer.getIzPackage(); + if(izPackage.equals("1")){ + dataPool.setPackageId(nuBizNuCustomerServer.getDirectiveId()); + }else{ + dataPool.setDirectiveId(nuBizNuCustomerServer.getDirectiveId()); + } + DataPool pool = baseMapper.queryPoolOne(dataPool); + if(pool!=null){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateStr = sdf.format(c.getTime()); - addDataPoolLog(dateStr,dataPool.getId()); - addDataPoolSubLog(dateStr,dataPool.getId()); + addDataPoolLog(dateStr,pool.getId()); + addDataPoolSubLog(dateStr,pool.getId()); + } + } + + /** + * 编辑数据池 + * @param nuBizNuCustomerServer + */ + @Override + public void editDataPool(NuBizNuCustomerServer nuBizNuCustomerServer) { + deleteDataPool(nuBizNuCustomerServer); + DataPool dataPool = baseMapper.queryPlanById(nuBizNuCustomerServer.getId()); + DataPool pool = baseMapper.queryPoolOne(dataPool); + if(pool==null){ + + addDataPool(dataPool);; } } @@ -327,9 +388,10 @@ public class DataPoolServiceImpl extends ServiceImpl i dataPool.setTableName(tableName); baseMapper.createDataPoolLog(dataPool);//创建日志主表 Calendar c = Calendar.getInstance(); - c.set(Calendar.HOUR,0); + c.set(Calendar.HOUR_OF_DAY,0); c.set(Calendar.MINUTE,0); c.set(Calendar.SECOND,0); + c.set(Calendar.MILLISECOND,0); dataPool.setEndTime(c.getTime()); dataPool.setOperationFlag("1"); baseMapper.addDataPoolLog(dataPool);//保存数据池数据到日志主表 @@ -345,9 +407,10 @@ public class DataPoolServiceImpl extends ServiceImpl i dataPool.setTableName(tableName); baseMapper.createDataPoolLogSub(dataPool);//创建日志子表 Calendar c = Calendar.getInstance(); - c.set(Calendar.HOUR,0); + c.set(Calendar.HOUR_OF_DAY,0); c.set(Calendar.MINUTE,0); c.set(Calendar.SECOND,0); + c.set(Calendar.MILLISECOND,0); dataPool.setEndTime(c.getTime()); dataPool.setOperationFlag("1"); baseMapper.addDataPoolSubLog(dataPool);//保存数据池数据到日志子表 @@ -362,6 +425,7 @@ public class DataPoolServiceImpl extends ServiceImpl i @Override public Result addInstant(DataPool dataPool){ Calendar c = Calendar.getInstance(); + c.set(Calendar.MILLISECOND,0); c.set(Calendar.SECOND,0); c.add(Calendar.MINUTE,1); dataPool.setStartTime(c.getTime());