public static final String purchaseRequestCode = AppContext.getSystemProperty("srmjc.purchaseRequisitions"); public static final String purchaseRequestCode2 = AppContext.getSystemProperty("srmjc.purchaseRequisitions1"); //融通模板编号 public static final String rongtongCode = AppContext.getSystemProperty("srmjc.rongtong"); //内江模板编号 public static final String neijiangCode = AppContext.getSystemProperty("srmjc.neijiang"); //江油模板编号 public static final String jiangyouCode = AppContext.getSystemProperty("srmjc.jiangyou"); public static final String rongtongDept = AppContext.getSystemProperty("srmjc.rongtongDept"); public static final String neijiangDept = AppContext.getSystemProperty("srmjc.neijiangDept"); public static final String jiangyouDept = AppContext.getSystemProperty("srmjc.jiangyouDept"); String department = jsonObject.get("department").toString(); String summaryId = ""; String code = ""; String formExport = transOrderGoodsJsonToFormExport(jsonObject, code).toString(); switch (department) { case rongtongDept: code = rongtongCode; break; case neijiangDept: code = neijiangCode; break; case jiangyouDept: code = jiangyouCode; break; case dept: code = purchaseRequestCode; break; case dept2: code = purchaseRequestCode2; break; } summaryId = flowFactory.sendCollaboration(LOGIN_NAME, code, null, formExport, null, "0", null); 这样代码有哪些问题 并改正
时间: 2024-02-14 21:13:23 浏览: 113
Android 数据库SQLite-IT计算机-毕业设计.zip
这段代码的问题在于,在switch语句之前的代码块中,变量code被使用了,但是此时它还没有被赋值。因此,需要将switch语句放在变量code赋值之后。
另外,还有几个变量(如dept和dept2)没有在代码中定义,需要根据实际情况进行定义。
修改后的代码如下:
```
public static final String purchaseRequestCode = AppContext.getSystemProperty("srmjc.purchaseRequisitions");
public static final String purchaseRequestCode2 = AppContext.getSystemProperty("srmjc.purchaseRequisitions1");
//融通模板编号
public static final String rongtongCode = AppContext.getSystemProperty("srmjc.rongtong");
//内江模板编号
public static final String neijiangCode = AppContext.getSystemProperty("srmjc.neijiang");
//江油模板编号
public static final String jiangyouCode = AppContext.getSystemProperty("srmjc.jiangyou");
public static final String rongtongDept = AppContext.getSystemProperty("srmjc.rongtongDept");
public static final String neijiangDept = AppContext.getSystemProperty("srmjc.neijiangDept");
public static final String jiangyouDept = AppContext.getSystemProperty("srmjc.jiangyouDept");
String department = jsonObject.get("department").toString();
String summaryId = "";
String code = "";
String formExport = transOrderGoodsJsonToFormExport(jsonObject, code).toString();
//根据实际情况定义dept和dept2
String dept = "dept";
String dept2 = "dept2";
//先赋值再使用
switch (department) {
case rongtongDept:
code = rongtongCode;
break;
case neijiangDept:
code = neijiangCode;
break;
case jiangyouDept:
code = jiangyouCode;
break;
case dept:
code = purchaseRequestCode;
break;
case dept2:
code = purchaseRequestCode2;
break;
}
summaryId = flowFactory.sendCollaboration(LOGIN_NAME, code, null, formExport, null, "0", null);
```
阅读全文