yaoyu 1 year ago
parent
commit
74df5da6f7

+ 40 - 21
mmpac/mmpac/src/client/u8c/ui/mmpac/action/ToSaleOutDialog.java

@@ -311,11 +311,11 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 		if(null!=orderinvos && orderinvos.size()>0) {
 			for(OrderInVO invo:orderinvos) {
 				UFDouble num = invo.getNum() == null ? new UFDouble(0) : invo.getNum();
-				UFDouble execnum = invo.getExecnum() == null ? new UFDouble(0) : invo.getExecnum();
-				if(num.sub(execnum).compareTo(UFDouble.ZERO_DBL)==0) {
+				UFDouble bdef8 = invo.getBdef8()== null ? UFDouble.ZERO_DBL :new UFDouble(invo.getBdef8());//销售出库已执行主数量
+				if(num.sub(bdef8).compareTo(UFDouble.ZERO_DBL)==0) {
 					continue;
 				}
-				invo.setBdef5(num.sub(execnum).toString());
+				invo.setBdef5(num.sub(bdef8).toString());
 				invos.add(invo);
 			}
 			
@@ -327,14 +327,14 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 				//执行完的表体在生单界面不展示
 				OrderInVO invo = (OrderInVO) vo;
 				UFDouble num = invo.getNum() == null ? new UFDouble(0) : invo.getNum();
-				UFDouble execnum = invo.getExecnum() == null ? new UFDouble(0) : invo.getExecnum();
+				UFDouble bdef8 = invo.getBdef8() == null ?UFDouble.ZERO_DBL : new UFDouble(invo.getBdef8());
 //				if(num.equals(execnum) && num.equals(new UFDouble(0))) {
 //					continue;
 //				}
-				if(num.sub(execnum).compareTo(UFDouble.ZERO_DBL)==0) {
+				if(num.sub(bdef8).compareTo(UFDouble.ZERO_DBL)==0) {
 					continue;
 				}
-				invo.setBdef5(num.sub(execnum).toString());
+				invo.setBdef5(num.sub(bdef8).toString());
 				invos.add(invo);
 			}
 		}
@@ -397,7 +397,7 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 						execsize = execsize + 1;
 						UFDouble execnum = new UFDouble(vector.get(1).toString());//本次执行数量
 						UFDouble nnum = new UFDouble(vector.get(22).toString());//主数量
-						UFDouble usednum = vector.get(30) == null?new UFDouble(0):new UFDouble(vector.get(30).toString());//已执行主数量
+						UFDouble usednum = vector.get(51) == null?new UFDouble(0):new UFDouble(vector.get(51).toString());//已执行主数量
 						if(execnum.compareTo(nnum.sub(usednum)) > 0) {
 							errmsg.append("第"+(i+1)+"行本次执行数量超过订单剩余数量!");
 						}
@@ -417,7 +417,7 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 				String billtype=headvo.getBusitype();
 				String pk_corp = headvo.getPk_corp();
 				String pk_order = headvo.getPk_order();
-				String prjcode = headvo.getProjectid();//项目主键
+				String prjcode = headvo.getProjectid();//项目管理主键
 				GeneralBillVO[] aggvos = new GeneralBillVO[1];
 				GeneralBillVO aggvo = new GeneralBillVO();
 				GeneralBillHeaderVO icheadvo = new GeneralBillHeaderVO();
@@ -438,13 +438,14 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 				icheadvo.setVnote("来源生产总订单");//备注
 				icheadvo.setCbilltypecode("4C");
 				icheadvo.setBassetcard(UFBoolean.FALSE);
-		//		icheadvo.setCbiztypeid("1001V51000000000002V");//业务流程
+				icheadvo.setCbiztypeid("1001F810000000000015");//业务流程
 		//		String def1 = GetBaseDAOUtil.getJobbasfilDef1("prjcode");
-				String def1 = GetBaseDAOUtil.getJobbasfilDef1(prjcode);
-				icheadvo.setCcustomerid(def1);//客户
+				String def1 = GetBaseDAOUtil.getJobbasmngDef1(prjcode);
+				icheadvo.setCcustomerid(getpkcumdoc(def1));//客商管理档案
+				icheadvo.setPk_cubasdocC(def1);//客商基本
 				icheadvo.setCdptid(headvo.getPlandeptid());//部门
 				icheadvo.setFreplenishflag(UFBoolean.FALSE);
-				icheadvo.setPk_cubasdocC(def1);//客户基本档案
+//				icheadvo.setPk_cubasdocC(def1);//客户基本档案
 				icheadvo.setFbillflag(2);
 				icheadvo.setCoperatoridnow(PubEnv.getPk_user());//设置当前操作人
 	//			icheadvo.setAttributeValue("pk_defdoc1", vectors.get(0).get(2)==null?"":vectors.get(0).get(2).toString());//开票类型
@@ -498,7 +499,7 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 //						icheadvo.setCinventoryid(pk_invmandoc);
 						itemvo.setCinventorycode(cmaterialcode);
 						itemvo.setCprojectid(cprojectid);
-						itemvo.setCreceieveid(def1);//收货单位
+						itemvo.setCreceieveid(def1);//收货单位基本档案
 						itemvo.setCrowno(Integer.toString((k+1)*10));
 						itemvo.setCsourcebillhid(pk_order);
 						itemvo.setCsourcebillbid(vector.get(34).toString());
@@ -518,8 +519,9 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 						//换算率						
 						itemvo.setHsl(Hsl);
 						//没有换算率则辅数量为空
+						UFDouble ninassistnum =UFDouble.ZERO_DBL;
 						if(Hsl != null) {
-							UFDouble ninassistnum = new UFDouble(ninnum.div(Hsl).toString(),2);
+							ninassistnum = new UFDouble(ninnum.div(Hsl).toString(),2);
 							itemvo.setNoutassistnum(new UFDouble(ninassistnum));//实出辅数量
 							itemvo.setNshouldoutassistnum(ninassistnum);//应入辅数量 
 						}
@@ -554,9 +556,10 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 						itemvo.setAttributeValue("pk_defdoc12",vector.get(20)==null?null:vector.get(20).toString());//高度
 						itemvo.setAttributeValue("pk_defdoc13",vector.get(47)==null?null:vector.get(47).toString());//系列
 						itemvo.setAttributeValue("pk_defdoc14",vector.get(48)==null?null:vector.get(48).toString());//玻璃编号
-						itemvo.setAttributeValue("pk_defdoc20",vector.get(2)==null?null:vector.get(2).toString());//开票类型
+						itemvo.setAttributeValue("pk_defdoc20",vector.get(36)==null?null:vector.get(36).toString());//开票类型
 						//回写数量
-						UFDouble updatenum =  new UFDouble(vector.get(30)==null?"0":vector.get(30).toString()).add(new UFDouble(vector.get(1)==null?"0":vector.get(1).toString()));
+						UFDouble updatenum =  new UFDouble(vector.get(51)==null?"0":vector.get(51).toString())
+								.add(new UFDouble(vector.get(1)==null?"0":vector.get(1).toString()));
 						updatemap.put(vector.get(34).toString(), updatenum);
 						itemvos[k]=itemvo;
 						k = k + 1;
@@ -568,8 +571,8 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 				GeneralBillVO[] res = isaleout.insertSaleOuts(aggvos);
 				GeneralBillVO resvo = res[0];
 				Boolean updateres = iorder.UpdateInExecNum(updatemap);
-				
-			//	MessageDialog.showHintDlg(mainpanel, "成功", "销售出库单"+resvo.getVBillCode()+"新增成功");
+	//			MessageDialog.showHintDlg(mainpanel, "成功", "销售出库单"+resvo.getVBillCode()+"新增成功");
+				MessageDialog.showHintDlg(mainpanel, "成功", "销售出库单新增成功!");
 				this.closeCancel();
 			}  catch (Exception e1) {
 				MessageDialog.showErrorDlg(mainpanel, "错误", e1.getMessage());
@@ -649,17 +652,33 @@ public class ToSaleOutDialog extends UIDialog implements ActionListener,BillEdit
 	
 	}
 	
