| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390 |
- package restcontroller.sale.cashbill;
- import beans.clear.ClearData;
- import beans.data.BatchDeleteErr;
- import beans.datacontrllog.DataContrlLog;
- import beans.datateam.DataTeam;
- import beans.remind.Remind;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import common.Controller;
- import common.YosException;
- import common.annotation.*;
- import common.data.*;
- import common.data.Row;
- import org.apache.commons.lang.StringUtils;
- import org.apache.poi.ss.usermodel.*;
- import org.apache.poi.xssf.usermodel.*;
- import restcontroller.R;
- import restcontroller.system.attachment.Attachment;
- import java.io.IOException;
- import java.math.BigDecimal;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import static beans.order.Order.getOrderRows;
- import static restcontroller.webmanage.saletool.orderclue.orderclue.isBigDecimal;
- public class cashbill extends Controller {
- public cashbill(JSONObject arg0) throws YosException {
- super(arg0);
- // TODO Auto-generated constructor stub
- }
- /**
- * 下载凭证导入单模板
- *
- * @return
- */
- @API(title = "下载凭证导入单模板", apiversion = R.ID20230506162603.v1.class)
- public String downloadCashbillExcel() throws YosException {
- ExcelFactory excelFactory = new ExcelFactory("ImportTemplateForCashbill");
- XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet("Sheet1");
- XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
- CellStyle style = xssfFWorkbook.createCellStyle();
- // 设置为文本格式,防止身份证号变成科学计数法
- DataFormat format = xssfFWorkbook.createDataFormat();
- style.setDataFormat(format.getFormat("@"));
- // 对单独某一列进行样式赋值,第一个参数为列数,第二个参数为样式
- for (int i = 0; i <= 10; i++) {
- sheet.setDefaultColumnStyle(i, style);
- }
- if (content.getString("type").equals("收入")) {
- IncomeExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
- XSSFCellStyle titleCellStyle1 = IncomeExportExcel.createTitleCellStyle1(xssfFWorkbook);
- XSSFCellStyle titleCellStyle2 = IncomeExportExcel.createTitleCellStyle2(xssfFWorkbook);
- XSSFCellStyle titleCellStyle3 = IncomeExportExcel.createBodyCellStyle(xssfFWorkbook);
- XSSFCellStyle titleCellStyle4 = IncomeExportExcel.createTitleCellStyle3(xssfFWorkbook);
- IncomeExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
- xssfFWorkbook);// 写入标题
- } else if (content.getString("type").equals("支出")) {
- PayExportExcel.setBatchDetailSheetColumn1(sheet);// 设置工作薄列宽
- XSSFCellStyle titleCellStyle1 = PayExportExcel.createTitleCellStyle1(xssfFWorkbook);
- XSSFCellStyle titleCellStyle2 = PayExportExcel.createTitleCellStyle2(xssfFWorkbook);
- XSSFCellStyle titleCellStyle3 = PayExportExcel.createBodyCellStyle(xssfFWorkbook);
- XSSFCellStyle titleCellStyle4 = PayExportExcel.createTitleCellStyle3(xssfFWorkbook);
- PayExportExcel.batchDetail(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, titleCellStyle4,
- xssfFWorkbook);// 写入标题
- } else {
- return getErrReturnObject().setErrMsg("凭证类型不匹配,无法下载导入文件").toString();
- }
- Rows aa = uploadExcelToObs(excelFactory);
- String url = "";
- if (!aa.isEmpty()) {
- url = aa.get(0).getString("url");
- }
- return getSucReturnObject().setData(url).toString();
- }
- /**
- * 导入凭证
- *
- * @return
- */
- @API(title = "导入凭证", apiversion = R.ID20230506162703.v1.class)
- @CACHEING_CLEAN(apiClass = cashbill.class)
- public String uploadCashbillByExcel() throws YosException {
- ExcelFactory e;
- try {
- // 华为云
- e = getPostExcelFactory(content.getLong("attachmentid"));
- // 本地
- //e = getPostExcelFactory();
- // Rows keyRow = dbConnect.runSqlQuery("select fagentnum,faddress from tagents
- // where 1=2");
- // Rows row1 = e.getSheetRows(1, keyRow, 1);
- ArrayList<String> keys = new ArrayList<>();
- ArrayList<String> sqllist = new ArrayList<>();
- keys.add("agentnum");
- keys.add("accountname");
- keys.add("amount");
- keys.add("type");
- keys.add("typemx");
- keys.add("period");
- keys.add("remarks");
- Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid,accountname from sa_accountclass where siteid='" + siteid + "' and isused=1");
- RowsMap accountclassRowsMap = accountclassRows.toRowsMap("accountname");
- Rows agentRows = dbConnect.runSqlQuery("select agentnum,sys_enterpriseid from sa_agents where siteid='" + siteid + "'");
- RowsMap agentRowsMap = agentRows.toRowsMap("agentnum");
- if (!(content.getString("type") + "凭证导入")
- .equals(((String) getCellFormatValue(e.getSheet(0).getRow(0).getCell(0))).replace(" ", ""))) {
- return getErrReturnObject().setErrMsg("导入失败,不符合" + content.getString("type") + "凭证导入要求").toString();
- }
- Rows rows = e.getSheetRows(0, keys, 3);
- int a = 1;
- int i = 0;
- // String msg = "";
- boolean iserr = false;
- Rows rowserr = new Rows();
- Rows rowssuc = new Rows();
- for (Row row : rows) {
- String msg = "";
- if (StringUtils.isEmpty(row.getString("agentnum"))) {
- iserr = true;
- msg = msg + "【经销商编码为空】";
- }
- if (StringUtils.isEmpty(row.getString("accountname"))) {
- iserr = true;
- msg = msg + "【账户名称为空】";
- }
- if (!isValidFormat(row.getString("period"))) {
- iserr = true;
- msg = msg + "【归属日期格式错误】";
- }
- if (!isBigDecimal(row.getString("amount"))) {
- iserr = true;
- msg = msg + "【金额错误:" + row.getString("amount") + "】";
- }
- if (StringUtils.isEmpty(row.getString("type"))) {
- iserr = true;
- msg = msg + "【分类为空】";
- }
- if (!agentRowsMap.containsKey(row.getString("agentnum"))) {
- iserr = true;
- msg = msg + "【该经销商编码找不到匹配的经销商】";
- } else {
- if (agentRowsMap.get(row.getString("agentnum")).isEmpty()) {
- iserr = true;
- msg = msg + "【该经销商编码找不到匹配的经销商】";
- }
- }
- if (!accountclassRowsMap.containsKey(row.getString("accountname"))) {
- iserr = true;
- msg = msg + "【该账户名称找不到匹配的账户】";
- } else {
- if (accountclassRowsMap.get(row.getString("accountname")).isEmpty()) {
- iserr = true;
- msg = msg + "【该账户名称找不到匹配的账户】";
- }
- }
- if (iserr) {
- row.put("msg", "错误信息:" + msg);
- rowserr.add(row);
- } else {
- rowssuc.add(row);
- }
- // if (!msg.equals("111")) {
- // XSSFWorkbook xssfFWorkbook = e.getXssfWorkbook();
- // XSSFCellStyle cellStyle = xssfFWorkbook.createCellStyle();
- //
- // XSSFFont font = xssfFWorkbook.createFont();
- //
- // font.setColor((short) 0xa);
- // font.setFontHeightInPoints((short) 8);
- // font.setBold(true);
- // cellStyle.setFont(font);
- // datarow.createCell(8).setCellValue("错误信息:" + msg);
- // datarow.getCell(8).setCellStyle(cellStyle);
- //
- // }
- }
- long[] sa_cashbillid = createTableID("sa_cashbill",
- rowssuc.size());
- if (!rowssuc.isEmpty()) {
- for (Row row : rowssuc) {
- SQLFactory sqlFactoryupload = new SQLFactory(this, "收支凭证新增");
- sqlFactoryupload.addParameter("sa_cashbillid", sa_cashbillid[i]);
- sqlFactoryupload.addParameter("billno", createBillCode("cashbill"));
- if (agentRowsMap.containsKey(row.getString("agentnum"))) {
- sqlFactoryupload.addParameter("sys_enterpriseid", agentRowsMap.get(row.getString("agentnum")).get(0).getLong("sys_enterpriseid"));
- } else {
- continue;
- }
- if (accountclassRowsMap.containsKey(row.getString("accountname"))) {
- sqlFactoryupload.addParameter("sa_accountclassid", accountclassRowsMap.get(row.getString("accountname")).get(0).getLong("sa_accountclassid"));
- } else {
- continue;
- }
- if (content.getString("type").equals("收入")) {
- sqlFactoryupload.addParameter("type", 1);
- } else {
- sqlFactoryupload.addParameter("type", 0);
- }
- sqlFactoryupload.addParameter("siteid", siteid);
- sqlFactoryupload.addParameter("remarks", row.getString("remarks"));
- sqlFactoryupload.addParameter("amount", row.getDouble("amount"));
- sqlFactoryupload.addParameter("subclass", row.getString("typemx"));
- sqlFactoryupload.addParameter("class", row.getString("type"));
- sqlFactoryupload.addParameter("userid", userid);
- sqlFactoryupload.addParameter("username", username);
- sqlFactoryupload.addParameter("ownertable", "");
- sqlFactoryupload.addParameter("ownerid", 0);
- sqlFactoryupload.addParameter("source", "");
- sqlFactoryupload.addParameter("sourcenote", "");
- sqlFactoryupload.addParameter("discountamount", 0);
- if (StringUtils.isBlank(row.getString("period"))) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- sqlFactoryupload.addParameter("period", sdf.format(new Date()));
- } else {
- sqlFactoryupload.addParameter("period", row.getString("period"));
- }
- sqllist.add(sqlFactoryupload.getSQL());
- i++;
- }
- }
- //System.out.println(sqllist.size());
- dbConnect.runSqlUpdate(sqllist);
- if (iserr) {
- ExcelFactory excelFactory = new ExcelFactory("sa_cashbillerr");
- HashMap<String, String> map = new HashMap<String, String>();
- map.put("agentnum", "经销商编码");
- map.put("accountname", "账户名称");
- map.put("amount", "金额");
- map.put("type", "分类");
- map.put("typemx", "分类明细");
- map.put("period", "归属日期");
- map.put("remarks", "备注");
- map.put("msg", "错误信息");
- ArrayList<String> colNameList = new ArrayList<String>();
- HashMap<String, Class> keytypemap = new HashMap<String, Class>();
- colNameList.add("agentnum");
- colNameList.add("accountname");
- colNameList.add("amount");
- colNameList.add("type");
- colNameList.add("typemx");
- colNameList.add("period");
- colNameList.add("remarks");
- colNameList.add("msg");
- keytypemap.put("agentnum", String.class);
- keytypemap.put("accountname", String.class);
- keytypemap.put("amount", String.class);
- keytypemap.put("type", String.class);
- keytypemap.put("typemx", String.class);
- keytypemap.put("period", String.class);
- keytypemap.put("remarks", String.class);
- keytypemap.put("msg", String.class);
- rowserr.setFieldList(colNameList);
- rowserr.setFieldTypeMap(keytypemap);
- if (content.getString("type").equals("收入")) {
- addSheetIncome(excelFactory, "Sheet1", rowserr, map);
- } else {
- addSheetPay(excelFactory, "Sheet1", rowserr, map);
- }
- Rows aa = uploadExcelToObs(excelFactory);
- String url = "";
- if (!aa.isEmpty()) {
- url = aa.get(0).getString("url");
- }
- return getSucReturnObject().setData(url).toString();
- }
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- return getErrReturnObject().setErrMsg(e1.getMessage()).toString();
- }
- return getSucReturnObject().toString();
- }
- @API(title = "收支凭证新建更新", apiversion = R.ID20221009102803.v1.class, intervaltime = 200)
- @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})
- public String insertormodify_creditbill() throws YosException {
- Long sa_cashbillid = content.getLong("sa_cashbillid");
- Long type = content.getLong("type"); //收支类型(1:收;0:支)
- Long sys_enterpriseid = content.getLong("sys_enterpriseid");
- Long sa_accountclassid = content.getLong("sa_accountclassid");
- String billcode = createBillCode("cashbill");
- String subclass = content.getStringValue("subclass");
- String class1 = content.getStringValue("class");
- String period = content.getStringValue("period");
- if (StringUtils.isEmpty(period)) {
- if (type == 1) {
- return getErrReturnObject().setErrMsg("未填写归属日期").toString();
- } else if (type == 0 && subclass.equals("拨款")) {
- period = getDate_Str();
- }
- }
- BigDecimal amount = content.getBigDecimal("amount");
- BigDecimal discountamount = content.getBigDecimal("discountamount");
- String remarks = content.getString("remarks");
- ArrayList<String> sqlList = new ArrayList<>();
- if (sa_cashbillid <= 0 || dbConnect
- .runSqlQuery("select sa_cashbillid from sa_cashbill where sa_cashbillid="
- + sa_cashbillid)
- .isEmpty()) {
- if (sa_cashbillid <= 0) {
- sa_cashbillid = createTableID("sa_cashbill");
- }
- SQLFactory sqlFactory = new SQLFactory(this, "收支凭证新增");
- sqlFactory.addParameter("billno", billcode);
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
- sqlFactory.addParameter("type", type);
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("remarks", remarks);
- sqlFactory.addParameter("amount", amount);
- sqlFactory.addParameter("subclass", subclass);
- sqlFactory.addParameter("class", class1);
- sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
- sqlFactory.addParameter("userid", userid);
- sqlFactory.addParameter("username", username);
- sqlFactory.addParameter("ownertable", "");
- sqlFactory.addParameter("ownerid", 0);
- sqlFactory.addParameter("source", "");
- sqlFactory.addParameter("sourcenote", "");
- sqlFactory.addParameter("period", period);
- sqlFactory.addParameter("discountamount", discountamount);
- content.put("sa_cashbillid", sa_cashbillid);
- sqlList.add(sqlFactory.getSQL());
- if (type == 1) {
- sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "新增", "收入凭证新增成功").getSQL());
- } else {
- sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "新增", "支出凭证新增成功").getSQL());
- }
- } else {
- Rows rowscount = dbConnect.runSqlQuery(
- "select status from sa_cashbill where sa_cashbillid=" + sa_cashbillid);
- if (rowscount.isNotEmpty()) {
- if (!rowscount.get(0).getString("status").equals("新建")) {
- return getErrReturnObject().setErrMsg("非新建状态的收支凭证无法更新").toString();
- }
- }
- SQLFactory sqlFactory = new SQLFactory(this, "收支凭证更新");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("remarks", remarks);
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
- sqlFactory.addParameter("amount", amount);
- sqlFactory.addParameter("subclass", subclass);
- sqlFactory.addParameter("class", class1);
- sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
- sqlFactory.addParameter("userid", userid);
- sqlFactory.addParameter("username", username);
- sqlFactory.addParameter("source", "");
- sqlFactory.addParameter("sourcenote", "");
- sqlFactory.addParameter("period", period);
- sqlFactory.addParameter("discountamount", discountamount);
- sqlList.add(sqlFactory.getSQL());
- sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "更新", "收支凭证更新成功").getSQL());
- }
- dbConnect.runSqlUpdate(sqlList);
- return queryCashbillMain();
- }
- // @API(title = "合作企业档案列表",apiversion = R.ID20221008164103.v1.class)
- // @CACHEING
- // public String queryEnterpriseList() throws YosException {
- //
- // /*
- // * 过滤条件设置
- // */
- // String where = " 1=1 ";
- // if (content.containsKey("where")) {
- // JSONObject whereObject = content.getJSONObject("where");
- // if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- // where = where + " and(t1.enterprisename like'%" + whereObject.getString("condition")
- // + "%' or t1.phonenumber like '%" + whereObject.getString("condition") + "%')";
- // }
- // }
- // SQLFactory sqlFactory = new SQLFactory(this, "合作企业档案列表查询", pageSize, pageNumber, pageSorting);
- // sqlFactory.addParameter_SQL("where", where);
- // sqlFactory.addParameter("siteid", siteid);
- // Rows rows = dbConnect.runSqlQuery(sqlFactory);
- // return getSucReturnObject().setData(rows).toString();
- // }
- //
- // @API(title = "营销账户类别列表",apiversion = R.ID20221008164203.v1.class)
- // @CACHEING
- // public String queryAccountclassList() throws YosException {
- // long sys_enterpriseid=content.getLong("sys_enterpriseid");
- //
- // SQLFactory sqlFactory = new SQLFactory(this, "营销账户类别列表查询");
- // sqlFactory.addParameter("siteid", siteid);
- // sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- // Rows rows = dbConnect.runSqlQuery(sqlFactory);
- // return getSucReturnObject().setData(rows).toString();
- // }
- @API(title = "更新收支凭证明细分类", apiversion = R.ID20231205134103.v1.class)
- public String updateTypemx() throws YosException {
- Long sa_cashbillid = content.getLong("sa_cashbillid");
- String subclass = content.getStringValue("subclass");
- String class1 = content.getStringValue("class");
- Rows cashbillRows = dbConnect.runSqlQuery("select * from sa_cashbill where siteid='" + siteid + "' and sa_cashbillid=" + sa_cashbillid);
- if (cashbillRows.isEmpty()) {
- return getErrReturnObject().setErrMsg("收支凭证不存在").toString();
- }
- dbConnect.runSqlUpdate("update sa_cashbill set subclass='" + subclass + "',class='" + class1 + "' where sa_cashbillid=" + sa_cashbillid);
- return queryCashbillMain();
- }
- @API(title = "收入凭证列表", apiversion = R.ID20221009102903.v1.class)
- @CACHEING
- public String queryIncomeCashbillList() throws YosException, IOException {
- /*
- * 过滤条件设置
- */
- boolean isExport = content.getBooleanValue("isExport");
- String where = " 1=1 and t1.type=1 ";
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("condition")
- + "%' or t3.accountname like '%" + whereObject.getString("condition") + "%'"
- + " or t2.abbreviation like '%" + whereObject.getString("condition") + "%'"
- + " or t1.billno like '%" + whereObject.getString("condition") + "%'"
- + " or t1.remarks like '%" + whereObject.getString("condition") + "%'"
- + " or t4.agentnum like '%" + whereObject.getString("condition") + "%'"
- + " or t1.class like '%" + whereObject.getString("condition") + "%'"
- + " or t1.subclass like '%" + whereObject.getString("condition") + "%'"
- + " or t1.amount like '%" + whereObject.getString("condition") + "%'"
- + ")";
- }
- if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
- where = where + " and t1.status ='" + whereObject.getString("status") + "' ";
- }
- if (whereObject.containsKey("accountname") && !"".equals(whereObject.getString("accountname"))) {
- where = where + " and t3.accountname ='" + whereObject.getString("accountname") + "' ";
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where = where + " and DATE_FORMAT(t1.createdate, '%Y-%m-%d') >='" + whereObject.getString("begindate") + "'";
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where = where + " and DATE_FORMAT(t1.createdate, '%Y-%m-%d') <='" + whereObject.getString("enddate") + "'";
- }
- if (whereObject.containsKey("beginperiod") && !"".equals(whereObject.getString("beginperiod"))) {
- where = where + " and t1.period >='" + whereObject.getString("beginperiod") + "' ";
- }
- if (whereObject.containsKey("endperiod") && !"".equals(whereObject.getString("endperiod"))) {
- where = where + " and t1.period <='" + whereObject.getString("endperiod") + "' ";
- }
- if (whereObject.containsKey("billno") && !"".equals(whereObject.getString("billno"))) {
- where = where + " and t1.billno ='" + whereObject.getString("billno") + "'";
- }
- if (whereObject.containsKey("isrebate") && !"".equals(whereObject.getString("isrebate"))) {
- where = where + " and ifnull(t3.isrebate,0) ='" + whereObject.getLongValue("isrebate") + "'";
- }
- if (whereObject.containsKey("remarks") && !"".equals(whereObject.getString("remarks"))) {
- where = where + " and t1.remarks like'%" + whereObject.getString("remarks") + "%' ";
- }
- if (whereObject.containsKey("period") && !"".equals(whereObject.getString("period"))) {
- where = where + " and t1.period like'%" + whereObject.getString("period") + "%' ";
- }
- if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'"
- + " or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'"
- + ")";
- }
- }
- // if (pageSorting.equals("''")) {
- // pageSorting = "status desc, period desc";
- // }
- QuerySQL querySQL = queryList(where);
- querySQL.setOrderBy(pageSorting);
- // if (!isExport) {
- querySQL.setPage(pageSize, pageNumber);
- // }
- Rows rows = querySQL.query();
- SQLFactory areasqlFactory = new SQLFactory(this, "收支凭证关联区域列表查询");
- areasqlFactory.addParameter("siteid", siteid);
- areasqlFactory.addParameter_in("sys_enterpriseids", rows.toArrayList("sys_enterpriseid", new ArrayList<>()));
- Rows areaRows = dbConnect.runSqlQuery(areasqlFactory);
- RowsMap areaRowsMap = areaRows.toRowsMap("sys_enterpriseid");
- ArrayList sa_cashbillids = rows.toArrayList("sa_cashbillid", new ArrayList<>());
- sa_cashbillids.add(0L);
- String sql = "select t1.sa_cashbillid,t2.billno from sa_cashbill t1 inner join sa_cashbill t2 on t1.siteid=t2.siteid and t1.ownerid=t2.sa_cashbillid and t1.ownertable='sa_cashbill' where t1.siteid='" + siteid + "' and t1.ownerid in " + sa_cashbillids;
- sql = sql.replace("[", "(").replace("]", ")");
- RowsMap offsettingRowsMap = dbConnect.runSqlQuery(sql).toRowsMap("sa_cashbillid");
- for (Row row : rows) {
- if (row.getString("ownertable").equals("sa_cashbill") && offsettingRowsMap.containsKey(row.getString("sa_cashbillid"))) {
- row.put("offsettingbillno", offsettingRowsMap.get(row.getString("sa_cashbillid")).get(0).getString("billno"));
- }
- row.put("amount", row.getBigDecimal("amount"));
- if (areaRowsMap.containsKey(row.getString("sys_enterpriseid"))) {
- row.put("areaname", areaRowsMap.get(row.getString("sys_enterpriseid")).get(0).getString("areaname"));
- } else {
- row.put("areaname", "");
- }
- }
- // if (isExport) {
- // //去除不需要导出项
- // rows.getFieldList().remove("sa_accountclassid");
- // rows.getFieldList().remove("period");
- // rows.getFieldList().remove("sys_enterpriseid");
- // rows.getFieldList().remove("abbreviation");
- // rows.getFieldList().remove("enterprisename");
- // rows.getFieldList().remove("sa_accountclassid");
- // rows.getFieldList().remove("status");
- // rows.getFieldList().remove("sourcenote");
- // rows.getFieldList().remove("ownertable");
- // rows.getFieldList().remove("ownerid");
- // rows.getFieldList().remove("createuserid");
- // rows.getFieldList().remove("createby");
- // rows.getFieldList().remove("createdate");
- // rows.getFieldList().remove("changeuserid");
- // rows.getFieldList().remove("changeby");
- // rows.getFieldList().remove("changedate");
- // rows.getFieldList().remove("subclass");
- // rows.getFieldList().remove("class");
- // rows.getFieldList().remove("unwriteoffamount");
- // rows.getFieldList().remove("offsettingbillno");
- //
- // Rows uploadRows = uploadExcelToObs("cashBill", "收入凭证列表", rows, getTitleMap());
- // return getSucReturnObject().setData(uploadRows).toString();
- // }
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "支出收入凭证列表", apiversion = R.ID20221010102903.v1.class)
- @CACHEING
- public String queryPayCashbillList() throws YosException, IOException {
- /*
- * 过滤条件设置
- */
- boolean isExport = content.getBooleanValue("isExport");
- String where = " 1=1 and t1.type=0 ";
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("condition")
- + "%' or t3.accountname like '%" + whereObject.getString("condition") + "%'"
- + " or t2.abbreviation like '%" + whereObject.getString("condition") + "%'"
- + " or t1.billno like '%" + whereObject.getString("condition") + "%'"
- + " or t4.agentnum like '%" + whereObject.getString("condition") + "%'"
- + " or t1.remarks like '%" + whereObject.getString("condition") + "%'"
- + " or t1.class like '%" + whereObject.getString("condition") + "%'"
- + " or t1.subclass like '%" + whereObject.getString("condition") + "%'"
- + " or t1.amount like '%" + whereObject.getString("condition") + "%'"
- + ")";
- }
- if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
- where = where + " and t1.status ='" + whereObject.getString("status") + "' ";
- }
- if (whereObject.containsKey("accountname") && !"".equals(whereObject.getString("accountname"))) {
- where = where + " and t3.accountname ='" + whereObject.getString("accountname") + "' ";
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where = where + " and DATE_FORMAT(t1.createdate, '%Y-%m-%d') >='" + whereObject.getString("begindate") + "'";
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where = where + " and DATE_FORMAT(t1.createdate, '%Y-%m-%d') <='" + whereObject.getString("enddate") + "'";
- }
- if (whereObject.containsKey("beginperiod") && !"".equals(whereObject.getString("beginperiod"))) {
- where = where + " and t1.period >='" + whereObject.getString("beginperiod") + "' ";
- }
- if (whereObject.containsKey("endperiod") && !"".equals(whereObject.getString("endperiod"))) {
- where = where + " and t1.period <='" + whereObject.getString("endperiod") + "' ";
- }
- if (whereObject.containsKey("billno") && !"".equals(whereObject.getString("billno"))) {
- where = where + " and t1.billno ='" + whereObject.getString("billno") + "'";
- }
- if (whereObject.containsKey("isrebate") && !"".equals(whereObject.getString("isrebate"))) {
- where = where + " and ifnull(t3.isrebate,0) ='" + whereObject.getLongValue("isrebate") + "'";
- }
- if (whereObject.containsKey("remarks") && !"".equals(whereObject.getString("remarks"))) {
- where = where + " and t1.remarks like'%" + whereObject.getString("remarks") + "%' ";
- }
- if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
- where = where + " and(t2.enterprisename like'%" + whereObject.getString("agentinfo") + "%'"
- + " or t4.agentnum like '%" + whereObject.getString("agentinfo") + "%'"
- + ")";
- }
- }
- if (pageSorting.equals("''")) {
- pageSorting = "status desc, createdate desc";
- }
- QuerySQL querySQL = queryList(where);
- querySQL.setOrderBy(pageSorting);
- querySQL.setPage(pageSize, pageNumber);
- Rows rows = querySQL.query();
- SQLFactory areasqlFactory = new SQLFactory(this, "收支凭证关联区域列表查询");
- areasqlFactory.addParameter("siteid", siteid);
- areasqlFactory.addParameter_in("sys_enterpriseids", rows.toArrayList("sys_enterpriseid", new ArrayList<>()));
- Rows areaRows = dbConnect.runSqlQuery(areasqlFactory);
- RowsMap areaRowsMap = areaRows.toRowsMap("sys_enterpriseid");
- for (Row row : rows) {
- row.put("amount", row.getBigDecimal("amount"));
- if (areaRowsMap.containsKey(row.getString("sys_enterpriseid"))) {
- row.put("areaname", areaRowsMap.get(row.getString("sys_enterpriseid")).get(0).getString("areaname"));
- } else {
- row.put("areaname", "");
- }
- }
- // if (isExport) {
- // //去除不需要导出项
- // rows.getFieldList().remove("sa_accountclassid");
- // rows.getFieldList().remove("period");
- // rows.getFieldList().remove("sys_enterpriseid");
- // rows.getFieldList().remove("abbreviation");
- // rows.getFieldList().remove("enterprisename");
- // rows.getFieldList().remove("sa_accountclassid");
- // rows.getFieldList().remove("status");
- // rows.getFieldList().remove("sourcenote");
- // rows.getFieldList().remove("ownertable");
- // rows.getFieldList().remove("ownerid");
- // rows.getFieldList().remove("createuserid");
- // rows.getFieldList().remove("createby");
- // rows.getFieldList().remove("createdate");
- // rows.getFieldList().remove("changeuserid");
- // rows.getFieldList().remove("changeby");
- // rows.getFieldList().remove("changedate");
- // rows.getFieldList().remove("subclass");
- // rows.getFieldList().remove("class");
- // rows.getFieldList().remove("unwriteoffamount");
- // rows.getFieldList().remove("offsettingbillno");
- //
- // Rows uploadRows = uploadExcelToObs("cashBill", "支出凭证列表", rows, getTitleMap());
- // return getSucReturnObject().setData(uploadRows).toString();
- // }
- return getSucReturnObject().setData(rows).toString();
- }
- public QuerySQL queryList(String where) throws YosException {
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill","*");
- querySQL.setTableAlias("t1");
- querySQL.addQueryFields("unwriteoffamount", "t1.amount - t1.writeoffamount");
- querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.sys_enterpriseid = t2.sys_enterpriseid and t1.siteid = t2.siteid",
- "enterprisename", "abbreviation", "sys_enterpriseid");
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t4.sys_enterpriseid = t2.sys_enterpriseid and t4.siteid = t2.siteid",
- "agentnum");
- querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t3", "t1.sa_accountclassid = t3.sa_accountclassid and t1.siteid = t3.siteid and t3.isused = 1",
- "accountno", "accountname");
- querySQL.addJoinTable(JOINTYPE.left, "sa_cashbill", "t5", "t1.siteid = t5.siteid and t5.ownerid = t1.sa_cashbillid and t5.ownertable = 'sa_cashbill'");
- querySQL.addQueryFields("offsettingbillno", "t5.billno");
- querySQL.setWhere(where);
- querySQL.setWhere("t1.siteid", siteid);
- return querySQL;
- }
- @API(title = "收支凭证详情", apiversion = R.ID20221009103003.v1.class)
- public String queryCashbillMain() throws YosException {
- Long sa_cashbillid = content.getLong("sa_cashbillid");
- SQLFactory sqlFactory = new SQLFactory(this, "收支凭证详情查询");
- sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory);
- if (rows.size() > 0) {
- Rows offsetting = dbConnect.runSqlQuery("select billno from sa_cashbill where siteid='" + siteid + "' and '" + rows.get(0).getString("ownertable") + "'='sa_cashbill' and sa_cashbillid=" + rows.get(0).getLong("ownerid"));
- if (offsetting.isNotEmpty()) {
- rows.get(0).put("offsettingbillno", offsetting.get(0).getString("billno"));
- }
- rows.get(0).put("amount", rows.get(0).getBigDecimal("amount"));
- }
- return getSucReturnObject().setData(rows.size() > 0 ? rows.get(0) : new Row()).toString();
- }
- /**
- * 收支凭证审核
- *
- * @return
- */
- @API(title = "收支凭证审核", apiversion = R.ID20221009103103.v1.class)
- @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20221008145903.v1.class, R.ID20221009160003.v1.class, R.ID20230111103403.v1.class})
- public String release() throws YosException {
- long sa_cashbillid = content.getLong("sa_cashbillid");
- String[] s = {"sa_cashbillid"};
- for (String s1 : s) {
- if (!content.containsKey(s1))
- return getErrReturnObject().setErrMsg("缺少" + s1 + "参数").toString();
- }
- //List<String> list = sa_creditbillids.toJavaList(String.class);
- //String[] stringArray = list.toArray(new String[0]);
- //SQLFactory sqlFactoryquery = new SQLFactory(this, "信用额度调整单状态查询");
- //sqlFactoryquery.addParameter("siteid", siteid);
- //sqlFactoryquery.addParameter_in("sa_creditbillids", stringArray);
- Rows rows = dbConnect.runSqlQuery("select t1.sa_cashbillid,t1.sys_enterpriseid,t1.sa_accountclassid,t1.status,t1.billno,t1.amount,ifnull(t1.discountamount,0) discountamount,t1.type,t1.ownerid,t2.accountname,t1.remarks from sa_cashbill t1 left join sa_accountclass t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid where t1.sa_cashbillid ='" + sa_cashbillid + "' and t1.siteid='" + siteid + "'");
- for (Row row : rows) {
- if (row.getString("status").equals("审核")) {
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证已审核,无法再次审核")
- .toString();
- }
- if (!row.getString("status").equals("新建")) {
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非新建状态,无法审核")
- .toString();
- }
- }
- ArrayList<String> sqlList = new ArrayList<>();
- BigDecimal balance = BigDecimal.ZERO; //当前账户余额
- BigDecimal discountamount = BigDecimal.ZERO; //当前账户余额
- if (!rows.isEmpty()) {
- long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
- long sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
- long type = rows.get(0).getLong("type");
- Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota,ifnull(discountamount,0) discountamount from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
- if (type == 1) {
- Rows offsettingRows = dbConnect.runSqlQuery("select amount from sa_cashbill where siteid='" + siteid + "' and ownertable='sa_cashbill' and ownerid=" + rows.get(0).getLong("ownerid"));
- if (offsettingRows.isNotEmpty()) {
- sqlList.add("update sa_cashbill set writeoffamount=writeoffamount+" + offsettingRows.get(0).getBigDecimal("amount").abs() + " where siteid='" + siteid + "' and sa_cashbillid=" + rows.get(0).getLong("ownerid"));
- }
- if (rowsaccountbalance.isEmpty()) {
- balance = rows.get(0).getBigDecimal("amount");
- SQLFactory sqlFactory = new SQLFactory(this, "营销账户余额新增");
- sqlFactory.addParameter("sa_accountbalanceid", createTableID("sa_accountbalance"));
- sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("balance", rows.get(0).getBigDecimal("amount"));
- sqlFactory.addParameter("discountamount", rows.get(0).getBigDecimal("discountamount"));
- sqlFactory.addParameter("userid", userid);
- sqlFactory.addParameter("username", username);
- sqlList.add(sqlFactory.getSQL());
- } else {
- BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
- if ((rows.get(0).getBigDecimal("amount").add(canuseamount)).compareTo(BigDecimal.ZERO) == -1 && rows.get(0).getBigDecimal("amount").compareTo(BigDecimal.ZERO)<=0) {
- return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法审核")
- .toString();
- }
- balance = rows.get(0).getBigDecimal("amount").add(rowsaccountbalance.get(0).getBigDecimal("balance"));
- discountamount = rows.get(0).getBigDecimal("discountamount").add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
- sqlList.add("update sa_accountbalance set balance='" + rows.get(0).getBigDecimal("amount").add(rowsaccountbalance.get(0).getBigDecimal("balance")) + "',discountamount="+discountamount+",changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
- }
- sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "审核", "收入凭证审核成功").getSQL());
- } else {
- if (rowsaccountbalance.isEmpty()) {
- // SQLFactory sqlFactory = new SQLFactory(this, "营销账户余额新增");
- // sqlFactory.addParameter("sa_accountbalanceid", createTableID("sa_accountbalance"));
- // sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- // sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
- // sqlFactory.addParameter("siteid", siteid);
- // sqlFactory.addParameter("balance", -rows.get(0).getLong("amount"));
- // sqlFactory.addParameter("userid", userid);
- // sqlFactory.addParameter("username", username);
- // sqlList.add(sqlFactory.getSQL());
- return getErrReturnObject().setErrMsg("该营销账户不存在,支出凭证无法审核")
- .toString();
- } else {
- BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("amount")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
- if (rows.get(0).getBigDecimal("amount").compareTo(canuseamount) == 1 ) {
- return getErrReturnObject().setErrMsg("该营销账户可用余额不足,支出凭证无法审核")
- .toString();
- }
- BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
- balance = newbalance;
- discountamount = rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(rows.get(0).getBigDecimal("discountamount"));
- sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount="+discountamount+",changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
- }
- sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "审核", "支出凭证审核成功").getSQL());
- }
- }
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证审核");
- sqlFactoryupdate.addParameter("siteid", siteid);
- sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
- sqlFactoryupdate.addParameter("balance", balance);
- sqlFactoryupdate.addParameter("checkby", username);
- sqlList.add(sqlFactoryupdate.getSQL());
- dbConnect.runSqlUpdate(sqlList);
- if (!rows.isEmpty()) {
- long type = rows.get(0).getLong("type");
- if (type == 1) {
- String message = "您的【" + rows.get(0).getString("accountname") + "】账户已收入【" + rows.get(0).getBigDecimal("amount") + "】元!";
- sendMsg(message, sa_cashbillid, rows.get(0).getLong("sys_enterpriseid"));
- } else {
- String message = "您的【" + rows.get(0).getString("accountname") + "】账户已支出【" + rows.get(0).getBigDecimal("amount") + "】元,【备注:" + rows.get(0).getString("remarks") + "】!!";
- sendMsg(message, sa_cashbillid, rows.get(0).getLong("sys_enterpriseid"));
- }
- }
- return getSucReturnObject().toString();
- }
- /**
- * 收支凭证反审核
- *
- * @return
- */
- @API(title = "收入凭证反审核", apiversion = R.ID20230509085703.v1.class)
- @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20221008145903.v1.class, R.ID20221009160003.v1.class, R.ID20230111103403.v1.class})
- public String unrelease() throws YosException {
- long sa_cashbillid = content.getLong("sa_cashbillid");
- //List<String> list = sa_creditbillids.toJavaList(String.class);
- //String[] stringArray = list.toArray(new String[0]);
- //SQLFactory sqlFactoryquery = new SQLFactory(this, "信用额度调整单状态查询");
- //sqlFactoryquery.addParameter("siteid", siteid);
- //sqlFactoryquery.addParameter_in("sa_creditbillids", stringArray);
- Rows rows = dbConnect.runSqlQuery("select checkdate,sa_cashbillid,sys_enterpriseid,sa_accountclassid,status,billno,amount,type,ownerid,ifnull(discountamount,0) discountamount from sa_cashbill where sa_cashbillid ='" + sa_cashbillid + "' and siteid='" + siteid + "'");
- Date date = new Date();
- for (Row row : rows) {
- if (!row.getString("status").equals("审核")) {
- return getErrReturnObject().setErrMsg("单号为:【" + row.getString("billno") + "】的收支凭证为非审核状态,无法反审核")
- .toString();
- }
- if (row.getLong("type") != 1) {
- return getErrReturnObject().setErrMsg("非收入凭证无法反审核")
- .toString();
- }
- if (!isMonth(row.getDate("checkdate"), date)) {
- return getErrReturnObject().setErrMsg("跨月禁止反审").toString();
- }
- }
- ArrayList<String> sqlList = new ArrayList<>();
- BigDecimal balance = BigDecimal.ZERO; //当前账户余额
- BigDecimal discountamount = BigDecimal.ZERO; //当前账户余额
- if (!rows.isEmpty()) {
- long sys_enterpriseid = rows.get(0).getLong("sys_enterpriseid");
- long sa_accountclassid = rows.get(0).getLong("sa_accountclassid");
- long type = rows.get(0).getLong("type");
- Rows rowsaccountbalance = dbConnect.runSqlQuery("select sa_accountbalanceid,balance,creditquota,ifnull(discountamount,0) discountamount from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
- //System.out.println("select sa_accountbalanceid,balance,creditquota from sa_accountbalance where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
- if (type == 1) {
- Rows offsettingRows = dbConnect.runSqlQuery("select amount from sa_cashbill where siteid='" + siteid + "' and ownertable='sa_cashbill' and ownerid=" + rows.get(0).getLong("ownerid"));
- if (offsettingRows.isNotEmpty()) {
- sqlList.add("update sa_cashbill set writeoffamount=writeoffamount+" + offsettingRows.get(0).getBigDecimal("amount").abs() + " where siteid='" + siteid + "' and sa_cashbillid=" + rows.get(0).getLong("ownerid"));
- }
- if (rowsaccountbalance.isEmpty()) {
- return getErrReturnObject().setErrMsg("该营销账户不存在,收入凭证无法反审核")
- .toString();
- } else {
- BigDecimal canuseamount = rowsaccountbalance.get(0).getBigDecimal("creditquota").add(rowsaccountbalance.get(0).getBigDecimal("balance")).add(rowsaccountbalance.get(0).getBigDecimal("discountamount"));
- if (rows.get(0).getBigDecimal("amount").compareTo(canuseamount) == 1) {
- return getErrReturnObject().setErrMsg("该营销账户可用余额不足,收入凭证无法反审核")
- .toString();
- }
- BigDecimal newbalance = rowsaccountbalance.get(0).getBigDecimal("balance").subtract(rows.get(0).getBigDecimal("amount"));
- balance = newbalance;
- discountamount= rowsaccountbalance.get(0).getBigDecimal("discountamount").subtract(rows.get(0).getBigDecimal("discountamount"));
- sqlList.add("update sa_accountbalance set balance='" + newbalance + "',discountamount="+discountamount+",changedate=CURRENT_TIME,changeby ='" + username + "',changeuserid='" + userid + "' where sys_enterpriseid ='" + sys_enterpriseid + "' and sa_accountclassid='" + sa_accountclassid + "' and siteid='" + siteid + "'");
- }
- sqlList.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "反审核", "收入凭证反审核成功").getSQL());
- }
- }
- SQLFactory sqlFactoryupdate = new SQLFactory(this, "收支凭证反审核");
- sqlFactoryupdate.addParameter("siteid", siteid);
- sqlFactoryupdate.addParameter("sa_cashbillid", sa_cashbillid);
- sqlFactoryupdate.addParameter("balance", balance);
- sqlList.add(sqlFactoryupdate.getSQL());
- dbConnect.runSqlUpdate(sqlList);
- return getSucReturnObject().toString();
- }
- @API(title = "删除", apiversion = R.ID20221009103203.v1.class)
- @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})
- public String delete() throws YosException {
- JSONArray sa_cashbillids = content.getJSONArray("sa_cashbillids");
- BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_cashbillids.size());
- for (Object o : sa_cashbillids) {
- long sa_cashbillid = Long.parseLong(o.toString());
- Rows RowsStatus = dbConnect.runSqlQuery("select billno,class,subclass,amount,status,sa_cashbillid,source,sourcenote,remarks from sa_cashbill where siteid='"
- + siteid + "' and sa_cashbillid='" + sa_cashbillid + "'");
- ArrayList<String> list = new ArrayList<>();
- if (RowsStatus.isNotEmpty()) {
- if (!RowsStatus.get(0).getString("status").equals("新建")) {
- batchDeleteErr.addErr(sa_cashbillid, "非新建状态的凭证无法删除");
- continue;
- }
- list.add(DataContrlLog.createLog(this, "sa_cashbill", sa_cashbillid, "删除", RowsStatus.get(0).toString()).getSQL());
- }
- list.add("delete from sa_cashbill where siteid='" + siteid
- + "' and sa_cashbillid=" + sa_cashbillid);
- dbConnect.runSqlUpdate(list);
- }
- ClearData.clearCashbill(this);
- return batchDeleteErr.getReturnObject().toString();
- }
- @API(title = "审核状态的收支凭证详情列表", apiversion = R.ID20221022161304.v1.class)
- @CACHEING
- public String query_cashnill_audit() throws Exception {
- /*
- 过滤条件
- */
- StringBuffer where = new StringBuffer(" 1=1 ");
- Long sa_accountclassid = content.getLong("sa_accountclassid");
- Long sys_enterpriseid = content.getLong("sys_enterpriseid");
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where.append(" and (t1.billno like '%").append(whereObject.getString("condition")).append("%'");
- where.append(" or t3.enterprisename like '%").append(whereObject.getString("condition")).append("%'");
- where.append(" or t1.remarks like '%").append(whereObject.getString("condition")).append("%'");
- where.append(" or t1.source like '%").append(whereObject.getString("condition")).append("%')");
- }
- if (whereObject.containsKey("minAmount") && whereObject.getBigDecimal("minAmount").compareTo(new BigDecimal("0")) == 1) {
- BigDecimal minAmount = whereObject.getBigDecimal("minAmount");
- if (whereObject.containsKey("maxAmount") && whereObject.getBigDecimal("maxAmount").compareTo(new BigDecimal("0")) == 1) {
- BigDecimal maxAmount = whereObject.getBigDecimal("maxAmount");
- where.append(" and t1.amount between ").append(minAmount).append(" and ").append(maxAmount);
- } else {
- where.append(" and t1.amount > ").append(minAmount);
- }
- } else if (whereObject.containsKey("maxAmount") && whereObject.getBigDecimal("maxAmount").compareTo(new BigDecimal("0")) == 1) {
- BigDecimal maxAmount = whereObject.getBigDecimal("maxAmount");
- where.append(" and t1.amount < ").append(maxAmount);
- }
- if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
- where.append(" and t1.type = ").append(whereObject.getLong("type"));
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
- }
- }
- //// boolean isExport = content.getBooleanValue("isExport");
- // SQLFactory sqlFactory = new SQLFactory(this, "审核状态的收支凭证详情列表", pageSize, pageNumber, pageSorting);
- //// if (isExport) {
- //// sqlFactory = new SQLFactory(this, "审核状态的收支凭证详情列表");
- //// }
- // sqlFactory.addParameter_SQL("where", where);
- // sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
- // sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
- // sqlFactory.addParameter("siteid", siteid);
- // Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "billno", "type",
- "amount","remarks","balance","source","checkby","checkdate","sa_accountclassid");
- querySQL.setTableAlias("t1");
- querySQL.addQueryFields("type_ch", "if(t1.type=1,'收入','支出')");
- querySQL.addQueryFields("unwriteoffamount", "t1.amount - t1.writeoffamount");
- querySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t2", "t1.sa_accountclassid = t2.sa_accountclassid and t1.siteid = t2.siteid","accountname");
- querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t3", "t1.sys_enterpriseid = t3.sys_enterpriseid and t1.siteid = t3.siteid","enterprisename");
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t4", "t1.sys_enterpriseid = t4.sys_enterpriseid AND t1.siteid = t4.siteid","agentnum");
- querySQL.setSiteid(siteid);
- querySQL.setWhere("t1.status = '审核'");
- querySQL.setWhere("t1.sa_accountclassid",sa_accountclassid);
- querySQL.setWhere("t1.sys_enterpriseid",sys_enterpriseid);
- querySQL.setWhere(where.toString());
- querySQL.setPage(pageSize, pageNumber);
- Rows rows = querySQL.query();
- // if (isExport) {
- // //去除不需要导出项
- // rows.getFieldList().remove("sa_accountclassid");
- // rows.getFieldList().remove("unwriteoffamount");
- // rows.getFieldList().remove("agentnum");
- // rows.getFieldList().remove("type");
- // Rows uploadRows = uploadExcelToObs("cashBill", "审核状态的收支凭证详情列表", rows, getTitleMap_audit());
- // return getSucReturnObject().setData(uploadRows).toString();
- // }
- return getSucReturnObject().setData(rows).toString();
- }
- //返回导出的标题
- public HashMap<String, String> getTitleMap_audit() {
- HashMap<String, String> titleMap = new HashMap<>();
- titleMap.put("billno", "凭证编号");
- titleMap.put("enterprisename", "企业名称");
- titleMap.put("type_ch", "收支类型");
- titleMap.put("accountname", "账户名称");
- titleMap.put("amount", "收支金额");
- titleMap.put("remarks", "备注");
- titleMap.put("source", "凭证来源");
- titleMap.put("checkby", "审核人");
- titleMap.put("checkdate", "审核时间");
- return titleMap;
- }
- @API(title = "资金流水账列表查询", apiversion = R.ID20230111103403.v1.class)
- @CACHEING
- public String query_cashBill() throws YosException, IOException {
- /*
- 过滤条件
- */
- Long sa_accountclassid = content.getLong("sa_accountclassid");
- if (content.containsKey("sys_enterpriseid")) {
- sys_enterpriseid = content.getLong("sys_enterpriseid");
- }
- Map<String, Rows> map = new HashMap<String, Rows>();
- /**
- * 过滤条件设置
- */
- String where = " 1=1 ";
- if (content.containsKey("where")) {
- JSONObject whereObject = content.getJSONObject("where");
- if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
- where = where + " and(t1.class like '%" + whereObject.getString("condition")
- + "%' or t1.subclass like '%" + whereObject.getString("condition")
- + "%' or t1.billno like '%" + whereObject.getString("condition")
- + "%' or t1.remarks like '%" + whereObject.getString("condition") + "%')";
- }
- if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
- where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') >=DATE_FORMAT('" + whereObject.getString("begindate") + "','%Y-%m-%d')";
- }
- if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
- where = where + " and DATE_FORMAT(t1.checkdate,'%Y-%m-%d') <=DATE_FORMAT('" + whereObject.getString("enddate") + "','%Y-%m-%d')";
- }
- if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
- where = where + " and t1.type ='" + whereObject.getString("type") + "' ";
- }
- if (whereObject.containsKey("class") && !"".equals(whereObject.getString("class"))) {
- where = where + " and t1.class ='" + whereObject.getString("class") + "' ";
- }
- if (whereObject.containsKey("class") && !"".equals(whereObject.getString("class"))) {
- where = where + " and t1.class ='" + whereObject.getString("class") + "' ";
- }
- if (whereObject.containsKey("subclass") && !"".equals(whereObject.getString("subclass"))) {
- where = where + " and t1.subclass ='" + whereObject.getString("subclass") + "' ";
- }
- }
- /**
- * SQL资金流水账查询参数设置并查询
- */
- // boolean isExport = content.getBooleanValue("isExport");
- // SQLFactory factory = new SQLFactory(this, "资金流水账查询", pageSize, pageNumber, pageSorting);
- //// if (isExport) {
- //// factory = new SQLFactory(this, "资金流水账查询导出");
- //// }
- // factory.addParameter("sys_enterpriseid", sys_enterpriseid);
- // factory.addParameter("sa_accountclassid", sa_accountclassid);
- // factory.addParameter("siteid", siteid);
- // factory.addParameter_SQL("where", where);
- // Rows rows = dbConnect.runSqlQuery(factory.getSQL());
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_cashbill", "billno", "type",
- "class","subclass","amount","remarks","source","sourcenote","ownerid","ownertable","createdate","createby","checkby","checkdate","sa_accountclassid");
- querySQL.setTableAlias("t1");
- querySQL.addQueryFields("balance", "ifnull(t1.balance,0)");
- querySQL.addJoinTable(JOINTYPE.inner, "sa_accountclass", "t4", "t1.sa_accountclassid = t4.sa_accountclassid and t1.siteid = t4.siteid","accountname");
- querySQL.setSiteid(siteid);
- querySQL.setWhere("t1.status = '审核'");
- querySQL.setWhere("t1.sa_accountclassid",sa_accountclassid);
- querySQL.setWhere("t1.sys_enterpriseid",sys_enterpriseid);
- querySQL.setWhere(where);
- querySQL.setPage(pageSize, pageNumber);
- querySQL.setOrderBy(pageSorting);
- Rows rows = querySQL.query();
- // if (isExport) {
- // //去除不需要导出项
- // rows.getFieldList().remove("sa_accountclassid");
- // Rows uploadRows = uploadExcelToObs("cashBill", "资金流水账列表", rows, getTitleMap());
- // return getSucReturnObject().setData(uploadRows).toString();
- // }
- /**
- * SQL资金流水账汇总信息查询参数设置并查询
- */
- SQLFactory factoryhz = new SQLFactory(this, "资金流水账查询汇总");
- factoryhz.addParameter("sys_enterpriseid", sys_enterpriseid);
- factoryhz.addParameter("sa_accountclassid", sa_accountclassid);
- factoryhz.addParameter("siteid", siteid);
- factoryhz.addParameter_SQL("where", where);
- Rows rowszh = dbConnect.runSqlQuery(factoryhz.getSQL());
- if (!rows.isEmpty()) {
- rows.get(0).put("total", rowszh);
- }
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "核销单关联查询", apiversion = R.ID20230224185904.v1.class)
- @CACHEING
- public String querywriteoffamount() throws YosException {
- Long sa_cashbillid = content.getLong("sa_cashbillid");
- // SQLFactory sqlFactory = new SQLFactory(this, "核销单关联查询", pageSize, pageNumber, pageSorting);
- // sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
- // sqlFactory.addParameter("siteid", siteid);
- // Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_writeoffbill", "billno", "billnodate",
- "unwriteoffamount","writeoffamount","sys_enterpriseid","status","remarks","createuserid","createby","createdate","changeuserid","checkby","checkdate","changeby","changedate");
- querySQL.setTableAlias("t1");
- querySQL.setSiteid(siteid);
- querySQL.setWhere("t1.sa_cashbillid",sa_cashbillid);
- querySQL.setPage(pageSize, pageNumber);
- Rows rows = querySQL.query();
- return getSucReturnObject().setData(rows).toString();
- }
- @API(title = "收入凭证对冲生成", apiversion = R.ID20230306102904.v1.class)
- @CACHEING_CLEAN(apiversions = {R.ID20221009102903.v1.class, R.ID20221010102903.v1.class, R.ID20221009103003.v1.class, R.ID20230111103403.v1.class})
- public String cashbilloffsetting() throws YosException {
- Long sa_cashbillid = content.getLong("sa_cashbillid");
- SQLFactory sqlFactory = new SQLFactory(this, "收支凭证详情查询");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("sa_cashbillid", sa_cashbillid);
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
- if (rows.isEmpty()) {
- return getErrReturnObject().setErrMsg("无效收入凭证").toString();
- }
- if (rows.get(0).getLong("type") == 0) {
- return getErrReturnObject().setErrMsg("支出凭证不能生成对冲").toString();
- }
- if (!rows.get(0).getString("status").equals("审核")) {
- return getErrReturnObject().setErrMsg("非审核状态不能生成对冲").toString();
- }
- if (rows.get(0).getBigDecimal("unwriteoffamount").compareTo(new BigDecimal(0)) < 1) {
- return getErrReturnObject().setErrMsg("未核销金额必须大于0").toString();
- }
- if (dbConnect.runSqlQuery("select 1 from sa_cashbill where siteid='" + siteid + "' and ownertable='sa_cashbill' and sa_cashbillid=" + sa_cashbillid).isNotEmpty()) {
- return getErrReturnObject().setErrMsg("该凭证已生成对冲凭证").toString();
- }
- if (dbConnect.runSqlQuery("select 1 from sa_cashbill where siteid='" + siteid + "' and ownertable='sa_cashbill' and ownerid=" + sa_cashbillid).isNotEmpty()) {
- return getErrReturnObject().setErrMsg("该凭证已生成对冲凭证").toString();
- }
- Long offsettingCashbillid = createTableID("sa_cashbill");
- sqlFactory = new SQLFactory(this, "收支凭证新增");
- sqlFactory.addParameter("siteid", siteid);
- sqlFactory.addParameter("userid", userid);
- sqlFactory.addParameter("username", username);
- sqlFactory.addParameter("sa_cashbillid", offsettingCashbillid);
- sqlFactory.addParameter("billno", createBillCode("cashbill"));
- sqlFactory.addParameter("sys_enterpriseid", rows.get(0).getLong("sys_enterpriseid"));
- sqlFactory.addParameter("sa_accountclassid", rows.get(0).getLong("sa_accountclassid"));
- sqlFactory.addParameter("type", rows.get(0).getLong("type"));
- sqlFactory.addParameter("remarks", "凭证对冲");
- sqlFactory.addParameter("amount", rows.get(0).getBigDecimal("unwriteoffamount").negate());
- sqlFactory.addParameter("source", rows.get(0).getString("amount"));
- sqlFactory.addParameter("sourcenote", rows.get(0).getString("sourcenote"));
- sqlFactory.addParameter("subclass", rows.get(0).getString("subclass"));
- sqlFactory.addParameter("class", rows.get(0).getString("class"));
- sqlFactory.addParameter("ownertable", "sa_cashbill");
- sqlFactory.addParameter("ownerid", sa_cashbillid);
- dbConnect.runSqlUpdate(sqlFactory.getSQL());
- content.put("sa_cashbillid", offsettingCashbillid);
- return queryCashbillMain();
- }
- public Object getCellFormatValue(Cell cell) {
- Object cellValue = null;
- if (cell != null) {
- // 判断cell类型
- CellType cellType = cell.getCellType();
- switch (cellType) {
- case NUMERIC: {
- if (DateUtil.isCellDateFormatted(cell)) {
- short num = cell.getCellStyle().getDataFormat();
- String format = "YYYY-mm-dd";
- SimpleDateFormat df = new SimpleDateFormat(format);
- cellValue = df.format(cell.getDateCellValue());
- } else {
- cell.setCellType(CellType.STRING); // 将数值型cell设置为string型
- cellValue = cell.getStringCellValue();
- }
- break;
- }
- case FORMULA: {
- // 判断cell是否为日期格式
- if (DateUtil.isCellDateFormatted(cell)) {
- // 转换为日期格式YYYY-mm-dd
- cellValue = cell.getDateCellValue();
- } else {
- // 数字
- cellValue = String.valueOf(cell.getNumericCellValue());
- }
- break;
- }
- case STRING: {
- cellValue = cell.getRichStringCellValue().getString();
- break;
- }
- default:
- cellValue = cell.getRichStringCellValue().getString();
- break;
- }
- } else {
- cellValue = "";
- }
- return cellValue;
- }
- public XSSFSheet addSheetIncome(ExcelFactory excelFactory, String sheetname, Rows datarows,
- HashMap<String, String> titlemap) {
- ArrayList<String> keylist = datarows.getFieldList();
- XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
- XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
- XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
- XSSFFont font = xssfFWorkbook.createFont();
- font.setColor((short) 0xa);
- font.setFontHeightInPoints((short) 12);
- font.setBold(true);
- xssfCellStyle1.setFont(font);
- IncomeExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
- XSSFCellStyle titleCellStyle1 = IncomeExportExcel.createTitleCellStyle1(xssfFWorkbook);
- XSSFCellStyle titleCellStyle2 = IncomeExportExcel.createTitleCellStyle2(xssfFWorkbook);
- XSSFCellStyle titleCellStyle3 = IncomeExportExcel.createTitleCellStyle3(xssfFWorkbook);
- IncomeExportExcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
- for (int n = 0; n < datarows.size(); n++) {
- Row row = datarows.get(n);
- XSSFRow datarow = sheet.createRow(n + 3);
- for (int i1 = 0; i1 < keylist.size(); i1++) {
- Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
- if (fieldclazztype == Integer.class) {
- datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)));
- } else if (fieldclazztype == Long.class) {
- datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
- } else if (fieldclazztype == Float.class) {
- datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
- } else if (fieldclazztype == Double.class) {
- datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
- } else {
- datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
- }
- if (i1 == 7) {
- datarow.getCell(i1).setCellStyle(xssfCellStyle1);
- }
- }
- }
- return sheet;
- }
- public XSSFSheet addSheetPay(ExcelFactory excelFactory, String sheetname, Rows datarows,
- HashMap<String, String> titlemap) {
- ArrayList<String> keylist = datarows.getFieldList();
- XSSFSheet sheet = excelFactory.getXssfWorkbook().createSheet(sheetname);
- XSSFWorkbook xssfFWorkbook = excelFactory.getXssfWorkbook();
- XSSFCellStyle xssfCellStyle1 = xssfFWorkbook.createCellStyle();
- XSSFFont font = xssfFWorkbook.createFont();
- font.setColor((short) 0xa);
- font.setFontHeightInPoints((short) 12);
- font.setBold(true);
- xssfCellStyle1.setFont(font);
- PayExportExcel.setBatchDetailSheetColumn2(sheet);// 设置工作薄列宽
- XSSFCellStyle titleCellStyle1 = PayExportExcel.createTitleCellStyle1(xssfFWorkbook);
- XSSFCellStyle titleCellStyle2 = PayExportExcel.createTitleCellStyle2(xssfFWorkbook);
- XSSFCellStyle titleCellStyle3 = PayExportExcel.createTitleCellStyle3(xssfFWorkbook);
- PayExportExcel.batchDetailErr(sheet, titleCellStyle1, titleCellStyle2, titleCellStyle3, xssfFWorkbook);// 写入标题
- for (int n = 0; n < datarows.size(); n++) {
- Row row = datarows.get(n);
- XSSFRow datarow = sheet.createRow(n + 3);
- for (int i1 = 0; i1 < keylist.size(); i1++) {
- Class fieldclazztype = datarows.getFieldMeta(keylist.get(i1)).getFieldtype();
- if (fieldclazztype == Integer.class) {
- datarow.createCell(i1).setCellValue(row.getInteger((String) keylist.get(i1)));
- } else if (fieldclazztype == Long.class) {
- datarow.createCell(i1).setCellValue(row.getLong((String) keylist.get(i1)));
- } else if (fieldclazztype == Float.class) {
- datarow.createCell(i1).setCellValue(row.getFloat((String) keylist.get(i1)));
- } else if (fieldclazztype == Double.class) {
- datarow.createCell(i1).setCellValue(row.getDouble((String) keylist.get(i1)));
- } else {
- datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
- }
- if (i1 == 7) {
- datarow.getCell(i1).setCellStyle(xssfCellStyle1);
- }
- }
- }
- return sheet;
- }
- //返回导出的标题
- public HashMap<String, String> getTitleMap() {
- HashMap<String, String> titleMap = new HashMap<>();
- titleMap.put("billno", "凭证编号");
- titleMap.put("type", "收支类型");
- titleMap.put("accountname", "账户名称");
- titleMap.put("amount", "收支金额");
- titleMap.put("balance", "账户结余");
- titleMap.put("source", "凭证来源");
- titleMap.put("class", "分类");
- titleMap.put("subclass", "分类明细");
- titleMap.put("remarks", "备注");
- titleMap.put("checkby", "审核人");
- titleMap.put("checkdate", "审核时间");
- return titleMap;
- }
- /**
- * 判断是否在同一个月
- *
- * @return false:不在同一个月内,true在同一个月内
- */
- public boolean isMonth(Date date1, Date date2) {
- Calendar calendar1 = Calendar.getInstance();
- calendar1.setTime(date1);
- Calendar calendar2 = Calendar.getInstance();
- calendar2.setTime(date2);
- int year1 = calendar1.get(Calendar.YEAR);
- int year2 = calendar2.get(Calendar.YEAR);
- int month1 = calendar1.get(Calendar.MONTH);
- int month2 = calendar2.get(Calendar.MONTH);
- return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR) && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH);
- }
- public void sendMsg(String content, Long sa_cashbillid, Long sys_enterpriseid) throws YosException {
- ArrayList<Long> userList = getEnterpriseHrs(sys_enterpriseid).toArrayList("userid", new ArrayList<>());
- Remind remind = new Remind(this);
- remind.setTitle("收支凭证消息");
- remind.setContent(content);
- remind.setType("应用");
- remind.setObjectid(sa_cashbillid);
- remind.setObjectname("sa_cashbill");
- remind.setTouserid(userList);
- remind.sendByDialogMsg().createSys_message();
- }
- public boolean isValidFormat(String date) throws ParseException {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- dateFormat.setLenient(false); // 设置解析日期时是否宽松,即是否允许解析不严格符合格式的日期字符串
- try {
- Date parsedDate = dateFormat.parse(date);
- return true;
- } catch (ParseException e) {
- return false;
- }
- }
- }
|