mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2025-06-30 21:04:16 +00:00
add project adins
This commit is contained in:
parent
ad06ac5505
commit
f8f85d679d
5299 changed files with 625430 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
package com.adins.mss.base.todolist;
|
||||
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JsonTaskList extends MssResponseType {
|
||||
@SerializedName("listTaskH")
|
||||
private List<TaskH> listTaskH;
|
||||
|
||||
public List<TaskH> getListTaskH() {
|
||||
return listTaskH;
|
||||
}
|
||||
|
||||
public void setListTaskH(List<TaskH> listTaskH) {
|
||||
this.listTaskH = listTaskH;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.adins.mss.base.commons;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* Created by Aditya Purwa on 1/6/2015.
|
||||
* Used to create activity based model.
|
||||
*/
|
||||
public abstract class ActivityModel extends ContextModel {
|
||||
/**
|
||||
* Initialize a new instance of context model.
|
||||
*
|
||||
* @param context The context for the model. Must be an activity.
|
||||
*/
|
||||
public ActivityModel(Context context) {
|
||||
super(context);
|
||||
if (!(context instanceof Activity)) {
|
||||
throw new IllegalArgumentException("ActivityModel only accept activity as the context.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model activity.
|
||||
*
|
||||
* @return Model activity.
|
||||
*/
|
||||
public Activity getContextAsActivity() {
|
||||
if (!(getContext() instanceof Activity)) {
|
||||
throw new IllegalArgumentException("ActivityModel only accept activity as the context.");
|
||||
}
|
||||
return (Activity) getContext();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape>
|
||||
<solid android:color="#F0F0F0" />
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/gradient_end" /> <!-- Border color for pressed state -->
|
||||
<corners android:radius="8dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<gradient
|
||||
android:startColor="#F0F0F0"
|
||||
android:endColor="#F0F0F0"
|
||||
android:angle="270" />
|
||||
<stroke
|
||||
android:width="1.5dp"
|
||||
android:color="@android:color/darker_gray" /> <!-- Border color for default state -->
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="#ffffff" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#7d7d7d" />
|
||||
<corners android:radius="0dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="1dp">
|
||||
<shape>
|
||||
<solid android:color="@android:color/transparent" />
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="#7d7d7d" />
|
||||
<corners android:radius="0dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -0,0 +1,34 @@
|
|||
package com.adins.mss.coll.dashboardcollection;
|
||||
|
||||
import com.adins.mss.coll.dashboardcollection.model.CollResultDetail;
|
||||
import com.adins.mss.coll.models.ReportSummaryResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDashboardCollDataSource {
|
||||
//sync mode
|
||||
int getTotalOutstandingTask();
|
||||
double getOutstandingAmount();
|
||||
double getTotalAmountCollected();
|
||||
double getTotalAmountToCollect();
|
||||
List<CollResultDetail> getTaskCollectedDetails();
|
||||
List<CollResultDetail> getTaskPTPDetails();
|
||||
List<CollResultDetail> getTaskFailedDetails();
|
||||
|
||||
//async mode
|
||||
void getTotalOutstandingTaskAsync(DashboardResultListener<Integer> listener);
|
||||
void getOutstandingAmountAsync(DashboardResultListener<Double> listener);
|
||||
void getTotalAmountCollectedAsync(DashboardResultListener<Double> listener);
|
||||
void getTotalAmountToCollectAsync(DashboardResultListener<Double> listener);
|
||||
void getTaskCollectedDetailsAsync(DashboardResultListener<List<CollResultDetail>> listener);
|
||||
void getTaskPTPDetailsAsync(DashboardResultListener<List<CollResultDetail>> listener);
|
||||
void getTaskFailedDetailsAsync(DashboardResultListener<List<CollResultDetail>> listener);
|
||||
|
||||
//remote data
|
||||
void requestDashboardData(DashboardResultListener<ReportSummaryResponse> listener);
|
||||
|
||||
interface DashboardResultListener<T>{
|
||||
void onResult(T result);
|
||||
void onError(Exception e);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.adins.mss.foundation.http;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.NewMainActivity;
|
||||
import com.adins.mss.foundation.http.HttpConnection.ConnectionCryptor;
|
||||
import com.adins.mss.foundation.security.SAKFormatter;
|
||||
|
||||
/**
|
||||
* A subclass of HttpConnection which use SAKFormatter as the encryption engine by default, communicate via ConnectionCryptor interface
|
||||
* <br>Still, this class allow the usage of other cryptor, by change the default cryptor in GlobalData
|
||||
* <p>
|
||||
* <p>The Cryptor used is set from GlobalData
|
||||
*
|
||||
* @author glen.iglesias
|
||||
* @see GlobalData
|
||||
*/
|
||||
public class HttpCryptedConnection extends HttpConnection implements ConnectionCryptor {
|
||||
|
||||
/**
|
||||
* Construct a HttpCryptedConnection with cryptor as stated on GlobalData, or SAKFormatter by default
|
||||
*
|
||||
* @param enableEncryption flag for outgoing data encryption
|
||||
* @param enableDecryption flag for incoming data decryption
|
||||
*/
|
||||
public HttpCryptedConnection(boolean enableEncryption, boolean enableDecryption) {
|
||||
|
||||
//Use cryptor set on GlobalData, if any
|
||||
ConnectionCryptor connCryptor = GlobalData.getSharedGlobalData().getConnectionCryptor();
|
||||
if (connCryptor != null) {
|
||||
this.setCryptor(connCryptor);
|
||||
} else {
|
||||
this.setCryptor(this);
|
||||
}
|
||||
|
||||
this.setEnableEncryption(enableEncryption);
|
||||
this.setEnableDecryption(enableDecryption);
|
||||
}
|
||||
|
||||
public HttpCryptedConnection(Context context, boolean enableEncryption, boolean enableDecryption, boolean enableSecureConnection) {
|
||||
ConnectionCryptor connCryptor = GlobalData.getSharedGlobalData().getConnectionCryptor();
|
||||
if (connCryptor != null) {
|
||||
this.setCryptor(connCryptor);
|
||||
} else {
|
||||
this.setCryptor(this);
|
||||
}
|
||||
|
||||
this.setEnableEncryption(enableEncryption);
|
||||
this.setEnableDecryption(enableDecryption);
|
||||
this.setContext(context);
|
||||
this.setSecureConnection(enableSecureConnection);
|
||||
}
|
||||
|
||||
public HttpCryptedConnection(Context context, boolean enableEncryption, boolean enableDecryption) {
|
||||
ConnectionCryptor connCryptor = GlobalData.getSharedGlobalData().getConnectionCryptor();
|
||||
if (connCryptor != null) {
|
||||
this.setCryptor(connCryptor);
|
||||
} else {
|
||||
this.setCryptor(this);
|
||||
}
|
||||
|
||||
this.setEnableEncryption(enableEncryption);
|
||||
this.setEnableDecryption(enableDecryption);
|
||||
this.setContext(context);
|
||||
this.setSecureConnection(GlobalData.getSharedGlobalData().isSecureConnection());
|
||||
}
|
||||
|
||||
public HttpCryptedConnection(Activity activity, boolean enableEncryption, boolean enableDecryption) {
|
||||
ConnectionCryptor connCryptor = GlobalData.getSharedGlobalData().getConnectionCryptor();
|
||||
if (connCryptor != null) {
|
||||
this.setCryptor(connCryptor);
|
||||
} else {
|
||||
this.setCryptor(this);
|
||||
}
|
||||
|
||||
this.setEnableEncryption(enableEncryption);
|
||||
this.setEnableDecryption(enableDecryption);
|
||||
this.setActivity(activity);
|
||||
this.setContext(activity);
|
||||
this.setSecureConnection(GlobalData.getSharedGlobalData().isSecureConnection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a HttpCryptedConnection with own implementation of ConnectionCryptor to allow custom cryptor
|
||||
*
|
||||
* @param enableEncryption
|
||||
* @param enableDecryption
|
||||
* @param cryptor
|
||||
*/
|
||||
public HttpCryptedConnection(boolean enableEncryption, boolean enableDecryption, ConnectionCryptor cryptor) {
|
||||
this.setCryptor(cryptor);
|
||||
this.setEnableEncryption(enableEncryption);
|
||||
this.setEnableDecryption(enableDecryption);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encrpyt(String data) {
|
||||
byte[] cryptedBytes = SAKFormatter.cipherData(data);
|
||||
String result = new String(cryptedBytes);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decrypt(String data) {
|
||||
String result = SAKFormatter.decipherData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 7.3 KiB |
|
@ -0,0 +1,16 @@
|
|||
package com.adins.mss.coll.models.loyaltymodels;
|
||||
|
||||
import com.adins.mss.foundation.http.MssResponseType;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoyaltyPointsResponse extends MssResponseType {
|
||||
|
||||
@SerializedName("MEMBERSHIP_PROGRAM_CODE")
|
||||
public String membershipProgramId;
|
||||
@SerializedName("LOGIN_ID")
|
||||
public String loginId;
|
||||
@SerializedName("DATA_DETAIL")
|
||||
public List<GroupPointData> dataDetail;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.adins.mss.odr.catalogue.imageslider;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.Scroller;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by olivia.dg on 11/28/2017.
|
||||
*/
|
||||
|
||||
public class SliderView extends ViewPager {
|
||||
public static final int DEFAULT_SCROLL_DURATION = 200;
|
||||
public static final int SLIDE_MODE_SCROLL_DURATION = 1000;
|
||||
|
||||
public SliderView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public SliderView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setDurationScroll(DEFAULT_SCROLL_DURATION);
|
||||
// this.setOnTouchListener(new OnTouchListener() {
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public void setDurationScroll(int millis) {
|
||||
try {
|
||||
Class<?> viewpager = ViewPager.class;
|
||||
Field scroller = viewpager.getDeclaredField("mScroller");
|
||||
scroller.setAccessible(true);
|
||||
scroller.set(this, new OwnScroller(getContext(), millis));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public class OwnScroller extends Scroller {
|
||||
|
||||
private int durationScrollMillis = 1;
|
||||
|
||||
public OwnScroller(Context context, int durationScroll) {
|
||||
super(context, new DecelerateInterpolator());
|
||||
this.durationScrollMillis = durationScroll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
|
||||
super.startScroll(startX, startY, dx, dy, durationScrollMillis);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.adins.mss.base.dynamicform;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.adins.mss.base.GlobalData;
|
||||
import com.adins.mss.base.crashlytics.FireCrash;
|
||||
import com.adins.mss.base.util.GsonHelper;
|
||||
import com.adins.mss.base.util.Utility;
|
||||
import com.adins.mss.constant.Global;
|
||||
import com.adins.mss.dao.TaskD;
|
||||
import com.adins.mss.dao.TaskH;
|
||||
import com.adins.mss.foundation.http.HttpConnectionResult;
|
||||
import com.adins.mss.foundation.http.HttpCryptedConnection;
|
||||
import com.google.firebase.perf.FirebasePerformance;
|
||||
import com.google.firebase.perf.metrics.HttpMetric;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VerifTaskApi {
|
||||
private Activity activity;
|
||||
private TaskH taskH;
|
||||
private List<TaskD> taskDs;
|
||||
private String notes;
|
||||
|
||||
public VerifTaskApi(Activity activity, TaskH taskH, List<TaskD> taskDs, String notes) {
|
||||
this.activity = activity;
|
||||
this.taskH = taskH;
|
||||
this.taskDs = taskDs;
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public HttpConnectionResult request() {
|
||||
JsonRequestVerificationTask task = new JsonRequestVerificationTask();
|
||||
task.setAudit(GlobalData.getSharedGlobalData().getAuditData());
|
||||
task.addImeiAndroidIdToUnstructured();
|
||||
task.setTaskH(taskH);
|
||||
task.setTaskD(taskDs);
|
||||
task.setNotes(notes);
|
||||
|
||||
String json = GsonHelper.toJson(task);
|
||||
String url = GlobalData.getSharedGlobalData().getURL_SUBMITVERIFICATIONTASK();
|
||||
|
||||
boolean encrypt = GlobalData.getSharedGlobalData().isEncrypt();
|
||||
boolean decrypt = GlobalData.getSharedGlobalData().isDecrypt();
|
||||
HttpCryptedConnection httpConn = new HttpCryptedConnection(activity, encrypt, decrypt);
|
||||
HttpConnectionResult serverResult = null;
|
||||
|
||||
//Firebase Performance Trace HTTP Request
|
||||
HttpMetric networkMetric =
|
||||
FirebasePerformance.getInstance().newHttpMetric(url, FirebasePerformance.HttpMethod.POST);
|
||||
Utility.metricStart(networkMetric, json);
|
||||
|
||||
try {
|
||||
serverResult = httpConn.requestToServer(url, json, Global.DEFAULTCONNECTIONTIMEOUT);
|
||||
Utility.metricStop(networkMetric, serverResult);
|
||||
return serverResult;
|
||||
} catch (Exception e) {
|
||||
FireCrash.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.adins.mss.foundation.print.rv;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.adins.mss.base.R;
|
||||
import com.adins.mss.dao.ReceiptVoucher;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by angga.permadi on 5/11/2016.
|
||||
*/
|
||||
public class RvNumberAdapter extends ArrayAdapter<ReceiptVoucher> {
|
||||
private List<ReceiptVoucher> entities;
|
||||
private int resource;
|
||||
|
||||
public RvNumberAdapter(Context context, int resource, List<ReceiptVoucher> objects) {
|
||||
super(context, resource, objects);
|
||||
this.resource = resource;
|
||||
this.entities = objects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int position) {
|
||||
return position != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
RvNumberItem item;
|
||||
|
||||
if (convertView == null) {
|
||||
item = new RvNumberItem(parent.getContext(), R.layout.spinner_style_hint);
|
||||
} else {
|
||||
item = (RvNumberItem) convertView;
|
||||
}
|
||||
|
||||
item.bind(entities.get(position), 1);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getDropDownView(int position, View convertView, ViewGroup parent) {
|
||||
RvNumberItem item;
|
||||
if (convertView == null) {
|
||||
item = new RvNumberItem(parent.getContext(), resource);
|
||||
} else {
|
||||
item = (RvNumberItem) convertView;
|
||||
}
|
||||
|
||||
item.bind(entities.get(position), position);
|
||||
return item;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,567 @@
|
|||
package zj.com.command.sdk;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import zj.com.customize.sdk.Other;
|
||||
|
||||
public class PrinterCommand {
|
||||
|
||||
/**
|
||||
* 打<>?<3F>机<EFBFBD>?始化
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_PrtInit() {
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_Init});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打<>?<3F>并<EFBFBD>?<3F>行
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_LF() {
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.LF});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打<>?<3F>并走纸 (0~255)
|
||||
*
|
||||
* @param feed
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_PrtAndFeedPaper(int feed) {
|
||||
if (feed > 255 | feed < 0)
|
||||
return null;
|
||||
|
||||
Command.ESC_J[2] = (byte) feed;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_J});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打<>?<3F>自检页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_PrtSelfTest() {
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.US_vt_eot
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 蜂鸣指令
|
||||
*
|
||||
* @param m 蜂鸣次数
|
||||
* @param t <20>?次蜂鸣的时间
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Beep(int m, int t) {
|
||||
|
||||
if ((m < 1 || m > 9) || (t < 1 || t > 9))
|
||||
return null;
|
||||
|
||||
Command.ESC_B_m_n[2] = (byte) m;
|
||||
Command.ESC_B_m_n[3] = (byte) t;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_B_m_n
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切刀指令(走纸到切刀<E58887>?置并切纸)
|
||||
*
|
||||
* @param cut 0~255
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Cut(int cut) {
|
||||
if (cut > 255 | cut < 0)
|
||||
return null;
|
||||
|
||||
Command.GS_V_m_n[3] = (byte) cut;
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_V_m_n
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 钱箱指令
|
||||
*
|
||||
* @param nMode
|
||||
* @param nTime1
|
||||
* @param nTime2
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Cashbox(int nMode, int nTime1, int nTime2) {
|
||||
|
||||
if ((nMode < 0 || nMode > 1) || nTime1 < 0 || nTime1 > 255 || nTime2 < 0 || nTime2 > 255)
|
||||
return null;
|
||||
Command.ESC_p[2] = (byte) nMode;
|
||||
Command.ESC_p[3] = (byte) nTime1;
|
||||
Command.ESC_p[4] = (byte) nTime2;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_p
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置<E8AEBE>?对打<E5AFB9>?<3F><>?置
|
||||
*
|
||||
* @param absolute
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Absolute(int absolute) {
|
||||
if (absolute > 65535 | absolute < 0)
|
||||
return null;
|
||||
|
||||
Command.ESC_Relative[2] = (byte) (absolute % 0x100);
|
||||
Command.ESC_Relative[3] = (byte) (absolute / 0x100);
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_Relative
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置相对打<E5AFB9>?<3F><>?置
|
||||
*
|
||||
* @param relative
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Relative(int relative) {
|
||||
if (relative < 0 | relative > 65535)
|
||||
return null;
|
||||
|
||||
Command.ESC_Absolute[2] = (byte) (relative % 0x100);
|
||||
Command.ESC_Absolute[3] = (byte) (relative / 0x100);
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_Absolute
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置左边<E5B7A6>?
|
||||
*
|
||||
* @param left
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_LeftSP(int left) {
|
||||
if (left > 255 | left < 0)
|
||||
return null;
|
||||
|
||||
Command.GS_LeftSp[2] = (byte) (left % 100);
|
||||
Command.GS_LeftSp[3] = (byte) (left / 100);
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_LeftSp
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置对<E7BDAE>?模<>?
|
||||
*
|
||||
* @param align
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_S_Align(int align) {
|
||||
if ((align < 0 || align > 2) || (align < 48 || align > 50))
|
||||
return null;
|
||||
|
||||
byte[] data = Command.ESC_Align;
|
||||
data[2] = (byte) align;
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置打<E7BDAE>?<3F>区域宽度
|
||||
*
|
||||
* @param width
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_PrintWidth(int width) {
|
||||
if (width < 0 | width > 255)
|
||||
return null;
|
||||
|
||||
Command.GS_W[2] = (byte) (width % 100);
|
||||
Command.GS_W[3] = (byte) (width / 100);
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_W
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认行间<E8A18C>?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_DefLineSpace() {
|
||||
|
||||
byte[] data = Command.ESC_Two;
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置行间<E8A18C>?
|
||||
*
|
||||
* @param space
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_LineSpace(int space) {
|
||||
if (space < 0 | space > 255)
|
||||
return null;
|
||||
|
||||
Command.ESC_Three[2] = (byte) space;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_Three
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择字符代<E7ACA6>?页
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_CodePage(int page) {
|
||||
if (page > 255)
|
||||
return null;
|
||||
|
||||
Command.ESC_t[2] = (byte) page;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_t
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打<>?<3F>文本文档
|
||||
*
|
||||
* @param pszString <20>?打<>?<3F>的字符串
|
||||
* @param encoding 打<>?<3F>字符对应编<E5BA94>?
|
||||
* @param codepage 设置代<E7BDAE>?页(0--255)
|
||||
* @param nWidthTimes <20>?宽(0--4)
|
||||
* @param nHeightTimes <20>?高(0--4)
|
||||
* @param nFontType 字体类型(<28>?<3F>对Ascii<69>?有效)(0,1 48,49)
|
||||
*/
|
||||
public static byte[] POS_Print_Text(String pszString, String encoding, int codepage,
|
||||
int nWidthTimes, int nHeightTimes, int nFontType) {
|
||||
|
||||
if (codepage < 0 || codepage > 255 || pszString == null || "".equals(pszString) || pszString.length() < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] pbString = null;
|
||||
try {
|
||||
pbString = pszString.getBytes(encoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] intToWidth = {0x00, 0x10, 0x20, 0x30};
|
||||
byte[] intToHeight = {0x00, 0x01, 0x02, 0x03};
|
||||
Command.GS_ExclamationMark[2] = (byte) (intToWidth[nWidthTimes] + intToHeight[nHeightTimes]);
|
||||
|
||||
Command.ESC_t[2] = (byte) codepage;
|
||||
|
||||
Command.ESC_M[2] = (byte) nFontType;
|
||||
|
||||
if (codepage == 0) {
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_ExclamationMark, Command.ESC_t, Command.FS_and, Command.ESC_M, pbString});
|
||||
|
||||
return data;
|
||||
} else {
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_ExclamationMark, Command.ESC_t, Command.FS_dot, Command.ESC_M, pbString});
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加粗指令(最低<E69C80>?为1有效)
|
||||
*
|
||||
* @param bold
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Bold(int bold) {
|
||||
|
||||
Command.ESC_E[2] = (byte) bold;
|
||||
Command.ESC_G[2] = (byte) bold;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_E, Command.ESC_G
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置倒置打<E7BDAE>?<3F>模<EFBFBD>?(当最低<E69C80>?为1时有效)
|
||||
*
|
||||
* @param brace
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_LeftBrace(int brace) {
|
||||
|
||||
Command.ESC_LeftBrace[2] = (byte) brace;
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_LeftBrace
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下划线
|
||||
*
|
||||
* @param line
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_UnderLine(int line) {
|
||||
|
||||
if ((line < 0 || line > 2))
|
||||
return null;
|
||||
|
||||
Command.ESC_Minus[2] = (byte) line;
|
||||
Command.FS_Minus[2] = (byte) line;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_Minus, Command.FS_Minus
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/*
|
||||
* 选择字体大<E4BD93>?(<28>?高<>?宽)
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_FontSize(int size1, int size2) {
|
||||
if (size1 < 0 | size1 > 7 | size2 < 0 | size2 > 7)
|
||||
return null;
|
||||
|
||||
byte[] intToWidth = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70};
|
||||
byte[] intToHeight = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
|
||||
Command.GS_ExclamationMark[2] = (byte) (intToWidth[size1] + intToHeight[size2]);
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_ExclamationMark
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置<E8AEBE>??显打<E698BE>?<3F>
|
||||
*
|
||||
* @param inverse
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Inverse(int inverse) {
|
||||
|
||||
Command.GS_B[2] = (byte) inverse;
|
||||
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.GS_B
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置旋转90度打<E5BAA6>?<3F>
|
||||
*
|
||||
* @param rotate
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Rotate(int rotate) {
|
||||
if (rotate < 0 || rotate > 1)
|
||||
return null;
|
||||
Command.ESC_V[2] = (byte) rotate;
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_V
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择字体字型
|
||||
*
|
||||
* @param font
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_ChoseFont(int font) {
|
||||
if (font > 1 | font < 0)
|
||||
return null;
|
||||
|
||||
Command.ESC_M[2] = (byte) font;
|
||||
byte[] data = Other.byteArraysToBytes(new byte[][]{
|
||||
Command.ESC_M
|
||||
});
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
//***********************************以下函数为公开函数***********************************************************//
|
||||
|
||||
/**
|
||||
* 二维<E4BA8C>?打<>?<3F>函数
|
||||
*
|
||||
* @param str 打<>?<3F>二维<E4BA8C>?数<>?<3F>
|
||||
* @param nVersion 二维<E4BA8C>?类型
|
||||
* @param nErrorCorrectionLevel 纠错级别
|
||||
* @param nMagnification 放大<E694BE>?数
|
||||
* @return
|
||||
*/
|
||||
public static byte[] getBarCommand(String str, int nVersion, int nErrorCorrectionLevel,
|
||||
int nMagnification) {
|
||||
|
||||
if (nVersion < 0 | nVersion > 19 | nErrorCorrectionLevel < 0 | nErrorCorrectionLevel > 3
|
||||
| nMagnification < 1 | nMagnification > 8) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] bCodeData = null;
|
||||
try {
|
||||
bCodeData = str.getBytes("GBK");
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] command = new byte[bCodeData.length + 7];
|
||||
|
||||
command[0] = 27;
|
||||
command[1] = 90;
|
||||
command[2] = ((byte) nVersion);
|
||||
command[3] = ((byte) nErrorCorrectionLevel);
|
||||
command[4] = ((byte) nMagnification);
|
||||
command[5] = (byte) (bCodeData.length & 0xff);
|
||||
command[6] = (byte) ((bCodeData.length & 0xff00) >> 8);
|
||||
System.arraycopy(bCodeData, 0, command, 7, bCodeData.length);
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打<>?<3F>一维<E4B880>?<3F><>?
|
||||
*
|
||||
* @param str 打<>?<3F><>?<3F><>?字符
|
||||
* @param nType <20>?<3F><>?类型(65~73)
|
||||
* @param nWidthX <20>?<3F><>?宽度
|
||||
* @param nHeight <20>?<3F><>?高度
|
||||
* @param nHriFontType HRI字型
|
||||
* @param nHriFontPosition HRI<52>?置
|
||||
* @return
|
||||
*/
|
||||
public static byte[] getCodeBarCommand(String str, int nType, int nWidthX, int nHeight,
|
||||
int nHriFontType, int nHriFontPosition) {
|
||||
|
||||
if (nType < 0x41 | nType > 0x49 | nWidthX < 2 | nWidthX > 6
|
||||
| nHeight < 1 | nHeight > 255 | str.length() == 0)
|
||||
return null;
|
||||
|
||||
byte[] bCodeData = null;
|
||||
try {
|
||||
bCodeData = str.getBytes("GBK");
|
||||
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] command = new byte[bCodeData.length + 16];
|
||||
|
||||
command[0] = 29;
|
||||
command[1] = 119;
|
||||
command[2] = ((byte) nWidthX);
|
||||
command[3] = 29;
|
||||
command[4] = 104;
|
||||
command[5] = ((byte) nHeight);
|
||||
command[6] = 29;
|
||||
command[7] = 102;
|
||||
command[8] = ((byte) (nHriFontType & 0x01));
|
||||
command[9] = 29;
|
||||
command[10] = 72;
|
||||
command[11] = ((byte) (nHriFontPosition & 0x03));
|
||||
command[12] = 29;
|
||||
command[13] = 107;
|
||||
command[14] = ((byte) nType);
|
||||
command[15] = (byte) (byte) bCodeData.length;
|
||||
System.arraycopy(bCodeData, 0, command, 16, bCodeData.length);
|
||||
|
||||
|
||||
return command;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置打<E7BDAE>?<3F>模<EFBFBD>?(选择字体(font:A font:B),加粗,字体<E5AD97>?高<>?宽(最大4<E5A4A7>?高宽))
|
||||
*
|
||||
* @param str 打<>?<3F>的字符串
|
||||
* @param bold 加粗
|
||||
* @param font 选择字型
|
||||
* @param widthsize <20>?宽
|
||||
* @param heigthsize <20>?高
|
||||
* @return
|
||||
*/
|
||||
public static byte[] POS_Set_Font(String str, int bold, int font, int widthsize, int heigthsize) {
|
||||
|
||||
if (str.length() == 0 | widthsize < 0 | widthsize > 4 | heigthsize < 0 | heigthsize > 4
|
||||
| font < 0 | font > 1)
|
||||
return null;
|
||||
|
||||
byte[] strData = null;
|
||||
try {
|
||||
strData = str.getBytes("GBK");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] command = new byte[strData.length + 9];
|
||||
|
||||
byte[] intToWidth = {0x00, 0x10, 0x20, 0x30};//最大四<E5A4A7>?宽
|
||||
byte[] intToHeight = {0x00, 0x01, 0x02, 0x03};//最大四<E5A4A7>?高
|
||||
|
||||
command[0] = 27;
|
||||
command[1] = 69;
|
||||
command[2] = ((byte) bold);
|
||||
command[3] = 27;
|
||||
command[4] = 77;
|
||||
command[5] = ((byte) font);
|
||||
command[6] = 29;
|
||||
command[7] = 33;
|
||||
command[8] = (byte) (intToWidth[widthsize] + intToHeight[heigthsize]);
|
||||
|
||||
System.arraycopy(strData, 0, command, 9, strData.length);
|
||||
return command;
|
||||
}
|
||||
//**********************************************************************************************************//
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue