|
@@ -0,0 +1,59 @@
|
|
|
|
+package org.springblade.manager.dto;
|
|
|
|
+
|
|
|
|
+import lombok.Data;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author yangyj
|
|
|
|
+ * @Date 2024/5/9 15:47
|
|
|
|
+ * @description 标识转换
|
|
|
|
+ */
|
|
|
|
+@Data
|
|
|
|
+public class Structure {
|
|
|
|
+ /**表头表尾*/
|
|
|
|
+ private boolean isHeadTail=false;
|
|
|
|
+ /**业务数据*/
|
|
|
|
+ private boolean isMeasure=false;
|
|
|
|
+ /**每页固定不变*/
|
|
|
|
+ private boolean isFixed=false;
|
|
|
|
+ /*状态值二进制*/
|
|
|
|
+ private char[] state =new char[]{'0','0','0'};
|
|
|
|
+ public Structure(Integer state) {
|
|
|
|
+ if(state!=null) {
|
|
|
|
+ char[] arr = Integer.toBinaryString(state).toCharArray();
|
|
|
|
+ int offset = this.state.length - arr.length;
|
|
|
|
+ System.arraycopy(arr, 0, this.state, offset, arr.length);
|
|
|
|
+ this.isHeadTail = this.state[index(1)] == '1';
|
|
|
|
+ this.isMeasure = this.state[index(2)] == '1';
|
|
|
|
+ this.isFixed = this.state[index(3)] == '1';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public Integer toInt(){
|
|
|
|
+ return Integer.parseInt(String.valueOf(state), 2);
|
|
|
|
+ }
|
|
|
|
+ public int index(int n){
|
|
|
|
+ return this.state.length-n;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+/* public static void main(String[] args) {
|
|
|
|
+ Structure structure = new Structure();
|
|
|
|
+ structure.setFixed(true);
|
|
|
|
+ System.out.println(structure.toInt());
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ public void setHeadTail(boolean headTail) {
|
|
|
|
+ this.state[index(1)]=headTail?'1':'0';
|
|
|
|
+ isHeadTail = headTail;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setMeasure(boolean measure) {
|
|
|
|
+ this.state[index(2)]=measure?'1':'0';
|
|
|
|
+ isMeasure = measure;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setFixed(boolean fixed) {
|
|
|
|
+ this.state[index(3)]=fixed?'1':'0';
|
|
|
|
+ isFixed = fixed;
|
|
|
|
+ }
|
|
|
|
+}
|