Commit e4b91448 authored by 李贺贺's avatar 李贺贺

Merge branch 'develop' of https://hel.hand-china.com/hlcm/leaf-hlcm into develop

parents 8cf21590 871d986f
package com.hand.hls.hlcm.importexcel.controllers;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.controllers.BaseController;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hls.hlcm.importexcel.service.ImportExcelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* Copyright (C) Hand Business Consulting Services
* AllRights Reserved
*
* @Author: administrator
* @Date: 2021/4/29 11:11
* @Description:建机模板导入二开
*/
@Controller
public class ImportExcelController extends BaseController {
@Autowired
ImportExcelService importExcelService;
@RequestMapping(value = "/hls/importExcel/import")
@ResponseBody
public ResponseData importExcel(@RequestParam Map <String,String> map,@RequestParam(value = "content",required = false) MultipartFile importFile, HttpServletRequest request) throws Exception{
ResponseData responseData = new ResponseData();
String template_code=request.getParameter("template_code");
Assert.notNull(template_code,"templateCode为空");
IRequest requestContext = createRequestContext(request);
requestContext.setAttribute("template_code",template_code);
responseData=importExcelService.importExcel(requestContext,importFile);
return responseData;
}
}
package com.hand.hls.hlcm.importexcel.mapper;
import com.hand.hap.mybatis.common.BaseMapper;
import java.util.List;
import java.util.Map;
/**
* Copyright (C) Hand Business Consulting Services
* AllRights Reserved
*
* @Author: administrator
* @Date: 2021/4/30 11:26
* @Description:导入表
*/
public interface ImportExcelMapper {
/**
* 新增行表
* @param fieldValues
*/
void insertInterfaceLine(Map<String, List<Object>> fieldValues);
/**
* 新增头表
* @param map
*/
void insertInterfaceHead(Map map);
/**
* 获取headId
* @return
*/
Long getHeadId();
/**
* 更新数据
* @param map
*/
void updateJournalData(Map map);
}
package com.hand.hls.hlcm.importexcel.service;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.ResponseData;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* Copyright (C) Hand Business Consulting Services
* AllRights Reserved
*
* @Author: administrator
* @Date: 2021/4/29 13:19
* @Description:
*/
public interface ImportExcelService {
/**
*导入excel等文件
* @param iRequest
* @param file
* @return
* @throws Exception
*/
ResponseData importExcel(IRequest iRequest, MultipartFile file) throws Exception;
}
package com.hand.hls.hlcm.importexcel.service.impl;
import com.hand.hap.core.IRequest;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hls.hlcm.importexcel.mapper.ImportExcelMapper;
import com.hand.hls.hlcm.importexcel.service.ImportExcelService;
import leaf.plugin.dataimport.ImportExcel;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Copyright (C) Hand Business Consulting Services
* AllRights Reserved
*
* @Author: administrator
* @Date: 2021/4/29 13:24
* @Description:
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class ImportExcelServiceImpl implements ImportExcelService {
public static final int TOTAL_CELL = 7;
FormulaEvaluator evaluator;
/**
* //public static final String XLS_KEY = ".xls";
* // public static final String XLSX_KEY = ".xlsx";
* //public static final String CSV_KEY = ".csv";
* //public static final String TXT_KEY = ".txt";
*/
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
ImportExcelMapper importExcelMapper;
@Override
public ResponseData importExcel(IRequest iRequest, MultipartFile file) throws Exception {
ResponseData responseData = new ResponseData();
String fileName;
fileName = file.getOriginalFilename();
logger.info(fileName);
String suffix = fileName.substring(fileName.lastIndexOf("."));
Workbook wb = null;
if (ImportExcel.XLS_KEY.equalsIgnoreCase(suffix)) {
wb = new HSSFWorkbook(file.getInputStream());
} else if (ImportExcel.XLSX_KEY.equalsIgnoreCase(suffix)) {
wb = new XSSFWorkbook(file.getInputStream());
}
if (wb != null) {
evaluator = wb.getCreationHelper().createFormulaEvaluator();
}
Sheet sheet = null;
Row row;
Cell cell;
if (wb != null && wb.getNumberOfSheets() > 1) {
responseData.setSuccess(false);
responseData.setMessage("sheet页数大于1,请检查模板!");
return responseData;
}
if (wb != null) {
sheet = wb.getSheetAt(0);
}
assert sheet != null;
int checkRow = sheet.getRow(0).getPhysicalNumberOfCells();
if (checkRow != TOTAL_CELL) {
responseData.setSuccess(false);
responseData.setMessage("模板列数不匹配,请检查模板!");
return responseData;
}
//获取头id
Long headId = importExcelMapper.getHeadId();
Map<String, Object> headMap = new HashMap<>(16);
headMap.put("headId", headId);
headMap.put("templateCode",iRequest.getAttribute("template_code"));
headMap.put("jobId", null);
headMap.put("status", "NEW");
headMap.put("userId", iRequest.getUserId());
headMap.put("attribute_5", "N");
headMap.put("file_name", fileName);
importExcelMapper.insertInterfaceHead(headMap);
//获取行
for (int i = 0; i <= sheet.getLastRowNum(); i++) {
Map<String, List<Object>> fieldValues = new HashMap<>(16);
List<Object> fields = new ArrayList<>();
List<Object> values = new ArrayList<>();
fields.add("HEADER_ID");
fields.add("LINE_NUMBER");
fields.add("CREATED_BY");
fields.add("CREATION_DATE");
fields.add("LAST_UPDATED_BY");
fields.add("LAST_UPDATE_DATE");
values.add(headId);
values.add(i);
values.add(iRequest.getUserId());
values.add(new Date());
values.add(iRequest.getUserId());
values.add(new Date());
row = sheet.getRow(i);
for (int j = 0; j < row.getLastCellNum(); j++) {
//获取列
cell = row.getCell(j);
fields.add("ATTRIBUTE_" + (j + 1));
String value;
if (cell != null) {
value = resetValue(cell);
values.add(value);
}
}
fieldValues.put("columns", fields);
fieldValues.put("values", values);
importExcelMapper.insertInterfaceLine(fieldValues);
}
Map<String, Object> journalMap = new HashMap<>(16);
journalMap.put("headId", headId);
journalMap.put("userId", iRequest.getUserId());
importExcelMapper.updateJournalData(journalMap);
responseData.setSuccess(true);
return responseData;
}
public String resetValue(Cell cell) {
CellValue cellValue = evaluator.evaluate(cell);
String value = null;
if (cellValue != null) {
switch (cellValue.getCellTypeEnum()) {
case BOOLEAN:
value = Boolean.toString(cellValue
.getBooleanValue());
break;
case NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
if (cell.getDateCellValue() != null) {
value = df.format(cell.getDateCellValue());
}
} else {
value = BigDecimal
.valueOf(cellValue.getNumberValue())
.stripTrailingZeros().toPlainString();
}
break;
case STRING:
value = cellValue.getStringValue();
break;
case BLANK:
case ERROR:
case FORMULA:
break;
default:
}
}
if (value != null && !"".equalsIgnoreCase(value)) {
return value;
} else {
return "";
}
}
}
package leaf.plugin.dataimport;
import leaf.database.service.SqlServiceContext;
import leaf.plugin.csv.CsvParse;
import leaf.plugin.poi.usermodel.ExcelParse;
import leaf.service.ServiceInstance;
import leaf.service.http.HttpServiceInstance;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import uncertain.composite.CompositeMap;
import uncertain.composite.TextParser;
import uncertain.core.UncertainEngine;
import uncertain.proc.AbstractEntry;
import uncertain.proc.ProcedureRunner;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class ImportExcel extends AbstractEntry {
public static final String XLS_KEY = ".xls";
public static final String XLSX_KEY = ".xlsx";
public static final String CSV_KEY = ".csv";
public static final String TXT_KEY = ".txt";
String maxFileSize = null;
public String fileName;
public String separator = ",";
public String header_id;
public String user_id = "${/session/@user_id}";
public String template_code;
public String job_id;
public String attribute1;
public String attribute2;
public String attribute3;
public String attribute4;
public String attribute5 = "N"; // 是否保存文件,不为N时保存文件。一般格式为 filePath,tableName,tablePkValue
public String dataSourceName;
UncertainEngine mUncertainEngine;
Connection conn;
CallableStatement lineCstm = null;
boolean is_first = true;
int count = 0;
int maxcell;
public ImportExcel(UncertainEngine uncertainEngine) {
mUncertainEngine = uncertainEngine;
}
public String getTemplate_code() {
return template_code;
}
public void setTemplate_code(String template_code) {
this.template_code = template_code;
}
public String getDataSourceName() {
return dataSourceName;
}
public void setDataSourceName(String dataSourceName) {
this.dataSourceName = dataSourceName;
}
public void run(ProcedureRunner runner) throws Exception {
CompositeMap context = runner.getContext();
validatePara(context);
HttpServiceInstance serviceInstance = (HttpServiceInstance) ServiceInstance
.getInstance(context);
SqlServiceContext sqlServiceContext = SqlServiceContext
.createSqlServiceContext(context);
conn = sqlServiceContext.getNamedConnection(dataSourceName);
if (conn == null) {
sqlServiceContext.initConnection(
mUncertainEngine.getObjectRegistry(), dataSourceName);
conn = sqlServiceContext.getNamedConnection(dataSourceName);
}
if (dataSourceName == null && conn == null) {
conn = sqlServiceContext.getConnection();
}
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload up = new ServletFileUpload(factory);
long fileSizeMaxLong = 10 * 1024 * 1024;
if (this.getMaxFileSize() != null)
fileSizeMaxLong = Long.parseLong(this.getMaxFileSize());
up.setSizeMax(fileSizeMaxLong);
List items = up.parseRequest(serviceInstance.getRequest());
Iterator i = items.iterator();
while (i.hasNext()) {
FileItem fileItem = (FileItem) i.next();
if (!fileItem.isFormField()) {
fileName = fileItem.getName();
saveHead();
String suffix = fileName.substring(fileName.lastIndexOf("."));
parseFile(fileItem.getInputStream(), suffix.toLowerCase(), this);
// 新增 2016-12-19 yangyang 在导入excel同时保存文件到服务器
if(!"N".equals(attribute5)){ // 不为N时保存文件
String[] parts = attribute5.split(",");
if(parts.length == 3){ // 由三个部分组成,以‘,’分割
String filePath = parts[0].replaceAll("\\\\", "/");
String tableName = parts[1];
String tablePkValue = parts[2];
InputStream inputStream = fileItem.getInputStream();
if(!filePath.endsWith("/")){
filePath = filePath + "/";
}
filePath = filePath + UUID.randomUUID().toString();
saveParseExcel(inputStream, filePath,fileName,suffix,tableName,tablePkValue);
}else{
throw new IllegalArgumentException("attribute5没有按照正确的格式设定savePath,tableName,tablePkValue");
}
}
// 新增结束 2016-12-19
executeBatchUpdate();
}
}
}
/**
*
* @param in 文件输入流
* @param savePath 文件保存的路径
* @param fileName 文件名
* @param fileTypeCode 文件类型
* @throws Exception
* <p>
* 当in为null时,抛出IllegalArgumentException.
* 可能还会抛出SQLException
* </p>
*/
void saveParseExcel(InputStream in, String savePath, String fileName,
String fileTypeCode,String tableName,String tablePkValue)
throws Exception{
if(in == null){
throw new IllegalArgumentException();
}
FileOutputStream fout = new FileOutputStream(savePath);
byte[] buffer = new byte[1024];
int len = 0;
int size = 0;
while((len = in.read(buffer)) > 0 ){
fout.write(buffer, 0, len);
size += len;
}
fout.flush();
fout.close();
in.close();
// 保存记录到数据库
//fnd_atm_attachment
String sql = "{call fnd_atm_attachment_pkg.insert_fnd_atm_attachment(?,?,?,?,?,?,?,?,?) }";
CallableStatement cstm = conn.prepareCall(sql);
cstm.registerOutParameter(1, java.sql.Types.NUMERIC);
cstm.setString(2, "fnd_atm_attachment_multi"); // v_source_type_code
cstm.setString(3, "123"); // v_source_pk_value
cstm.setString(4, fileTypeCode); // v_file_type_code
cstm.setString(5, "application/vnd.ms-excel"); // v_mime_type
cstm.setString(6, fileName); // v_file_name
cstm.setLong(7, size); // v_file_size
cstm.setString(8, savePath); // v_file_path
cstm.setLong(9, Long.valueOf(user_id)); // v_user_id
cstm.execute();
Long aid = cstm.getLong(1);
cstm.close();
//fnd_atm_attachment_multi
sql = "{call fnd_atm_attachment_all_pkg.insert_fnd_attachment_multi(?,?,?,?)}";
cstm = conn.prepareCall(sql);
cstm.setString(1, tableName);// tableName
cstm.setString(2, tablePkValue);// tablePkValue
cstm.setLong(3, aid);// attachment_id
cstm.setLong(4, Long.valueOf(user_id));// user_id
cstm.execute();
cstm.close();
}
void saveHead() throws SQLException {
CallableStatement cstm = null;
String headSql = "fnd_interface_load_pkg.ins_fnd_interface_headers(?,?,?,?,?,?,?,?,?,?,?)";
try {
cstm = conn.prepareCall("{call " + headSql + "}");
cstm.setLong(1, new Long(header_id));
if (job_id == null)
cstm.setNull(2, java.sql.Types.NUMERIC);
else
cstm.setLong(2, new Long(job_id));
cstm.setString(3, "NEW");
cstm.setString(4, user_id);
cstm.setString(5, fileName);
if (template_code == null)
cstm.setNull(6, java.sql.Types.VARCHAR);
else
cstm.setString(6, template_code);
if (attribute1 == null)
cstm.setNull(7, java.sql.Types.VARCHAR);
else
cstm.setString(7, attribute1);
if (attribute2 == null)
cstm.setNull(8, java.sql.Types.VARCHAR);
else
cstm.setString(8, attribute2);
if (attribute3 == null)
cstm.setNull(9, java.sql.Types.VARCHAR);
else
cstm.setString(9, attribute3);
if (attribute4 == null)
cstm.setNull(10, java.sql.Types.VARCHAR);
else
cstm.setString(10, attribute4);
if (attribute5 == null)
cstm.setNull(11, java.sql.Types.VARCHAR);
else
cstm.setString(11, attribute5);
cstm.execute();
} finally {
if (cstm != null)
cstm.close();
}
}
void parseFile(InputStream is, String suffix, ImportExcel importExcel)
throws Exception {
try {
if (XLS_KEY.equals(suffix) || XLSX_KEY.equals(suffix)) {
ExcelParse xlsParse = new ExcelParse();
xlsParse.parseFile(is, importExcel, suffix);
} else if (CSV_KEY.equals(suffix) || TXT_KEY.equals(suffix)) {
if (separator == null)
throw new IllegalArgumentException("separator is undefined");
CsvParse cvsParser = new CsvParse();
cvsParser.parseFile(is, importExcel);
}
} finally {
if (is != null) {
try {
is.close();
} catch (Exception e) {
}
}
}
}
void validatePara(CompositeMap context) {
header_id = TextParser.parse(header_id, context);
if (header_id == null||"".equals(header_id))
throw new IllegalArgumentException("header_id is undefined");
user_id = TextParser.parse(user_id, context);
if (user_id == null && "".equals(user_id))
throw new IllegalArgumentException("user_id is undefined");
template_code = TextParser.parse(template_code, context);
job_id = TextParser.parse(job_id, context);
attribute1 = TextParser.parse(attribute1, context);
attribute2 = TextParser.parse(attribute2, context);
attribute3 = TextParser.parse(attribute3, context);
attribute4 = TextParser.parse(attribute4, context);
attribute5 = TextParser.parse(attribute5, context);
}
public void saveLine(CompositeMap data, int rownum) throws SQLException {
boolean is_new = data.getBoolean("is_new", false);
count++;
if (validateData(data))
return;
if (is_first || is_new) {
executeBatchUpdate();
generateSql();
is_first = false;
count=0;
}
addBatchUpdate(data, rownum);
if (count % 1000 == 0){
executeBatchUpdate();
count=0;
}
}
boolean validateData(CompositeMap data) {
boolean isValidate = true;
if (data.getLong("maxCell") == null)
return isValidate;
if (maxcell != data.getInt("maxCell")) {
maxcell = data.getInt("maxCell");
this.is_first = true;
}
for (int i = 0; i < maxcell; i++) {
String valueString = data.getString("C" + i);
if (valueString != null && !"".equals(valueString)) {
isValidate = false;
break;
}
}
return isValidate;
}
void generateSql() throws SQLException {
StringBuffer lineSql = new StringBuffer(
"fnd_interface_load_pkg.ins_fnd_interface_lines(?,?,?,?,?,?,?");
for (int i = 0; i < maxcell; i++) {
lineSql.append(",?");
}
lineSql.append(")");
this.lineCstm = conn.prepareCall("{call " + lineSql + "}");
}
void executeBatchUpdate() throws SQLException {
if (lineCstm != null) {
try {
lineCstm.executeBatch();
is_first = true;
} finally {
if (this.lineCstm != null) {
try {
lineCstm.close();
} catch (Exception e) {
}
this.lineCstm = null;
}
}
}
}
void addBatchUpdate(CompositeMap data, int rownum) throws SQLException {
try {
lineCstm.setLong(1, new Long(header_id));
lineCstm.setNull(2, java.sql.Types.VARCHAR);
lineCstm.setNull(3, java.sql.Types.VARCHAR);
lineCstm.setString(4, user_id);
lineCstm.setLong(5, rownum);
String sheetName = data.getString("sheetName");
if (sheetName == null)
lineCstm.setNull(6, java.sql.Types.VARCHAR);
else
lineCstm.setString(6, sheetName);
lineCstm.setNull(7, java.sql.Types.NUMERIC);
String valueString;
for (int i = 0; i < maxcell; i++) {
valueString = data.getString("C" + i);
if (valueString == null)
lineCstm.setNull(8 + i, java.sql.Types.VARCHAR);
else
lineCstm.setString(8 + i, valueString);
}
lineCstm.addBatch();
} catch (SQLException e) {
if (lineCstm != null)
try {
lineCstm.close();
} catch (SQLException ex) {
}
throw e;
}
}
public String getHeader_id() {
return header_id;
}
public void setHeader_id(String header_id) {
this.header_id = header_id;
}
public String getSeparator() {
return separator;
}
public void setSeparator(String separator) {
this.separator = separator;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getJob_id() {
return job_id;
}
public void setJob_id(String job_id) {
this.job_id = job_id;
}
public String getAttribute1() {
return attribute1;
}
public void setAttribute1(String attribute1) {
this.attribute1 = attribute1;
}
public String getAttribute2() {
return attribute2;
}
public void setAttribute2(String attribute2) {
this.attribute2 = attribute2;
}
public String getAttribute3() {
return attribute3;
}
public void setAttribute3(String attribute3) {
this.attribute3 = attribute3;
}
public String getAttribute4() {
return attribute4;
}
public void setAttribute4(String attribute4) {
this.attribute4 = attribute4;
}
public String getAttribute5() {
return attribute5;
}
public void setAttribute5(String attribute5) {
this.attribute5 = attribute5;
}
public String getMaxFileSize() {
return maxFileSize;
}
public void setMaxFileSize(String maxFileSize) {
this.maxFileSize = maxFileSize;
}
public static void main(String[] args) throws Exception {
ImportExcel importExcel = new ImportExcel(null);
InputStream is = new FileInputStream(
"/Volumes/MacintoshHD/download/a.xls");
importExcel.parseFile(is, ".xls", importExcel);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.hand.hls.hlcm.importexcel.mapper.ImportExcelMapper">
<sql id="values">
<foreach item="item" collection="values" separator="," >
#{item}
</foreach>
</sql>
<insert id="insertInterfaceLine" parameterType="Map" >
insert into fnd_interface_lines (line_id,
<foreach collection="columns" item="listItem" separator=",">
${listItem}
</foreach>
)
values (fnd_interface_lines_s.nextval,<include refid="values"/> )
</insert>
<insert id="insertInterfaceHead" parameterType="Map" >
insert into fnd_interface_headers
(header_id,
template_code,
job_id,
status,
created_by,
creation_date,
last_updated_by,
last_update_date,
attribute_1,
attribute_2,
attribute_3,
attribute_4,
attribute_5,
file_name)
values
(#{headId},
#{templateCode},
#{jobId},
#{status},
#{userId},
sysdate,
#{userId},
sysdate,
#{attribute_1},
#{attribute_2},
#{attribute_3},
#{attribute_4},
#{attribute_5},
#{file_name})
</insert>
<select id="getHeadId" resultType="java.lang.Long">
select
fnd_interface_headers_s.nextval
from dual
</select>
<select id="updateJournalData" parameterType="Map" statementType="CALLABLE">
call hl_sbo_inf_pkg.update_hls_sbo_num(p_header_id => #{headId,mode=IN},p_user_id => #{userId,mode=IN})
</select>
</mapper>
\ No newline at end of file
......@@ -16,6 +16,7 @@
Where cc1.contract_id = t1.contract_id
And cc1.due_date <= Sysdate
And cc1.cf_item In (1, 8, 9)
and cc1.cf_status='RELEASE'
And cc1.write_off_flag <> 'FULL'
And cc1.due_date = t1.min_overdue_date) min_overdue_times
FROM (SELECT
......@@ -87,6 +88,7 @@
AND gwo.cf_item IN (1, 8, 250)
and gwo.cf_item = ccw.cf_item
and gwo.times = ccw.times
and ccw.cf_status='RELEASE'
and gwo.contract_id = ccw.contract_id
AND trunc(ccw.due_date) <= trunc(SYSDATE)), 0) account_due_amount,
......@@ -129,6 +131,7 @@
FROM con_contract_cashflow ccc
WHERE ccc.contract_id = cc.contract_id
AND ccc.due_amount > 0
and ccc.cf_status = 'RELEASE'
AND ccc.due_date <= sysdate
AND ccc.cf_item in (1, 8, 9)
AND ccc.write_off_flag <> 'FULL') min_overdue_date,
......@@ -137,12 +140,14 @@
(SELECT SUM(nvl(ccc.received_amount, 0))
FROM con_contract_cashflow ccc
WHERE ccc.contract_id = cc.contract_id
and ccc.cf_status = 'RELEASE'
AND ccc.cf_item IN
(1, 8, 250)) business_received_amount,
--营业未收租金
(SELECT SUM(ccc.due_amount - nvl(ccc.received_amount, 0))
FROM con_contract_cashflow ccc
WHERE ccc.contract_id = cc.contract_id
and ccc.cf_status = 'RELEASE'
AND ccc.cf_item IN (1, 8, 250)
) business_unreceived_amount,
--会计已收租金
......@@ -273,10 +278,10 @@
<bm:query-field name="contract_number"
queryExpression="contract_number like &apos;%&apos;|| ${@contract_number} ||&apos;%&apos;"/>
<!--<bm:query-field name="bp_id_tenant" queryExpression="t1.bp_id_tenant = ${@bp_id_tenant}"/>-->
<bm:query-field name="bp_id_tenant_desc" queryExpression="t1.bp_id_tenant_desc like ${@bp_id_tenant_desc}"/>
<bm:query-field name="bp_id_tenant_desc" queryExpression="t1.bp_id_tenant_desc like &apos;%&apos;|| ${@bp_id_tenant_desc} ||&apos;%&apos;"/>
<!-- <bm:query-field name="contract_name" queryExpression="t1.contract_name like ${@contract_name} "/>-->
<bm:query-field name="project_number" queryExpression="t1.project_number like ${@project_number}"/>
<bm:query-field name="bp_id_agent_desc" queryExpression="t1.bp_id_agent_desc like ${@bp_id_agent_desc}"/>
<bm:query-field name="bp_id_agent_desc" queryExpression="t1.bp_id_agent_desc like &apos;%&apos;|| ${@bp_id_agent_desc}||&apos;%&apos;"/>
<!-- <bm:query-field name="lease_start_date_from" queryExpression="t1.inception_of_lease &gt;=to_date(${@lease_start_date_from},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="lease_start_date_to" queryExpression="t1.inception_of_lease &lt;=to_date(${@lease_start_date_to},&apos;yyyy-mm-dd&apos;)"/>
-->
......
......@@ -58,7 +58,7 @@
<!-- <bm:query-field name="due_date_to" queryExpression="t.due_date between nvl(to_date(${@due_date_from},'yyyy-mm-dd'),t.due_date) and to_date(${@due_date_to},'yyyy-mm-dd')"/>-->
<bm:query-field name="cf_item" queryExpression="t.cf_item = ${@cf_item}"/>
<bm:query-field name="deposit_flag"
queryExpression="((nvl(${@deposit_flag},'N') = 'Y' and cf_item in (1,8,9,200,11)) or (nvl(${@deposit_flag},'N') = 'N'))"/>
queryExpression="((nvl(${@deposit_flag},'N') = 'Y' and cf_item in (1,8,9,200,11,250)) or (nvl(${@deposit_flag},'N') = 'N'))"/>
<bm:query-field name="due_date_from"
queryExpression="due_date &gt;= to_date(${@due_date_from},&apos;yyyy-mm-dd&apos;)"/>
<bm:query-field name="due_date_to"
......
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="execute">
<bm:update-sql><![CDATA[
begin
hl_sbo_inf_pkg.update_hls_sbo_num(p_header_id =>${@header_id},
p_user_id =>${/session/@user_id});
end;
]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
......@@ -498,14 +498,16 @@
if(record.get('transaction_type') == 'ADVANCE_RECEIPT'||record.get('transaction_type') == 'DEPOSIT'){
header_id = record.get('source_csh_trx_id');
}
var url = $('transaction_downloadFile_id').getUrl() + '?table_name=CSH_TRANSACTION&header_id=' + header_id;
var win = new Leaf.Window({
url: url,
title: '${l:HLS.SUPPORTING_DOCUMENT}',
id: 'transaction_downFile_winid',
width: 850,
height: 400
});
if(header_id){
var url = $('transaction_downloadFile_id').getUrl() + '?table_name=CSH_TRANSACTION&header_id=' + header_id;
var win = new Leaf.Window({
url: url,
title: '${l:HLS.SUPPORTING_DOCUMENT}',
id: 'transaction_downFile_winid',
width: 850,
height: 400
});
}
// win.on('close', function () {
// window.location.href = $('csh_transaction_receipt_id').getUrl();
// // var url = $('csh_transaction_receipt_id').getUrl();
......@@ -518,7 +520,7 @@
}
function attachment_rendered() {
return '<a href="javascript:attachment_upload()"><span style="color:red;">附件上传</span></a>';
return '<a href="javascript:attachment_upload()"><span style="color:red;">附件查看</span></a>';
}
function csh531_add_fun(ds, record, index) {
......@@ -941,7 +943,7 @@
bindTarget="csh_transaction_receipt_write_off_detail_ds" readOnly="true"/>
</a:box>
<a:box column="3" labelWidth="100">
<a:label prompt="附件上传" colspan="2" bindTarget="csh_transaction_receipt_write_off_detail_ds"
<a:label prompt="附件查看" colspan="2" bindTarget="csh_transaction_receipt_write_off_detail_ds"
renderer="attachment_rendered" width="370"/>
<a:numberField name="for_allocate_amount" renderer="Leaf.formatMoney" prompt="剩余可分配金额" readOnly="true" bindTarget="csh_transaction_receipt_write_off_detail_ds" />
</a:box>
......
......@@ -142,7 +142,7 @@
fullScreen: true
});
win.on('close', function () {
ds.query(ds.currentPage);
$('csh_transaction_receipt_maintain_result_ds').query($('csh_transaction_receipt_maintain_result_ds').currentPage);
});
},
failure: function () {
......@@ -161,23 +161,48 @@
var ds = $('csh_transaction_receipt_maintain_result_ds');
var record = ds.findById(id);
var bp_category = record.get('bp_category');
var status = record.get('confirmed_flag');
var write_off_flag = record.get('write_off_flag');
var readOnly = 'N';
var interfaceQueryFlag = 'Y';
var paid_byother_flag = record.get('paid_byother_flag');
var transaction_type = record.get('transaction_type');
var depositDisplayFlag = 'N';
var advanceDisplayFlag = 'N';
var confirmed_flag = record.get('confirmed_flag');
var interfaceQueryFlag = 'N';
// if (bp_category == 'AGENT') {
// depositDisplayFlag = 'Y';
// }
if (confirmed_flag == 'WF_APPROVING') {
interfaceQueryFlag = 'Y';
}
var approval_flag = '${/model/result_position/record/@approval_enbale}' || 'N';
if (approval_flag == 'Y') {
readOnly = 'Y';
if (status == 'APPROVED') {
interfaceQueryFlag = 'N';
}
} else {
if (write_off_flag == 'FULL') {
readOnly = 'Y';
interfaceQueryFlag = 'N';
} else {
if (status == 'WF_APPROVING') {
readOnly = 'Y';
}
}
}
if (status != 'WF_APPROVING') {
approval_flag = 'N';
}
if (transaction_type != 'ADVANCE_RECEIPT' && transaction_type != 'DEPOSIT') {
advanceDisplayFlag = 'Y';
} else {
if (paid_byother_flag == 'Y') {
depositDisplayFlag = 'Y';
}
}
Leaf.Masker.mask(Ext.getBody(), '正在执行...');
Leaf.request({
url: $('check_csh_transaction_status_link_id').getUrl(),
para: {
contract_id: record.get('contract_id')
transaction_id: record.get('transaction_id')
},
success: function () {
Leaf.Masker.unmask(Ext.getBody());
......@@ -185,9 +210,9 @@
var win = new Leaf.Window({
id: 'csh_write_off_upload_window',
params: {
deposit_flag:'Y',
transaction_id: record.get('transaction_id'),
depositDisplayFlag: depositDisplayFlag,
advanceDisplayFlag: advanceDisplayFlag,
bank_slip_num: record.get('bank_slip_num'),
company_id: record.get('company_id'),
transaction_date: Leaf.formatDate(record.get('transaction_date')),
......@@ -196,9 +221,10 @@
bp_bank_account_num: record.get('bp_bank_account_num'),
bp_bank_account_name: record.get('bp_bank_account_name'),
bp_id: record.get('bp_id'),
advanceDisplayFlag: advanceDisplayFlag,
readOnly: readOnly,
approval_flag: approval_flag,
interfaceQueryFlag: interfaceQueryFlag,
approval_flag: approval_flag,
winid: 'csh_write_off_upload_window'
},
......@@ -207,7 +233,7 @@
fullScreen: true
});
win.on('close', function () {
ds.query(ds.currentPage);
$('csh_transaction_receipt_maintain_result_ds').query($('csh_transaction_receipt_maintain_result_ds').currentPage);
});
},
failure: function () {
......@@ -219,19 +245,12 @@
scope: this
});
}
function csh531n_detail_renderer(value, record, name) {
var text = '';
var status = record.get('confirmed_flag');
var write_off_flag = record.get('write_off_flag');
var readOnly = 'N';
if ((status == 'WF_APPROVING' || status == 'WF_APPROVED') && write_off_flag != 'FULL') {
readOnly = 'Y';
}
if (name == 'csh531n_detail') {
return '<a href="Javascript:csh531n_open_write_off_detail(' + record.id + ',\'' + readOnly + '\')">明细</a>';
} else if (name == 'transaction_num') {
if (name == 'transaction_num') {
return '<a href="Javascript:csh531n_open_write_off_detail(' + record.id + ',\'' + readOnly + '\')">' + value + '</a>';
}
}
......@@ -518,9 +537,9 @@
<a:button click="csh510_export" text="导出"/>
</a:toolBar>-->
<a:columns>
<a:column name="transaction_num" prompt="CSH510.CSH_TRANSACTION.CSH_TRANSACTION_NUM" width="110"
align="center"/>
<!--<a:column name="transaction_num" prompt="CSH510.CSH_TRANSACTION.CSH_TRANSACTION_NUM" renderer="csh531n_detail_renderer" width="110" align="center"/>-->
<!-- <a:column name="transaction_num" prompt="CSH510.CSH_TRANSACTION.CSH_TRANSACTION_NUM" width="110"-->
<!-- align="center"/>-->
<a:column name="transaction_num" prompt="CSH510.CSH_TRANSACTION.CSH_TRANSACTION_NUM" renderer="csh531n_detail_renderer" width="110" align="center"/>
<a:column name="bp_name" prompt="代理店/厂商" align="center"/>
<a:column name="bp_id_telnet_n" prompt="承租人" align="center"/>
<a:column name="contract_number" prompt="合同编号" align="center"/>
......
......@@ -22,6 +22,7 @@
<a:link id="hls301_send_data" url="${/request/@context_path}/modules/hls/HLS301/hls_journal_send.lsc"/>
<a:link id="hls301_send_data_splice_id" model="hls.HLS301.hls_journal_post_to_sbo" modelaction="update"/>
<a:link id="hls301_send_bp_to_sbo" model="hls.HLS301.hls_bp_post_to_sbo" modelaction="update"/>
<a:link id="hls301_improt_sbo_num_link" url="${/request/@context_path}/modules/hls/HLS301/hls_sbo_import_upload.lview"/>
<script><![CDATA[
function lock_current_window2(msg) {
Leaf.Masker.mask(Ext.getBody(), msg);
......@@ -373,6 +374,22 @@
}
return '';
}
function hls301_improt_sbo_num() {
var win = new Leaf.Window({
id: 'hls301_improt_sbo_num_window',
params: {
winid:'hls301_improt_sbo_num_window'
},
url: $('hls301_improt_sbo_num_link').getUrl(),
title: '导入替换凭单号',
width: 430,
height: 300
});
win.on('close', function() {
$('hls_journal_header_result_ds').query();
});
}
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
<a:dataSets>
......@@ -470,6 +487,7 @@
<a:toolbarButton click="hls301_journal_query" text="HLS.QUERY"/>
<a:toolbarButton click="hls301_journal_send" text="凭证传输"/>
<a:toolbarButton click="hls301_bp_send" text="商业伙伴传输"/>
<a:toolbarButton click="hls301_improt_sbo_num" text="导入替换凭单号"/>
<!--<a:toolbarButton click="hls301_journal_import" text="批量导入"/>
<a:toolbarButton click="hls301_sap_transafer" text="转换为SAP凭证"/>
<a:toolbarButton click="hls301_sap_send" text="发送SAP凭证"/> -->
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: lpc 9874
$Date: $
$Revision: 1.0 $
$Purpose:
-->
<a:service xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" xmlns:p="uncertain.proc" trace="true">
<a:init-procedure>
<p:echo></p:echo>
<a:model-query model="basic.hls_fnd_attribute_sequence" rootPath="header"/>
<!-- <a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="HLCM_SBO_REPLACE" user_id="${/session/@user_id}"/>-->
<a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="HLCM_SBO_REPLACE" user_id="${/session/@user_id}"/>
<a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;HLCM_SBO_REPLACE&apos;" model="basic.hls_fnd_attribute_status" rootPath="status"/>
<!-- <s:server-script><![CDATA[-->
<!-- println($ctx.parameter.toXML());-->
<!-- println(${/model/header/record/@header_id});-->
<!-- var hls_sbo_import_update_bm = $bm('hls.HLS301.hls_sbo_import');-->
<!-- hls_sbo_import_update_bm.execute({-->
<!-- header_id: ${/model/header/record/@header_id}-->
<!-- });-->
<!-- ]]></s:server-script>-->
</a:init-procedure>
<a:service-output output="/parameter"/>
</a:service>
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application">
<a:init-procedure>
</a:init-procedure>
<a:view>
<script><![CDATA[
var header = $jq('meta[name=_csrf_header]').attr('content');
var token = $jq('meta[name=_csrf]').attr('content');
$jq(document).ajaxSend(function (e, xhr, options) {
xhr.setRequestHeader(header, token);
});
function saveClick() {
if (document.getElementById('importFile').value) {
var fileName = document.getElementById('importFile').value;
var fileType = fileName.substr(fileName.lastIndexOf("."));
if (fileType != '.xls' && fileType != '.xlsx') {
alert('${l:SELECT_CORRECT_IMPORT_FILE}');
} else {
var formData = new FormData(document.getElementById('importForm'));
formData.append("session_id",${/session/@session_id});
formData.append("template_code", 'HLCM_SBO_REPLACE');
// var formData = new FormData(document.getElementById('importForm'));
Leaf.Masker.mask(Ext.getBody(), '正在导入模板。。。');
$jq.ajax({
url: '${/request/@context_path}/hls/importExcel/import',
type: 'post',
processData: false,
contentType: false,
data: formData,
success: function (res) {
Leaf.Masker.unmask(Ext.getBody());
// Leaf.Masker.unmask(Ext.getBody());
// $('${/parameter/@winid}').close();
if (res.success) {
// document.getElementById('importForm').submit();
Leaf.SideBar.show({
msg: '保存成功',
duration: 2000
});
$('${/parameter/@winid}').close();
} else {
Leaf.showErrorMessage('提示', res.error.message);
}
},
failure: function (res) {
Leaf.Masker.unmask(Ext.getBody());
Leaf.showErrorMessage('提示', res.message);
},
error: function (res) {
Leaf.Masker.unmask(Ext.getBody());
Leaf.showErrorMessage('提示', res.message);
}
});
}
} else {
Leaf.showMessage('${l:PROMPT}', '未上传数据导入文件!');
}
}
function reInput() {
//重置修改后的文件
var file = document.getElementById('importFile');
file.value = "";
}
]]></script>
<a:dataSets>
<a:dataSet id="label_ds" autoCreate="true">
<a:fields>
<a:field name="label2" defaultValue="${l:STRICT_IMPORTED_TEMPLATE_DATA}"/>
<a:field name="label3" defaultValue="${l:PRODUCT_MASTER_DATA_IMPORT}"/>
<a:field name="label4" defaultValue="${l:IMPORTER_ONLY_SUPPORTS}"/>
<a:field name="label5" defaultValue="${l:READ_THE_ABOVE_CAREFULLY}"/>
<a:field name="label6" defaultValue="${l:THE_IMPORT_IS_COMPLETE}"/>
</a:fields>
</a:dataSet>
</a:dataSets>
<a:fieldSet style="margin-left:10px;margin-top:10px;" title="IMPORT_CONSIDERATIONS" width="400">
<a:label name="label2" bindTarget="label_ds" style="margin-left:10px;" width="380"/>
<a:label name="label3" bindTarget="label_ds" style="margin-left:10px;" width="380"/>
<a:label name="label4" bindTarget="label_ds" style="margin-left:10px;" width="380"/>
<a:label name="label5" bindTarget="label_ds" style="color:#055A78;font-weight:bold;margin-left:10px;"
width="380"/>
<a:box column="2" row="1" style="margin-left:-3px;">
<a:label name="label6" bindTarget="label_ds" style="color:#055A78;font-weight:bold;margin-left:10px;"
width="266"/>
<!-- <input onclick="downloadTemp()" style="width:64px;" type="button" value="模板下载"/>-->
</a:box>
</a:fieldSet>
<a:fieldSet style="margin-left:10px;margin-top:10px;" title="TMPLT_IMPORT_FILE" width="400">
<form name="upload" id="importForm"
action="${/request/@context_path}/modules/hls/HLS301/hls_sbo_import_upload_info.lview?_csrf=${/session/@_csrf.token}"
enctype="multipart/form-data" method="post">
<label style="margin-left:10px;margin-top:10px"><![CDATA[${l:PLEASE_SELECT_A_FILE}]]></label>
<input name="content" id="importFile" style="margin-bottom:4px;width:160px;height:22px;" type="file"
onclick="reInput()"/>
<input id="hls301_upload_id" onclick="saveClick()" style="margin-left:50px;margin-top:10px;width:60px;"
type="button" value="导入"/>
<!--<input type="hidden" name="bp_id" value="" id="hiddenField" />-->
</form>
</a:fieldSet>
</a:view>
</a:screen>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: lara
$Date: 2019-1-1 下午3:48:04
$Revision: 1.0
$Purpose:
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true" xmlns:p="uncertain.proc">
<a:init-procedure>
<p:echo></p:echo>
<a:model-query model="basic.hls_fnd_attribute_sequence" rootPath="header"/>
<a:import-excel header_id="${/model/header/record/@header_id}" separator="," status_field="/parameter/@ImportSuccess" template_code="HLCM_SBO_REPLACE" user_id="${/session/@user_id}"/>
<!-- <a:import-excel header_id="" separator="," status_field="/parameter/@ImportSuccess" template_code="HLCM_SBO_REPLACE" user_id="${/session/@user_id}"/>-->
<a:model-query defaultWhereClause="header_id=${/model/header/record/@header_id} and TEMPLATE_CODE = &apos;HLCM_SBO_REPLACE&apos;" model="basic.hls_fnd_attribute_status" rootPath="status"/>
</a:init-procedure>
<a:view>
<a:link id="hls_sbo_save_data_link" model="hls.HLS301.hls_sbo_import" modelaction="execute"/>
<a:link id="hls_journal_query_link" url="${/request/@context_path}/modules/hls/HLS301/hls_journal_query.lview"/>
<script><![CDATA[
function success() {
Leaf.showInfoMessage('${l:HLS.PROMPT}', '导入成功', function callback() {
window.location.href =$('hls_journal_query_link').getUrl();
});
}
function loadComplete() {
if ('${/model/status/record/@status}' == 'NEW') {
Leaf.Masker.mask(Ext.get(document.documentElement), '正在更新数据。。。');
var param = {};
param['header_id'] = '${/model/header/record/@header_id}';
param['user_id'] = '${/session/@user_id}';
Leaf.request({
url: $('hls_sbo_save_data_link').getUrl(),
para: param,
success: function() {
Leaf.Masker.unmask(Ext.get(document.documentElement));
// Leaf.SideBar.show({
// msg: '导入成功!',
// duration: 2000
// });
success();
// window.location.href = $('hls_journal_query_link').getUrl();
},
error: function() {
},
failure: function() {},
scope: this
});
} else {
//Ext.get('success_form').setStyle('display', 'none');
Ext.get('failure_form').setStyle('visibility', 'visible');
}
}
]]></script>
<a:dataSets>
<a:dataSet id="error_ds">
<a:fields>
<a:field name="import_field_1" prompt="import_field_1"/>
<a:field name="import_field_2" prompt="import_field_2"/>
<a:field name="import_field_3" prompt="import_field_3"/>
</a:fields>
</a:dataSet>
</a:dataSets>
<a:screenBody>
<a:form id="failure_form" height="400" style="visibility:hidden" title="ERROR_MESSAGE" width="980">
<a:grid bindTarget="error_ds" height="340" navBar="true" width="980">
<a:columns>
<a:column name="import_field_1"/>
<a:column name="import_field_2"/>
<a:column name="import_field_3"/>
</a:columns>
</a:grid>
</a:form>
</a:screenBody>
<script><![CDATA[
loadComplete();
]]></script>
</a:view>
</a:screen>
......@@ -3,7 +3,7 @@
<a:init-procedure>
<a:model-query fetchAll="true" model="rpt.RPT5014.rpt5014_six_month" rootPath="/model/day"/>
<a:model-query fetchAll="true" model="rpt.RPT5014.rpt5014_result_query" rootPath="/model/datasource"/>
<dr:excel-report enableTask="false" filename="${/parameter/@file_name}">
<dr:excel-report enableTask="true" filename="${/parameter/@file_name}">
<dr:styles>
<dr:cell-style name="cell1" align="ALIGN_CENTER" vertical="VERTICAL_CENTER">
<dr:font bold="false" fontName="Arial" height="10"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment