| @@ -1,45 +1,43 @@ | |||||
| package com.iformall.print.data; | package com.iformall.print.data; | ||||
| import java.io.ByteArrayInputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.StringReader; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| import javax.xml.parsers.DocumentBuilderFactory; | |||||
| import javax.xml.parsers.ParserConfigurationException; | |||||
| import javax.xml.xpath.XPath; | |||||
| import javax.xml.xpath.XPathFactory; | |||||
| import org.jsoup.Jsoup; | import org.jsoup.Jsoup; | ||||
| import org.jsoup.nodes.Document; | import org.jsoup.nodes.Document; | ||||
| import org.jsoup.nodes.Element; | import org.jsoup.nodes.Element; | ||||
| import org.jsoup.nodes.Node; | import org.jsoup.nodes.Node; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | ||||
| import com.iformall.domain.po.WxFinanceReceive; | |||||
| @Service | @Service | ||||
| public class PrintCustomedTableDataHandler{ | public class PrintCustomedTableDataHandler{ | ||||
| public String getTableContent(String componentContent,JSONArray datas,JSONObject entity) { | |||||
| if (null != entity) { | |||||
| public String getTableContent(String componentContent,PrintDataParser objectParser,Object object,PrintDataParser listParser,List listdata,Object... params) { | |||||
| if (null != object) { | |||||
| JSONObject entity = JSON.parseObject(JSON.toJSONString(object)); | |||||
| for (Iterator<String> it = entity.keySet().iterator(); it.hasNext();) { | for (Iterator<String> it = entity.keySet().iterator(); it.hasNext();) { | ||||
| String fieldName = it.next(); | String fieldName = it.next(); | ||||
| Object o = entity.get(fieldName); | |||||
| componentContent = componentContent.replaceAll("\\{"+fieldName+"\\}", String.valueOf(o)); | |||||
| //Object o = entity.get(fieldName); | |||||
| if (StringUtils.isBlank(fieldName)) { | |||||
| }else { | |||||
| Object o = objectParser.getObjectValue(fieldName, object,params); | |||||
| if (null == o) { | |||||
| componentContent = componentContent.replaceAll("\\{"+fieldName+"\\}", ""); | |||||
| }else { | |||||
| componentContent = componentContent.replaceAll("\\{"+fieldName+"\\}", String.valueOf(o)); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| componentContent = getTableListContent(componentContent,datas); | |||||
| componentContent = getTableListContent(listParser,componentContent,listdata,params); | |||||
| return componentContent; | return componentContent; | ||||
| } | } | ||||
| private String getTableListContent(String componentContent,JSONArray datas) { | |||||
| if (null == datas || datas.size() <= 0) { | |||||
| private String getTableListContent(PrintDataParser parser,String componentContent,List listdata,Object... params) { | |||||
| if (null == listdata || listdata.size() <= 0) { | |||||
| return componentContent; | return componentContent; | ||||
| } | } | ||||
| Document doc = Jsoup.parse(componentContent); | Document doc = Jsoup.parse(componentContent); | ||||
| @@ -48,8 +46,9 @@ public class PrintCustomedTableDataHandler{ | |||||
| String trclass = titleTr.attr("class"); | String trclass = titleTr.attr("class"); | ||||
| String trstyle = titleTr.attr("style"); | String trstyle = titleTr.attr("style"); | ||||
| StringBuffer sb = new StringBuffer(); | StringBuffer sb = new StringBuffer(); | ||||
| for (int i = 0 ; i < datas.size(); i ++) { | |||||
| JSONObject o = datas.getJSONObject(i); | |||||
| for (int i = 0 ; i < listdata.size(); i ++) { | |||||
| Object object = listdata.get(i); | |||||
| JSONObject o = JSON.parseObject(JSON.toJSONString(object)); | |||||
| Element tr = titleTr.parent().appendElement("tr"); | Element tr = titleTr.parent().appendElement("tr"); | ||||
| sb.append("<tr "); | sb.append("<tr "); | ||||
| if (StringUtils.isNotBlank(trclass)) { | if (StringUtils.isNotBlank(trclass)) { | ||||
| @@ -90,7 +89,8 @@ public class PrintCustomedTableDataHandler{ | |||||
| String[] fs = fieldName.split(","); | String[] fs = fieldName.split(","); | ||||
| if (null != fs) { | if (null != fs) { | ||||
| for (int k = 0 ; k<fs.length; k++) { | for (int k = 0 ; k<fs.length; k++) { | ||||
| Object v = o.get(fs[k]); | |||||
| //Object v = o.get(fs[k]); | |||||
| Object v = parser.getObjectValue(fs[k], object, params); | |||||
| if (k == fs.length-1) { | if (k == fs.length-1) { | ||||
| sep = ""; | sep = ""; | ||||
| } | } | ||||
| @@ -104,7 +104,8 @@ public class PrintCustomedTableDataHandler{ | |||||
| } | } | ||||
| }else { | }else { | ||||
| Object v = o.get(fieldName); | |||||
| //Object v = o.get(fieldName); | |||||
| Object v = parser.getObjectValue(fieldName, object, params); | |||||
| if (null != v) { | if (null != v) { | ||||
| tdcontent.append(v); | tdcontent.append(v); | ||||
| }else { | }else { | ||||
| @@ -120,19 +121,4 @@ public class PrintCustomedTableDataHandler{ | |||||
| } | } | ||||
| return doc.head().html() + doc.body().html(); | return doc.head().html() + doc.body().html(); | ||||
| } | } | ||||
| public static void main(String[] args) { | |||||
| PrintCustomedTableDataHandler p = new PrintCustomedTableDataHandler(); | |||||
| String s = "<style>table,td,th{border:1px solid #000;border-collapse:collapse}table{width:515px;font-size:10px;text-align:center}tr{height:30px}.one{width:10%}.two{width:16%}.three{width:32.5%}.four{width:10%}.five{width:10%}.six{width:10%}.seven{width:10%}</style><table id=\"fmbraidhtmltable\"><tr id=\"titletr\"><td class=\"one\" fieldName=\"shopNumber\">房间名称</td><td class=\"two\" fieldName=\"feesName\">费用科目</td><td class=\"three\" fieldName=\"starttime,endtime\" sep=\"~\">费用区间</td><td class=\"four\" fieldName=\"receivePay\">应收金额</td><td class=\"five\" fieldName=\"setOff\">冲抵金额</td><td class=\"six\" fieldName=\"youhui\">优惠金额</td><td class=\"seven\" fieldName=\"pay\">实收金额</td></tr></table>"; | |||||
| List<WxFinanceReceive> rlist = new ArrayList<WxFinanceReceive>(); | |||||
| WxFinanceReceive r1 = new WxFinanceReceive(); | |||||
| r1.setFeesName("adssasd"); | |||||
| WxFinanceReceive r2 = new WxFinanceReceive(); | |||||
| r2.setFeesName("11111"); | |||||
| rlist.add(r1); | |||||
| rlist.add(r2); | |||||
| String sss = p.getTableListContent(s, JSON.parseArray(JSON.toJSONString(rlist))); | |||||
| System.out.println(sss); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,6 @@ | |||||
| package com.iformall.print.data; | |||||
| public interface PrintDataParser { | |||||
| public Object getObjectValue(String name, Object o,Object... params); | |||||
| } | |||||
| @@ -1,4 +1,4 @@ | |||||
| package com.iformall.print.data; | |||||
| package com.iformall.print.data.impl; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -6,15 +6,19 @@ import org.springframework.stereotype.Service; | |||||
| import com.iformall.domain.po.WxAllBill; | import com.iformall.domain.po.WxAllBill; | ||||
| import com.iformall.domain.po.WxEnergyFees; | import com.iformall.domain.po.WxEnergyFees; | ||||
| import com.iformall.domain.po.WxFinanceReceive; | |||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.print.data.PrintDataParser; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| @Service | @Service | ||||
| public class PrintBillDataHandler{ | |||||
| public class PrintBillDataHandler implements PrintDataParser{ | |||||
| public Object getObjectValue(String name, Object o,Map<Long,WxMerchant> merchantMap,Map<Long,WxEnergyFees> feesMap) { | |||||
| @Override | |||||
| public Object getObjectValue(String name, Object o,Object... params) { | |||||
| Map<Long, WxMerchant> merchantMap = (Map<Long, WxMerchant>) params[0]; | |||||
| Map<Long, WxEnergyFees> feesMap = (Map<Long, WxEnergyFees>) params[1]; | |||||
| Map<Long,String> shopNumber = (Map<Long, String>) params[2]; | |||||
| WxAllBill receive = (WxAllBill) o; | WxAllBill receive = (WxAllBill) o; | ||||
| if (name.equals("id")) { | if (name.equals("id")) { | ||||
| return receive.getId(); | return receive.getId(); | ||||
| @@ -26,10 +30,12 @@ public class PrintBillDataHandler{ | |||||
| return receive.getPay(); | return receive.getPay(); | ||||
| }else if (name.equals("setOff")) { | }else if (name.equals("setOff")) { | ||||
| return receive.getSetOff(); | return receive.getSetOff(); | ||||
| }else if (name.equals("returnPay")) { | |||||
| return receive.getReturnPay(); | |||||
| }else if (name.equals("starttime")) { | }else if (name.equals("starttime")) { | ||||
| return DateUtils.date2String(receive.getStarttime()); | |||||
| return DateUtils.date2String(receive.getStarttime(),DateUtils.DATE_PATTERN); | |||||
| }else if (name.equals("endtime")) { | }else if (name.equals("endtime")) { | ||||
| return DateUtils.date2String(receive.getEndtime()); | |||||
| return DateUtils.date2String(receive.getEndtime(),DateUtils.DATE_PATTERN); | |||||
| }else if (name.equals("owe")) { | }else if (name.equals("owe")) { | ||||
| return receive.getOwe(); | return receive.getOwe(); | ||||
| }else if (name.equals("statusName")) { | }else if (name.equals("statusName")) { | ||||
| @@ -42,7 +48,7 @@ public class PrintBillDataHandler{ | |||||
| } | } | ||||
| } | } | ||||
| return ""; | return ""; | ||||
| }else if (name.equals("energyFeesName")) { | |||||
| }else if (name.equals("feesName")) { | |||||
| if (null != feesMap) { | if (null != feesMap) { | ||||
| WxEnergyFees f = feesMap.get(receive.getEnergyFeesId()); | WxEnergyFees f = feesMap.get(receive.getEnergyFeesId()); | ||||
| if (null != f) { | if (null != f) { | ||||
| @@ -50,10 +56,14 @@ public class PrintBillDataHandler{ | |||||
| } | } | ||||
| } | } | ||||
| return ""; | return ""; | ||||
| }else if (name.equals("returnPay")) { | |||||
| return receive.getReturnPay(); | |||||
| }else if (name.equals("billRemark")) { | }else if (name.equals("billRemark")) { | ||||
| return receive.getBillRemark(); | return receive.getBillRemark(); | ||||
| }else if (name.equals("shopNumber")) { | |||||
| if (null != shopNumber) { | |||||
| String m = shopNumber.get(receive.getMerchantId()); | |||||
| return m; | |||||
| } | |||||
| return ""; | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| package com.iformall.print.data; | |||||
| package com.iformall.print.data.impl; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -11,6 +11,7 @@ import com.iformall.domain.po.WxAllBill; | |||||
| import com.iformall.domain.po.WxEnergyFees; | import com.iformall.domain.po.WxEnergyFees; | ||||
| import com.iformall.domain.po.WxFinanceReceive; | import com.iformall.domain.po.WxFinanceReceive; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.print.data.PrintDataParser; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| /** | /** | ||||
| @@ -21,10 +22,14 @@ import com.iformall.utils.DateUtils; | |||||
| * | * | ||||
| */ | */ | ||||
| @Service | @Service | ||||
| public class PrintFinanceReceiveDataHandler { | |||||
| public class PrintFinanceReceiveDataHandler implements PrintDataParser{ | |||||
| public Object getObjectValue(String name, Object o,Map<Long,WxMerchant> merchantMap,Map<Long,WxEnergyFees> feesMap,Map<Long,String> shopNumber) { | |||||
| WxFinanceReceive receive = (WxFinanceReceive) o; | |||||
| @Override | |||||
| public Object getObjectValue(String name, Object o, Object... params) { | |||||
| Map<Long, WxMerchant> merchantMap = (Map<Long, WxMerchant>) params[0]; | |||||
| Map<Long, WxEnergyFees> feesMap = (Map<Long, WxEnergyFees>) params[1]; | |||||
| Map<Long,String> shopNumber = (Map<Long, String>) params[2]; | |||||
| WxFinanceReceive receive = (WxFinanceReceive) o; | |||||
| if (name.equals("id")) { | if (name.equals("id")) { | ||||
| return receive.getId(); | return receive.getId(); | ||||
| }else if (name.equals("createTime")) { | }else if (name.equals("createTime")) { | ||||
| @@ -49,7 +54,7 @@ public class PrintFinanceReceiveDataHandler { | |||||
| if (null != merchantMap) { | if (null != merchantMap) { | ||||
| WxMerchant m = merchantMap.get(receive.getMerchantId()); | WxMerchant m = merchantMap.get(receive.getMerchantId()); | ||||
| if (null != m) { | if (null != m) { | ||||
| return receive.getRemark(); | |||||
| return m.getName(); | |||||
| } | } | ||||
| } | } | ||||
| return ""; | return ""; | ||||
| @@ -60,6 +65,6 @@ public class PrintFinanceReceiveDataHandler { | |||||
| return ""; | return ""; | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| package com.iformall.print.data; | |||||
| package com.iformall.print.data.impl; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -8,13 +8,19 @@ import com.iformall.domain.po.WxAllBill; | |||||
| import com.iformall.domain.po.WxEnergyFees; | import com.iformall.domain.po.WxEnergyFees; | ||||
| import com.iformall.domain.po.WxFinanceReceive; | import com.iformall.domain.po.WxFinanceReceive; | ||||
| import com.iformall.domain.po.WxMerchant; | import com.iformall.domain.po.WxMerchant; | ||||
| import com.iformall.domain.vo.WxMerchantBillVo; | |||||
| import com.iformall.print.data.PrintDataParser; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| @Service | @Service | ||||
| public class PrintMerchantSettleDataHandler{ | |||||
| public class PrintMerchantSettleDataHandler implements PrintDataParser{ | |||||
| public Object getObjectValue(String name, Object o,Map<Long,WxMerchant> merchantMap,Map<Long,WxEnergyFees> feesMap) { | |||||
| @Override | |||||
| public Object getObjectValue(String name, Object o,Object... params) { | |||||
| Map<Long, WxMerchant> merchantMap = (Map<Long, WxMerchant>) params[0]; | |||||
| Map<Long, WxEnergyFees> feesMap = (Map<Long, WxEnergyFees>) params[1]; | |||||
| Map<Long,String> shopNumber = (Map<Long, String>) params[2]; | |||||
| WxMerchantBillVo receive = (WxMerchantBillVo) o; | |||||
| //根据科目来查询对应的信息 | //根据科目来查询对应的信息 | ||||
| // if (name.equals("id")) { | // if (name.equals("id")) { | ||||
| // return receive.getId(); | // return receive.getId(); | ||||
| @@ -29,10 +29,11 @@ import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxFinancePrintDataMapper; | import com.iformall.mapper.WxFinancePrintDataMapper; | ||||
| import com.iformall.mapper.WxFinancePrintTemplateMapper; | import com.iformall.mapper.WxFinancePrintTemplateMapper; | ||||
| import com.iformall.print.PrintComponentHandler; | import com.iformall.print.PrintComponentHandler; | ||||
| import com.iformall.print.data.PrintBillDataHandler; | |||||
| import com.iformall.print.data.PrintCustomedTableDataHandler; | import com.iformall.print.data.PrintCustomedTableDataHandler; | ||||
| import com.iformall.print.data.PrintFinanceReceiveDataHandler; | |||||
| import com.iformall.print.data.PrintMerchantSettleDataHandler; | |||||
| import com.iformall.print.data.PrintDataParser; | |||||
| import com.iformall.print.data.impl.PrintBillDataHandler; | |||||
| import com.iformall.print.data.impl.PrintFinanceReceiveDataHandler; | |||||
| import com.iformall.print.data.impl.PrintMerchantSettleDataHandler; | |||||
| import com.iformall.service.WxAllBillService; | import com.iformall.service.WxAllBillService; | ||||
| import com.iformall.service.WxEnergyService; | import com.iformall.service.WxEnergyService; | ||||
| import com.iformall.service.WxFinancePrintService; | import com.iformall.service.WxFinancePrintService; | ||||
| @@ -191,6 +192,41 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { | |||||
| return isSetDefaultValue; | return isSetDefaultValue; | ||||
| } | } | ||||
| private PrintVo handleComponentData(Long templateId,JSONObject templateContent,JSONArray items,PrintDataParser objectParser,Object object,PrintDataParser listParser,List listdata,Object... params) { | |||||
| if (null != items) { | |||||
| PrintVo vo = new PrintVo(); | |||||
| vo.setDataId(templateId); | |||||
| for (int j = 0 ; j < items.size() ; j ++) { | |||||
| JSONObject ov = items.getJSONObject(j); | |||||
| //是否是定制化的表格 | |||||
| Integer isCustomedTable = ov.getInteger("isFmCustomizedTable"); | |||||
| boolean isSetDefaultValue = isSetDefaultValue(ov); | |||||
| if (null != isCustomedTable && EnumYesOrNo.YES.getCode().intValue() == isCustomedTable.intValue()) { | |||||
| //表格解析 | |||||
| String componentContent = ov.getString("value"); | |||||
| if (null != listdata) { | |||||
| ov.put("defaultValue",printCustomedTableDataHandler.getTableContent(componentContent, objectParser,object,listParser,listdata,params)); | |||||
| } | |||||
| }else { | |||||
| String fieldName = ov.getString("name"); | |||||
| if (StringUtils.isBlank(fieldName)) { | |||||
| }else { | |||||
| if (isSetDefaultValue) { | |||||
| ov.put("defaultValue", objectParser.getObjectValue(fieldName,object,params)); | |||||
| }else { | |||||
| ov.put("value", objectParser.getObjectValue(fieldName,object,params)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| vo.setTemplate(templateContent); | |||||
| return vo; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| @Override | @Override | ||||
| public List<PrintVo> parseTemplateData(String tenantId, Long templateId, List<Long> dataIds,Object entity) { | public List<PrintVo> parseTemplateData(String tenantId, Long templateId, List<Long> dataIds,Object entity) { | ||||
| WxFinancePrintTemplate template = this.getTemplateById(templateId); | WxFinancePrintTemplate template = this.getTemplateById(templateId); | ||||
| @@ -225,9 +261,6 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { | |||||
| List<PrintVo> voList = new ArrayList<PrintVo>(); | List<PrintVo> voList = new ArrayList<PrintVo>(); | ||||
| for (int i = 0 ; i < receiveList.size(); i ++) { | for (int i = 0 ; i < receiveList.size(); i ++) { | ||||
| WxFinanceReceive re = receiveList.get(i); | WxFinanceReceive re = receiveList.get(i); | ||||
| PrintVo vo = new PrintVo(); | |||||
| vo.setDataId(templateId); | |||||
| WxFinanceReceiveBill rb = new WxFinanceReceiveBill(); | WxFinanceReceiveBill rb = new WxFinanceReceiveBill(); | ||||
| rb.updateTenantInfo(re); | rb.updateTenantInfo(re); | ||||
| rb.setReceiveId(re.getId()); | rb.setReceiveId(re.getId()); | ||||
| @@ -239,32 +272,10 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { | |||||
| billq.setIds(billIdList); | billq.setIds(billIdList); | ||||
| billList = wxAllBillService.list(billq); | billList = wxAllBillService.list(billq); | ||||
| } | } | ||||
| if (null != items) { | |||||
| for (int j = 0 ; j < items.size() ; j ++) { | |||||
| JSONObject ov = items.getJSONObject(j); | |||||
| //是否是定制化的表格 | |||||
| Integer isCustomedTable = ov.getInteger("isFmCustomizedTable"); | |||||
| boolean isSetDefaultValue = isSetDefaultValue(ov); | |||||
| if (null != isCustomedTable && EnumYesOrNo.YES.getCode().intValue() == isCustomedTable.intValue()) { | |||||
| //表格解析 | |||||
| String componentContent = ov.getString("value"); | |||||
| if (null != billList) { | |||||
| ov.put("defaultValue",printCustomedTableDataHandler.getTableContent(componentContent, JSON.parseArray(JSON.toJSONString(billList)),JSON.parseObject(JSON.toJSONString(re)))); | |||||
| ov.put("value", ""); | |||||
| } | |||||
| }else { | |||||
| if (isSetDefaultValue) { | |||||
| ov.put("defaultValue", printFinanceReceiveDataHandler.getObjectValue(ov.getString("name"),re,merchantMap,feesMap,shopNumber)); | |||||
| ov.put("value", ""); | |||||
| }else { | |||||
| ov.put("value", printFinanceReceiveDataHandler.getObjectValue(ov.getString("name"),re,merchantMap,feesMap,shopNumber)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| vo.setTemplate(o); | |||||
| voList.add(vo); | |||||
| PrintVo vo = handleComponentData(templateId,o,items, printFinanceReceiveDataHandler,re,printBillDataHandler, billList,merchantMap,feesMap,shopNumber); | |||||
| if (null != vo) { | |||||
| voList.add(vo); | |||||
| } | |||||
| } | } | ||||
| return voList; | return voList; | ||||
| }else if (printDatatype.getCode().intValue() == EnumFinancePrintDataType.BILL.getCode()) { | }else if (printDatatype.getCode().intValue() == EnumFinancePrintDataType.BILL.getCode()) { | ||||
| @@ -278,34 +289,10 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { | |||||
| List<PrintVo> voList = new ArrayList<PrintVo>(); | List<PrintVo> voList = new ArrayList<PrintVo>(); | ||||
| for (int i = 0 ; i < billAllList.size(); i ++) { | for (int i = 0 ; i < billAllList.size(); i ++) { | ||||
| WxAllBill re = billAllList.get(i); | WxAllBill re = billAllList.get(i); | ||||
| PrintVo vo = new PrintVo(); | |||||
| vo.setDataId(templateId); | |||||
| if (null != items) { | |||||
| for (int j = 0 ; j < items.size() ; j ++) { | |||||
| JSONObject ov = items.getJSONObject(j); | |||||
| //是否是定制化的表格 | |||||
| Integer isCustomedTable = ov.getInteger("isFmCustomizedTable"); | |||||
| boolean isSetDefaultValue = isSetDefaultValue(ov); | |||||
| if (null != isCustomedTable && EnumYesOrNo.YES.getCode().intValue() == isCustomedTable.intValue()) { | |||||
| //表格解析 | |||||
| String componentContent = ov.getString("value"); | |||||
| //if (null != billList) { | |||||
| // printCustomedTableDataHandler.getTableContent(componentContent, JSON.parseArray(JSON.toJSONString(billList))); | |||||
| //} | |||||
| }else { | |||||
| if (isSetDefaultValue) { | |||||
| ov.put("defaultValue", printBillDataHandler.getObjectValue(ov.getString("name"),re,merchantMap,feesMap)); | |||||
| ov.put("value", ""); | |||||
| }else { | |||||
| ov.put("value", printBillDataHandler.getObjectValue(ov.getString("name"),re,merchantMap,feesMap)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| vo.setTemplate(o); | |||||
| voList.add(vo); | |||||
| PrintVo vo = handleComponentData(templateId,o,items, printBillDataHandler,re,null, null,merchantMap,feesMap,shopNumber); | |||||
| if (null != vo) { | |||||
| voList.add(vo); | |||||
| } | |||||
| } | } | ||||
| return voList; | return voList; | ||||
| }else if (printDatatype.getCode().intValue() == EnumFinancePrintDataType.RENT_OWE.getCode()) { | }else if (printDatatype.getCode().intValue() == EnumFinancePrintDataType.RENT_OWE.getCode()) { | ||||
| @@ -314,65 +301,43 @@ public class WxFinancePrintServiceImpl implements WxFinancePrintService { | |||||
| List<Long> feesId = dataIds; | List<Long> feesId = dataIds; | ||||
| List<PrintVo> voList = new ArrayList<PrintVo>(); | List<PrintVo> voList = new ArrayList<PrintVo>(); | ||||
| PrintVo vo = new PrintVo(); | |||||
| vo.setDataId(templateId); | |||||
| if (null != items) { | |||||
| for (int j = 0 ; j < items.size() ; j ++) { | |||||
| JSONObject ov = items.getJSONObject(j); | |||||
| //是否是定制化的表格 | |||||
| Integer isCustomedTable = ov.getInteger("isFmCustomizedTable"); | |||||
| boolean isSetDefaultValue = isSetDefaultValue(ov); | |||||
| if (null != isCustomedTable && EnumYesOrNo.YES.getCode().intValue() == isCustomedTable.intValue()) { | |||||
| //表格解析 | |||||
| List<WxBillSum> sumlist = new ArrayList<WxBillSum>(); | |||||
| BigDecimal receiveTotal = new BigDecimal(0); | |||||
| BigDecimal payTotal = new BigDecimal(0); | |||||
| BigDecimal oweTotal = new BigDecimal(0); | |||||
| for (int k = 0 ; k< bq.getBillSumList().size() ; k++) { | |||||
| WxBillSum billSum = bq.getBillSumList().get(k); | |||||
| if (feesId.contains(billSum.getEnergyFeesId())) { | |||||
| WxEnergyFees fee = feesMap.get(billSum.getEnergyFeesId()); | |||||
| billSum.setTaxRate(fee.getTaxRate()); | |||||
| sumlist.add(billSum); | |||||
| receiveTotal = receiveTotal.add(billSum.getNeedPayNumber()); | |||||
| payTotal = payTotal.add(billSum.getPaidNumber()); | |||||
| oweTotal = oweTotal.add(billSum.getOweNumber()); | |||||
| } | |||||
| } | |||||
| WxBillSum heji = new WxBillSum(); | |||||
| heji.setBillName("合计"); | |||||
| heji.setNeedPay(receiveTotal.toPlainString()); | |||||
| sumlist.add(heji); | |||||
| WxBillSum yishou = new WxBillSum(); | |||||
| yishou.setBillName("已收"); | |||||
| yishou.setNeedPay(payTotal.toPlainString()); | |||||
| sumlist.add(yishou); | |||||
| WxBillSum owe = new WxBillSum(); | |||||
| owe.setBillName("本期应收"); | |||||
| owe.setNeedPay(payTotal.toPlainString()); | |||||
| sumlist.add(owe); | |||||
| String componentContent = ov.getString("value"); | |||||
| if (null != sumlist && sumlist.size() > 0 ) { | |||||
| ov.put("defaultValue",printCustomedTableDataHandler.getTableContent(componentContent, JSON.parseArray(JSON.toJSONString(sumlist)),JSON.parseObject(JSON.toJSONString(bq)))); | |||||
| ov.put("value", ""); | |||||
| } | |||||
| }else { | |||||
| if (isSetDefaultValue) { | |||||
| ov.put("defaultValue", printMerchantSettleDataHandler.getObjectValue(ov.getString("name"),bq,merchantMap,feesMap)); | |||||
| ov.put("value", ""); | |||||
| }else { | |||||
| ov.put("value", printMerchantSettleDataHandler.getObjectValue(ov.getString("name"),bq,merchantMap,feesMap)); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| vo.setTemplate(o); | |||||
| voList.add(vo); | |||||
| List<WxBillSum> sumlist = new ArrayList<WxBillSum>(); | |||||
| BigDecimal receiveTotal = new BigDecimal(0); | |||||
| BigDecimal payTotal = new BigDecimal(0); | |||||
| BigDecimal oweTotal = new BigDecimal(0); | |||||
| for (int k = 0 ; k< bq.getBillSumList().size() ; k++) { | |||||
| WxBillSum billSum = bq.getBillSumList().get(k); | |||||
| if (feesId.contains(billSum.getEnergyFeesId())) { | |||||
| WxEnergyFees fee = feesMap.get(billSum.getEnergyFeesId()); | |||||
| billSum.setTaxRate(fee.getTaxRate()); | |||||
| sumlist.add(billSum); | |||||
| receiveTotal = receiveTotal.add(billSum.getNeedPayNumber()); | |||||
| payTotal = payTotal.add(billSum.getPaidNumber()); | |||||
| oweTotal = oweTotal.add(billSum.getOweNumber()); | |||||
| } | |||||
| } | |||||
| WxBillSum heji = new WxBillSum(); | |||||
| heji.setBillName("合计"); | |||||
| heji.setNeedPay(receiveTotal.toPlainString()); | |||||
| sumlist.add(heji); | |||||
| WxBillSum yishou = new WxBillSum(); | |||||
| yishou.setBillName("已收"); | |||||
| yishou.setNeedPay(payTotal.toPlainString()); | |||||
| sumlist.add(yishou); | |||||
| WxBillSum owe = new WxBillSum(); | |||||
| owe.setBillName("本期应收"); | |||||
| owe.setNeedPay(payTotal.toPlainString()); | |||||
| sumlist.add(owe); | |||||
| PrintVo vo = handleComponentData(templateId,o,items, printMerchantSettleDataHandler,bq,printMerchantSettleDataHandler, sumlist,merchantMap,feesMap,shopNumber); | |||||
| if (null != vo) { | |||||
| voList.add(vo); | |||||
| } | |||||
| return voList; | return voList; | ||||
| } | } | ||||
| return null; | return null; | ||||