mirror of
https://gitee.com/willfree/minoaClientWindows_gradle.git
synced 2026-10-05 01:15:44 +08:00
198 lines
8.6 KiB
Java
198 lines
8.6 KiB
Java
package cn.minoa.view.home;
|
|
|
|
import cn.minoa.MainApp;
|
|
import cn.minoa.dataRequestInterface.OrderInfo;
|
|
import cn.minoa.dataRequestInterface.ResponseData;
|
|
import cn.minoa.model.Reimbursement;
|
|
import javafx.fxml.FXML;
|
|
import javafx.scene.control.ListView;
|
|
import javafx.scene.layout.Pane;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
public class ReimbursementDealController {
|
|
private MainApp mainApp;
|
|
private List<Reimbursement> reimbursementInfoList;
|
|
|
|
@FXML
|
|
private ListView<Pane> reimbursementList;
|
|
|
|
public ReimbursementDealController(){
|
|
reimbursementInfoList = new LinkedList<Reimbursement>();
|
|
}
|
|
|
|
@FXML
|
|
private void initialize() {
|
|
// 在fxml被载入时候被自动调用
|
|
// 监听选择的改变
|
|
reimbursementList.getSelectionModel().selectedItemProperty()
|
|
.addListener((observable, oldValue, newValue) -> showReimbursementDetails(Integer.parseInt(newValue.getId())));
|
|
}
|
|
|
|
// 展示报销的详细信息的弹窗
|
|
private void showReimbursementDetails(Integer paneId) {
|
|
// 在当前数据结构中找到这个emailId对应的邮件
|
|
Reimbursement reimbursement = new Reimbursement();
|
|
for (int i = 0; i < reimbursementInfoList.size(); i++) {
|
|
reimbursement = reimbursementInfoList.get(i);
|
|
if (reimbursement.getId() == paneId) {
|
|
break;
|
|
}
|
|
}
|
|
// 传递给主函数
|
|
mainApp.dealReimbursementDetailsDialog(reimbursement);
|
|
}
|
|
|
|
//弹出一个可以选择通过审批或者拒绝通过审批的弹窗
|
|
private void dealReimbursementDetails(Integer paneId){
|
|
// 在当前数据结构中找到这个emailId对应的邮件
|
|
Reimbursement reimbursement = new Reimbursement();
|
|
for (int i = 0; i < reimbursementInfoList.size(); i++) {
|
|
reimbursement = reimbursementInfoList.get(i);
|
|
if (reimbursement.getId() == paneId) {
|
|
break;
|
|
}
|
|
}
|
|
//然后发条消息将这个审批给通过或否决
|
|
//...
|
|
}
|
|
|
|
/*
|
|
* @param mainApp
|
|
*/
|
|
public void setMainApp(MainApp mainApp) {
|
|
// 被mainApp调用
|
|
this.mainApp = mainApp;
|
|
// 初始化list
|
|
getReimbursement(1);
|
|
// 反应到前端
|
|
for (int i = 0; i < reimbursementInfoList.size(); i++) {
|
|
reimbursementList.getItems().add(new ReimbursementListItem(reimbursementInfoList.get(i)).getPaneItem());
|
|
}
|
|
}
|
|
|
|
// 发送数据请求请求发送给登录者的报销列表
|
|
// 0表示我发送的,1表示发送给我的
|
|
// 要判断是否是已经被审核的,process=0表示还审核
|
|
private Integer getReimbursement(Integer queryCode) {
|
|
// 请求数据
|
|
OrderInfo orderInfo = new OrderInfo();
|
|
ResponseData responseData = new ResponseData();
|
|
Long seqLong = mainApp.getNewDataReqId();
|
|
orderInfo.setSeq(seqLong);
|
|
orderInfo.setJsonString(getGetApproval(queryCode));
|
|
mainApp.minoaDataAPI.executeOrder("/getApproval", orderInfo);
|
|
responseData = mainApp.minoaDataAPI.dataCacheQueue.getResponseDataBySeq(seqLong);
|
|
JSONObject jsonObject = responseData.praseRequestData();
|
|
responseData.printSelf();
|
|
// 解析数据
|
|
Integer codeInteger = null;
|
|
try {
|
|
codeInteger = jsonObject.getInt("code");
|
|
} catch (JSONException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
if (codeInteger == 200) {
|
|
String dataString;
|
|
try {
|
|
dataString = jsonObject.getString("data");
|
|
if ((dataString.equals("")) || (dataString.equals("null"))) {
|
|
reimbursementInfoList.clear();
|
|
return 0;
|
|
}
|
|
reimbursementInfoList.clear();
|
|
JSONArray dataJsonArray = new JSONArray(dataString);
|
|
String reimbursementCacheString;
|
|
JSONObject reimbursementCacheJsonObject;
|
|
// 遍历每个信息
|
|
for (int i = 0; i < dataJsonArray.length(); i++) {
|
|
reimbursementCacheString = dataJsonArray.getString(i);
|
|
reimbursementCacheJsonObject = new JSONObject(reimbursementCacheString);
|
|
Integer id = reimbursementCacheJsonObject.getInt("approvalId");
|
|
String senderInfo = reimbursementCacheJsonObject.getString("proposer");
|
|
// 解析发送者和接收者的姓名
|
|
String receiverInfo = reimbursementCacheJsonObject.getString("approver");
|
|
Integer process=reimbursementCacheJsonObject.getInt("process");
|
|
String detailString = reimbursementCacheJsonObject.getString("detail");
|
|
JSONObject receiverJsonObject = new JSONObject(receiverInfo);
|
|
JSONObject senderJsonObject = new JSONObject(senderInfo);
|
|
String sender_usernameString = senderJsonObject.getString("username");
|
|
String receiver_usernameString = receiverJsonObject.getString("username");
|
|
// 解析报销详细内容
|
|
JSONObject detailJsonObject = new JSONObject(detailString);
|
|
Long detail_date = detailJsonObject.getLong("date");
|
|
String detail_content = detailJsonObject.getString("content");
|
|
Integer detail_invoiceNum = detailJsonObject.getInt("invoiceNum");
|
|
Double detail_totalMoney = detailJsonObject.getDouble("totalMoney");
|
|
String detail_detail = detailJsonObject.getString("detail");
|
|
//解析邮件的附件列表
|
|
String filesString=detailJsonObject.getString("pictures");
|
|
JSONArray filesJsonArray=new JSONArray(filesString);
|
|
List<String> reimbursementfiles=new LinkedList<String>();
|
|
for(int j=0;j<filesJsonArray.length();j++) {
|
|
String onefileString=filesJsonArray.getString(j);
|
|
reimbursementfiles.add(onefileString);
|
|
}
|
|
//构建一个报销对象
|
|
Reimbursement reimbursement = new Reimbursement();
|
|
reimbursement.setId(id);
|
|
reimbursement.setProcess(process);
|
|
reimbursement.setDate(detail_date);
|
|
reimbursement.setContent(detail_content);
|
|
reimbursement.setDetail(detail_detail);
|
|
reimbursement.setNumber(detail_invoiceNum);
|
|
reimbursement.setTotalMoney(detail_totalMoney);
|
|
reimbursement.setSender(sender_usernameString);
|
|
reimbursement.setReceiver(receiver_usernameString);
|
|
reimbursement.files=reimbursementfiles;
|
|
if(reimbursement.getProcess()==0){
|
|
reimbursementInfoList.add(reimbursement);
|
|
}else{
|
|
//do nothing
|
|
}
|
|
}
|
|
return 0;
|
|
} catch (JSONException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
return -1;
|
|
}
|
|
} else if(codeInteger==201){
|
|
System.out.println("201:报销审批,请使用大数据接口获取数据");
|
|
} else {
|
|
return -1;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// 获取邮件记录命令: 0表示查询我发送的,1表示查询发送给我的
|
|
private String getGetApproval(Integer queryCode) {
|
|
JSONObject jsonObject = new JSONObject();
|
|
String commandString = "/getApproval";
|
|
String usernameString = mainApp.loginer.getUserName();
|
|
String uuidString = mainApp.loginer.getUuid();
|
|
Integer typeCodeInteger = 2;
|
|
Integer queryCodeInteger = queryCode;
|
|
Integer pageNoInteger = 0; // 页编号
|
|
Integer pageSizeInteger = 6; // 页大小
|
|
try {
|
|
jsonObject.put("command", commandString);
|
|
jsonObject.put("username", usernameString);
|
|
jsonObject.put("uuid", uuidString);
|
|
jsonObject.put("typeCode", typeCodeInteger);
|
|
jsonObject.put("queryCode", queryCodeInteger);
|
|
jsonObject.put("pageNo", pageNoInteger);
|
|
jsonObject.put("pageSize", pageSizeInteger);
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
System.out.println("exception: " + e.getMessage());
|
|
}
|
|
return jsonObject.toString();
|
|
}
|
|
}
|