bpo
<input id="uuid" name="uuid" type="hidden"> <div id="bpoPushDataDiv"> <div class="horizon-list" name = "bpoPushDataQuery"> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">付款确认书编号</span> <input type="text" name="payId" class="am-form-field" id="payId" maxlength="40" /> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">保理金额</span> <input type="text" name="accountReceivableOne" class="am-form-field" id="accountReceivableOne" maxlength="30" /> </div> <div class="am-input-group am-input-group-lg separator" style="margin-left:-15px"> <span class="am-input-group-label">--</span> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">至</span> <input type="text" name="accountReceivableTwo" class="am-form-field" id="accountReceivableTwo" maxlength="30" /> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">供应商名称</span> <input type="text" name="suppliersName" class="am-form-field" id="suppliersName" maxlength="255" /> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">项目公司名称</span> <input type="text" name="itemCompany" class="am-form-field" id="itemCompany" maxlength="255" /> </div> </div> <div class="horizon-list" name = "bpoPushDataQuery"> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">核心企业</span> <select id="coreEnterpriseId" name="coreEnterpriseId" data-am-selected> </select> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">金融机构</span> <select id="financialInstitutionsId" name="financialInstitutionsId" data-am-selected> </select> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">签约主体</span> <select id="signBodyId" name="signBodyId" data-am-selected> </select> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">期数</span> <select name="periods" id="periods" data-am-selected> </select> </div> <div class="am-input-group am-input-group-lg"> <span class="am-input-group-label">是否急单</span> <select id="payPriority" name="payPriority" data-am-selected> <option value="">请选择</option> <option value="1">是</option> <option value="0">否</option> </select> </div> <button type="button" id="search" class="am-btn am-btn-primary ">查询</button> </div> <div class="am-g am-cf am-padding"> <div class="c-dt-title am-fl"> <span>付款确认书数据</span> </div> <div id="import_admin_toolbar" class="am-btn-toolbar"> <div class="am-btn-group am-btn-group-xs"> <input type="file" id="importBTN" class="input-file-upload" auto="true" title="导入" /> </div> </div> <div id="downloadTemplate_admin_toolbar" class="am-btn-toolbar"> <div class="am-btn-group am-btn-group-xs"> <button type="button" id="downloadTemplateBTN" class="am-btn am-btn-primary" style="height: 35px;">下载模板</button> </div> </div> <div id="itemCompanyManage_admin_toolbar" class="am-btn-toolbar"> <div class="am-btn-group am-btn-group-xs"> <button type="button" id="pushBPO" class="am-btn am-btn-primary " style="height: 35px;">推送BPO</button> </div> </div> </div> <div id="processStatusMonitor_admin_wrapper" class="dataTables_wrapper am-datatable am-form-inline dt-amazeui"> <div class="am-g"> <div class="am-u-sm-12 am-scrollable-horizontal"> <table class="am-table am-table-striped am-table-bordered am-table-compact dataTable am-table-centered" id="bpoPushData_dt" role="grid" aria-describedby="bpoPushData_dt"> <thead> <tr role="row"> <th class="table-check am-text-nowrap" rowspan="1" style="text-align: center;" colspan="1" width="5%"> <input type="checkbox" name="allCheck" id="allCheck" /> </th> <th class="am-text-nowrap" tabindex="0" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="付款确认书编号: 以升序排列此列">付款确认书编号</th> <th class="am-text-nowrap" tabindex="0" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="核心企业名称: 以升序排列此列">核心企业名称</th> <th class="am-text-nowrap" tabindex="0" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="供应商名称: 以升序排列此列">供应商名称</th> <th class="am-text-nowrap" tabindex="0" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="金融机构: 以升序排列此列">金融机构</th> <th class="am-text-nowrap" tabindex="0" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="签约主体: 以升序排列此列">签约主体</th> <th class="am-text-nowrap" tabindex="0" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="应收账款金额: 以升序排列此列">应收账款金额</th> <th class="am-text-nowrap" tabindex="0" style="text-align: center;" aria-controls="bpoPushData_dt" rowspan="1" colspan="1" aria-label="项目公司名称: 以升序排列此列">项目公司名称</th> <th class="am-text-nowrap" tabindex="0" style="text-align: center;" aria-controls="bpoBackData_dt" rowspan="1" colspan="1" aria-label="是否急单: 以升序排列此列">是否急单</th> <th class="am-text-nowrap" tabindex="0" style="text-align: center;" aria-controls="bpoBackData_dt" rowspan="1" colspan="1" aria-label="期数: 以升序排列此列">期数</th> </tr> </thead> </table> </div> </div> </div> </div> <script type="text/javascript"> //每个模块都应该提供一个init方法用来进行事件注册 function bpoPushData() { }// 定义一个类(函数) //为该类(函数)添加一个静态方法extend bpoPushData.extend = function(obj) { for ( var a in obj) this[a] = obj[a];// 注意:这里的this即bpoPushData } bpoPushData.dt = null; bpoPushData .extend({ init : function() { //父类div $div = $("#bpoPushDataDiv"); var thisClzz = bpoPushData; //查询div 对象 var $query = $("div[name='bpoPushDataQuery']"); //bpoPushData.loadDataTable(); //初始化下拉列表 //核心企业列表 addOption($query.find("#coreEnterpriseId"), "请选择", ""); var response = ajax_jsonp_sync("app/bl/businessInfoManagement/selectInit?type=enterprise"); if (!isNotNull(response) || !checkResponseData(response.responseJSON)) return; $.each(response.responseJSON.data[0], function(index, obj) { //数据绑定 addOption($query.find("#coreEnterpriseId"), obj.name, obj.uuid); }); //金融机构列表 addOption($query.find("#financialInstitutionsId"), "请选择", ""); var response = ajax_jsonp_sync("app/bl/businessInfoManagement/selectInit?type=financial"); if (!isNotNull(response) || !checkResponseData(response.responseJSON)) return; $.each(response.responseJSON.data[0], function(index, obj) { //数据绑定 addOption($query.find("#financialInstitutionsId"), obj.name, obj.uuid); }); //签约主体列表 addOption($query.find("#signBodyId"), "请选择", ""); var response = ajax_jsonp_sync("app/bl/businessInfoManagement/selectInit?type=signing"); if (!isNotNull(response) || !checkResponseData(response.responseJSON)) return; $.each(response.responseJSON.data[0], function(index, obj) { //数据绑定 addOption($query.find("#signBodyId"), obj.name, obj.uuid); }); //期数列表 addOption($query.find("#periods"), "请选择", ""); var response = ajax_jsonp_sync("app/bl/businessInfoManagement/selectInit?type=periods"); if (!isNotNull(response) || !checkResponseData(response.responseJSON)) return; $.each(response.responseJSON.data[0], function(index, obj) { //数据绑定 addOption($query.find("#periods"), obj.name, obj.uuid); }); var isOpenloading = true; //付款确认书 dt columns = autoBuildDtColumns([ "uuid", "payId", "coreEnterpriseName", "suppliersName", "financialInstitutionsName","signBodyName", "accountReceivable", "itemCompanyName", "payPriority","periods"]); thisClzz.dtConfigs = { "retrieve":true, "columns" : columns, "bAutoWidth": false, // "ordering" : false, // "bPaginate" : false, "columnDefs" : [{ "targets" : [0], "render" : function(data, type, full) { return "<input type='checkbox' id='passFlag' name='passFlag' class='dt-input-element dt-select-click checkRows ' " + " data-option='def:0,choosed:1'/>"; }}, { "targets" : [6], "render" : $.fn.dataTable.render.number( ',','.',2) }, { "targets":[8], "render":function(data){ if(data==0)return "否"; if(data==1)return "是"; }}, { "targets":[9], "render":function(data){ if("" == data || null == data){ return ""; }else { return data; } }} ] }; //查询按钮注册单击事件 $div.find("#search").on('click', function(){debugger // 表格已经初始化先销毁表格 if (bpoPushData.dt) { bpoPushData.dt.draw(); $('#bpoPushData_dt').find("#allCheck").attr("checked", false); } var periods = $query.find("#periods option:selected").val(); /* if("" == periods || null == periods){ alertMsg("请选择查询期数!"); return; } */ thisClzz.reloadDataTable(isOpenloading); }); //分配推送按钮注册单击事件 $div.find("#pushBPO").on('click', function(){ var data = getSelectedData(bpoPushData.dt, 0); var uuid = ""; var commitFlag = false; if(null == data || "" == data){ alertMsg("请选择至少一行数据!"); return; }else{ for (var d = 0;d<data.length;d++){ if("" == uuid){ uuid = data[d].uuid; }else{ uuid += ","+data[d].uuid; } } commitFlag = alertMsg("确认选中的付款确认书推送BPO?",'COMFIR'); } if(commitFlag){ //推送前查询该数据是否被领取 openLoading("提交中,请稍候..."); ajax_jsonp("/bpo/public/isReceive", {"uuid":uuid}, function(response) { if (!checkResponseData(response)) { closeLoading(); return; } if("success" == response.data[0]){ alertMsg("推送成功!"); closeLoading(); thisClzz.reloadDataTable(isOpenloading); }else{ alertMsg(response.data[0]); closeLoading(); thisClzz.reloadDataTable(isOpenloading); } },"GET"); } }); //下载模板 $("#downloadTemplate_admin_toolbar").find("#downloadTemplateBTN").on('click', function(){ downloadFile("765cace9561b4e348df484ed83597756"); }); //导入文件处理 init_uploadify($("#import_admin_toolbar").find("#importBTN"),{"reBtnText":"导入"},function(file,data){ //文件名(含后缀) var fileName = file.name; var fileType = fileName.substring(fileName.lastIndexOf(".")+1); //判断文件类型 if(!(fileType == "xlsx")) { getAlertInfo("ME498E011"); return; } var fileUuid = data.data[0]; openLoading("正在加载..."); ajax_jsonp("/bpo/public/payImport/",{"fileUuid":fileUuid}, function(response){ debugger; if (!checkResponseData(response)) {// 判断响应是否正常 // 关闭遮罩 closeLoading(); return; } // 获取导入成功的付款确认书的数据 var isImportData=response.data[0].isImportData; var errFileUuid=response.data[0].errFileUuid if(isNotBlank(isImportData)){ // 如果表格不为空,首先销毁数据 if(isNotNull(bpoPushData.dt)){ //destroy datatable bpoPushData.dt.destroy(); bpoPushData.dt.clear(); // 解除绑定点击事件,防止重复绑定 $("#bpoPushData_dt").unbind("click"); } // 初始化表格 bpoPushData.dt = dtInit("#bpoPushData_dt",null,isImportData, bpoPushData.dtConfigs); // 勾选当前所有的数据 $('#bpoPushData_dt').find("#allCheck").prop("checked", true); $('#bpoPushData_dt').find('.checkRows').attr("checked", true); closeLoading(); if(isNotBlank(errFileUuid)){ downloadFile(errFileUuid); getAlertInfo("BPO01I001"); } }else{ closeLoading(); getAlertInfo("BPO01I002"); } }, null, "POST"); }); // 注册全选按钮点击事件 $('#bpoPushData_dt').find("#allCheck").click(function(){ var checkFlags = $('#bpoPushData_dt').find('input[name=passFlag]'); if (this.checked) { for(var i = 0; i < checkFlags.length; i++){ checkFlags[i].checked = true; } }else{ for(var i = 0; i < checkFlags.length; i++){ checkFlags[i].checked = false; } } }); // 注册checkbox点击事件 $("#bpoPushData_dt").on('draw.dt',function(){ // 初始化时勾选SelectAll,存在未勾选的checkbox,则取消勾选SelectAll var backManageSelectAllbox = $("#bpoPushData_dt").find("input[name=allCheck]"); //注册checkbox点击事件 $("#bpoPushData_dt").find(":checkbox").change(function() { // 设置全选 $("#bpoPushData_dt").find("input[name=allCheck]")[0].checked = true; // 遍历表格,当存在未勾选的checkbox,取消勾选全选 $("#bpoPushData_dt tr:gt(0)").each(function(){ if($(this).find("#passFlag").length == 1){ var checkTest = $(this).find("#passFlag")[0].checked; // 若存在 if(checkTest == false){ backManageSelectAllbox[0].checked = false; return false; } } }); }); }); //init 结束 },getQueryPara : function() { //获取查询条件参数值 var $query = $("div[name='bpoPushDataQuery']"); return { "payId": $query.find("#payId").val(), "accountReceivableOne": $query.find("#accountReceivableOne").val(), "accountReceivableTwo": $query.find("#accountReceivableTwo").val(), "suppliersName": $query.find("#suppliersName").val(), "itemCompany": $query.find("#itemCompany").val(), "coreEnterpriseId": $query.find("#coreEnterpriseId option:selected").val(), "financialInstitutionsId": $query.find("#financialInstitutionsId option:selected").val(), "signBodyId": $query.find("#signBodyId option:selected").val(), "payPriority": $query.find("#payPriority option:selected").val(), "flag":"3", "periods":$query.find("#periods option:selected").val(), "sendBpoFlag":"" } },reloadDataTable:function(isOpenloading){ // 表格已经初始化先销毁表格 if (bpoPushData.dt) { bpoPushData.dt.draw(); bpoPushData.dt.clear(); bpoPushData.dt.destroy(); // 解除绑定点击事件,防止重复绑定 $("#bpoPushData_dt").unbind("click"); } openLoading("正在加载..."); ajax_jsonp("/bpo/public/selectComfirmInfo", bpoPushData.getQueryPara(), function(response) { if (!checkResponseData(response)){ closeLoading(); return; } // 付款确认书信息 var dtData = response.data[0]; // 初始化表格 bpoPushData.dt = dtInit("#bpoPushData_dt",null,dtData, bpoPushData.dtConfigs); closeLoading(); // 注册全选按钮点击事件 $('#bpoPushData_dt').find("#allCheck").click(function(){ var checkFlags = $('#bpoPushData_dt').find('input[name=passFlag]'); if (this.checked) { for(var i = 0; i < checkFlags.length; i++){ checkFlags[i].checked = true; } }else{ for(var i = 0; i < checkFlags.length; i++){ checkFlags[i].checked = false; } } }); // 注册checkbox点击事件 $('#bpoPushData_dt').find('input[name=passFlag]').click( function() { var checkFlags = $('#bpoPushData_dt').find('input[name=passFlag]'); var allCheckbox = $('#bpoPushData_dt').find('input[name=allCheck]'); var allCheck = true; for (var i = 0; i < checkFlags.length; i++) { if (checkFlags[i].checked == false) { allCheck = false; break; } } if (!allCheck) { allCheckbox[0].checked = false; } else { allCheckbox[0].checked = true; } }); }); } })//extend End </script>
/** * 导入推送/撤回的付款确认书 * * @param controller * @return * @throws Exception */ public Map<String,Object> payImport(QhyfController controller,String mark) throws Exception { String fileUuid = controller.getPara("fileUuid"); StringTools.isNotBlank(fileUuid); // 解析文件获取数据 FileInfo fileInfo = this.getFileInfoByUuid(fileUuid); AssertTools.notNull(fileInfo); String excelSheetName = "付款确认书"; // 设置文件解析范围 ImportFilePageInfo paySheet = new ImportFilePageInfo(1, 0, 1); Map<String, ImportFilePageInfo> pageInfos = new HashMap<String, ImportFilePageInfo>(); pageInfos.put(excelSheetName, paySheet); // 获取文件数据 String path = fileInfo.getStorePath(); File tempFile = new File(path); //判断文件是否存在 if(!tempFile.exists()){ //创建文件父目录 tempFile.getParentFile().mkdirs(); //从oss上读取文件 IFileReader AliReader = new AliOssReaderImpl(); Files.createParentDirs(FileUtils.getFile(fileInfo.getStorePath())); AliReader.read(fileInfo, NioUtils.DEFAULT_CHARSETS ,new IInputStreamCallback(){ @Override public void executeInputStream(InputStream inputStream, FileInfo saveFileInfo) throws Exception { // 写入到本地文件 NioUtils.write2file(fileInfo.getStorePath(), inputStream, NioUtils.DEFAULT_CHARSETS); } }); } // 获取文件数据 Map<String, Object> excelMap = this.importFromExcel(fileInfo, pageInfos); AssertTools.hasItem(excelMap); // 获取项目公司数据 List<Map<String, Object>> payIdList = (List<Map<String, Object>>) excelMap.get(excelSheetName); if (payIdList.size() == 0){ String exit = null; AssertUtils.notNull(exit,AlertUtils.getErrMsg("ME498E012")); } // 付款确认书编号 String payID = null; String errorMsg = ""; String msg = ""; boolean errorFlag = false; //创建表头 XSSFWorkbook workbook = new XSSFWorkbook(); String savePath = EnvironmentUtils.me().getEnv().getGeneratePath(); File save = new File(savePath); if (!save.exists()&& !save.isDirectory()) { save.mkdirs(); } String fileName = "《付款确认书错误信息》.xlsx"; savePath = savePath+File.separator + fileName; FileOutputStream fout = new FileOutputStream(savePath); // 创建检测结果sheet XSSFSheet sheet = workbook.createSheet(excelSheetName); sheet.createFreezePane(0, 0, 0, 0); XSSFRow headRow = sheet.createRow(0); String[] headArr = { "付款确认书编号",""}; // 单元格 XSSFCell headCell = null; XSSFCellStyle style = workbook.createCellStyle(); // 表头样式设置 style.setBorderBottom(XSSFCellStyle.BORDER_THIN); style.setBorderLeft(XSSFCellStyle.BORDER_THIN); style.setBorderTop(XSSFCellStyle.BORDER_THIN); style.setBorderRight(XSSFCellStyle.BORDER_THIN); // 设置背景色 style.setFillForegroundColor(new XSSFColor(new Color(156, 195, 230))); style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); sheet.setColumnWidth(0, 20 * 256); sheet.setColumnWidth(1, 20 * 256); // 写入表头 for (int i = 0; i < headArr.length; i++) { sheet.autoSizeColumn(i); headCell = headRow.createCell(i); headCell.setCellValue(headArr[i]); headCell.setCellStyle(style); } //设置单元格样式 XSSFCellStyle cellStyle = workbook.createCellStyle(); //边框 cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN); cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN); cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN); //内容换行 cellStyle.setWrapText(true); //垂直居中 cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER); int rowNum = 1; int num = 0; //存放付款确认书信息 List<Record> rdList = new ArrayList<Record>(); List<Record> recordList = new ArrayList<>(); //返回界面的参数 Map<String,Object> map=new HashMap<>(); for (Map<String, Object> payIdData : payIdList) { // 如果第一列和第二例都为空 if (payIdData.get("c0") == null){ //付款确认书编号为空则不过任何处理 num=num+1; if (num == 199){ String exit = null; //不允许导入空表! AssertUtils.notNull(exit,AlertUtils.getErrMsg("ME498E012")); } continue; }else { if (payIdData.get("c0") != null) { // 付款确认书编号不为空 payID = this.replaceBlank(payIdData.get("c0").toString()); if (!StringUtils.notBlank(payID)) { // 付款确认书编号不为空字符串 msg = "付款确认书编号不能为空字符串;"; errorMsg = errorMsg+msg; } } else { // 付款确认书编号为空 msg = "付款确认书编号不能为空;"; errorMsg = errorMsg+msg; } } // 判断付款确认书编号是否存在 if (StringUtils.notBlank(payID)) { boolean flag = this.payIdIsExist(payID); if (!flag) { // 付款确认书编号不存在 msg = "付款确认书编号不存在;"; errorMsg = errorMsg + msg; } else { // 推送BPO if ("push".equals(mark)) { // 查询当前这笔付款确认书的数据信息 recordList = selectComfirmInfo(controller, "pushData", payID); // 获取第一条数据且只有一条数据,放入变量中 if (!recordList.isEmpty()) { rdList.add(recordList.get(0)); } else { // 为空,该付款确认书编号有问题,展示错误文件里面 errorMsg = "该付款确认书编号查询不到数据,请核实!;"; } } else if ("recall".equals(mark)) { // 撤回BPO // 查询当前这笔付款确认书的数据信息 recordList = selectComfirmInfo(controller, "recallData", payID); // 获取第一条数据且只有一条数据,放入变量中 if (!recordList.isEmpty()) { rdList.add(recordList.get(0)); } else { // 为空,该付款确认书编号有问题,展示错误文件里面 errorMsg = "该付款确认书编号查询不到数据,请核实!;"; } } } } if (StringUtils.notBlank(errorMsg)) { // 存在错误信息 errorFlag = true; // 创建第几行,如rowNum=1,创建第一行 XSSFRow row = sheet.createRow(rowNum); // 设置有几排,这里是2排 XSSFCell[] cellErr = new XSSFCell[2]; //循环每排写入的数据,i是从0开始算的 for (int i = 0; i < 2; i++) { cellErr[i] = row.createCell(i); // 当为第二列的时候,写入错误信息 if (i == 1) { cellErr[i].setCellValue(errorMsg); } else { if (payIdData.get("c" + (i)) == null) { cellErr[i].setCellValue(""); } else { cellErr[i].setCellValue(payIdData.get("c" + (i)).toString()); } } // 设置样式 cellErr[i].setCellStyle(cellStyle); } rowNum++; errorMsg = ""; } }
//去重
LinkedHashSet<Record> set = new LinkedHashSet<Record>(rdList.size());//这个集合去重
set.addAll(rdList);
rdList.clear();
rdList.addAll(set); //存放付款确认书信息 if (rdList.size()>0) { map.put("isImportData", rdList); } try { if (errorFlag) { workbook.write(fout); fout.close(); // 保存文件信息到文件表 String errFileUuid = StringUtils.randomUuid(); File file = new File(savePath); FileInfo savefileInfo = new FileInfo(); savefileInfo.setFile(file); savefileInfo.setOriginalFileName(fileName); SysFile saveFile = SysFileUtils.fileInfo2SysFile(savefileInfo, null); saveFile.set("uuid", errFileUuid); boolean isTrue = saveFile.save(); if (isTrue) { // 保存成功 // 文件上传云端 FileInfo UpFileInfo = this.getFileInfoByUuid(errFileUuid); this.upload2cloud(UpFileInfo, true); // 存放错误文件的uuid map.put("errFileUuid", errFileUuid); return map; } else { map.put("errFileUuid", ""); return map; } } } catch (IOException e) { e.printStackTrace(); } return map; } /** * 去掉字符串中的空格、回车、换行符、制表符 * * @param str * 字符串 * @return 去除后的字符串 * @throws Exception */ private String replaceBlank(String str) throws Exception { // 替换字符串中的空格、回车、换行符、制表符 str = str.replaceAll("\\s*|\t|\r|\n", ""); return str; } /** * 判断付款确认书是否存在 * @param payId * @return * @throws ActiveRecordException */ private boolean payIdIsExist(String payId) throws ActiveRecordException{ String sql = "SELECT count(1) AS count FROM biz_pay_comfirm_info WHERE sys_status = 1 and pay_id = ?"; Record record = Db.findFirst(sql,payId); if (record.getLong("count")>0) { return true; } return false; }