| | |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.util.UriComponentsBuilder; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.ExecutionException; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | if (comType == 1) { |
| | | virtualCard.setInUse((byte) 0); |
| | | virtualCard.setIntakeId(null); |
| | | virtualCard.setOpenTime(null); |
| | | } else { |
| | | virtualCard.setInUse((byte) 1); |
| | | virtualCard.setIntakeId(intakeId); |
| | |
| | | if (comType == 1) { |
| | | virtualCard.setInUse((byte) 1); |
| | | virtualCard.setIntakeId(intakeId); |
| | | |
| | | // 如果是计划开阀,从命令日志中获取计划时间,否则取当前时间 |
| | | if(commandCode.equals(CodeV1.cd_A1) || commandCode.equals(CodeV1.cd_A2)) { |
| | | // 计划开阀 |
| | | Date openTime = null; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | try { |
| | | openTime = sdf.parse(rmCommandHistoryMapper.getTimeByCommId(comId)); |
| | | }catch (ParseException e) { |
| | | } |
| | | virtualCard.setOpenTime(openTime); |
| | | }else { |
| | | // 非计划开阀 |
| | | virtualCard.setOpenTime(new Date()); |
| | | } |
| | | } else { |
| | | virtualCard.setInUse((byte) 0); |
| | | virtualCard.setIntakeId(null); |
| | |
| | | * @return |
| | | */ |
| | | List<VoCommand> getCommandHistories(Map<?, ?> params); |
| | | |
| | | /** |
| | | * 根据命令日志ID获取预约时间,向虚拟卡写开阀时间用 |
| | | * @param commId |
| | | * @return |
| | | */ |
| | | String getTimeByCommId(Long commId); |
| | | } |
| | |
| | | private Byte inUse; |
| | | |
| | | /** |
| | | * 取水口ID(虚拟卡使用时所应用于的取水口ID) |
| | | */ |
| | | @Schema(description = "取水口ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long intakeId; |
| | | |
| | | /** |
| | | * 开阀时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date openTime; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 取水口ID(虚拟卡使用时所应用于的取水口ID) |
| | | */ |
| | | @Schema(description = "取水口ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED) |
| | | private Long intakeId; |
| | | |
| | | } |
| | |
| | | </if> |
| | | </trim> |
| | | </select> |
| | | |
| | | <!--根据命令日志ID获取预约时间,向虚拟卡写开阀时间用--> |
| | | <select id="getTimeByCommId" resultType="java.lang.String"> |
| | | SELECT |
| | | CONCAT(param ->> '$.year', '-', param ->> '$.month', '-', param ->> '$.day', ' ', param ->> '$.hour', ':', param ->> '$.minute', ':00') AS openTime |
| | | FROM rm_command_history |
| | | WHERE com_id = #{commId} |
| | | </select> |
| | | </mapper> |
| | |
| | | <result column="last_operate_time" jdbcType="TIMESTAMP" property="lastOperateTime" /> |
| | | <result column="in_use" jdbcType="TINYINT" property="inUse" /> |
| | | <result column="intake_id" jdbcType="BIGINT" property="intakeId" /> |
| | | <result column="open_time" jdbcType="TIMESTAMP" property="openTime" /> |
| | | <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!--@mbg.generated--> |
| | | id, vc_num, client_id, money, state, last_operate, last_operate_time, in_use, intake_id, create_time |
| | | id, vc_num, client_id, money, state, last_operate, last_operate_time, in_use, intake_id, open_time, create_time |
| | | </sql> |
| | | <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
| | | <!--@mbg.generated--> |
| | |
| | | <!--@mbg.generated--> |
| | | insert into se_virtual_card (id, vc_num, client_id, |
| | | money, state, last_operate, last_operate_time, |
| | | in_use, intake_id, create_time) |
| | | in_use, intake_id, open_time, create_time) |
| | | values (#{id,jdbcType=BIGINT}, #{vcNum,jdbcType=BIGINT}, #{clientId,jdbcType=BIGINT}, |
| | | #{money,jdbcType=FLOAT}, #{state,jdbcType=TINYINT}, #{lastOperate,jdbcType=TINYINT}, #{lastOperateTime,jdbcType=TIMESTAMP}, |
| | | #{inUse,jdbcType=TINYINT}, #{intakeId,jdbcType=BIGINT},#{createTime,jdbcType=TIMESTAMP}) |
| | | #{inUse,jdbcType=TINYINT}, #{intakeId,jdbcType=BIGINT},#{openTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP}) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeVirtualCard"> |
| | | <!--@mbg.generated--> |
| | |
| | | <if test="intakeId != null"> |
| | | intake_id, |
| | | </if> |
| | | <if test="openTime != null"> |
| | | open_time, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time, |
| | | </if> |
| | |
| | | </if> |
| | | <if test="intakeId != null"> |
| | | #{intakeId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="openTime != null"> |
| | | #{openTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | #{createTime,jdbcType=TIMESTAMP}, |
| | |
| | | <if test="intakeId != null"> |
| | | intake_id = #{intakeId,jdbcType=BIGINT}, |
| | | </if> |
| | | <if test="openTime != null"> |
| | | open_time = #{openTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | | <if test="createTime != null"> |
| | | create_time = #{createTime,jdbcType=TIMESTAMP}, |
| | | </if> |
| | |
| | | last_operate_time = #{lastOperateTime,jdbcType=TIMESTAMP}, |
| | | in_use = #{inUse,jdbcType=TINYINT}, |
| | | intake_id = #{intakeId,jdbcType=BIGINT}, |
| | | open_time = #{openTime,jdbcType=TIMESTAMP}, |
| | | create_time = #{createTime,jdbcType=TIMESTAMP} |
| | | where id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "open_wx", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> open(@RequestBody @Valid ValveOpen valve, BindingResult bindingResult) { |
| | | if (bindingResult != null && bindingResult.hasErrors()) { |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |