diff --git a/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java b/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java index 7ca899c46..079bafe37 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/PileRemoteService.java @@ -145,6 +145,7 @@ public class PileRemoteService { * @return */ public boolean publishBillingTemplate(PublishBillingTemplateDTO dto) { + // 获取计费模板信息 BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateByTemplateId(dto.getTemplateId()); if (billingTemplateVO == null) { @@ -181,6 +182,9 @@ public class PileRemoteService { if (CollectionUtils.isNotEmpty(relationList)) { pileBillingTemplateService.insertPileBillingRelation(relationList); } + + // 修改计费模板状态 + pileBillingTemplateService.changeStationTemplate(dto.getStationId(), dto.getTemplateId()); return true; } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java index 22db03161..439aa70f0 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/PileBillingTemplateMapper.java @@ -162,4 +162,13 @@ public interface PileBillingTemplateMapper { * @param pileSnList */ void deleteRelationByPileSn(@Param("pileSnList") List pileSnList); + + /** + * 根据站点id修改状态 + * @param stationId + * @param status + */ + void updateStatusByStationId(@Param("stationId") String stationId, @Param("status") String status); + + void updateStatusByTemplateId(@Param("templateId") String templateId, @Param("status") String status); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java index 8669e72a3..e59ff55fe 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileBillingTemplateService.java @@ -166,10 +166,10 @@ public interface IPileBillingTemplateService { // 批量查询站点计费模板 List selectBillingTemplateByStationIdList(List stationIdList); + /** * 修改站点计费模板状态并下发最新模板 - * @param pileBillingTemplate * @return */ - int changeStationTemplate(PileBillingTemplate pileBillingTemplate); + int changeStationTemplate(String stationId, String templateId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java index 30d5baefe..98ef77999 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBillingTemplateServiceImpl.java @@ -34,6 +34,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; @@ -381,28 +382,17 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi /** * 修改站点计费模板状态并下发最新模板 - * @param pileBillingTemplate * @return */ @Override - public int changeStationTemplate(PileBillingTemplate pileBillingTemplate) { - PileBillingTemplate template = new PileBillingTemplate(); - // 先将以前正在使用的模板查出来,状态改为0 - BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(String.valueOf(pileBillingTemplate.getStationId())); - if (billingTemplateVO != null) { - template.setId(Long.parseLong(billingTemplateVO.getTemplateId())); - template.setStatus("0"); - - updatePileBillingTemplate(template); - } - // 将当前这条模板状态改为1 - template.setId(pileBillingTemplate.getId()); - template.setStatus("1"); - - updatePileBillingTemplate(template); - - // 下发站点下所有桩 - // pileRemoteService.publishBillingTemplate() + @Transactional(readOnly = false, propagation = Propagation.REQUIRED) + public int changeStationTemplate(String stationId, String templateId) { + // 根据stationId把站点下所有的计费模板设置为 未启用 + pileBillingTemplateMapper.updateStatusByStationId(stationId, Constants.ZERO); + // 根据templateId 修改状态为启用 + pileBillingTemplateMapper.updateStatusByTemplateId(templateId, Constants.ONE); + // 清缓存 + cleanCache(stationId, Long.parseLong(templateId)); return 0; } diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml index 414b081a7..3f4aa8b42 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileBillingTemplateMapper.xml @@ -537,4 +537,16 @@ #{item,jdbcType=VARCHAR} + + + update pile_billing_template + set status = #{status,jdbcType=VARCHAR} + where station_id = #{stationId,jdbcType=VARCHAR} + + + + update pile_billing_template + set status = #{status,jdbcType=VARCHAR} + where id = #{templateId,jdbcType=VARCHAR} + \ No newline at end of file