付款单模板,导入文件修复bug

product
chuang 2 years ago
parent 99f043b45a
commit 4e7e5660e8

@ -2,6 +2,7 @@ package jnpf.paymentdoc.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -407,9 +408,40 @@ public class PaymentdocServiceImpl extends ServiceImpl<PaymentdocMapper, Payment
paymentdocMessage.setFullName(PermissionUtil.getLinkInfoByOrgId(userEntity.getOrganizeId(), organizeService, false)); paymentdocMessage.setFullName(PermissionUtil.getLinkInfoByOrgId(userEntity.getOrganizeId(), organizeService, false));
} }
} }
String substring = null;
String substring1 = null;
if (paymentdocMessage.getFullName()!=null){
String fullName = paymentdocMessage.getFullName();
substring = fullName.substring(fullName.indexOf("/")+1, fullName.indexOf("/", fullName.indexOf("/")+1));
if (fullName.length()>fullName.indexOf(substring)+2){
substring1 = fullName.substring(fullName.indexOf(substring) + substring.length()+1, fullName.length());
}
}
StringBuilder payEnclosureStr = new StringBuilder();
if (paymentdocMessage.getEnclosure()!=null){
String enclosure = paymentdocMessage.getEnclosure();
JSONArray jsonToJsonArray = JsonUtil.getJsonToJsonArray(enclosure);
for (int i = 0; i < jsonToJsonArray.size(); i++) {
Map o = (Map)jsonToJsonArray.get(i);
Object name = o.get("name");
if (i==0){
payEnclosureStr.append(name);
payEnclosureStr.append("<br/>"+name);
}else {
payEnclosureStr.append("<br/>"+name);
}
}
paymentdocMessage.setEnclosure(payEnclosureStr.toString());
}
// StringUtil.indexOf()
// String templateFilePath = configValueUtil.getTemplateFilePath() +"paymentDocPdf//"; // String templateFilePath = configValueUtil.getTemplateFilePath() +"paymentDocPdf//";
Map<String, Object> map = JsonUtil.stringToMap(JSONUtil.toJsonStr(paymentDocMessage)); Map<String, Object> map = JsonUtil.stringToMap(JSONUtil.toJsonStr(paymentDocMessage));
map.put("substring",substring);
map.put("substring1",substring1);
// map.put("reportList",paymentDocNodeInfo); // map.put("reportList",paymentDocNodeInfo);
FlowBeforeController bean = SpringContext.getBean(FlowBeforeController.class); FlowBeforeController bean = SpringContext.getBean(FlowBeforeController.class);
ActionResult info = null; ActionResult info = null;
@ -432,8 +464,23 @@ public class PaymentdocServiceImpl extends ServiceImpl<PaymentdocMapper, Payment
map1.put("node",map2.get("node")); map1.put("node",map2.get("node"));
maps.add(map1); maps.add(map1);
} }
ArrayList<Map<String, Object>> maps1 = new ArrayList<Map<String, Object>>();
int num=6;
if (maps.size()>num){
for (int i = 0; i < maps.size(); i++) {
Map<String, Object> map1 = maps.get(i);
if (i>=num){
maps1.add(map1);
}
}
while (maps.size()>num){
maps.remove(num);
}
}
map.put("reportList",maps); map.put("reportList",maps);
map.put("reportList1",maps1);
byte[] bytes = null; byte[] bytes = null;
ByteArrayOutputStream out = null; ByteArrayOutputStream out = null;
ExportPdf exportPdf = new ExportPdf(); ExportPdf exportPdf = new ExportPdf();
@ -445,8 +492,10 @@ public class PaymentdocServiceImpl extends ServiceImpl<PaymentdocMapper, Payment
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (substring==null){
String fileName = paymentdocMessage.getCustomerName()==null?"城市矿产请示.pdf":paymentdocMessage.getCustomerName()+"请示.pdf"; substring="城市矿产";
}
String fileName = paymentdocMessage.getCustomerName()==null?substring+"请示.pdf":substring+"请示("+paymentdocMessage.getCustomerName()+").pdf";
HttpServletResponse response = ServletUtil.getResponse(); HttpServletResponse response = ServletUtil.getResponse();
response.reset(); response.reset();

@ -75,8 +75,10 @@ public class VehiclePictureFolderUtils {
} }
@Test @Test
public void test1(){ System.out.println( public void test1(){ //System.out.println(
VehiclePictureFolderUtils.getVehiclePictureFolder("2-皖D39239-13955463796")); // VehiclePictureFolderUtils.getVehiclePictureFolder("2-皖D39239-13955463796"));
String a=" 济钢集团/济钢城市矿产科技有限公司/再生资源事业部 ";
System.out.println(StringUtil.indexOf(a, "/", 6));
} }

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save