| | |
| | | import com.dayu.qihealonelibrary.card.ConfigurationPowerCard; |
| | | import com.dayu.qihealonelibrary.card.ConfigureDeviceRegistrationCrad; |
| | | import com.dayu.qihealonelibrary.card.DomainCard; |
| | | import com.dayu.qihealonelibrary.card.ElectricPriceCard; |
| | | import com.dayu.qihealonelibrary.card.ManageCard; |
| | | import com.dayu.qihealonelibrary.card.PassWordCard; |
| | | import com.dayu.qihealonelibrary.card.RegionCard; |
| | | import com.dayu.qihealonelibrary.card.RegisteredCard; |
| | | import com.dayu.qihealonelibrary.card.TestCard; |
| | | import com.dayu.qihealonelibrary.card.UserCard; |
| | |
| | | */ |
| | | public class NFCWreatActivity extends BaseNfcActivity { |
| | | |
| | | RegisteredCard registeredCard; |
| | | CleanUserCard cleanUserCard; |
| | | ManageCard manageCard; |
| | | DomainCard domainCard; |
| | | |
| | | CleanCard cleanCard; |
| | | ConfigureDeviceRegistrationCrad configureDeviceRegistrationCrad; |
| | | TestCard testCard; |
| | | //区域表号卡 |
| | | RegionCard regionCard; |
| | | ConfigurationPowerCard configurationPowerCard; |
| | | //密码卡 |
| | | PassWordCard passWordCard; |
| | | //用户电量单价卡 |
| | | ElectricPriceCard electricPriceCard; |
| | | UserCardBean userCardBeanByManager; |
| | | boolean electricPriceFlag = false; |
| | | boolean passwordFlag = false; |
| | | boolean cleanFlag = false; |
| | | boolean regionFlag = false; |
| | | boolean userFlag = false; |
| | | boolean manageCardFlag = false; |
| | | boolean registeredFlag = false; |
| | |
| | | Intent intent; |
| | | |
| | | |
| | | RegisteredCard registeredCard; |
| | | CleanUserCard cleanUserCard; |
| | | ManageCard manageCard; |
| | | DomainCard domainCard; |
| | | |
| | | CleanCard cleanCard; |
| | | ConfigureDeviceRegistrationCrad configureDeviceRegistrationCrad; |
| | | TestCard testCard; |
| | | |
| | | ConfigurationPowerCard configurationPowerCard; |
| | | //打印 |
| | | QHAloneApplication baseApp; |
| | | |
| | |
| | | if (this.getIntent().hasExtra("userCard")) { |
| | | userCard = (UserCard) this.getIntent().getSerializableExtra("userCard"); |
| | | } |
| | | if (this.getIntent().hasExtra("electricPriceCard")) { |
| | | electricPriceCard = (ElectricPriceCard) this.getIntent().getSerializableExtra("electricPriceCard"); |
| | | binding.cardData.setText("制作用户电量单价卡\n当前单价:" + electricPriceCard.getElectricPrice().toString() + "元"); |
| | | } |
| | | if (this.getIntent().hasExtra("passWordCard")) { |
| | | passWordCard = (PassWordCard) this.getIntent().getSerializableExtra("passWordCard"); |
| | | binding.cardData.setText("制作密码卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("cleanCard")) { |
| | | cleanCard = (CleanCard) this.getIntent().getSerializableExtra("cleanCard"); |
| | | binding.cardData.setText("制作清零卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("manageCard")) { |
| | | manageCard = (ManageCard) this.getIntent().getSerializableExtra("manageCard"); |
| | | binding.cardData.setText("制作管理卡"); |
| | | if (this.getIntent().hasExtra("userCardBean_manager")) { |
| | | userCardBeanByManager = (UserCardBean) this.getIntent().getSerializableExtra("userCardBean_manager"); |
| | | } |
| | | binding.cardData.setText("制作管理卡(请将管理卡贴在设备上)\n用户卡号:" + manageCard.getUserCard()); |
| | | } |
| | | if (this.getIntent().hasExtra("registeredCard")) { |
| | | registeredCard = (RegisteredCard) this.getIntent().getSerializableExtra("registeredCard"); |
| | |
| | | if (this.getIntent().hasExtra("configurationPowerCard")) { |
| | | configurationPowerCard = (ConfigurationPowerCard) this.getIntent().getSerializableExtra("configurationPowerCard"); |
| | | binding.cardData.setText("制作配置水泵功率卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("regionCard")) { |
| | | regionCard = (RegionCard) this.getIntent().getSerializableExtra("regionCard"); |
| | | binding.cardData.setText("制作区域表号卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("morny")) { |
| | | // 充值逻辑 |
| | |
| | | || registeredCard != null || cleanUserCard != null |
| | | || domainCard != null || testCard != null |
| | | || configureDeviceRegistrationCrad != null |
| | | || configurationPowerCard != null) { |
| | | || configurationPowerCard != null || regionCard != null || passWordCard != null || electricPriceCard != null) { |
| | | if (userCard != null && TextUtils.isEmpty(morny)) { |
| | | userFlag = WriteCardUtils.setUser(intent, userCard, this); |
| | | } |
| | | if (electricPriceCard != null) { |
| | | setElectricPriceCard(intent, electricPriceCard); |
| | | } |
| | | if (passWordCard != null) { |
| | | setPassWordCard(intent, passWordCard); |
| | | } |
| | | if (regionCard != null) { |
| | | setRegionCard(intent, regionCard); |
| | | } |
| | | if (cleanCard != null) { |
| | | setClean(intent, cleanCard); |
| | | } |
| | | if (manageCard != null) { |
| | | setmanageCard(intent, manageCard); |
| | | if (manageCardFlag && userCardBeanByManager != null) { |
| | | //修改用户表信息 |
| | | userCardBeanByManager.setCardNumber(manageCard.getUserCard()); |
| | | baseDao.userCardDao().update(userCardBeanByManager); |
| | | } |
| | | } |
| | | if (registeredCard != null) { |
| | | setRegisteredCard(intent, registeredCard); |
| | |
| | | if (configurationPowerCard != null) { |
| | | setConfigurationPower(intent, configurationPowerCard); |
| | | } |
| | | if ((configPowerFlag || configDeviceRegiestFlag || testCardFlag || domainCrdFlag || userFlag || cleanFlag || manageCardFlag || registeredFlag || administrativeCardFlag || cleanUserCardFlag)) { |
| | | if (electricPriceFlag || passwordFlag || regionFlag || configPowerFlag || configDeviceRegiestFlag || testCardFlag || domainCrdFlag || userFlag || cleanFlag || manageCardFlag || registeredFlag || administrativeCardFlag || cleanUserCardFlag) { |
| | | try { |
| | | if (userFlag && userCardBean != null) { |
| | | //用户卡 |
| | |
| | | } |
| | | |
| | | private void setmanageCard(Intent intent, final ManageCard manageCard) { |
| | | manageCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(manageCard.toZeroByte(baseDao), 1, 0); |
| | | manageCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(manageCard.toByte(baseDao), 1, 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param intent |
| | | * @param clearOrInitCard |
| | | */ |
| | | private void setClean(Intent intent, final CleanCard clearOrInitCard) { |
| | | private void setClean(Intent intent, CleanCard clearOrInitCard) { |
| | | cleanFlag = NFCWriteHelper.getInstence(intent, this).writeData(clearOrInitCard.toByte(baseDao), 1, 0); |
| | | } |
| | | |
| | | /** |
| | | * 保存区域表号卡 |
| | | * |
| | | * @param intent |
| | | * @param regionCard |
| | | */ |
| | | private void setRegionCard(Intent intent, RegionCard regionCard) { |
| | | regionFlag = NFCWriteHelper.getInstence(intent, this).writeData(regionCard.toByte(), 1, 0); |
| | | } |
| | | |
| | | /** |
| | | * 密码卡 |
| | | * |
| | | * @param intent |
| | | * @param passWordCard |
| | | */ |
| | | private void setPassWordCard(Intent intent, PassWordCard passWordCard) { |
| | | passwordFlag = NFCWriteHelper.getInstence(intent, this).writeData(passWordCard.toByte(baseDao), 1, 0); |
| | | } |
| | | |
| | | /** |
| | | * 用户电量单价 |
| | | * |
| | | * @param intent |
| | | * @param electricPriceCard |
| | | */ |
| | | private void setElectricPriceCard(Intent intent, ElectricPriceCard electricPriceCard) { |
| | | electricPriceFlag = NFCWriteHelper.getInstence(intent, this).writeData(electricPriceCard.toByte(baseDao), 1, 0); |
| | | } |
| | | |
| | | /** |
| | | * 重新注册设备卡 |