|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.noblelift.imp.products.mes.service.st.is; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import org.wdk.WDK; |
|
|
@ -8,11 +9,14 @@ import org.wdk.core.bean.WDKException; |
|
|
|
import org.wdk.core.env.context.ServiceContext; |
|
|
|
import org.wdk.core.spring.SpringContext; |
|
|
|
import org.wdk.core.spring.annotation.WDKTransaction; |
|
|
|
import org.wdk.core.util.uExcelUtilByPOI; |
|
|
|
import org.wdk.core.util.uMath; |
|
|
|
import org.wdk.core.util.uString; |
|
|
|
import org.wdk.core.wql.WQL; |
|
|
|
import org.wdk.core.wql.core.bean.ResultBean; |
|
|
|
import org.wdk.core.wql.core.bean.WQLObject; |
|
|
|
import org.wdk.module.file.FileReturn; |
|
|
|
import org.wdk.module.file.FileServerFactory; |
|
|
|
|
|
|
|
import com.noblelift.imp.platform.core.util.ServiceParameterParseUtil; |
|
|
|
import com.noblelift.imp.platform.core.util.WdkUtil; |
|
|
@ -153,7 +157,42 @@ public class IssueBillOtherServiceImpl implements IssueBillOtherService { |
|
|
|
HashMap<String, String> param = WDK.json2map(form); |
|
|
|
if (uString.isNotBlank(form.optString("searchBar"))) |
|
|
|
param.put("material_code", form.optString("searchBar")); |
|
|
|
|
|
|
|
JSONArray result = form.optJSONArray("result"); |
|
|
|
|
|
|
|
String material_codes = ""; |
|
|
|
HashMap<String,Double> map = new HashMap<String,Double> (); |
|
|
|
if(result != null){ |
|
|
|
for (int i = 0; i < result.size(); i++) { |
|
|
|
map.put(result.getJSONObject(i).optString("material_code"), result.getJSONObject(i).optDouble("audit_qty")); |
|
|
|
if (material_codes.equals("")) |
|
|
|
material_codes = result.getJSONObject(i).optString("material_code"); |
|
|
|
else |
|
|
|
material_codes = material_codes + "," + result.getJSONObject(i).optString("material_code"); |
|
|
|
} |
|
|
|
if(uString.isNotBlank(material_codes)){ |
|
|
|
material_codes = "'" + material_codes.replaceAll(",", "','") + "'"; |
|
|
|
param.put("material_codes", material_codes); |
|
|
|
} |
|
|
|
} |
|
|
|
param.remove("result"); |
|
|
|
JSONObject jres = WQL.getWO("ST_IS_ISSUE_OTHER_01").addParamMap(param).addParam("flag", "12").pageQuery(context, ""); |
|
|
|
|
|
|
|
|
|
|
|
if(result != null){ |
|
|
|
JSONArray rows = jres.optJSONArray("rows"); |
|
|
|
JSONArray new_rows = new JSONArray(); |
|
|
|
for(int i=0;i<rows.size();i++){ |
|
|
|
JSONObject jo = rows.getJSONObject(i); |
|
|
|
if(map.containsKey(jo.optString("material_code"))){ |
|
|
|
Double fact_qty = map.get(jo.optString("material_code")); |
|
|
|
jo.put("audit_qty", fact_qty); |
|
|
|
} |
|
|
|
new_rows.add(jo); |
|
|
|
} |
|
|
|
jres.put("rows", new_rows); |
|
|
|
} |
|
|
|
|
|
|
|
ServiceResultBean srb = new ServiceResultBean(); |
|
|
|
srb.setSuccess(); |
|
|
|
srb.setDesc("查询成功"); |
|
|
@ -1943,4 +1982,42 @@ public class IssueBillOtherServiceImpl implements IssueBillOtherService { |
|
|
|
srb.setSuccess(); |
|
|
|
return srb; |
|
|
|
} |
|
|
|
|
|
|
|
@WDKTransaction |
|
|
|
@Override |
|
|
|
public ServiceResultBean excelSave(ServiceContext context, JSONObject accountInfo, String fileid) { |
|
|
|
if (uString.isEmpty(fileid)) { |
|
|
|
throw new WDKException("Excel文件ID不能为空"); |
|
|
|
} |
|
|
|
FileReturn fr = null; |
|
|
|
try { |
|
|
|
fr = FileServerFactory.getInstance().get(fileid); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
ArrayList<?> excelList = uExcelUtilByPOI._readExcel(fr.getInputstream()); |
|
|
|
|
|
|
|
JSONArray jres = new JSONArray(); |
|
|
|
for (int i = 0, j = excelList.size(); i < j; i++) { |
|
|
|
// 对应Excel的每一列
|
|
|
|
ArrayList<?> list = (ArrayList<?>) excelList.get(i); |
|
|
|
JSONObject tblexport = new JSONObject(); |
|
|
|
// 对应Excel的第一列
|
|
|
|
tblexport.put("material_code", list.get(0)); |
|
|
|
tblexport.put("audit_qty", list.get(1)); |
|
|
|
|
|
|
|
// 说明到了最后一行
|
|
|
|
if (uString.isEmpty(tblexport.optString("material_code"))) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
jres.add(tblexport); |
|
|
|
} |
|
|
|
|
|
|
|
ServiceResultBean srb = new ServiceResultBean(); |
|
|
|
srb.setDesc("导入excel成功!"); |
|
|
|
srb.addJSONArray("result", jres); |
|
|
|
srb.setSuccess(); |
|
|
|
return srb; |
|
|
|
} |
|
|
|
} |
|
|
|