+	//客商项目档案
+	private String getpkcumdoc(String pk_cubasdoc ) throws BusinessException {
+	  String sql="select pk_cumandoc from bd_cumandoc where pk_cubasdoc='"+pk_cubasdoc+"'  ";
+	  IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
+	  
+	  Object pk_cumandocobj = iuap.executeQuery(sql, new ColumnProcessor());
+      if (pk_cumandocobj == null) {
+          return "";
+      }
+      return pk_cumandocobj.toString();
+		
+	}
+	
 	//收发类别
 	private String getpkrdcl(String rdcode ) throws BusinessException {
 	  String sql="select pk_rdcl from bd_rdcl where rdcode='"+rdcode+"'  ";
 	  IUAPQueryBS iuap=(IUAPQueryBS) NCLocator.getInstance().lookup(IUAPQueryBS.class.getName());
 	  
-	  String pk_rdcl = (String) iuap.executeQuery(sql, new ColumnProcessor());
-      if (pk_rdcl == null) {
+	  Object pk_rdclobj =  iuap.executeQuery(sql, new ColumnProcessor());
+      if (pk_rdclobj == null) {
           return "";
       }
-      return pk_rdcl;
+      return pk_rdclobj.toString();
 		
 	}
+	
+	
+	
 
 }

+ 5 - 5
xc/cg/src/client/u8c/ui/mytest/datamodel/DemandDataModel.java

@@ -14,10 +14,10 @@ public class DemandDataModel extends ManageDataModel{
 	public DemandDataModel(){
 		super();
 		
-		// 锟斤拷头锟斤拷
-		setHeadPk(new DemandVO().getPKFieldName()); // 锟斤拷锟矫憋拷头锟斤拷锟斤拷锟斤拷锟街讹拷锟斤拷
-		setHeadVOClass(DemandVO.class); // 锟斤拷锟矫憋拷头锟斤拷锟斤拷锟斤拷锟�
-		// 锟接憋拷锟斤拷
+		// 表头信
+		setHeadPk(new DemandVO().getPKFieldName()); // 设置表头的主键字段名
+		setHeadVOClass(DemandVO.class); // 设置表头的类对象
+		// 表体信
 		this.setBodyVOClassArray(new Class[] {DemandBVO.class});
 		this.setBodyTableNames(new String[] {new DemandBVO().getTableName()});
 		this.setBodyTableCodeArray(new String[] { new DemandBVO().getTableName()});
@@ -31,7 +31,7 @@ public class DemandDataModel extends ManageDataModel{
 	}
 
 	@Override
-	public String getBillTempletCode() { // 锟斤拷锟斤拷模锟斤拷锟斤拷锟�
+	public String getBillTempletCode() { 
 		return "A2A3";
 	}
 

+ 12 - 13
xc/cg/src/client/u8c/ui/mytest/panel/DemandTestUI.java

@@ -36,7 +36,7 @@ public class DemandTestUI extends FrameUI{
 
 	@Override
 	protected void initButtons() {
-		// 锟斤拷始锟斤拷锟斤拷
+		// 初始化按
 		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_ADD);
 		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_EDIT);
 		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_DELETE);
@@ -53,12 +53,12 @@ public class DemandTestUI extends FrameUI{
 //		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_EXPORT);
 //		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_IMPORT);
 //		getBtnManager().addButtonByID(AbstractBtnReg.USERBTN_ADDPRAYBILL);
-		getBtnManager().addButtonByID(AbstractBtnReg.USERBTN_boExportImport); //锟斤拷锟斤拷/锟斤拷锟斤拷
+		getBtnManager().addButtonByID(AbstractBtnReg.USERBTN_boExportImport); //导入/导出
 		getBtnManager().addChildButtonsByIDs(AbstractBtnReg.USERBTN_boExportImport , 
 				new int []{AbstractBtnReg.SYSBTN_EXPORT,AbstractBtnReg.SYSBTN_IMPORT});
 		getBtnManager().addButtonByID(AbstractBtnReg.USERBTN_ClOSE);
 
-		// 锟斤拷锟矫帮拷钮锟斤拷锟斤拷锟斤拷
+		// 配置按钮动作类
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_ADD, new DemandAddAction(this));
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_EDIT, new DemandEditAction(this));
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_DELETE, new DemandDeleteAction(this));
@@ -79,7 +79,7 @@ public class DemandTestUI extends FrameUI{
 
 		
 
-		// 锟斤拷钮锟斤拷锟斤拷
+		// 按钮排序
 		getBtnManager().adjustButtonOrder(new int[] {
 				AbstractBtnReg.SYSBTN_ADD,
 				AbstractBtnReg.SYSBTN_EDIT,
@@ -103,44 +103,43 @@ public class DemandTestUI extends FrameUI{
 	}
 	
 	@Override
-	protected MainPanel createMainPanel() { // 锟斤拷锟斤拷锟斤拷
+	protected MainPanel createMainPanel() { 
 		ManageDataModel model = (ManageDataModel) getDataModel();
 		return new DemandMainPanel(this,  model.getBillTempletCode(), model.getBillTempletBusiType());
 	}
 
 	@Override
-	protected TopPanel createTopPanel() { //锟斤拷锟斤拷锟斤拷锟�
+	protected TopPanel createTopPanel() { 
 		return new DemandTopPanel(this);
 	}
 	
 	@Override
-	protected BtnStateReg createButtonStateRegister() { // 锟斤拷钮状态注锟斤拷锟斤拷
+	protected BtnStateReg createButtonStateRegister() {
 		return  new DemandBtnStateReg(getDataModel().getState());
 	}
 	
 	@Override
-	protected DemandDataModel createDataModel() { // 锟斤拷锟斤拷锟斤拷模锟斤拷锟斤拷
+	protected DemandDataModel createDataModel() {
 		return new DemandDataModel();
 	}
 
 	@Override
-	public boolean needLeftPanel() { // 锟斤拷锟斤拷要锟斤拷说锟斤拷锟�
+	public boolean needLeftPanel() {
 		return false;
 	}
 
 	@Override
-	public boolean needTopPanel() { //锟斤拷要锟斤拷锟斤拷锟斤拷锟�
+	public boolean needTopPanel() {
 		return true;
 	}
 	
 	@Override
-	public String getQueryNodeKey() { // 锟节★拷锟斤拷锟杰节碉拷默锟斤拷模锟斤拷锟斤拷锟矫★拷锟叫诧拷询模锟斤拷慕诘锟斤拷识
-		// (锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷貌锟斤拷裕锟斤拷锟斤拷锟斤拷询锟斤拷钮时锟酵会报锟斤拷前锟矫伙拷没锟叫匡拷锟矫的诧拷询模锟斤拷)
+	public String getQueryNodeKey() { 
 		return "400303";
 	}
 	
 	@Override
-	public String getModuleCode() { // 锟节碉拷锟斤拷锟�
+	public String getModuleCode() { 
 		return "400303";
 	}
 	

+ 18 - 0
xc/stock/src/client/u8c/ic/safetystock/action/SafetystockImportAction.java

@@ -0,0 +1,18 @@
+package u8c.ic.safetystock.action;
+
+import nc.ui.hr.frame.FrameUI;
+import nc.ui.hr.frame.action.AbstractAction;
+import u8c.ui.excel.ExcelFileProcess;
+
+public class SafetystockImportAction extends AbstractAction {
+
+	public SafetystockImportAction(FrameUI frameUI) {
+		super(frameUI);
+	}
+
+	@Override
+	public void execute() throws Exception {
+		new ExcelFileProcess().importExcelData("mmpac.safetystock.importinsert");
+	}
+
+}

+ 7 - 5
xc/stock/src/client/u8c/ic/safetystock/button/SafetystockBtnStateReg.java

@@ -17,22 +17,24 @@ public class SafetystockBtnStateReg extends ManageBtnStateReg{
 		// ³õʼ
         ButtonStateVO btnStateVO = new ButtonStateVO();
         btnStateVO.setStateID(StateRegister.STATE_INIT);
-        btnStateVO.setEnableBtnIDs(new int[]{AbstractBtnReg.SYSBTN_QUERY, AbstractBtnReg.SYSBTN_ADD, AbstractBtnReg.SYSBTN_REFRESH});
-        btnStateVO.setVisibleBtnIDs(new int[]{AbstractBtnReg.SYSBTN_EDIT, AbstractBtnReg.SYSBTN_DELETE});
+        btnStateVO.setEnableBtnIDs(new int[]{AbstractBtnReg.SYSBTN_QUERY, AbstractBtnReg.SYSBTN_ADD, AbstractBtnReg.SYSBTN_REFRESH,AbstractBtnReg.SYSBTN_IMPORT});
+        btnStateVO.setVisibleBtnIDs(new int[]{AbstractBtnReg.SYSBTN_EDIT, AbstractBtnReg.SYSBTN_DELETE,AbstractBtnReg.SYSBTN_IMPORT});
         addStateVO(btnStateVO.getStateID(), btnStateVO);
         
 		// ±íÍ·ÐÐÑ¡Ôñ
         btnStateVO = new ButtonStateVO();
         btnStateVO.setStateID(StateRegister.STATE_LINE_SELECTED);
-        btnStateVO.setEnableBtnIDs(new int[]{AbstractBtnReg.SYSBTN_QUERY, AbstractBtnReg.SYSBTN_ADD,AbstractBtnReg.SYSBTN_EDIT,AbstractBtnReg.SYSBTN_DELETE});
+        btnStateVO.setEnableBtnIDs(new int[]{AbstractBtnReg.SYSBTN_QUERY, AbstractBtnReg.SYSBTN_ADD,AbstractBtnReg.SYSBTN_EDIT,AbstractBtnReg.SYSBTN_DELETE,
+        		AbstractBtnReg.SYSBTN_IMPORT});
         btnStateVO.setVisibleBtnIDs(new int[]{});
         addStateVO(btnStateVO.getStateID(), btnStateVO);
         
         // ä¯ÀÀ
         btnStateVO = new ButtonStateVO();
         btnStateVO.setStateID(StateRegister.STATE_NOTEDIT);
-        btnStateVO.setEnableBtnIDs(new int[]{AbstractBtnReg.SYSBTN_ADD, AbstractBtnReg.SYSBTN_EDIT, AbstractBtnReg.SYSBTN_DELETE,AbstractBtnReg.SYSBTN_RETURN});
-        btnStateVO.setVisibleBtnIDs(new int[]{AbstractBtnReg.SYSBTN_QUERY, AbstractBtnReg.SYSBTN_REFRESH});
+        btnStateVO.setEnableBtnIDs(new int[]{AbstractBtnReg.SYSBTN_ADD, AbstractBtnReg.SYSBTN_EDIT, AbstractBtnReg.SYSBTN_DELETE,AbstractBtnReg.SYSBTN_RETURN,
+        		AbstractBtnReg.SYSBTN_IMPORT});
+        btnStateVO.setVisibleBtnIDs(new int[]{AbstractBtnReg.SYSBTN_QUERY, AbstractBtnReg.SYSBTN_REFRESH,AbstractBtnReg.SYSBTN_IMPORT});
         addStateVO(btnStateVO.getStateID(), btnStateVO);
 
 	}

+ 6 - 5
xc/stock/src/client/u8c/ic/safetystock/panel/SafetystockTestUI.java

@@ -3,10 +3,7 @@ package u8c.ic.safetystock.panel;
 import nc.ui.hr.frame.FrameUI;
 import nc.ui.hr.frame.MainPanel;
 import nc.ui.hr.frame.TopPanel;
-import nc.ui.hr.frame.action.AddLineAction;
 import nc.ui.hr.frame.action.CancelAction;
-import nc.ui.hr.frame.action.DeleteLineAction;
-import nc.ui.hr.frame.action.EditLineAction;
 import nc.ui.hr.frame.action.RefreshAction;
 import nc.ui.hr.frame.action.ReturnFromCardToListAction;
 import nc.ui.hr.frame.button.AbstractBtnReg;
@@ -15,6 +12,7 @@ import nc.ui.pub.bill.BillCardPanel;
 import u8c.ic.safetystock.action.SafetystockAddAction;
 import u8c.ic.safetystock.action.SafetystockDeleteAction;
 import u8c.ic.safetystock.action.SafetystockEditAction;
+import u8c.ic.safetystock.action.SafetystockImportAction;
 import u8c.ic.safetystock.action.SafetystockQueryAction;
 import u8c.ic.safetystock.action.SafetystockSaveAction;
 import u8c.ic.safetystock.button.SafetystockBtnStateReg;
@@ -36,7 +34,8 @@ public class SafetystockTestUI extends FrameUI{
 		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_REFRESH);
 		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_SAVE);
 		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_CANCEL);
-		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_RETURN);	
+		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_RETURN);
+		getBtnManager().addButtonByID(AbstractBtnReg.SYSBTN_IMPORT);
 		
 		// 配置按钮动作类
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_ADD, new SafetystockAddAction(this));
@@ -47,6 +46,7 @@ public class SafetystockTestUI extends FrameUI{
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_SAVE, new SafetystockSaveAction(this));
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_CANCEL, new CancelAction(this));
 		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_RETURN, new ReturnFromCardToListAction(this));
+		getBtnManager().regCmd(AbstractBtnReg.SYSBTN_IMPORT, new SafetystockImportAction(this));
 		
 		// 按钮排序
 		getBtnManager().adjustButtonOrder(new int[] {
@@ -57,7 +57,8 @@ public class SafetystockTestUI extends FrameUI{
 				AbstractBtnReg.SYSBTN_REFRESH, 
 				AbstractBtnReg.SYSBTN_SAVE,
 				AbstractBtnReg.SYSBTN_CANCEL,
-				AbstractBtnReg.SYSBTN_RETURN});
+				AbstractBtnReg.SYSBTN_RETURN,
+				AbstractBtnReg.SYSBTN_IMPORT});
 	}
 	
 	@Override

+ 21 - 0
xc/stock/src/private/u8c/bs/stock/bp/DefaultValueRule.java

@@ -0,0 +1,21 @@
+package u8c.bs.stock.bp;
+
+import nc.vo.SafetystockVO;
+import nc.vo.pub.BusinessException;
+import u8c.pubitf.rule.IRule;
+
+/**
+ * ĬÈÏÖµÉèÖÃ
+ * @author 
+ *
+ */
+public class DefaultValueRule implements IRule<SafetystockVO>{
+
+	@Override
+	public void process(SafetystockVO[] vos) throws BusinessException {
+		for(int i = 0; i < vos.length; i++) {
+			SafetystockVO headVO = (SafetystockVO) vos[i];
+		}
+	}
+
+}

+ 82 - 0
xc/stock/src/private/u8c/bs/stock/bp/SafetystockImportInsetBP.java

@@ -0,0 +1,82 @@
+package u8c.bs.stock.bp;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import nc.bs.dao.BaseDAO;
+import nc.vo.SafetystockVO;
+import nc.vo.pub.BusinessException;
+import u8c.pubitf.rule.ICompareRule;
+import u8c.pubitf.rule.IRule;
+import u8c.pubitf.rule.IValidate;
+
+public class SafetystockImportInsetBP {
+	BaseDAO dao = new BaseDAO();
+
+	public SafetystockVO[] save(SafetystockVO[] bills) throws BusinessException {
+		if (bills != null && bills.length != 0) {
+			SafetystockVO[] vos = null;
+			this.execBeforeRules(bills);
+			vos = this.insertBills(bills);
+			this.execAfterRules(bills);
+			return vos;
+		} else {
+			return null;
+		}
+	}
+
+	private SafetystockVO[] insertBills(SafetystockVO[] bills) throws BusinessException {
+		for (int i = 0; i < bills.length; i++) {
+			SafetystockVO safetystockVO = bills[i];
+			String pk_demand = dao.insertVO(safetystockVO);
+		}
+		return bills;
+	}
+
+	protected void addBeforeRule(List<Object> rules) throws BusinessException {
+		// 默认值填充
+		rules.add(new DefaultValueRule());
+		//数据处理
+		rules.add(new SpecialDataRule());
+		//数据校验
+		rules.add(new ValidateRule());
+	}
+
+	protected void addAfterRule(List<Object> rules) throws BusinessException {
+	}
+
+	private void execBeforeRules(SafetystockVO[] bills) throws BusinessException {
+		List<Object> rules = new ArrayList();
+		this.addBeforeRule(rules);
+		this.execRules(rules, bills);
+	}
+
+	private void execAfterRules(SafetystockVO[] bills) throws BusinessException {
+		List<Object> rules = new ArrayList();
+		this.addAfterRule(rules);
+		this.execRules(rules, bills);
+	}
+
+	private void execRules(List<Object> rules, SafetystockVO[] bills) throws BusinessException {
+		if (null != rules && rules.size() > 0) {
+			Iterator var3 = rules.iterator();
+
+			while (var3.hasNext()) {
+				Object object = var3.next();
+				if (object instanceof IValidate) {
+					IValidate<SafetystockVO> rule = (IValidate) object;
+					rule.validate(bills);
+				} else if (object instanceof IRule) {
+					IRule<SafetystockVO> rule = (IRule) object;
+					rule.process(bills);
+				} else if (object instanceof ICompareRule) {
+					ICompareRule<SafetystockVO> rule = (ICompareRule) object;
+					rule.process(bills, (SafetystockVO[]) null);
+				}
+			}
+		}
+
+	}
+
+}

+ 124 - 0
xc/stock/src/private/u8c/bs/stock/bp/SpecialDataRule.java

@@ -0,0 +1,124 @@
+package u8c.bs.stock.bp;
+
+import java.util.Map;
+
+import nc.bs.framework.common.InvocationInfoProxy;
+import nc.bs.framework.common.NCLocator;
+import nc.itf.uap.IUAPQueryBS;
+import nc.itf.uap.bd.def.IDefdoc;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.jdbc.framework.processor.MapProcessor;
+import nc.vo.SafetystockVO;
+import nc.vo.bd.def.DefdocVO;
+import nc.vo.pub.BusinessException;
+import u8c.pubitf.rule.IRule;
+
+
+/**
+ *	数据处理
+ * @author 
+ *
+ */
+public class SpecialDataRule implements IRule<SafetystockVO>{
+	private  IUAPQueryBS iuap = NCLocator.getInstance().lookup(IUAPQueryBS.class);
+	@Override
+	public void process(SafetystockVO[] vos) throws BusinessException {
+		String w = InvocationInfoProxy.getInstance().getLangCode();
+		for(int i = 0; i < vos.length; i++) {
+			SafetystockVO headvo =  vos[i];
+			Map<String,String> invbasdocMap = getInvbasdoc(headvo.getCmaterialcode());
+			//存货名称
+			headvo.setCmaterialname(invbasdocMap.get("invname"));
+			//存货编码
+			headvo.setCmaterialcode(invbasdocMap.get("pk_invmandoc"));
+			//规格
+			headvo.setSpec(invbasdocMap.get("invspec"));
+			//型号
+			headvo.setModel(invbasdocMap.get("invtype"));
+			//可能存在新增
+			disposeDefdoc("YS(颜色)", headvo.getColor());
+			disposeDefdoc("DC(定尺)", headvo.getSizing());
+			//查对应pk
+			headvo.setColor(getDefdocPK("YS(颜色)", headvo.getColor()));
+			headvo.setSizing(getDefdocPK("DC(定尺)", headvo.getSizing()));
+			headvo.setAlloy(getDefdocPK("HJ(合金)", headvo.getAlloy()));
+			headvo.setStandard(getDefdocPK("BZ(标准)", headvo.getStandard()));
+			
+		}
+	}
+	
+    
+    //查询物料
+    public Map<String,String> getInvbasdoc(String code)throws BusinessException {
+    	StringBuffer sql = new StringBuffer();
+    	sql.append("SELECT");
+    	sql.append(" bd_invbasdoc.invname as invname,");
+    	sql.append(" bd_invbasdoc.invspec as invspec,");
+    	sql.append(" bd_invbasdoc.invtype as invtype,");
+    	sql.append(" bd_invbasdoc.def1 as def1,");
+    	sql.append(" bd_invbasdoc.def2 as def2,");
+    	sql.append(" bd_invbasdoc.def3 as def3,");
+    	sql.append(" bd_measdoc.measname as measname,");
+    	sql.append(" bd_measdocs.measname as measnames,");
+    	sql.append(" bd_invmandoc.pk_invmandoc as pk_invmandoc");
+    	sql.append(" FROM");
+    	sql.append(" bd_invbasdoc bd_invbasdoc");
+    	sql.append(" left join bd_measdoc bd_measdoc  on bd_invbasdoc.pk_measdoc = bd_measdoc.pk_measdoc");
+    	sql.append(" left join bd_convert bd_convert on bd_invbasdoc.pk_invbasdoc = bd_convert.pk_invbasdoc");
+    	sql.append(" left join bd_measdoc bd_measdocs on bd_convert.pk_measdoc = bd_measdocs.pk_measdoc");
+    	sql.append(" left join bd_invmandoc bd_invmandoc on bd_invbasdoc.pk_invbasdoc = bd_invmandoc.pk_invbasdoc");
+    	sql.append(" WHERE");
+    	sql.append(" bd_invbasdoc.invcode = '"+code+"'");
+    	sql.append(" and bd_invbasdoc.dr = 0");
+    	Map<String,String> map =  (Map<String, String>) iuap.executeQuery(sql.toString(), new MapProcessor());
+    	if (map == null) {
+        	throw new BusinessException("以下档案在U8cloud系统中根据公司或者账簿信息找不到,请检查!详细信息:1、档案类型:存货档案,档案编码:"+code);
+        }
+		return map;
+    }
+    
+    
+	//自定义档案数据处理
+    public  void disposeDefdoc(String doclistcode,String docname) throws BusinessException {
+    	if(docname == null) {
+    		return ;
+    	}
+    	//取到自定义档案列表主键
+    	String sql = "select pk_defdoclist from bd_defdoclist where doclistcode = '"+doclistcode+"'";
+    	String pk_defdoclist = (String) iuap.executeQuery(sql, new ColumnProcessor());
+    	if(pk_defdoclist == null) {
+    		throw new BusinessException("以下档案在U8cloud系统中根据公司或者账簿信息找不到,请检查!详细信息:1、档案类型:自定义档案列表,档案编码:"+doclistcode);
+    	}
+        String sql1 = "select pk_defdoc,pk_defdoclist from bd_defdoc where pk_defdoclist = '"+pk_defdoclist+"' and docname ='"+docname+"'";
+        String pk_defdoc = (String) iuap.executeQuery(sql1, new ColumnProcessor());
+        //无数据新增档案
+        if (pk_defdoc == null) {
+        	DefdocVO defdocVO = new DefdocVO();
+        	//公司                  
+        	defdocVO.setPk_corp("0001");
+        	//档案编码
+        	defdocVO.setDoccode(docname);
+        	//档案名称
+        	defdocVO.setDocname(docname);
+        	//档案系统属性
+        	defdocVO.setDocsystype(1);
+        	defdocVO.setStatus(2);
+        	IDefdoc iDefdoc = NCLocator.getInstance().lookup(IDefdoc.class);
+        	iDefdoc.saveVOs(pk_defdoclist, new DefdocVO[] {defdocVO});
+        }
+    }
+    
+	// 查询自定义档案取对应pk
+	public String getDefdocPK(String doclistcode, String docname) throws BusinessException {
+		if (docname == null) {
+			return null;
+		}
+		String sql = "select pk_defdoc from bd_defdoc where pk_defdoclist = (select pk_defdoclist from bd_defdoclist where doclistcode = '"
+				+ doclistcode + "') and docname ='" + docname + "'";
+		String pk_defdoc = (String) iuap.executeQuery(sql, new ColumnProcessor());
+		if (pk_defdoc == null) {
+			throw new BusinessException("以下档案在U8cloud系统中根据公司或者账簿信息找不到,请检查!详细信息:1、档案类型 自定义档案,档案名称:" + docname + "");
+		}
+		return pk_defdoc;
+	}
+}

+ 82 - 0
xc/stock/src/private/u8c/bs/stock/bp/ValidateRule.java

@@ -0,0 +1,82 @@
+package u8c.bs.stock.bp;
+
+import java.util.Map;
+
+import nc.bs.framework.common.NCLocator;
+import nc.itf.uap.IUAPQueryBS;
+import nc.jdbc.framework.processor.ColumnProcessor;
+import nc.jdbc.framework.processor.MapProcessor;
+import nc.vo.SafetystockVO;
+import nc.vo.pub.BusinessException;
+import u8c.pubitf.rule.IRule;
+
+/**
+ * 数据校验
+ * 
+ * @author
+ *
+ */
+public class ValidateRule implements IRule<SafetystockVO> {
+
+	private IUAPQueryBS iuap = NCLocator.getInstance().lookup(IUAPQueryBS.class);
+
+	@Override
+	public void process(SafetystockVO[] vos) throws BusinessException {
+		for (int i = 0; i < vos.length; i++) {
+			SafetystockVO safetystockVO = vos[i];
+			Map<String, String> map = getInvbasdoc(safetystockVO.getCmaterialcode());
+			// 颜色
+			String free1 = map.get("free1");
+			if (free1 == null) {
+				if (safetystockVO.getColor() != null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "没有启用颜色,颜色不允许输入");
+				}
+			} else {
+				if (safetystockVO.getColor() == null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "启用了颜色,颜色不允许为空");
+				}
+			}
+			// 定尺
+			String free3 = map.get("free3");
+			if (free3 == null) {
+				if (safetystockVO.getSizing() != null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "没有启用定尺,定尺不允许输入");
+				}
+			} else {
+				if (safetystockVO.getSizing() == null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "启用了定尺,定尺不允许为空");
+				}
+			}
+			// 合金
+			String free2 = map.get("free2");
+			if (free2 == null) {
+				if (safetystockVO.getAlloy() != null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "没有启用合金,合金不允许输入");
+				}
+			} else {
+				if (safetystockVO.getAlloy() == null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "启用了合金,合金不允许为空");
+				}
+			}
+			// 标准
+			String free4 = map.get("free4");
+			if (free4 == null) {
+				if (safetystockVO.getStandard() != null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "没有启用标准,标准不允许输入");
+				}
+			} else {
+				if (safetystockVO.getStandard() == null) {
+					throw new BusinessException("存货档案:" + safetystockVO.getCmaterialcode() + "启用了标准,标准不允许为空");
+				}
+			}
+		}
+	}
+
+
+
+	public Map<String, String> getInvbasdoc(String cmaterialcode) throws BusinessException {
+		String sql = "select free1,free2,free3,free4 from bd_invbasdoc where pk_invbasdoc  = (select pk_invbasdoc from bd_invmandoc where pk_invmandoc='"+cmaterialcode+"') and dr = 0";
+		return (Map<String, String>) iuap.executeQuery(sql.toString(), new MapProcessor());
+	}
+
+}

+ 21 - 0
xc/stock/src/private/u8c/impl/SafetystockImportInsertAction.java

@@ -0,0 +1,21 @@
+package u8c.impl;
+
+import nc.vo.SafetystockVO;
+import nc.vo.pub.BusinessException;
+import u8c.bs.action.save.AbstractBatchSaveVOAction;
+import u8c.bs.stock.bp.SafetystockImportInsetBP;
+
+public class SafetystockImportInsertAction extends AbstractBatchSaveVOAction<SafetystockVO>{
+
+	@Override
+	protected String getBillMark() {
+		return "IC01";
+	}
+
+	@Override
+	protected SafetystockVO[] save(SafetystockVO[] vos) throws BusinessException {
+		return new SafetystockImportInsetBP().save(vos);
+	}
+
+
+}