| | |
| | | import android.view.View; |
| | | import android.widget.Toast; |
| | | |
| | | import com.dayu.baselibrary.activity.BaseNfcActivity; |
| | | import com.dayu.baselibrary.tools.BcdUtil; |
| | | import com.dayu.baselibrary.utils.AidlUtil; |
| | | import com.dayu.baselibrary.utils.BaseCommon; |
| | |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | import com.dayu.baselibrary.view.ConfirmDialog; |
| | | import com.dayu.baselibrary.view.TitleBar; |
| | | import com.dayu.henanlibrary.card.CleanCard; |
| | | import com.dayu.henanlibrary.card.CleanUserCard; |
| | | import com.dayu.henanlibrary.card.ConfigurationPowerCard; |
| | | import com.dayu.henanlibrary.card.CleanCardHN; |
| | | import com.dayu.henanlibrary.card.CleanUserCardHN; |
| | | import com.dayu.henanlibrary.card.ConfigurationPowerCardHN; |
| | | import com.dayu.henanlibrary.card.ConfigureDeviceRegistrationCrad; |
| | | import com.dayu.henanlibrary.card.DomainCard; |
| | | import com.dayu.henanlibrary.card.ManageCard; |
| | | import com.dayu.henanlibrary.card.RegisteredCard; |
| | | import com.dayu.henanlibrary.card.TestCard; |
| | | import com.dayu.henanlibrary.card.UserCard; |
| | | import com.dayu.henanlibrary.card.ManageCardHN; |
| | | import com.dayu.henanlibrary.card.RegisteredCardHN; |
| | | import com.dayu.henanlibrary.card.TestCardHN; |
| | | import com.dayu.henanlibrary.card.UserCardHN; |
| | | import com.dayu.henanlibrary.databinding.ActivityWriteTextHnBinding; |
| | | import com.dayu.henanlibrary.dbBean.AdminDataBean; |
| | | import com.dayu.henanlibrary.dbBean.ElectricPriceBean; |
| | |
| | | * Date: 2023-11-08 21:19 |
| | | * Description: nfc写卡界面 |
| | | */ |
| | | public class NFCWreatActivity extends BaseNfcActivity { |
| | | public class NFCWreatActivity extends HNBaseNfcActivity { |
| | | public static String TAG = "NFCWreatActivity"; |
| | | |
| | | boolean cleanFlag = false; |
| | |
| | | Intent intent; |
| | | |
| | | |
| | | RegisteredCard registeredCard; |
| | | CleanUserCard cleanUserCard; |
| | | ManageCard manageCard; |
| | | RegisteredCardHN registeredCard; |
| | | CleanUserCardHN cleanUserCard; |
| | | ManageCardHN manageCard; |
| | | DomainCard domainCard; |
| | | |
| | | CleanCard cleanCard; |
| | | CleanCardHN cleanCard; |
| | | ConfigureDeviceRegistrationCrad configureDeviceRegistrationCrad; |
| | | TestCard testCard; |
| | | TestCardHN testCard; |
| | | |
| | | ConfigurationPowerCard configurationPowerCard; |
| | | ConfigurationPowerCardHN configurationPowerCard; |
| | | //打印 |
| | | |
| | | public static NFCWreatActivity nfcWreatActivity; |
| | |
| | | boolean rechargeIsOk = false; |
| | | ActivityWriteTextHnBinding binding; |
| | | ConfirmDialog confirmDialog; |
| | | |
| | | @Override |
| | | public void onNfcBack(Intent intent) { |
| | | try { |
| | | this.intent = intent; |
| | | startAnim(); |
| | | Log.i("NFCWreatActivity", "isUser:" + isUser); |
| | | if (isUser) { |
| | | checkHasUser(); |
| | | } else if (isRecharge) { |
| | | if (rechargeIsOk) { |
| | | rechargeWrratCard(); |
| | | } else { |
| | | Toast.makeText(this, "正在通信请稍后", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | } else { |
| | | saveData(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | private void getData() { |
| | | try { |
| | | if (this.getIntent().hasExtra("userCard")) { |
| | | userCard = (UserCard) this.getIntent().getSerializableExtra("userCard"); |
| | | userCard = (UserCardHN) this.getIntent().getSerializableExtra("userCard"); |
| | | } |
| | | if (this.getIntent().hasExtra("cleanCard")) { |
| | | cleanCard = (CleanCard) this.getIntent().getSerializableExtra("cleanCard"); |
| | | cleanCard = (CleanCardHN) this.getIntent().getSerializableExtra("cleanCard"); |
| | | binding.cardData.setText("制作清零卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("manageCard")) { |
| | | manageCard = (ManageCard) this.getIntent().getSerializableExtra("manageCard"); |
| | | manageCard = (ManageCardHN) this.getIntent().getSerializableExtra("manageCard"); |
| | | binding.cardData.setText("制作管理卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("registeredCard")) { |
| | | registeredCard = (RegisteredCard) this.getIntent().getSerializableExtra("registeredCard"); |
| | | registeredCard = (RegisteredCardHN) this.getIntent().getSerializableExtra("registeredCard"); |
| | | binding.cardData.setText("制作重新注册设备卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("dbUserCard")) { |
| | |
| | | isUser = true; |
| | | } |
| | | if (this.getIntent().hasExtra("cleanUserCard")) { |
| | | cleanUserCard = (CleanUserCard) this.getIntent().getSerializableExtra("cleanUserCard"); |
| | | cleanUserCard = (CleanUserCardHN) this.getIntent().getSerializableExtra("cleanUserCard"); |
| | | binding.cardData.setText("制作删除全部用户卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("domainCard_xinxiang")) { |
| | |
| | | binding.cardData.setText("制作设置鹿邑域名卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("testCard")) { |
| | | testCard = (TestCard) this.getIntent().getSerializableExtra("testCard"); |
| | | testCard = (TestCardHN) this.getIntent().getSerializableExtra("testCard"); |
| | | binding.cardData.setText("制作测试卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("configureDeviceRegistrationCrad")) { |
| | |
| | | binding.cardData.setText("制作配置设备注册信息卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("configurationPowerCard")) { |
| | | configurationPowerCard = (ConfigurationPowerCard) this.getIntent().getSerializableExtra("configurationPowerCard"); |
| | | configurationPowerCard = (ConfigurationPowerCardHN) this.getIntent().getSerializableExtra("configurationPowerCard"); |
| | | binding.cardData.setText("制作配置水泵功率卡"); |
| | | } |
| | | if (this.getIntent().hasExtra("morny")) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onNewIntent(Intent intent) { |
| | | super.onNewIntent(intent); |
| | | try { |
| | | this.intent = intent; |
| | | startAnim(); |
| | | Log.i("NFCWreatActivity", "isUser:" + isUser); |
| | | if (isUser) { |
| | | checkHasUser(); |
| | | } else if (isRecharge) { |
| | | if (rechargeIsOk) { |
| | | rechargeWrratCard(); |
| | | } else { |
| | | Toast.makeText(this, "正在通信请稍后", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | |
| | | } else { |
| | | saveData(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | //往卡内写充值后的数据 |
| | | private void rechargeWrratCard() { |
| | | UserCard userCardold = NfcReadHelper.getInstence(intent, this).getUserCardData(); |
| | | UserCardHN userCardold = NfcReadHelper.getInstence(intent, this).getUserCardData(); |
| | | if (userCardold != null) { |
| | | //判断是否充值的是一个卡 |
| | | if (userCard.getInitPeasantCode().equals(userCardold.getInitPeasantCode()) || isAgainWrite) { |
| | |
| | | stopAnim(); |
| | | } |
| | | |
| | | private void setmanageCard(Intent intent, final ManageCard manageCard) { |
| | | private void setmanageCard(Intent intent, final ManageCardHN manageCard) { |
| | | try { |
| | | manageCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(manageCard.toZeroByte(baseDao), 1, 0); |
| | | } catch (Exception e) { |
| | |
| | | * @param intent |
| | | * @param clearOrInitCard |
| | | */ |
| | | private void setClean(Intent intent, final CleanCard clearOrInitCard) { |
| | | private void setClean(Intent intent, final CleanCardHN clearOrInitCard) { |
| | | try { |
| | | cleanFlag = NFCWriteHelper.getInstence(intent, this).writeData(clearOrInitCard.toByte(baseDao), 1, 0); |
| | | } catch (Exception e) { |
| | |
| | | * @param intent |
| | | * @param registeredCard |
| | | */ |
| | | private void setRegisteredCard(Intent intent, RegisteredCard registeredCard) { |
| | | private void setRegisteredCard(Intent intent, RegisteredCardHN registeredCard) { |
| | | try { |
| | | registeredFlag = NFCWriteHelper.getInstence(intent, this).writeData(registeredCard.toByte(baseDao), 1, 0); |
| | | } catch (Exception e) { |
| | |
| | | * @param intent |
| | | * @param cleanUserCard |
| | | */ |
| | | private void setCleanUserCard(Intent intent, CleanUserCard cleanUserCard) { |
| | | private void setCleanUserCard(Intent intent, CleanUserCardHN cleanUserCard) { |
| | | try { |
| | | cleanUserCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(cleanUserCard.toByte(baseDao), 1, 0); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | } |
| | | |
| | | private void setTestCard(Intent intent, TestCard testCard) { |
| | | private void setTestCard(Intent intent, TestCardHN testCard) { |
| | | testCardFlag = NFCWriteHelper.getInstence(intent, this).writeData(testCard.toByte(baseDao), 1, 0); |
| | | } |
| | | |
| | |
| | | configDeviceRegiestFlag = NFCWriteHelper.getInstence(intent, this).writeData(configureDeviceRegistrationCrad.toByte(baseDao), 1, 0); |
| | | } |
| | | |
| | | private void setConfigurationPower(Intent intent, ConfigurationPowerCard configurationPowerCard) { |
| | | private void setConfigurationPower(Intent intent, ConfigurationPowerCardHN configurationPowerCard) { |
| | | try { |
| | | configPowerFlag = NFCWriteHelper.getInstence(intent, this).writeData(configurationPowerCard.toByte(baseDao), 1, 0); |
| | | } catch (Exception e) { |
| | |
| | | stateText = new StringBuffer(); |
| | | String state = BcdUtil.bcdToStr(readData.getBodyBytes()[2]); //BCD码00启用 01禁用 02隶属信息不符 03无此卡信息 04其它s |
| | | if (userCard == null) { |
| | | userCard = new UserCard(); |
| | | userCard = new UserCardHN(); |
| | | userCard.setRechargeTimes(0); |
| | | ElectricPriceBean electricPriceBean = baseDao.electricPriceDao().findFirst(); |
| | | if (electricPriceBean != null) { |