This commit is contained in:
2023-06-27 11:11:43 +08:00
parent 6da9437ee8
commit 582a8296d9
5 changed files with 36 additions and 21 deletions

View File

@@ -145,6 +145,7 @@ public class PileRemoteService {
* @return * @return
*/ */
public boolean publishBillingTemplate(PublishBillingTemplateDTO dto) { public boolean publishBillingTemplate(PublishBillingTemplateDTO dto) {
// 获取计费模板信息 // 获取计费模板信息
BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateByTemplateId(dto.getTemplateId()); BillingTemplateVO billingTemplateVO = pileBillingTemplateService.selectBillingTemplateByTemplateId(dto.getTemplateId());
if (billingTemplateVO == null) { if (billingTemplateVO == null) {
@@ -181,6 +182,9 @@ public class PileRemoteService {
if (CollectionUtils.isNotEmpty(relationList)) { if (CollectionUtils.isNotEmpty(relationList)) {
pileBillingTemplateService.insertPileBillingRelation(relationList); pileBillingTemplateService.insertPileBillingRelation(relationList);
} }
// 修改计费模板状态
pileBillingTemplateService.changeStationTemplate(dto.getStationId(), dto.getTemplateId());
return true; return true;
} }

View File

@@ -162,4 +162,13 @@ public interface PileBillingTemplateMapper {
* @param pileSnList * @param pileSnList
*/ */
void deleteRelationByPileSn(@Param("pileSnList") List<String> pileSnList); void deleteRelationByPileSn(@Param("pileSnList") List<String> 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);
} }

View File

@@ -166,10 +166,10 @@ public interface IPileBillingTemplateService {
// 批量查询站点计费模板 // 批量查询站点计费模板
List<BillingTemplateVO> selectBillingTemplateByStationIdList(List<String> stationIdList); List<BillingTemplateVO> selectBillingTemplateByStationIdList(List<String> stationIdList);
/** /**
* 修改站点计费模板状态并下发最新模板 * 修改站点计费模板状态并下发最新模板
* @param pileBillingTemplate
* @return * @return
*/ */
int changeStationTemplate(PileBillingTemplate pileBillingTemplate); int changeStationTemplate(String stationId, String templateId);
} }

View File

@@ -34,6 +34,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -381,28 +382,17 @@ public class PileBillingTemplateServiceImpl implements IPileBillingTemplateServi
/** /**
* 修改站点计费模板状态并下发最新模板 * 修改站点计费模板状态并下发最新模板
* @param pileBillingTemplate
* @return * @return
*/ */
@Override @Override
public int changeStationTemplate(PileBillingTemplate pileBillingTemplate) { @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
PileBillingTemplate template = new PileBillingTemplate(); public int changeStationTemplate(String stationId, String templateId) {
// 先将以前正在使用的模板查出来状态改为0 // 根据stationId把站点下所有的计费模板设置为 未启用
BillingTemplateVO billingTemplateVO = queryUsedBillingTemplate(String.valueOf(pileBillingTemplate.getStationId())); pileBillingTemplateMapper.updateStatusByStationId(stationId, Constants.ZERO);
if (billingTemplateVO != null) { // 根据templateId 修改状态为启用
template.setId(Long.parseLong(billingTemplateVO.getTemplateId())); pileBillingTemplateMapper.updateStatusByTemplateId(templateId, Constants.ONE);
template.setStatus("0"); // 清缓存
cleanCache(stationId, Long.parseLong(templateId));
updatePileBillingTemplate(template);
}
// 将当前这条模板状态改为1
template.setId(pileBillingTemplate.getId());
template.setStatus("1");
updatePileBillingTemplate(template);
// 下发站点下所有桩
// pileRemoteService.publishBillingTemplate()
return 0; return 0;
} }

View File

@@ -537,4 +537,16 @@
#{item,jdbcType=VARCHAR} #{item,jdbcType=VARCHAR}
</foreach> </foreach>
</select> </select>
<update id="updateStatusByStationId">
update pile_billing_template
set status = #{status,jdbcType=VARCHAR}
where station_id = #{stationId,jdbcType=VARCHAR}
</update>
<update id="updateStatusByTemplateId">
update pile_billing_template
set status = #{status,jdbcType=VARCHAR}
where id = #{templateId,jdbcType=VARCHAR}
</update>
</mapper> </mapper>