nc65销售订单导入功能开发
1.在销售订单xml重添加导入按钮并且引用
<!-- 导入 -->
<bean id="saleOrderImportAction" class="nc.ui.so.m30.billui.action.SaleOrderImportAction">
<property name="model" ref="ManageAppModel" />
<property name="editor" ref="billFormEditor" />
</bean>
2.处理类
package nc.ui.so.m30.billui.action;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Pattern;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import nc.bs.framework.common.NCLocator;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.pf.IplatFormEntry;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.beans.UIFileChooser;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.ui.uif2.NCAction;
import nc.ui.uif2.model.AbstractAppModel;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.workflownote.WorkflownoteVO;
import nc.vo.pubapp.pflow.PfUserObject;
import nc.vo.so.m30.entity.SaleOrderBVO;
import nc.vo.so.m30.entity.SaleOrderHVO;
import nc.vo.so.m30.entity.SaleOrderVO;
public class SaleOrderImportAction extends NCAction {
/**
*
*/
private static final long serialVersionUID = 8846790840859243861L;
//private static String home_path = RuntimeEnv.getInstance().getNCHome();
//private static final String OBJTYPE_SALESMAN = "3";
private static final String BILLTYPE_SALESORDER = "30-06";
IUAPQueryBS iUAPQueryBS = (IUAPQueryBS)NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
HashMap<String,String> currentMap = new HashMap<String,String>();
HashMap<String,String> defdocMap = new HashMap<String,String>();
HashMap<String,String> userMap = new HashMap<String,String>();
HashMap<String,String> incomeMap = new HashMap<String,String>();
HashMap<String,String> stordocMap = new HashMap<String,String>();
HashMap<String,String> measdocMap = new HashMap<String,String>();
HashMap<String,String> busitypeMap = new HashMap<String,String>();
HashMap<String,String> userCountryMap = new HashMap<String,String>();
private String nexchangerate;
private BillForm editor;
private AbstractAppModel model;
public void setCode(String code) {
super.setCode("saleOrderImplExcelAction");
}
public SaleOrderImportAction() {
super.setCode("saleOrderImplExcelAction");
super.setBtnName("Excel导入");
}
@Override
public void doAction(ActionEvent e) throws Exception {
boolean isHead = false;
boolean isEnd = false;
String docFlag = "";
//销售订单Excel导入
try {
// String pk_UserId = InvocationInfoProxy.getInstance().getUserId();//获取当前系统登录用户
// new UFDateTime(System.currentTimeMillis());//获取当前系统时间
//构建文件选择框对象,返回用户选中的文件对象
UIFileChooser uiFile = new UIFileChooser();
uiFile.setDialogTitle("Excel数据导入");
int result = uiFile.showOpenDialog(null);//打开一个对话框
File file = uiFile.getSelectedFile();//获得地址
//当用户选择撤销时,直接返回
if(result!=0 || file==null)
return;
try {
//判断选择文件类型是否是Excel格式
String path=file.getPath();
//&& !path.endsWith(".xlsx")
if(!(path.endsWith(".xls")))
{
MessageDialog.showHintDlg(editor, "提示", "请选择Excel格式的文件!\n");
return;
}
//得到Excel文件对象
Workbook book = Workbook.getWorkbook(file);
Sheet seData= book.getSheet("Sheet1");
if(seData==null)
{
MessageDialog.showHintDlg(editor, "提示", "Excel中没有'销售订单'页签,无法完成导入,请将Excel补充完整!\n");
return;
}
//得到Excel数据总行数
int rownum = seData.getRows();
if(rownum<=0)
{
MessageDialog.showHintDlg(editor, "提示", "没有需要导入的数据\n");
return;
}
List<SaleOrderBVO> saleOrderBVOList = new ArrayList<SaleOrderBVO>();
//只有当时第一才需要给表头赋值。
SaleOrderHVO saleOrderHVO = new SaleOrderHVO();
for(int i = 1; i<rownum;i++){
String docFlagTemp = seData.getRow(i)[0].getContents().toString().trim();
String newDocFlag = seData.getRow(i)[0].getContents().toString();
String nextDocFlag = "";
if ((i+1) != rownum) {
nextDocFlag = seData.getRow(i+1)[0].getContents().toString();
}else{
nextDocFlag = "";
}
if (newDocFlag != null && !"".equals(newDocFlag.trim())) {
newDocFlag = docFlagTemp;
}
//只有当第一条和上一条不同的时候才表明他是新的一条单据.
if (!docFlag.equals(newDocFlag.trim())) {
isHead = true;
docFlag = newDocFlag.trim();
}
if (!docFlag.equals(nextDocFlag.trim())) {
isEnd = true;
}
boolean verification = verification(seData.getRow(0),seData.getRow(i),i,isHead);
if (!verification) {
return;
}
if (isHead) {
String fullSaleOrderHVOMessage = fullSaleOrderHVO(seData.getRow(i),saleOrderHVO);
if (fullSaleOrderHVOMessage != null && !"".equals(fullSaleOrderHVOMessage)) {
MessageDialog.showHintDlg(editor, "提示", "第"+(i+1)+"行:\n"+fullSaleOrderHVOMessage+"\n");
return;
}
}
SaleOrderBVO saleOrderBVO = new SaleOrderBVO();
//给表体赋值.
String fullSaleOrderBVOListMessage = fullSaleOrderBVOList(saleOrderBVO,saleOrderHVO,seData.getRow(i));
if (fullSaleOrderBVOListMessage != null && !"".equals(fullSaleOrderBVOListMessage)) {
MessageDialog.showHintDlg(editor, "提示", "第"+(i+1)+"行:\n"+fullSaleOrderBVOListMessage+"\n");
return;
}
saleOrderBVOList.add(saleOrderBVO);
if (isEnd) {
//组织生成单据需要的vo.
SaleOrderVO saleOrderVO = fullAggSaleOrderVO(saleOrderHVO,saleOrderBVOList);
//生成单据.
String createPayBillMessage = createPayBill(saleOrderVO);
if (createPayBillMessage != null && !"".equals(createPayBillMessage)) {
MessageDialog.showHintDlg(editor, "提示", "第"+(i+1)+"行:\n"+createPayBillMessage+"\n");
return;
}
//将两个初始化.
saleOrderBVOList.clear();
saleOrderHVO = new SaleOrderHVO();
}
//将两个初始化.
isHead = false;
isEnd = false;
}
MessageDialog.showHintDlg(editor, "提示","Excel导入完成!\n");
} catch (Exception e1)
{
MessageDialog.showHintDlg(editor, "提示", "Excel导入失败!错误代码:"+e1.getMessage()+"\n");
return;
}
}
catch (Exception e2) {
MessageDialog.showHintDlg(editor, "提示", "Excel导入失败!错误代码:"+e2.getMessage()+"\n");
return;
}
}
//我的方法
/**
* 每一行报一个错误.
* @param row 行数据.
* @param rownum 行号.
*/
public boolean verification(Cell[] head , Cell[] row , int rownum,boolean newBill){
boolean result = false;
StringBuilder sbMessage = new StringBuilder();
//非空校验.
for (int i = newBill?0:15 ; i < row.length; i++) {
Cell cell = row[i];
String cellVlaue = cell.getContents().toString();
if (i == 2) {
continue;
}
if (cellVlaue == null || "".equals(cellVlaue.trim())) {
sbMessage.append(head[i].getContents().toString().trim()).append(":不能为空!\n");
}
}
//字段合法性校验. 只有在是新的数据才需要校验表头.
if (newBill) {
//表头字段合法性校验.
//单据日期
String dbilldate = row[3].getContents().toString().trim();
String dateVerification = dateVerification(head[3].getContents().toString().trim(), dbilldate);
sbMessage.append(dateVerification);
//销售组织
String orgName = row[4].getContents().toString().trim();
String defDocOrgName = deptOrgVerification(head[4].getContents().toString().trim(), orgName);
sbMessage.append(defDocOrgName);
//订单类型
String ctrantypeid = row[5].getContents().toString().trim();
String billTypeMessage = billTypeVerification(head[5].getContents().toString().trim(), ctrantypeid);
sbMessage.append(billTypeMessage);
//业务流程名称
String busitypeName = row[6].getContents().toString().trim();
String busitypeNameMessage = busitypeVerification(head[6].getContents().toString().trim(), busitypeName);
sbMessage.append(busitypeNameMessage);
//类型--vdef4
/* String vdef4Name = row[7].getContents().toString().trim();
String defDocVdef4Name = defDocVerification(head[7].getContents().toString().trim(), vdef4Name);
sbMessage.append(defDocVdef4Name);*/
//客户
String ccustomerid = row[8].getContents().toString().trim();
String customeridMessage = customerVerification(head[8].getContents().toString().trim(), ccustomerid);
sbMessage.append(customeridMessage);
//部门
String cdeptvid = row[9].getContents().toString().trim();
String deptInfo = deptVerification(head[9].getContents().toString().trim(), cdeptvid);
sbMessage.append(deptInfo);
//业务员
String cemployeeid = row[10].getContents().toString().trim();
String cemployeeidEmassge = userCodeVerification(head[10].getContents().toString().trim(), cemployeeid);
sbMessage.append(cemployeeidEmassge);
//收款协议
//String cpaytermid = row[11].getContents().toString().trim();
//String incomeEmassge = incomeVerification(head[11].getContents().toString().trim(), cpaytermid);
// sbMessage.append(incomeEmassge);
//整单折扣
String ndiscountrate = row[12].getContents().toString().trim();
String numEmassge = numVerification(head[12].getContents().toString().trim(), ndiscountrate);
sbMessage.append(numEmassge);
//币种
String currentTypeCode = row[13].getContents().toString().trim();
String currencyMessage = currentTypeVerification(head[13].getContents().toString().trim(), currentTypeCode);
sbMessage.append(currencyMessage);
//折本汇率 nexchangerate
String exchangeRate = row[14].getContents().toString().trim();
String exchangeRateEmassge = numVerification(head[14].getContents().toString().trim(), exchangeRate);
sbMessage.append(exchangeRateEmassge);
}
//表体字段合法性校验.
//库存编码
String materialCode = row[16].getContents().toString().trim();
String materialEmassge = materialVerification(head[16].getContents().toString().trim(), materialCode);
sbMessage.append(materialEmassge);
//主单位
String cunitName = row[18].getContents().toString().trim();
String cunitEmassge = measdocVerification(head[18].getContents().toString().trim(), cunitName);
sbMessage.append(cunitEmassge);
//辅单位
String castunitName = row[19].getContents().toString().trim();
String castunitEmassge = measdocVerification(head[19].getContents().toString().trim(), castunitName);
sbMessage.append(castunitEmassge);
//主数量
String nnum = row[21].getContents().toString().trim();
String nnumEmassge = numVerification(head[21].getContents().toString().trim(), nnum);
sbMessage.append(nnumEmassge);
//辅数量
String nastnum = row[22].getContents().toString().trim();
String nastnumEmassge = numVerification(head[22].getContents().toString().trim(), nastnum);
sbMessage.append(nastnumEmassge);
//整单折扣
String ndiscountrateBody = row[23].getContents().toString().trim();
String ndiscountrateBodyEmassge = numVerification(head[23].getContents().toString().trim(), ndiscountrateBody);
sbMessage.append(ndiscountrateBodyEmassge);
//单品折扣
String nitemdiscountrate = row[24].getContents().toString().trim();
String nitemdiscountrateEmassge = numVerification(head[24].getContents().toString().trim(), nitemdiscountrate);
sbMessage.append(nitemdiscountrateEmassge);
//折扣额
String norigdiscount = row[25].getContents().toString().trim();
String norigdiscountEmassge = numVerification(head[25].getContents().toString().trim(), norigdiscount);
sbMessage.append(norigdiscountEmassge);
//税率
String ntaxrate = row[26].getContents().toString().trim();
String ntaxrateEmassge = numVerification(head[26].getContents().toString().trim(), ntaxrate);
sbMessage.append(ntaxrateEmassge);
//主含税单价
String norigtaxprice = row[27].getContents().toString().trim();
String norigtaxpriceEmassge = numVerification(head[27].getContents().toString().trim(), norigtaxprice);
sbMessage.append(norigtaxpriceEmassge);
//主无税单价
String nqtorigprice = row[28].getContents().toString().trim();
String nqtorigpriceEmassge = numVerification(head[28].getContents().toString().trim(), nqtorigprice);
sbMessage.append(nqtorigpriceEmassge);
//本币价税合计
String ntaxmny = row[29].getContents().toString().trim();
String ntaxmnyEmassge = numVerification(head[29].getContents().toString().trim(), ntaxmny);
sbMessage.append(ntaxmnyEmassge);
//成本单价
// String vdef15 = row[30].getContents().toString().trim();
// String vdef15Emassge = numVerification(head[30].getContents().toString().trim(), vdef15);
// sbMessage.append(vdef15Emassge);
//成本金额
// String vdef16 = row[31].getContents().toString().trim();
// String vdef16Emassge = numVerification(head[31].getContents().toString().trim(), vdef16);
// //校验 成本金额 = 成本单价*主数量
// String sumMessage = sumVerification(head[31].getContents().toString().trim(), vdef16, vdef15, nnum);
// sbMessage.append(vdef16Emassge).append(sumMessage);
//计划发货日期
String dsenddate = row[32].getContents().toString().trim();
String dateMessage = dateVerification(head[32].getContents().toString().trim(), dsenddate);
sbMessage.append(dateMessage);
//要求收货日期
String dreceivedate = row[33].getContents().toString().trim();
String dreceivedateMessage = dateVerification(head[33].getContents().toString().trim(), dreceivedate);
sbMessage.append(dreceivedateMessage);
//发货仓库
// String csendstordocid = row[34].getContents().toString().trim();
// String stordocMessage = stordocVerification(head[34].getContents().toString().trim(), csendstordocid);
// sbMessage.append(stordocMessage);
//发货库存组织
String csendstockorgvid = row[35].getContents().toString().trim();
String csendstockorgvidMessage = stockOrgVerification(head[35].getContents().toString().trim(), csendstockorgvid);
sbMessage.append(csendstockorgvidMessage);
//结算财务组织
String csettleorgvid = row[36].getContents().toString().trim();
String csettleorgvidMessage = financeOrgVerification(head[36].getContents().toString().trim(), csettleorgvid);
sbMessage.append(csettleorgvidMessage);
//批次号校验 pk_batchcode 批次档案 vbatchcode 批次号
String vbatchcode = row[20].getContents().toString().trim();
//启用了批次管理才需要去校验.没有就不需要.
if (wholemanaflag(getPkMateria(materialCode.trim()),getPkStockOrg(csendstockorgvid.trim()))) {
String vbatchcodeVidMessage = vbatchcodeVerification(head[20].getContents().toString().trim(), vbatchcode,getPkMateria(materialCode.trim()).trim());
sbMessage.append(vbatchcodeVidMessage);
}
//判断是否有错误信息.
String messageStr = sbMessage.toString();
if (messageStr != null && !"".equals(messageStr.trim())) {
MessageDialog.showHintDlg(editor, "提示", "第"+(rownum+1)+"行:\n"+messageStr);
}else{
result = true;
}
return result;
}
/**
* 判断是否是合法的数值.
* @param headName 列名.
* @param numStr 需要判断的列值.
* @return 返回错误xinx.
*/
public String numVerification(String headName , String numStr){
if (isNum(numStr.trim())) {
return "";
}else{
return headName+":请填入合法的数值!\n";
}
}
/**
* 判断是否是合法的数值.
* @param headName 列名.
* @param numStr 需要判断的列值.
* @return 返回错误xinx.
*/
public String vbatchcodeVerification(String headName , String vbatchcode,String cmaterialoid){
String pkVbatchcode = getPkVbatchcode(vbatchcode,cmaterialoid);
if (pkVbatchcode != null && !"".equals(pkVbatchcode.trim())) {
return "";
}else{
return headName+":该物料编码没有对应的该批次号!\n";
}
}
/**
* 判断是否需要校验批次号是否合法 true 需要,false 不需要.
* @param headName 列名.
* @param numStr 需要判断的列值.
* @return 返回错误xinx.
*/
public boolean wholemanaflag(String pk_material,String pk_org){
if (pk_material != null && !"".equals(pk_material.trim()) && pk_org != null && !"".equals(pk_org.trim())) {
String materialstockInfo = getMaterialstockInfo("wholemanaflag",pk_material,pk_org);
if (materialstockInfo != null && "Y".equals(materialstockInfo.trim()) && !"".equals(materialstockInfo.trim())) {
return true;
}
}
return false;
}
/**
* 获取批次pk
* @param vbatchcode 批次号.
* @param pk_material 物料pk
* @return
*/
public String getPkVbatchcode(String vbatchcode,String pk_material){
String psn_pk = "";
Object obj = null;
String sqlStr = "select PK_BATCHCODE from scm_batchcode where VBATCHCODE = '"+vbatchcode+"' and CMATERIALOID='"+pk_material+"' and nvl(dr,0) = 0";
try {
obj = iUAPQueryBS.executeQuery(sqlStr, new ColumnProcessor());
} catch (BusinessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if (obj != null ){
psn_pk = obj.toString();
}
return psn_pk;
}
/**
* 判断该物料代码是否开启了批次管理.
* @param dbName
* @param vbatchcode
* @return
*/
public String getMaterialstockInfo(String dbName , String pk_material,String pk_org){
String pkValue = "";
pkValue = getPkValue("bd_materialstock", dbName, "pk_material", pk_material," pk_org = '"+pk_org+"' ",true);
return pkValue == null?"":pkValue;
}
/**
* 校验 成本金额 = 成本单价*主数量
* @param vdef16 成本金额
* @param vdef15 成本单价
* @param nnum 主数量
* @return
*/
public String sumVerification(String headName ,String vdef16,String vdef15,String nnum){
if (isNum(vdef16.trim()) && isNum(vdef15.trim()) && isNum(nnum.trim())) {
UFDouble vdef16Double = new UFDouble(vdef16);
UFDouble vdef15Double = new UFDouble(vdef15);
UFDouble nnumDouble = new UFDouble(nnum);
UFDouble sum = vdef15Double.multiply(nnumDouble);
if (sum.setScale(2, UFDouble.ROUND_HALF_UP).equals(vdef16Double.setScale(2, UFDouble.ROUND_HALF_UP))) {
return "";
}else{
return headName+":成本金额 != 成本单价*主数量\n";
}
}
return "";
}
/**
* 判断币种是否合法.
* @param headName
* @param currentType
* @return
*/
public String currentTypeVerification(String headName , String currentType){
String pk_currentType = "";
pk_currentType = getCurrentType(currentType.trim());
if (!"".equals(pk_currentType.trim())) {
return "";
}else{
return headName+":填入的币种类型不存在!\n";
}
}
/**
* 判断自定义档案是否合法.
* @param headName
* @param currentType
* @return
*/
public String defDocVerification(String headName , String defDocName){
String pk_defDoc = "";
pk_defDoc = getDefdoc(defDocName.trim());
if (!"".equals(pk_defDoc.trim())) {
return "";
}else{
return headName+":填入的类型不存在!\n";
}
}
/**
* 部门组织名称是否合法.
* @param headName
* @param currentType
* @return
*/
public String deptOrgVerification(String headName , String deptOrgName){
String pk_deptOrg = "";
pk_deptOrg = getPkDeptOrg(deptOrgName.trim());
if (!"".equals(pk_deptOrg.trim())) {
return "";
}else{
return headName+":填入的信息不存在!\n";
}
}
/**
* 判断订单是否合法.
* @param headName
* @param currentType
* @return
*/
public String billTypeVerification(String headName , String billTypeName){
String pk_billType = "";
pk_billType = getBillType(billTypeName.trim());
if (!"".equals(pk_billType.trim())) {
return "";
}else{
return headName+":填入的类型不存在!\n";
}
}
/**
* 判断业务流程名称是否合法.
* @param headName
* @param busitypeName
* @return
*/
public String busitypeVerification(String headName , String busitypeName){
String pk_busitype = "";
pk_busitype = getPkBusitype(busitypeName.trim());
if (!"".equals(pk_busitype.trim())) {
return "";
}else{
return headName+":填入的类型不存在!\n";
}
}
/**
* 判断业务员编码是否合法.
* @param headName
* @param userCode
* @return
*/
public String userCodeVerification(String headName , String userCode){
String pk_user = "";
pk_user = getPkUser(userCode.trim());
if (!"".equals(pk_user.trim())) {
return "";
}else{
return headName+":填入的业务员不存在!\n";
}
}
/**
* 判断日期格式是否合法.
* @param headName
* @param dateStr
* @return
*/
public String dateVerification(String headName , String dateStr){
if (!"".equals(isDate(dateStr.trim()))) {
return "";
}else{
return headName+":日期格式不对!\n";
}
}
/**
* 判断客户信息是否存在.
* @param headName
* @param customerCode 客户编码.
* @return
*/
public String customerVerification(String headName , String customerCode){
if (!"".equals(getPkCustomer(customerCode.trim()))) {
return "";
}else{
return headName+":客户不存在!\n";
}
}
/**
* 判断部门是否存在.
* @param headName 列名
* @param deptCode 部门编码
* @return
*/
public String deptVerification(String headName , String deptCode){
if (!"".equals(getPkDept(deptCode.trim()))) {
return "";
}else{
return headName+":该部门不存在!\n";
}
}
/**
* 判断组织是否存在.
* @param headName 列名
* @param orgCode 组织编码
* @return
*/
public String orgVerification(String headName , String orgCode){
if (!"".equals(getPkOrg(orgCode.trim()))) {
return "";
}else{
return headName+":该组织不存在!\n";
}
}
/**
* 判断组织是否存在.
* @param headName 列名
* @param orgCode 组织编码
* @return
*/
public String financeOrgVerification(String headName , String orgCode){
if (!"".equals(getPkFinanceOrg(orgCode.trim()))) {
return "";
}else{
return headName+":该组织不存在!\n";
}
}
/**
* 判断库存组织是否存在.
* @param headName 列名
* @param orgCode 组织编码
* @return
*/
public String stockOrgVerification(String headName , String orgCode){
if (!"".equals(getPkStockOrg(orgCode.trim()))) {
return "";
}else{
return headName+":该库存组织不存在!\n";
}
}
/**
* 判断发货仓库是否存在.
* @param headName 列名
* @param stordocName 发货厂库名称.
* @return
*/
public String stordocVerification(String headName , String stordocName){
if (!"".equals(getStordoc(stordocName.trim()))) {
return "";
}else{
return headName+":该发货仓库不存在!\n";
}
}
/**
* 判断库存编码是否存在.
* @param headName 列名
* @param materialCode 库存编码.
* @return
*/
public String materialVerification(String headName , String materialCode){
StringBuilder sb = new StringBuilder("");
//校验库存组织 是否存在.
if (!"".equals(getPkMateria(materialCode.trim()))) {
//校验税收国家是否存在.
String reptaxcountry = getCmaterialvInfo("td.reptaxcountry" , materialCode);
if (reptaxcountry == null || "".equals(reptaxcountry.trim())) {
sb.append(headName+":该库存编码对应的报税国家不存在!\n");
}
//校验税码是否存在.
String pk_taxcode = getCmaterialvInfo("td.pk_taxcode" , materialCode);
if (pk_taxcode == null || "".equals(pk_taxcode.trim())) {
sb.append(headName+":该库存编码对应的税码不存在!\n");
}
}else{
sb.append(headName+":该库存编码不存在!\n");
}
return sb.toString();
}
/**
* 判断单位是否存在.
* @param headName 列名
* @param measdocName 单位名称.
* @return
*/
public String measdocVerification(String headName , String measdocName){
if (!"".equals(getPkMeasdoc(measdocName.trim()))) {
return "";
}else{
return headName+":该库存编码不存在!\n";
}
}
/**
* 判断收款协议是否存在.
* @param headName 列名
* @param incomeCode 收款协议编码
* @return
*/
public String incomeVerification(String headName , String incomeCode){
if (!"".equals(getPkIncome(incomeCode.trim()))) {
return "";
}else{
return headName+":该收款协议不存在!\n";
}
}
/**
* 获得币种pk.
* @param currentType
* @return
*/
public String getCurrentType(String currentType){
String pkValue = "";
if (currentMap.get(currentType) != null) {
return currentMap.get(currentType);
}else{
pkValue = getPkValue("bd_currtype", "PK_CURRTYPE", "CODE", currentType,null,true);
if (pkValue != null && !"".equals(pkValue.trim())) {
currentMap.put(currentType, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得档案pk.
* @param defdocName
* @return 返回pk值.
*/
public String getDefdoc(String defdocName){
String pkValue = "";
if (defdocMap.get(defdocName) != null) {
return defdocMap.get(defdocName);
}else{
pkValue = getPkValue("bd_defdoc", "PK_DEFDOC", "name", defdocName,null,true);
if (pkValue != null && !"".equals(pkValue.trim())) {
defdocMap.put(defdocName, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 部门组织pk.
* @param deptOrgName
* @return 返回pk值.
*/
public String getPkDeptOrg(String deptOrgName){
String pkValue = "";
pkValue = getPkValue("org_salesorg", "PK_SALESORG", "name", deptOrgName,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得档案中组织对应的组织pk.
* @param defdocName
* @return 返回pk值.
*/
public String getDefdocPKOrg(String defdocName){
String pkValue = "";
pkValue = getPkValue("bd_defdoc", "PK_ORG", "name", defdocName,null,true);
return pkValue == null?"":pkValue;
}
/**
* 获得单据类型pk.
* @param defdocName
* @return 返回pk值.
*/
public String getBillType(String billTypeName){
String pkValue = "";
pkValue = getPkValue("bd_billtype", "PK_BILLTYPEID", "BILLTYPENAME", billTypeName,null,false);
return pkValue == null?"":pkValue;
}
/** 获得单据类型编码.
* @param defdocName
* @return 返回pk值.
*/
public String getBillTypeCode(String billTypeName){
String pkValue = "";
pkValue = getPkValue("bd_billtype", "PK_BILLTYPECODE", "BILLTYPENAME", billTypeName,null,false);
return pkValue == null?"":pkValue;
}
/**
* 得到业务流程pK.
* @param billTypeName 业务流程名称.
* @return
*/
public String getPkBusitype(String busitypeName){
String pkValue = "";
if (busitypeMap.get(busitypeName) != null) {
return busitypeMap.get(busitypeName);
}else{
pkValue = getPkValue("bd_busitype", "PK_BUSITYPE", "BUSINAME", busitypeName,null,true);
if (pkValue != null && !"".equals(pkValue.trim())) {
busitypeMap.put(busitypeName, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得单位pk.
* @param measdocName
* @return 返回pk值.
*/
public String getPkMeasdoc(String measdocName){
String pkValue = "";
if (measdocMap.get(measdocName) != null) {
return measdocMap.get(measdocName);
}else{
pkValue = getPkValue("bd_measdoc", "PK_MEASDOC", "name", measdocName,null,true);
if (pkValue != null && !"".equals(pkValue.trim())) {
measdocMap.put(measdocName, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得发货厂库pk.
* @param stordocName
* @return 返回pk值.
*/
public String getStordoc(String stordocName){
String pkValue = "";
if (stordocMap.get(stordocName) != null) {
return stordocMap.get(stordocName);
}else{
pkValue = getPkValue("bd_stordoc", "PK_STORDOC", "name", stordocName,"ENABLESTATE = 2",true);
if (pkValue != null && !"".equals(pkValue.trim())) {
stordocMap.put(stordocName, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得人员pk.
* @param userCode 人员编码.
* @return 返回pk值.
*/
public String getPkUser(String userCode){
String pkValue = "";
if (userMap.get(userCode) != null) {
return userMap.get(userCode);
}else{
pkValue = getPkValue("bd_psndoc", "PK_PSNDOC", "code", userCode,null,true);
if (pkValue != null && !"".equals(pkValue.trim())) {
userMap.put(userCode, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得收款协议pk.
* @param incomeCode 收款协议编码.
* @return 返回pk值.
*/
public String getPkIncome(String incomeCode){
String pkValue = "";
if (incomeMap.get(incomeCode) != null) {
return incomeMap.get(incomeCode);
}else{
pkValue = getPkValue("bd_income", "PK_INCOME", "code", incomeCode,null,true);
if (pkValue != null && !"".equals(pkValue.trim())) {
incomeMap.put(incomeCode, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得客户pk.
* @param userCode 客户编码.
* @return 返回pk值.
*/
public String getPkCustomer(String customerCode){
String pkValue = "";
pkValue = getPkValue("bd_customer", "PK_CUSTOMER", "code", customerCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得客户国家pk.
* @param pk_customer 客户pk.
* @return 返回pk值.
*/
public String getPkcountry(String pk_customer){
String pkValue = "";
if (userCountryMap.get(pk_customer) != null) {
return userCountryMap.get(pk_customer);
}else{
pkValue = getPkValue("bd_customer", "pk_country", "pk_customer", pk_customer,"ENABLESTATE = 2",true);
if (pkValue != null && !"".equals(pkValue.trim())) {
userCountryMap.put(pk_customer, pkValue.trim());
}
}
return pkValue == null?"":pkValue;
}
/**
* 获得部门pk.
* @param deptCode 部门编码.
* @return 返回pk值.
*/
public String getPkDept(String deptCode){
String pkValue = "";
pkValue = getPkValue("org_dept", "PK_DEPT", "code", deptCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得财务部门pk.
* @param deptCode 部门编码.
* @return 返回pk值.
*/
public String getPkDept_V(String deptCode){
String pkValue = "";
pkValue = getPkValue("org_dept", "PK_VID", "code", deptCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 根据部门编码获得组织pk.
* @param deptCode 部门编码.
* @return 返回pk值.
*/
public String getPkOrgByDeptCode(String deptCode){
String pkValue = "";
pkValue = getPkValue("org_orgs", "PK_ORG", "code", deptCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 根据部门编码获得财务组织pk.
* @param deptCode 部门编码.
* @return 返回pk值.
*/
public String getPkOrg_VByPk_org(String pk_org){
String pkValue = "";
pkValue = getPkValue("org_orgs", "PK_VID", "PK_ORG", pk_org,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 根据组织pk获得集团pk.
* @param pk_org 组织pk.
* @return 返回pk值.
*/
public String getPkGroupByDeptCode(String pk_org){
String pkValue = "";
pkValue = getPkValue("org_orgs", "PK_GROUP", "PK_ORG", pk_org,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得存货编码pk.
* @param materiaCode 存货编码.
* @return 返回pk值.
*/
public String getPkMateria(String materiaCode){
String pkValue = "";
pkValue = getPkValue("bd_material_v", "PK_MATERIAL", "code", materiaCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得结算组织信息pk.
* @param orgCode 组织编码.
* @return 返回pk值.
*/
public String getPkFinanceOrg(String financeorgOrgCode){
String pkValue = "";
pkValue = getPkValue("org_financeorg_v", "PK_FINANCEORG", "code", financeorgOrgCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得结算组织_V信息pk.
* @param orgCode 组织编码.
* @return 返回pk值.
*/
public String getPkFinanceOrg_V(String financeorgOrgCode){
String pkValue = "";
pkValue = getPkValue("org_financeorg_v", "PK_VID", "code", financeorgOrgCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 客户收货地址pk.
* @param pk_customer 客户主键.
* @return 返回pk值.
*/
public String getPkAddressCustomer(String pk_customer){
String pkValue = "";
pkValue = getPkValue("bd_custaddress", "pk_address", "pk_customer", pk_customer,null,true);
return pkValue == null?"":pkValue;
}
/**
* 获得组织信息pk.
* @param orgCode 组织编码.
* @return 返回pk值.
*/
public String getPkOrg(String orgCode){
String pkValue = "";
pkValue = getPkValue("org_orgs", "PK_ORG", "code", orgCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得库存组织信息pk.
* @param orgCode 组织编码.
* @return 返回pk值.
*/
public String getPkStockOrg(String orgCode){
String pkValue = "";
pkValue = getPkValue("org_stockorg_v", "PK_STOCKORG", "code", orgCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 获得库存组织_V信息pk.
* @param orgCode 组织编码.
* @return 返回pk值.
*/
public String getPkStockOrg_V(String orgCode){
String pkValue = "";
pkValue = getPkValue("org_stockorg_v", "PK_VID", "code", orgCode,"ENABLESTATE = 2",true);
return pkValue == null?"":pkValue;
}
/**
* 判断一个字符串是否是合法的数字.
* @param str
* @return 是true,否false.
*/
public boolean isNum(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*.?[\\d]*$");
return pattern.matcher(str).matches();
}
/**
* 判断日期是否合法.
* @param dateStr 日期.
* @return 是true,否false.
*/
public boolean isDate(String dateStr) {
dateStr = dateStr.replaceAll("/", "-");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date parse = sdf.parse(dateStr);
} catch (Exception e) {
return false;
}
return true;
}
/**
* 转换日期类型由yyyy/mm/dd 或者 yyyy/m/d 转换成yyyy-mm-dd.
* @param dateStr 日期.
* @return 转换后的日期.
*/
public String tranDate(String dateStr) {
String format = "";
dateStr = dateStr.replaceAll("/", "-");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date parse = null;
try {
parse = sdf.parse(dateStr);
} catch (ParseException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if (parse != null) {
format = sdf.format(parse);
}
return format;
}
/**
* 根据查询条件返回pk值.
* @param tableName 表名称.
* @param pkName 主键表中字段名称.
* @param dbName 名称查询字段对应的表中字段名称.
* @param name 名称value值
* @param dbCode 编码查询字段对应的表中字段名称.
* @param code 编码value值.
* @param otherWhere 其他的一些查询条件.
* @return 返回pk值.
*/
public String getPkValue(String tableName ,String pkName , String dbName , String name , String otherWhere,boolean hasDr) {
String psn_pk = "";
StringBuilder sqlsb = new StringBuilder();
sqlsb.append("select ").append(pkName).append(" from ").append(tableName);
if (name != null && !"".equals(name.trim())) {
sqlsb.append(" where ").append(dbName).append(" = '").append(name);
}
sqlsb.append("' ");
if (otherWhere != null) {
sqlsb.append(" and ").append(otherWhere);
}
if (hasDr) {
sqlsb.append(" and dr = 0 ");
}
String sqlStr = sqlsb.toString();
if (sqlStr != null && !"".equals(sqlStr.trim())) {
Object obj = null;
try {
obj = iUAPQueryBS.executeQuery(sqlStr, new ColumnProcessor());
} catch (BusinessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if (obj != null ){
psn_pk = obj.toString();
}
}
return psn_pk;
}
/**
* 获取中国pk.
* @param orgName 销售组织名称.
* @return
*/
public String getPkCountryChina(){
String psn_pk = "";
Object obj = null;
String sqlStr = "select pk_country from bd_countryzone where code = 'CN' and nvl(dr,0) = 0";
try {
obj = iUAPQueryBS.executeQuery(sqlStr, new ColumnProcessor());
} catch (BusinessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if (obj != null ){
psn_pk = obj.toString();
}
return psn_pk;
}
/**
* 物料编码信息.
* @param cmaterialvCode 物料编码.
* @return
*/
public String getCmaterialvInfo(String dbName , String cmaterialvCode){
String psn_pk = "";
Object obj = null;
String sqlStr = "SELECT "+dbName+" FROM bd_material m left join bd_mattaxes mx ON m.pk_mattaxes = mx.pk_mattaxes "+
" left join bd_taxcode td ON mx.PK_MATTAXES = td.mattaxes left join bd_taxrate te ON td.pk_taxcode = te.pk_taxcode WHERE m.enablestate = 2 "
+" AND nvl( m.dr, 0 ) = 0 AND td.enablestate = 2 AND nvl( td.dr, 0 ) = 0 and m.code = '" + cmaterialvCode + "' ";
try {
obj = iUAPQueryBS.executeQuery(sqlStr, new ColumnProcessor());
} catch (BusinessException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
if (obj != null ){
psn_pk = obj.toString();
}
return psn_pk;
}
/**
* 填充AggregatedValueObject参数.
* @param parentVO 父类的vo.
* @param childrenVOs 子类vo的集合.
* @return AggregatedValueObject.
*/
public SaleOrderVO fullAggSaleOrderVO(SaleOrderHVO saleOrderHVO , List<SaleOrderBVO> childrenVOList){
SaleOrderVO saleOrderVO = new SaleOrderVO();
saleOrderVO.setParent(saleOrderHVO);
SaleOrderBVO [] childrenVOs = childrenVOList.toArray(new SaleOrderBVO[childrenVOList.size()]);
saleOrderVO.setChildren(SaleOrderBVO.class, childrenVOs);
return saleOrderVO;
}
/**
* 创建单据.
* @param aggPayBillVO 创建单据需要的聚合vo.
*/
public String createPayBill(SaleOrderVO saleOrderVO){
//工作项VO
WorkflownoteVO worknoteVO = null;
//用户对象
PfUserObject userObj = new PfUserObject();
HashMap businessCheckMap = new HashMap();
businessCheckMap.put("ARAP_COMMISSION_FLAG",null);
userObj.setBusinessCheckMap(businessCheckMap);
//环境参数
HashMap<String,String> eParam = new HashMap<String,String>();
eParam.put("notechecked", "notechecked"); //设置不需要走审批流.
eParam.put("nosendmessage", "nosendmessage"); //设置不需要走审批流.
IplatFormEntry IplatFormServer = NCLocator.getInstance().lookup(IplatFormEntry.class);
try {
IplatFormServer.processAction("WRITE", BILLTYPE_SALESORDER, worknoteVO, saleOrderVO, userObj, eParam);
} catch (BusinessException e) {
return e.getMessage();
}
return "";
}
/**
* 单据表头赋值.
* @param row 行数据.
* @param payBillVO 单据表头vo.
* @return 错误信息.
*/
public String fullSaleOrderHVO(Cell[] row , SaleOrderHVO saleOrderHVO){
String pk_user = WorkbenchEnvironment.getInstance().getLoginUser().getCuserid();
try{
//获取部门和组织信息.
String deptCode = row[9].getContents().toString().trim();
String orgName = row[4].getContents().toString();
String pkCustomer = getPkCustomer(row[8].getContents().toString().trim());
String ctrantypeName = row[5].getContents().toString().trim(); //订单类型名称.
String pk_org = getPkDeptOrg(orgName);
String dept_vid = getPkDept_V(deptCode);
String pk_dept = getPkDept(deptCode);
//String pk_org = getPkOrgByDeptCode(deptCode);
String org_vid = getPkOrg_VByPk_org(pk_org);
String pk_group = getPkGroupByDeptCode(pk_org);
String dbillDate = tranDate(row[3].getContents().toString().trim());
//saleOrderHVO.setCbiztypeid("0001A120000000000V77"); // 业务流程.
saleOrderHVO.setVbillcode(row[1].getContents().toString().trim());
saleOrderHVO.setVcooppohcode(row[2].getContents().toString().trim());
saleOrderHVO.setDbilldate(new UFDate(dbillDate));
saleOrderHVO.setPk_org_v(org_vid);
saleOrderHVO.setPk_org(pk_org);
saleOrderHVO.setPk_group(pk_group);
saleOrderHVO.setCtrantypeid(getBillType(ctrantypeName)); //订单类型pk
//saleOrderHVO.setVdef4(getDefdoc(row[7].getContents().toString().trim()));
saleOrderHVO.setCcustomerid(pkCustomer); //客户.
saleOrderHVO.setCdeptvid(dept_vid);
saleOrderHVO.setCdeptid(pk_dept);
saleOrderHVO.setCemployeeid(getPkUser(row[10].getContents().toString().trim()));
saleOrderHVO.setCpaytermid(getPkIncome(row[11].getContents().toString().trim()));
saleOrderHVO.setNdiscountrate(new UFDouble(row[12].getContents().toString().trim()));
saleOrderHVO.setCorigcurrencyid(getCurrentType(row[13].getContents().toString().trim())); //币种
nexchangerate = row[14].getContents().toString().trim();//折本汇率.
saleOrderHVO.setCreator(pk_user);
saleOrderHVO.setCreationtime(new UFDateTime());
saleOrderHVO.setBillmaker(pk_user);
saleOrderHVO.setCbiztypeid(getPkBusitype(row[6].getContents().toString().trim())); //业务流程
//saleOrderHVO.setChreceiveaddid("1101A120000000002ILY");
saleOrderHVO.setChreceivecustid(pkCustomer); //收货客户
saleOrderHVO.setCinvoicecustid(pkCustomer); //开票客户
//saleOrderHVO.setCsaleorderid("1101A91100000001HGP5"); //会自动赋值,赋值会报错.
saleOrderHVO.setVtrantypecode(getBillTypeCode(ctrantypeName)); //订单类型编码.
//
}catch(Exception e){
return e.getMessage();
}
return "";
}
/**
* 单据表体vo赋值.
* @param payBillItemVOList 表体vo集合.
* @param payBillItemVO 表体vo.
* @param row 行数据.
* @return
*/
public String fullSaleOrderBVOList(SaleOrderBVO saleOrderBVO ,SaleOrderHVO saleOrderHVO, Cell[] row){
try{
String nqtorigprice = row[28].getContents().toString().trim(); //主无税单价
String norigtaxprice = row[27].getContents().toString().trim(); //主含税单价
String norigtaxmny = row[29].getContents().toString().trim(); //价税合计
String nnum = row[21].getContents().toString().trim();//主数量
String vbatchcode = row[20].getContents().toString().trim(); //批次号
String cmaterialvid = row[16].getContents().toString().trim();//存货编码
String vchangerate = row[17].getContents().toString().trim(); //换算率
saleOrderBVO.setCmaterialvid(getPkMateria(cmaterialvid)); //存货编码
saleOrderBVO.setCmaterialid(getPkMateria(cmaterialvid));
saleOrderBVO.setPk_org(saleOrderHVO.getPk_org()); //组织
saleOrderBVO.setPk_group(saleOrderHVO.getPk_group()); //集团
saleOrderBVO.setVchangerate(vchangerate); //换算率
saleOrderBVO.setCunitid(getPkMeasdoc(row[18].getContents().toString().trim())); //主单位
saleOrderBVO.setCastunitid(getPkMeasdoc(row[19].getContents().toString().trim())); //辅单位
saleOrderBVO.setNnum(new UFDouble(row[21].getContents().toString().trim()).setScale(2, UFDouble.ROUND_HALF_UP)); //主数量
saleOrderBVO.setNastnum(new UFDouble(row[22].getContents().toString().trim()).setScale(2, UFDouble.ROUND_HALF_UP)); //辅数量
saleOrderBVO.setNdiscountrate(new UFDouble(row[23].getContents().toString().trim()).setScale(2, UFDouble.ROUND_HALF_UP)); //整单折扣
saleOrderBVO.setNitemdiscountrate(new UFDouble(row[24].getContents().toString().trim()).setScale(2, UFDouble.ROUND_HALF_UP)); //单品折扣
saleOrderBVO.setNorigdiscount(new UFDouble(row[25].getContents().toString().trim()).setScale(2, UFDouble.ROUND_HALF_UP)); //折扣额
saleOrderBVO.setNtaxrate(new UFDouble(row[26].getContents().toString().trim()).setScale(2, UFDouble.ROUND_HALF_UP)); //税率
saleOrderBVO.setNorigtaxprice(new UFDouble(norigtaxprice).setScale(6, UFDouble.ROUND_HALF_UP)); //主含税单价
saleOrderBVO.setNqtorigprice(new UFDouble(nqtorigprice).setScale(6, UFDouble.ROUND_HALF_UP)); //无税单价
saleOrderBVO.setNorigprice(new UFDouble(nqtorigprice).setScale(6, UFDouble.ROUND_HALF_UP)); //主无税单价
//saleOrderBVO.setVbdef14(new UFDouble(row[30].getContents().toString().trim()).setScale(6, UFDouble.ROUND_HALF_UP).toString()); //成本单价
// saleOrderBVO.setVbdef15(row[31].getContents().toString().trim()); //成本金额
saleOrderBVO.setDsenddate(new UFDate(tranDate(row[32].getContents().toString().trim()))); //计划发货日期
saleOrderBVO.setDreceivedate(new UFDate(tranDate(row[33].getContents().toString().trim()))); //要求收获日期
// saleOrderBVO.setCsendstordocid(getStordoc(row[34].getContents().toString().trim())); //发货仓库
saleOrderBVO.setCsendstockorgvid(getPkStockOrg_V(row[35].getContents().toString().trim())); //发货库存组织
saleOrderBVO.setCsettleorgvid(getPkFinanceOrg_V(row[36].getContents().toString().trim())); //结算财务组织
saleOrderBVO.setCcurrencyid(saleOrderHVO.getCorigcurrencyid());
saleOrderBVO.setNexchangerate(new UFDouble(nexchangerate).setScale(2, UFDouble.ROUND_HALF_UP));
//不需要批次管理就不赋值.
if (wholemanaflag(saleOrderBVO.getCmaterialvid(),getPkStockOrg(row[35].getContents().toString().trim()))) {
saleOrderBVO.setVbatchcode(vbatchcode); //批次号
saleOrderBVO.setPk_batchcode(getPkVbatchcode(vbatchcode,saleOrderBVO.getCmaterialvid())); // 批次档案
}
//未找到赋值方式.项目主键 项目主键 carorgvid
saleOrderBVO.setCarorgid(getPkFinanceOrg(row[36].getContents().toString().trim())); //应收组织 结算财务组织
saleOrderBVO.setCarorgvid(getPkFinanceOrg_V(row[36].getContents().toString().trim())); //应收组织_V 结算财务组织_V
saleOrderBVO.setCqtunitid(getPkMeasdoc(row[18].getContents().toString().trim()));
//saleOrderBVO.setCrececountryid("0001Z011000000079UJJ"); //收货国家
//saleOrderBVO.setCreceiveaddrid("1101A120000000002ILY");
saleOrderBVO.setCreceivecustid(saleOrderHVO.getCcustomerid());
//saleOrderBVO.setCsaleorderbid("1101A91100000001HGP6");
//saleOrderBVO.setCsaleorderid("1101A91100000001HGP5");
//saleOrderBVO.setCsendcountryid("0001Z011000000079UJJ");
saleOrderBVO.setCsendstockorgid(getPkStockOrg(row[35].getContents().toString().trim()));
saleOrderBVO.setCsettleorgid(getPkFinanceOrg(row[36].getContents().toString().trim()));
//saleOrderBVO.setCtaxcodeid("1101Z01100000003W0WX"); //税码
//saleOrderBVO.setCtaxcountryid("0001Z011000000079UJJ"); //报税国家
saleOrderBVO.setCtrafficorgid(getPkStockOrg(row[35].getContents().toString().trim())); //物流组织最新版本 发货库存组织
saleOrderBVO.setCtrafficorgvid(getPkStockOrg_V(row[35].getContents().toString().trim())); //物流组织_v 发货库存组织_V
saleOrderBVO.setBbsendendflag(UFBoolean.FALSE); //发货关闭
saleOrderBVO.setBboutendflag(UFBoolean.FALSE); //出库关闭
saleOrderBVO.setBbinvoicendflag(UFBoolean.FALSE); //开票关闭
saleOrderBVO.setNqtunitnum(new UFDouble(row[22].getContents().toString().trim()));
saleOrderBVO.setNqtorigtaxprice(new UFDouble(norigtaxprice).setScale(6, UFDouble.ROUND_HALF_UP)); //含税单价
saleOrderBVO.setNqtorigtaxnetprc(new UFDouble(norigtaxprice).setScale(6, UFDouble.ROUND_HALF_UP)); //含税净价
saleOrderBVO.setNorigtaxnetprice(new UFDouble(norigtaxprice).setScale(6, UFDouble.ROUND_HALF_UP)); //主含税净价
saleOrderBVO.setNqtorignetprice(new UFDouble(nqtorigprice).setScale(6, UFDouble.ROUND_HALF_UP)); //无税净价
saleOrderBVO.setNorignetprice(new UFDouble(nqtorigprice).setScale(2, UFDouble.ROUND_HALF_UP)); //主无税净价
saleOrderBVO.setNorigmny(new UFDouble(nqtorigprice).multiply(new UFDouble(nnum)).setScale(2, UFDouble.ROUND_HALF_UP)); //无税金额
saleOrderBVO.setNorigtaxmny(new UFDouble(norigtaxmny).setScale(2, UFDouble.ROUND_HALF_UP)); //价税合计
saleOrderBVO.setNcaltaxmny(new UFDouble(norigtaxmny).setScale(2, UFDouble.ROUND_HALF_UP)); //计税金额
saleOrderBVO.setNnetprice(new UFDouble(nqtorigprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP));//主本币无税净价
saleOrderBVO.setNtaxprice(new UFDouble(norigtaxprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP)); // 主本币含税单价
saleOrderBVO.setNtaxnetprice(new UFDouble(norigtaxprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP)); // 主本币含税净价
saleOrderBVO.setNprice(new UFDouble(nqtorigprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP)); // 主本币无税单价
saleOrderBVO.setNtaxmny(new UFDouble(norigtaxmny).multiply(new UFDouble(nexchangerate)).setScale(2, UFDouble.ROUND_HALF_UP)); //本币价税合计
saleOrderBVO.setNmny(saleOrderBVO.getNorigmny().multiply(new UFDouble(nexchangerate)).setScale(2, UFDouble.ROUND_HALF_UP)); //本币无税金额
saleOrderBVO.setNqtprice(new UFDouble(nqtorigprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP)); //本币无税单价
saleOrderBVO.setNqtnetprice(new UFDouble(nqtorigprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP)); //本币无税净价
saleOrderBVO.setNqttaxnetprice(new UFDouble(norigtaxprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP));//本币含税净价
saleOrderBVO.setNqttaxprice(new UFDouble(norigtaxprice).multiply(new UFDouble(nexchangerate)).setScale(6, UFDouble.ROUND_HALF_UP)); //本币含税单价
saleOrderBVO.setNtax(saleOrderBVO.getNtaxmny().sub(saleOrderBVO.getNmny()).setScale(2, UFDouble.ROUND_HALF_UP)); //本币税额
saleOrderBVO.setNdiscount(new UFDouble());//本币折扣额
saleOrderBVO.setNaccprice(new UFDouble());//主记账单价
saleOrderBVO.setFtaxtypeflag(1);// 扣税类别(默认:应税外加)
saleOrderBVO.setCtaxcodeid(getCmaterialvInfo("td.pk_taxcode",cmaterialvid));// 税码
saleOrderBVO.setFbuysellflag(new Integer(getCmaterialvInfo("td.pursaletype",cmaterialvid)));// 购销类型
saleOrderBVO.setCtaxcountryid(getCmaterialvInfo("td.reptaxcountry",cmaterialvid));// 报税国家 取物料编码对应的报税国.
saleOrderBVO.setCsendcountryid(getPkCountryChina());// 发货国家 中国
saleOrderBVO.setCrececountryid(getPkcountry(saleOrderHVO.getCcustomerid()));// 收货国家 客户所在国
saleOrderBVO.setFlargesstypeflag(new Integer(1)); //赠品价格分摊方式
saleOrderBVO.setFrowstatus(1); // 行状态
saleOrderBVO.setNweight(new UFDouble(0).setScale(2, UFDouble.ROUND_HALF_UP)); //重量
saleOrderBVO.setVqtunitrate(vchangerate); //报价换算率
saleOrderBVO.setCreceiveaddrid(getPkAddressCustomer(saleOrderHVO.getCcustomerid())); //客户收货地址 bd_custaddress
//赠品价税合计=0 赋Y 相反赋N
if ((new UFDouble(0.00).setScale(2, UFDouble.ROUND_HALF_UP)).equals(saleOrderBVO.getNorigtaxmny())) { //blargessflag
saleOrderBVO.setBlargessflag(UFBoolean.TRUE);
}else{
saleOrderBVO.setBlargessflag(UFBoolean.FALSE);
}
}catch(Exception e){
return e.getMessage();
}
return "";
}
//下面是导入的默认操作
/**
*
* @return BillForm
*/
public BillForm getEditor() {
return this.editor;
}
public AbstractAppModel getModel() {
return this.model;
}
/**
*
* @param editor
*/
public void setEditor(BillForm editor) {
this.editor = editor;
}
public void setModel(AbstractAppModel model) {
this.model = model;
}
}
3. 提供一个模板 ,根据第一列行号来区分条数
单据标识 | 销售订单号 | 客户订单号 | 单据日期 | 销售组织 | 订单类型 | 业务流程名称 | *** | 客户 | 部门 | 业务员 | 收款协议 | 整单折扣 | 币种 | 折本汇率 | 行号 | 存货编码 | 换算率 | 主单位 | 辅单位 | 批次号 | 主数量 | 辅数量 | 整单折扣 | 单品折扣 | 折扣额 | 税率 | 主含税单价 | 主无税单价 | 价税合计 | *** | *** | 计划发货日期 | 要求收货日期 | 发货仓库 | 发货库存组织 | 结算财务组织 | |||||||||||||
1 | FH-0055-1905-0755 | 2020-2-1 | 株洲宏达电子股份有限公司 | 军品期初销售业务流程 | 军品期初销售业务流程 | ~ | 2030546 | HD06 | LXYING | ~ | 100 | CNY | 1.00 | 1 | 050203020142 | 1/1 | 千克 | 千克 | 9999 | 20 | 20 | 100 | 100 | 0 | 13 | 40 | 11 | 800 | ~ | ~ | 2020/2/5 | 2020/2/5 | ~ | 1001 | 1001 | ||||||||||||||
1 | FH-0055-1905-0755 | 2020-2-1 | 株洲宏达电子股份有限公司 | 军品期初销售业务流程 | 军品期初销售业务流程 | ~ | 2030546 | HD06 | LXYING | ~ | 100 | CNY | 1.00 | 2 | 050203006849 | 1/1 | 千克 | 千克 | 9999 | 200 | 200 | 100 | 100 | 0 | 13 | 40 | 21 | 8000 | ~ | ~ | 2020/2/5 | 2020/2/5 | ~ | 1001 | 1001 |