Commit 94ad2118 authored by lings's avatar lings

Merge branch 'master' into lings

parents 6d37d496 1282ba88
# Created by .ignore support plugin (hsz.mobi)
...@@ -80,6 +80,7 @@ public class AppointmentOrderController { ...@@ -80,6 +80,7 @@ public class AppointmentOrderController {
/*
@GetMapping(value = "/signin/{appointmentOrderId}") @GetMapping(value = "/signin/{appointmentOrderId}")
@ApiOperation("签到") @ApiOperation("签到")
@LogOperation("签到") @LogOperation("签到")
...@@ -96,6 +97,7 @@ public class AppointmentOrderController { ...@@ -96,6 +97,7 @@ public class AppointmentOrderController {
return new Result(); return new Result();
} }
*/
@DeleteMapping @DeleteMapping
@ApiOperation("删除") @ApiOperation("删除")
......
...@@ -56,7 +56,7 @@ public class AppointmentOrderDTO implements Serializable { ...@@ -56,7 +56,7 @@ public class AppointmentOrderDTO implements Serializable {
private String appointmentIdCard; private String appointmentIdCard;
@ApiModelProperty(value = "预约时间") @ApiModelProperty(value = "预约时间")
private Date appointmentTime; private String appointmentTime;
@ApiModelProperty(value = "服务办事窗口") @ApiModelProperty(value = "服务办事窗口")
private String serviceWindow; private String serviceWindow;
...@@ -86,4 +86,4 @@ public class AppointmentOrderDTO implements Serializable { ...@@ -86,4 +86,4 @@ public class AppointmentOrderDTO implements Serializable {
private Date updateDate; private Date updateDate;
} }
\ No newline at end of file
...@@ -28,6 +28,9 @@ public class AppointmentServiceDTO implements Serializable { ...@@ -28,6 +28,9 @@ public class AppointmentServiceDTO implements Serializable {
@ApiModelProperty(value = "服务事项父类id") @ApiModelProperty(value = "服务事项父类id")
private Long pid; private Long pid;
@ApiModelProperty(value = "取号机系统服务id")
private String sid;
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
private Integer sort; private Integer sort;
......
...@@ -66,7 +66,7 @@ public class AppointmentOrderEntity extends BaseEntity { ...@@ -66,7 +66,7 @@ public class AppointmentOrderEntity extends BaseEntity {
/** /**
* 预约时间 * 预约时间
*/ */
private Date appointmentTime; private String appointmentTime;
/** /**
* 服务办事窗口 * 服务办事窗口
*/ */
...@@ -95,4 +95,4 @@ public class AppointmentOrderEntity extends BaseEntity { ...@@ -95,4 +95,4 @@ public class AppointmentOrderEntity extends BaseEntity {
* 更新时间 * 更新时间
*/ */
private Date updateDate; private Date updateDate;
} }
\ No newline at end of file
...@@ -27,6 +27,10 @@ public class AppointmentServiceEntity extends BaseEntity { ...@@ -27,6 +27,10 @@ public class AppointmentServiceEntity extends BaseEntity {
* 服务事项父类id * 服务事项父类id
*/ */
private Long pid; private Long pid;
/**
* 取号机系统服务id
*/
private String sid;
/** /**
* 排序 * 排序
*/ */
......
...@@ -38,7 +38,7 @@ public class AppointmentOrderExcel { ...@@ -38,7 +38,7 @@ public class AppointmentOrderExcel {
@Excel(name = "预约人身份证号码") @Excel(name = "预约人身份证号码")
private String appointmentIdCard; private String appointmentIdCard;
@Excel(name = "预约时间") @Excel(name = "预约时间")
private Date appointmentTime; private String appointmentTime;
@Excel(name = "服务办事窗口") @Excel(name = "服务办事窗口")
private String serviceWindow; private String serviceWindow;
@Excel(name = "备注") @Excel(name = "备注")
...@@ -58,4 +58,4 @@ public class AppointmentOrderExcel { ...@@ -58,4 +58,4 @@ public class AppointmentOrderExcel {
@Excel(name = "更新时间") @Excel(name = "更新时间")
private Date updateDate; private Date updateDate;
} }
\ No newline at end of file
...@@ -19,6 +19,8 @@ public class AppointmentServiceExcel { ...@@ -19,6 +19,8 @@ public class AppointmentServiceExcel {
private String serviceName; private String serviceName;
@Excel(name = "服务事项父类id") @Excel(name = "服务事项父类id")
private Long pid; private Long pid;
@Excel(name = "取号机系统服务id")
private String sid;
@Excel(name = "排序") @Excel(name = "排序")
private Integer sort; private Integer sort;
@Excel(name = "首页图标地址") @Excel(name = "首页图标地址")
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
<resultMap type="io.hmit.modules.appointment.entity.AppointmentServiceEntity" id="appointmentServiceMap"> <resultMap type="io.hmit.modules.appointment.entity.AppointmentServiceEntity" id="appointmentServiceMap">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="serviceName" column="service_name"/> <result property="serviceName" column="service_name"/>
<result property="serviceParentId" column="service_parent_id"/> <result property="pid" column="pid"/>
<result property="sid" column="sid"/>
<result property="sort" column="sort"/> <result property="sort" column="sort"/>
<result property="icon" column="icon"/> <result property="icon" column="icon"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
...@@ -18,4 +19,4 @@ ...@@ -18,4 +19,4 @@
</resultMap> </resultMap>
</mapper> </mapper>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.DateUtils; import io.hmit.common.utils.DateUtils;
import io.hmit.common.utils.HttpRequestUtil; import io.hmit.common.utils.HttpRequestUtil;
import io.hmit.common.utils.MD5; import io.hmit.common.utils.MD5;
...@@ -13,9 +14,8 @@ import io.hmit.common.validator.ValidatorUtils; ...@@ -13,9 +14,8 @@ import io.hmit.common.validator.ValidatorUtils;
import io.hmit.common.validator.group.AddGroup; import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup; import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup; import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.appointment.dto.AppointmentOrderDTO; import io.hmit.modules.appointment.dto.*;
import io.hmit.modules.appointment.dto.AppointmentOrderServiceDTO; import io.hmit.modules.appointment.entity.AppointmentOrderEntity;
import io.hmit.modules.appointment.dto.ReservationDTO;
import io.hmit.modules.appointment.service.AppointmentOrderService; import io.hmit.modules.appointment.service.AppointmentOrderService;
import io.hmit.modules.appointment.service.AppointmentOrderServiceService; import io.hmit.modules.appointment.service.AppointmentOrderServiceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -28,7 +28,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -28,7 +28,9 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -70,24 +72,24 @@ public class AppointmentOrderController { ...@@ -70,24 +72,24 @@ public class AppointmentOrderController {
return new Result<AppointmentOrderDTO>().ok(data); return new Result<AppointmentOrderDTO>().ok(data);
} }
@GetMapping("identity/{identity}") @GetMapping("orderInfo")
@ApiOperation("根据手机号或身份证号获取信息") @ApiOperation("根据手机号或身份证号获取信息")
@ApiImplicitParams({ public Result<List<ReservationOrderInfoDTO>> queryInfo(String identity){
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , // PageData<AppointmentOrderDTO> pageData = appointmentOrderService.getAppointmentInfoPage(params, identity);
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , List<ReservationOrderInfoDTO> data = appointmentOrderService.getAppointmentInfoPage(identity);
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
public Result<PageData<AppointmentOrderDTO>> queryInfo(@ApiIgnore @RequestParam Map<String, Object> params,
@PathVariable("identity") String identity){
PageData<AppointmentOrderDTO> pageData = appointmentOrderService.getAppointmentInfoPage(params, identity);
return new Result<PageData<AppointmentOrderDTO>>().ok(pageData); if(data == null ){
return new Result<List<ReservationOrderInfoDTO>>().error(1,"没有查询到此用户的预约信息");
}
if(data.size()==0){
return new Result<List<ReservationOrderInfoDTO>>().error(2,"当前时段没有此用户的预约信息");
}
return new Result<List<ReservationOrderInfoDTO>>().ok(data);
} }
@PostMapping @PostMapping
@ApiOperation("预约保存") @ApiOperation("预约保存")
public Result save(@RequestBody ReservationDTO dto){ public Result<ReservationSuccessDTO> save(@RequestBody ReservationDTO dto){
//校验数据 //校验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
...@@ -95,10 +97,34 @@ public class AppointmentOrderController { ...@@ -95,10 +97,34 @@ public class AppointmentOrderController {
appointmentOrderService.save(appointmentOrderDTO); appointmentOrderService.save(appointmentOrderDTO);
ReservationSuccessDTO successData = ConvertUtils.sourceToTarget(appointmentOrderDTO,ReservationSuccessDTO.class);
AppointmentOrderServiceDTO orderServiceDTO = new AppointmentOrderServiceDTO().assembleAppointmentOrderServiceDTO(appointmentOrderDTO); AppointmentOrderServiceDTO orderServiceDTO = new AppointmentOrderServiceDTO().assembleAppointmentOrderServiceDTO(appointmentOrderDTO);
appointmentOrderServiceService.save(orderServiceDTO); appointmentOrderServiceService.save(orderServiceDTO);
return new Result().ok(successData);
}
@PostMapping("/updateReservationInfo")
@ApiOperation("更新预约人取号信息")
public Result updateReservationInfo(@RequestBody UpdateInfoDTO dto){
AppointmentOrderEntity appointmentOrderEntity = appointmentOrderService.selectById(dto.getOrderId());
if(appointmentOrderEntity == null){
return new Result().error(1,"当前预约id: "+dto.getOrderId()+" 的预约信息不存在!");
}
appointmentOrderEntity.setAppointmentNum(dto.getAppointmentNum());
appointmentOrderEntity.setWaitNum(dto.getWaitNum());
appointmentOrderEntity.setServiceWindow(String.join(",", dto.getListWin()));
appointmentOrderEntity.setTicketDate(dto.getTicketDate());
//取号机生成取号码则设置取号预约状态为:完成
appointmentOrderEntity.setStatus(2);
appointmentOrderEntity.setStatusName("已完成");
appointmentOrderService.updateById(appointmentOrderEntity);
return new Result(); return new Result();
} }
...@@ -114,7 +140,7 @@ public class AppointmentOrderController { ...@@ -114,7 +140,7 @@ public class AppointmentOrderController {
return new Result(); return new Result();
} }
/*
@GetMapping(value = "/signin/{appointmentOrderId}") @GetMapping(value = "/signin/{appointmentOrderId}")
@ApiOperation("签到") @ApiOperation("签到")
public Result signin(@PathVariable(value = "appointmentOrderId") Long appointmentOrderId){ public Result signin(@PathVariable(value = "appointmentOrderId") Long appointmentOrderId){
...@@ -164,12 +190,10 @@ public class AppointmentOrderController { ...@@ -164,12 +190,10 @@ public class AppointmentOrderController {
//获取当前订单预约时间 //获取当前订单预约时间
Integer waitingNum = appointmentOrderService.waitingNum(DateUtils.format(appointmentOrderDTO.getAppointmentTime())); Integer waitingNum = appointmentOrderService.waitingNum(DateUtils.format(appointmentOrderDTO.getAppointmentTime()));
return new Result().ok(waitingNum); return new Result().ok(waitingNum);
}*/
}
@GetMapping(value = "/serviceWaitingNum/{serviceId}") @GetMapping(value = "/serviceWaitingNum/{serviceId}")
@ApiOperation("获取当前事项的预约排队人数") @ApiOperation("获取当前事项的预约排队人数")
public Result serviceWaitingNum (@PathVariable(value = "serviceId") Long serviceId){ public Result serviceWaitingNum (@PathVariable(value = "serviceId") Long serviceId){
......
...@@ -3,6 +3,7 @@ package io.hmit.modules.appointment.controller; ...@@ -3,6 +3,7 @@ package io.hmit.modules.appointment.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.utils.DateUtils;
import io.hmit.common.utils.Result; import io.hmit.common.utils.Result;
import io.hmit.common.validator.AssertUtils; import io.hmit.common.validator.AssertUtils;
import io.hmit.common.validator.ValidatorUtils; import io.hmit.common.validator.ValidatorUtils;
...@@ -10,6 +11,7 @@ import io.hmit.common.validator.group.AddGroup; ...@@ -10,6 +11,7 @@ import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup; import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup; import io.hmit.common.validator.group.UpdateGroup;
import io.hmit.modules.appointment.dto.AppointmentTimeManageDTO; import io.hmit.modules.appointment.dto.AppointmentTimeManageDTO;
import io.hmit.modules.appointment.dto.ReservationTimeDTO;
import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity; import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity;
import io.hmit.modules.appointment.service.AppointmentTimeManageService; import io.hmit.modules.appointment.service.AppointmentTimeManageService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -45,4 +48,15 @@ public class AppointmentTimeManageController { ...@@ -45,4 +48,15 @@ public class AppointmentTimeManageController {
return new Result<AppointmentTimeManageDTO>().ok(data); return new Result<AppointmentTimeManageDTO>().ok(data);
} }
@GetMapping("getReservationTime")
@ApiOperation("获取预约时间 今天往后7天的可预约时间")
public Result<List<ReservationTimeDTO>> getReservationTime() throws ParseException {
List<ReservationTimeDTO> data = appointmentTimeManageService.getReservationTimeList();
return new Result<List<ReservationTimeDTO>>().ok(data);
}
} }
package io.hmit.modules.appointment.controller;
import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData;
import io.hmit.common.utils.Result;
import io.hmit.modules.appointment.dto.CalendarDTO;
import io.hmit.modules.appointment.service.CalendarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
* 日历表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-03-04
*/
@RestController
@RequestMapping("appointment/calendar")
@Api(tags="日历表")
public class CalendarController {
@Autowired
private CalendarService calendarService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
public Result<PageData<CalendarDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<CalendarDTO> page = calendarService.page(params);
return new Result<PageData<CalendarDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
public Result<CalendarDTO> get(@PathVariable("id") Long id){
CalendarDTO data = calendarService.get(id);
return new Result<CalendarDTO>().ok(data);
}
}
...@@ -16,7 +16,9 @@ import org.apache.ibatis.annotations.Param; ...@@ -16,7 +16,9 @@ import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface AppointmentOrderDao extends BaseDao<AppointmentOrderEntity> { public interface AppointmentOrderDao extends BaseDao<AppointmentOrderEntity> {
IPage<AppointmentOrderDTO> getAppointmentInfo(IPage<AppointmentOrderEntity> page, String phone, String idCard); // Page版本V1.0
// IPage<AppointmentOrderDTO> getAppointmentInfo(IPage<AppointmentOrderEntity> page, String phone, String idCard);
AppointmentOrderDTO getAppointmentInfo(String phone, String idCard);
Integer waitingNum(@Param("appointmentTime") String appointmentTime); Integer waitingNum(@Param("appointmentTime") String appointmentTime);
Integer serviceWaitingNum(@Param("serviceId") Long serviceId); Integer serviceWaitingNum(@Param("serviceId") Long serviceId);
......
package io.hmit.modules.appointment.dao;
import io.hmit.common.dao.BaseDao;
import io.hmit.modules.appointment.entity.CalendarEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 日历表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-03-04
*/
@Mapper
public interface CalendarDao extends BaseDao<CalendarEntity> {
}
\ No newline at end of file
package io.hmit.modules.appointment.dto; package io.hmit.modules.appointment.dto;
import io.hmit.common.utils.SerialNumberTool;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -57,8 +58,8 @@ public class AppointmentOrderDTO implements Serializable { ...@@ -57,8 +58,8 @@ public class AppointmentOrderDTO implements Serializable {
@ApiModelProperty(value = "预约人身份证号码") @ApiModelProperty(value = "预约人身份证号码")
private String appointmentIdCard; private String appointmentIdCard;
@ApiModelProperty(value = "预约时间") @ApiModelProperty(value = "预约时间")
private Date appointmentTime; private String appointmentTime;
@ApiModelProperty(value = "服务办事窗口") @ApiModelProperty(value = "服务办事窗口")
private String serviceWindow; private String serviceWindow;
...@@ -78,24 +79,28 @@ public class AppointmentOrderDTO implements Serializable { ...@@ -78,24 +79,28 @@ public class AppointmentOrderDTO implements Serializable {
@ApiModelProperty(value = "订单发起人联系电话") @ApiModelProperty(value = "订单发起人联系电话")
private String creatorTel; private String creatorTel;
@ApiModelProperty(value = "创建时间")
private Date createDate;
@ApiModelProperty(value = "更新者") @ApiModelProperty(value = "更新者")
private Long updater; private Long updater;
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
private Date updateDate; private Date updateDate;
public AppointmentOrderDTO assembleAppointmentOrderDTO(ReservationDTO reservationDTO){ @ApiModelProperty(value = "创建时间")
private Date createDate;
@ApiModelProperty(value = "取号时间")
private String ticketDate;
@ApiModelProperty(value = "等候人数")
private Integer waitNum;
public AppointmentOrderDTO assembleAppointmentOrderDTO(ReservationDTO reservationDTO){
AppointmentOrderDTO dto = new AppointmentOrderDTO(); AppointmentOrderDTO dto = new AppointmentOrderDTO();
Date dt = new Date(); // 当天程序重启后标识位会重置,此处可以设置开始的标识位,4标识下一个生成的会是Y00004
SimpleDateFormat sf=new SimpleDateFormat("yyyyMMdd"); // SerialNumberTool.getInstance().operateFlag(4);
String strDate = sf.format(dt); //内存保存流水号增长标记,按天重置标识位(程序重启后会重置),格式为:Y00001
UUID uuid = UUID.randomUUID(); dto.setOrderNum("Y"+ SerialNumberTool.getInstance().generaterNextNumber(5));
String[] strSequence = uuid.toString().split("-");
dto.setOrderNum("YUYUE-"+strDate + "-" + strSequence[1]);
dto.setAppointmentNum(reservationDTO.getAppointmentNum()); dto.setAppointmentNum(reservationDTO.getAppointmentNum());
dto.setStatus(1); dto.setStatus(1);
......
...@@ -26,6 +26,9 @@ public class AppointmentServiceDTO extends TreeNode<AppointmentServiceDTO> imple ...@@ -26,6 +26,9 @@ public class AppointmentServiceDTO extends TreeNode<AppointmentServiceDTO> imple
@ApiModelProperty(value = "服务事项名称") @ApiModelProperty(value = "服务事项名称")
private String serviceName; private String serviceName;
@ApiModelProperty(value = "取号机系统服务id")
private String sid;
@ApiModelProperty(value = "服务事项父类id") @ApiModelProperty(value = "服务事项父类id")
private Long pid; private Long pid;
...@@ -53,5 +56,9 @@ public class AppointmentServiceDTO extends TreeNode<AppointmentServiceDTO> imple ...@@ -53,5 +56,9 @@ public class AppointmentServiceDTO extends TreeNode<AppointmentServiceDTO> imple
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "更新时间")
private Date updateDate; private Date updateDate;
@ApiModelProperty(value = "取号时间")
private String ticketDate;
@ApiModelProperty(value = "等候人数,包含本次")
private Integer waitNum;
} }
...@@ -37,5 +37,8 @@ public class AppointmentTimeManageDTO implements Serializable { ...@@ -37,5 +37,8 @@ public class AppointmentTimeManageDTO implements Serializable {
@ApiModelProperty(value = "使用状态 1 正在使用; 2 未使用") @ApiModelProperty(value = "使用状态 1 正在使用; 2 未使用")
private String useState; private String useState;
@ApiModelProperty(value = "预约时间段,返回时使用")
private String reservationTime;
} }
package io.hmit.modules.appointment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 日历表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-03-04
*/
@Data
@ApiModel(value = "日历表")
public class CalendarDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "")
private Integer id;
@ApiModelProperty(value = "日期")
private String day;
@ApiModelProperty(value = "是否节假日 0 正常工作日 1,周末 2,法定节假日 3调休")
private Integer holiday;
@ApiModelProperty(value = "星期")
private Integer dow;
}
\ No newline at end of file
...@@ -44,7 +44,7 @@ public class ReservationDTO implements Serializable { ...@@ -44,7 +44,7 @@ public class ReservationDTO implements Serializable {
private String appointmentIdCard; private String appointmentIdCard;
@ApiModelProperty(value = "预约时间") @ApiModelProperty(value = "预约时间")
private Date appointmentTime; private String appointmentTime;
@ApiModelProperty(value = "服务办事窗口") @ApiModelProperty(value = "服务办事窗口")
private String serviceWindow; private String serviceWindow;
......
package io.hmit.modules.appointment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
* 预约订单表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-02-13
*/
@Data
@ApiModel(value = "预约订单表")
public class ReservationOrderInfoDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "取号机系统服务id")
private String sid;
@ApiModelProperty(value = "预约工单状态 0未预约 ,1已预约 2已完成 3已取消")
private Integer status;
@ApiModelProperty(value = "预约工单状态名称")
private String statusName;
@ApiModelProperty(value = "预约人")
private String appointmentPerson;
@ApiModelProperty(value = "预约人电话")
private String appointmentPhone;
@ApiModelProperty(value = "预约人身份证号码")
private String appointmentIdCard;
@ApiModelProperty(value = "预约时间")
private String appointmentTime;
@ApiModelProperty(value = "备注")
private String remark;
}
package io.hmit.modules.appointment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 预约订单表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-02-13
*/
@Data
@ApiModel(value = "预约成功返回")
public class ReservationSuccessDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "预约工单编号(自己系统留痕用)")
private String orderNum;
@ApiModelProperty(value = "预约时间段")
private String appointmentTime;
@ApiModelProperty(value = "预约所属的服务事项名称")
private String serviceName;
}
package io.hmit.modules.appointment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 预约订单表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-02-13
*/
@Data
@ApiModel(value = "预约信息表")
public class ReservationTimeDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "预约时间")
private String reservationTime;
@ApiModelProperty(value = "备注")
private List<AppointmentTimeManageDTO> periods;
}
package io.hmit.modules.appointment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 预约订单表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-02-13
*/
@Data
@ApiModel(value = "更新预约取号信息DTO")
public class UpdateInfoDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "预约信息唯一ID")
private Long orderId;
@ApiModelProperty(value = "取号机生成的ID")
private String appointmentNum;
@ApiModelProperty(value = "等候人数")
private Integer waitNum;
@ApiModelProperty(value = "取号时间")
private String ticketDate;
@ApiModelProperty(value = "办理窗口")
private String[] listWin;
}
package io.hmit.modules.appointment.entity; package io.hmit.modules.appointment.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.hmit.common.entity.BaseEntity; import io.hmit.common.entity.BaseEntity;
import lombok.Data; import lombok.Data;
...@@ -66,7 +67,7 @@ public class AppointmentOrderEntity extends BaseEntity { ...@@ -66,7 +67,7 @@ public class AppointmentOrderEntity extends BaseEntity {
/** /**
* 预约时间 * 预约时间
*/ */
private Date appointmentTime; private String appointmentTime;
/** /**
* 服务办事窗口 * 服务办事窗口
*/ */
...@@ -95,4 +96,18 @@ public class AppointmentOrderEntity extends BaseEntity { ...@@ -95,4 +96,18 @@ public class AppointmentOrderEntity extends BaseEntity {
* 更新时间 * 更新时间
*/ */
private Date updateDate; private Date updateDate;
} /**
\ No newline at end of file * 更新时间
*/
@TableField(exist = false)
private String sid;
/**
* 取号时间
*/
private String ticketDate;
/**
* 等候人数
*/
private Integer waitNum;
}
...@@ -27,6 +27,10 @@ public class AppointmentServiceEntity extends BaseEntity { ...@@ -27,6 +27,10 @@ public class AppointmentServiceEntity extends BaseEntity {
* 服务事项父类id * 服务事项父类id
*/ */
private Long pid; private Long pid;
/**
* 取号机系统服务id
*/
private String sid;
/** /**
* 排序 * 排序
*/ */
...@@ -51,4 +55,5 @@ public class AppointmentServiceEntity extends BaseEntity { ...@@ -51,4 +55,5 @@ public class AppointmentServiceEntity extends BaseEntity {
* 更新时间 * 更新时间
*/ */
private Date updateDate; private Date updateDate;
} }
package io.hmit.modules.appointment.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.hmit.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 日历表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-03-04
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("calendar")
public class CalendarEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 日期
*/
private String day;
/**
* 是否节假日 0 正常工作日 1,周末 2,法定节假日 3调休
*/
private Integer holiday;
/**
* 星期
*/
private Integer dow;
}
\ No newline at end of file
...@@ -3,8 +3,10 @@ package io.hmit.modules.appointment.service; ...@@ -3,8 +3,10 @@ package io.hmit.modules.appointment.service;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.service.CrudService; import io.hmit.common.service.CrudService;
import io.hmit.modules.appointment.dto.AppointmentOrderDTO; import io.hmit.modules.appointment.dto.AppointmentOrderDTO;
import io.hmit.modules.appointment.dto.ReservationOrderInfoDTO;
import io.hmit.modules.appointment.entity.AppointmentOrderEntity; import io.hmit.modules.appointment.entity.AppointmentOrderEntity;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -15,7 +17,9 @@ import java.util.Map; ...@@ -15,7 +17,9 @@ import java.util.Map;
*/ */
public interface AppointmentOrderService extends CrudService<AppointmentOrderEntity, AppointmentOrderDTO> { public interface AppointmentOrderService extends CrudService<AppointmentOrderEntity, AppointmentOrderDTO> {
PageData<AppointmentOrderDTO> getAppointmentInfoPage(Map<String, Object> params, String identity); // Page版本V1.0
// PageData<AppointmentOrderDTO> getAppointmentInfoPage(Map<String, Object> params, String identity);
List<ReservationOrderInfoDTO> getAppointmentInfoPage(String identity);
Integer waitingNum (String appointmentTime); Integer waitingNum (String appointmentTime);
......
...@@ -2,8 +2,12 @@ package io.hmit.modules.appointment.service; ...@@ -2,8 +2,12 @@ package io.hmit.modules.appointment.service;
import io.hmit.common.service.CrudService; import io.hmit.common.service.CrudService;
import io.hmit.modules.appointment.dto.AppointmentTimeManageDTO; import io.hmit.modules.appointment.dto.AppointmentTimeManageDTO;
import io.hmit.modules.appointment.dto.ReservationTimeDTO;
import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity; import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity;
import java.text.ParseException;
import java.util.List;
/** /**
* 预约时间管理 * 预约时间管理
* *
...@@ -13,5 +17,6 @@ import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity; ...@@ -13,5 +17,6 @@ import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity;
public interface AppointmentTimeManageService extends CrudService<AppointmentTimeManageEntity, AppointmentTimeManageDTO> { public interface AppointmentTimeManageService extends CrudService<AppointmentTimeManageEntity, AppointmentTimeManageDTO> {
AppointmentTimeManageDTO getByUseState(); AppointmentTimeManageDTO getByUseState();
List<ReservationTimeDTO> getReservationTimeList() throws ParseException;
} }
package io.hmit.modules.appointment.service;
import io.hmit.common.service.CrudService;
import io.hmit.modules.appointment.dto.CalendarDTO;
import io.hmit.modules.appointment.entity.CalendarEntity;
import java.util.List;
/**
* 日历表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-03-04
*/
public interface CalendarService extends CrudService<CalendarEntity, CalendarDTO> {
List<CalendarDTO> weekDayList();
}
...@@ -6,15 +6,18 @@ import io.hmit.common.constant.Constant; ...@@ -6,15 +6,18 @@ import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils; import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.DateUtils;
import io.hmit.modules.appointment.dao.AppointmentOrderDao; import io.hmit.modules.appointment.dao.AppointmentOrderDao;
import io.hmit.modules.appointment.dto.AppointmentOrderDTO; import io.hmit.modules.appointment.dto.AppointmentOrderDTO;
import io.hmit.modules.appointment.dto.ReservationOrderInfoDTO;
import io.hmit.modules.appointment.entity.AppointmentOrderEntity; import io.hmit.modules.appointment.entity.AppointmentOrderEntity;
import io.hmit.modules.appointment.service.AppointmentOrderService; import io.hmit.modules.appointment.service.AppointmentOrderService;
import io.hmit.modules.appointment.service.AppointmentServiceService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Map; import java.util.*;
/** /**
* 预约订单表 * 预约订单表
...@@ -28,6 +31,9 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde ...@@ -28,6 +31,9 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde
@Resource @Resource
private AppointmentOrderDao appointmentOrderDao; private AppointmentOrderDao appointmentOrderDao;
@Resource
private AppointmentServiceService appointmentServiceService;
/** /**
* 电话号码校验(不包含港澳台手机号) * 电话号码校验(不包含港澳台手机号)
*/ */
...@@ -48,6 +54,45 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde ...@@ -48,6 +54,45 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde
return wrapper; return wrapper;
} }
@Override
public List<ReservationOrderInfoDTO> getAppointmentInfoPage(String identity) {
String phone = null;
String idCard = null;
if (identity.matches(VALIDATE_PHONE)) {
phone = identity;
}
if (identity.matches(ID_NUMBER)) {
idCard = identity;
}
String now = DateUtils.format(new Date());
String hour = DateUtils.format(new Date(),"HH:mm:ss");
List<AppointmentOrderEntity> appointmentOrderEntities = new ArrayList<>();
List<AppointmentOrderEntity> appointmentOrders = baseDao.selectList(new QueryWrapper<AppointmentOrderEntity>()
.eq(StringUtils.isNotBlank(phone), "appointment_phone", phone)
.eq(StringUtils.isNotBlank(idCard), "appointment_id_card", idCard)
.eq("status","1").like("appointment_time",now));
if(appointmentOrders.size()==0){
return null;
}
appointmentOrders.stream().forEach(item->{
List<String > hours = new ArrayList<>();
Arrays.stream(item.getAppointmentTime().substring(11).split("-"))
.forEach(time->hours.add(time));
if(hours.get(0).compareTo(hour)<0 && hours.get(1).compareTo(hour)>0){
item.setSid(appointmentServiceService.selectById(item.getServiceId()).getSid());
appointmentOrderEntities.add(item);
}
});
return ConvertUtils.sourceToTarget(appointmentOrderEntities, ReservationOrderInfoDTO.class);
}
/*
//Page版本V1.0
@Override @Override
public PageData<AppointmentOrderDTO> getAppointmentInfoPage(Map<String, Object> params, String identity) { public PageData<AppointmentOrderDTO> getAppointmentInfoPage(Map<String, Object> params, String identity) {
String phone = null; String phone = null;
...@@ -63,6 +108,7 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde ...@@ -63,6 +108,7 @@ public class AppointmentOrderServiceImpl extends CrudServiceImpl<AppointmentOrde
return getPageData(appointmentOrderDTOIPage, AppointmentOrderDTO.class); return getPageData(appointmentOrderDTOIPage, AppointmentOrderDTO.class);
} }
*/
@Override @Override
public Integer waitingNum(String appointmentTime) { public Integer waitingNum(String appointmentTime) {
......
package io.hmit.modules.appointment.service.impl; package io.hmit.modules.appointment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import io.hmit.common.constant.Constant;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils; import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.DateUtils;
import io.hmit.modules.appointment.dao.AppointmentTimeManageDao; import io.hmit.modules.appointment.dao.AppointmentTimeManageDao;
import io.hmit.modules.appointment.dto.AppointmentOrderDTO;
import io.hmit.modules.appointment.dto.AppointmentTimeManageDTO; import io.hmit.modules.appointment.dto.AppointmentTimeManageDTO;
import io.hmit.modules.appointment.dto.CalendarDTO;
import io.hmit.modules.appointment.dto.ReservationTimeDTO;
import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity; import io.hmit.modules.appointment.entity.AppointmentTimeManageEntity;
import io.hmit.modules.appointment.service.AppointmentTimeManageService; import io.hmit.modules.appointment.service.AppointmentTimeManageService;
import io.hmit.modules.appointment.service.CalendarService;
import net.sf.jsqlparser.statement.create.table.CreateTable; import net.sf.jsqlparser.statement.create.table.CreateTable;
import org.apache.commons.lang3.Conversion; import org.apache.commons.lang3.Conversion;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
...@@ -23,6 +34,12 @@ import java.util.Map; ...@@ -23,6 +34,12 @@ import java.util.Map;
@Service @Service
public class AppointmentTimeManageServiceImpl extends CrudServiceImpl<AppointmentTimeManageDao, AppointmentTimeManageEntity, AppointmentTimeManageDTO> implements AppointmentTimeManageService { public class AppointmentTimeManageServiceImpl extends CrudServiceImpl<AppointmentTimeManageDao, AppointmentTimeManageEntity, AppointmentTimeManageDTO> implements AppointmentTimeManageService {
@Autowired
private CalendarService calendarService;
@Autowired
private AppointmentTimeManageService appointmentTimeManageService;
@Override @Override
public QueryWrapper<AppointmentTimeManageEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<AppointmentTimeManageEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id"); String id = (String)params.get("id");
...@@ -43,4 +60,41 @@ public class AppointmentTimeManageServiceImpl extends CrudServiceImpl<Appointmen ...@@ -43,4 +60,41 @@ public class AppointmentTimeManageServiceImpl extends CrudServiceImpl<Appointmen
return ConvertUtils.sourceToTarget(entity, AppointmentTimeManageDTO.class); return ConvertUtils.sourceToTarget(entity, AppointmentTimeManageDTO.class);
} }
@Override
public List<ReservationTimeDTO> getReservationTimeList() throws ParseException {
AppointmentTimeManageDTO timeManageDTO = appointmentTimeManageService.getByUseState();
String startTime = timeManageDTO.getStartTime();
String endTime = timeManageDTO.getEndTime();
String period = timeManageDTO.getPeriod();
List<AppointmentTimeManageDTO> timeManageDTOS = new ArrayList<>();
List<String> timePeriods = new ArrayList<>();
List<String> amLists = DateUtils.getTimePeriod(startTime,Constant.AM_END_TIME,period);
List<String> pmLists = DateUtils.getTimePeriod(Constant.PM_START_TIME,endTime,period);
timePeriods.addAll(amLists);
timePeriods.addAll(pmLists);
timePeriods.stream().forEach(item->{
AppointmentTimeManageDTO dto = new AppointmentTimeManageDTO();
dto.setReservationTime(item);
timeManageDTOS.add(dto);
});
List<ReservationTimeDTO> reservationTimeDTOList = new ArrayList<>();
List<CalendarDTO> dayLists = calendarService.weekDayList().subList(0,6);
dayLists.stream().forEach(item->{
ReservationTimeDTO reservationTime = new ReservationTimeDTO();
reservationTime.setReservationTime(item.getDay());
reservationTime.setPeriods(timeManageDTOS);
reservationTimeDTOList.add(reservationTime);
});
return reservationTimeDTOList;
}
} }
package io.hmit.modules.appointment.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.common.utils.DateUtils;
import io.hmit.modules.appointment.dao.CalendarDao;
import io.hmit.modules.appointment.dto.CalendarDTO;
import io.hmit.modules.appointment.entity.CalendarEntity;
import io.hmit.modules.appointment.service.CalendarService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 日历表
*
* @author zsh 408538940@qq.com
* @since 1.0.0 2021-03-04
*/
@Service
public class CalendarServiceImpl extends CrudServiceImpl<CalendarDao, CalendarEntity, CalendarDTO> implements CalendarService {
@Override
public QueryWrapper<CalendarEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
QueryWrapper<CalendarEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
return wrapper;
}
@Override
public List<CalendarDTO> weekDayList() {
String now = DateUtils.format(new Date());
List<CalendarEntity> calendarList = baseDao.selectList(new QueryWrapper<CalendarEntity>().gt("day",now)
.ne("holiday",1).ne("holiday",2));
return ConvertUtils.sourceToTarget(calendarList,CalendarDTO.class);
}
}
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<result property="createDate" column="create_date"/> <result property="createDate" column="create_date"/>
<result property="updater" column="updater"/> <result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/> <result property="updateDate" column="update_date"/>
<result property="waitNum" column="wait_num"/>
<result property="ticketDate" column="ticket_date"/>
</resultMap> </resultMap>
<select id="getAppointmentInfo" resultType="io.hmit.modules.appointment.dto.AppointmentOrderDTO"> <select id="getAppointmentInfo" resultType="io.hmit.modules.appointment.dto.AppointmentOrderDTO">
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="serviceName" column="service_name"/> <result property="serviceName" column="service_name"/>
<result property="pid" column="pid"/> <result property="pid" column="pid"/>
<result property="sid" column="sid"/>
<result property="sort" column="sort"/> <result property="sort" column="sort"/>
<result property="icon" column="icon"/> <result property="icon" column="icon"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
......
<?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="io.hmit.modules.appointment.dao.CalendarDao">
<resultMap type="io.hmit.modules.appointment.entity.CalendarEntity" id="calendarMap">
<result property="id" column="id"/>
<result property="day" column="day"/>
<result property="holiday" column="holiday"/>
<result property="dow" column="dow"/>
</resultMap>
</mapper>
\ No newline at end of file
...@@ -92,6 +92,16 @@ public interface Constant { ...@@ -92,6 +92,16 @@ public interface Constant {
*/ */
String MAIL_CONFIG_KEY = "MAIL_CONFIG_KEY"; String MAIL_CONFIG_KEY = "MAIL_CONFIG_KEY";
/**
* 邮件配置KEY
*/
String AM_END_TIME = "11:30";
/**
* 邮件配置KEY
*/
String PM_START_TIME = "13:30";
/** /**
* 定时任务状态 * 定时任务状态
*/ */
...@@ -178,4 +188,5 @@ public interface Constant { ...@@ -178,4 +188,5 @@ public interface Constant {
return value; return value;
} }
} }
}
\ No newline at end of file }
...@@ -8,7 +8,10 @@ import org.joda.time.format.DateTimeFormatter; ...@@ -8,7 +8,10 @@ import org.joda.time.format.DateTimeFormatter;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 日期处理 * 日期处理
...@@ -192,4 +195,36 @@ public class DateUtils { ...@@ -192,4 +195,36 @@ public class DateUtils {
DateTime dateTime = new DateTime(date); DateTime dateTime = new DateTime(date);
return dateTime.plusYears(years).toDate(); return dateTime.plusYears(years).toDate();
} }
/**
* 将一段时间段拆分成子区间 按照时间间隔拆分
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param period 时间间隔 单位:分钟
* @return 按时间间隔划分的子时间区间List
* @throws ParseException
*/
public static List<String> getTimePeriod(String startTime, String endTime, String period) throws ParseException {
SimpleDateFormat sf = new SimpleDateFormat("HH:mm");
List<String> timeList = new ArrayList<>();
while(startTime.compareTo(endTime)<0){
Calendar c = Calendar.getInstance();
c.setTime(sf.parse(startTime));
long sec=c.getTimeInMillis();
sec += Integer.parseInt(period) * 60 * 1000;
Date data = new Date(sec);
String time21 = sf.format(data);
if(time21.compareTo(endTime)>0){
time21 = endTime;
}
System.out.println(startTime+"-"+time21);
timeList.add(startTime+"-"+time21);
startTime = time21;
}
return timeList;
}
} }
package io.hmit.common.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author Eve
* @email mengmengeve@gmail.com
* @create 2021/3/1
*/
/**
* 流水号生成类 :内存保存流水号增长标记,按天重置标识位
*/
public class SerialNumberTool {
private static SerialNumberTool serialNumberTool = null;
private static SimpleDateFormat yMd = new SimpleDateFormat("yyyyMMdd");
//用于自增长的标识
private Integer flag;
//用于记录日期
private Date date;
private SerialNumberTool() {
if(date == null || !(yMd.format(new Date()).equals(yMd.format(date)))){
date = new Date();
flag = 1;
}
}
/**
* 判断是否改变
*/
private void checkChangeDay(){
if(date == null || !(yMd.format(new Date()).equals(yMd.format(date)))){
date = new Date();
flag = 1;
}
}
/**
* 取得PrimaryGenerater的单例实现
*
* @return
*/
public static SerialNumberTool getInstance() {
if (serialNumberTool == null) {
synchronized (SerialNumberTool.class) {
if (serialNumberTool == null) {
serialNumberTool = new SerialNumberTool();
}
}
}
return serialNumberTool;
}
/**
* 生成下一个编号,前缀自动补全 0
* params:
* 2.places 需要补全的总位数
*
*/
public synchronized String generaterNextNumber(int places) {
checkChangeDay();
StringBuffer stringBuffer = new StringBuffer();
int numPlaces = flag.toString().length();
//数字位数小于需要补全的总位数,需要补全0
if(numPlaces < places ){
for (int i = 0; i < places - numPlaces; i++) {
stringBuffer.append("0");
}
stringBuffer.append(flag);
}
else stringBuffer.append(flag.toString());
flag++;
return stringBuffer.toString();
}
/**
* 避免当断网后重连或者服务器重启时导致标识flag清0,可以手动设置flag的开始点
* @param position
*/
public void operateFlag(int position){
this.flag = position;
}
}
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