<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
		SELECT
		u_bednet.bednetid,
		u_bednet.deptid,
		u_bednet.flag,
		u_bednet.bednetcode,
		u_bednet.bednetname,
		u_bednet.bednettypeid,
		u_bednet.mattress_width,
		u_bednet.mattress_length,
		u_bednet.mattress_height,
		u_bednet.if_doublenet,
		u_bednet.if_doublespring,
		u_bednet.snake_wire_diameter,
		u_bednet.snake_wire_mtrl_formula,
		u_bednet.snake_wire_mtrl_cost,
		u_bednet.pocket_around_spring_formula,
		u_bednet.pocket_around_spring_cost,
		u_bednet.pocket_around_fabrics_formula,
		u_bednet.pocket_around_fabrics_cost,
		u_bednet.hard_around_mtrl_formula,
		u_bednet.hard_around_mtrl_cost,
		u_bednet.hard_around_hr_formula,
		u_bednet.hard_around_hr_cost,
		u_bednet.spring_mtrl_cost,
		u_bednet.spring_hr_cost,
		u_bednet.glue_price,
		u_bednet.glue_mtrl_formula,
		u_bednet.glue_mtrl_cost,
		u_bednet.fabrics1_mtrl_formula,
		u_bednet.fabrics1_mtrl_cost,
		u_bednet.fabrics2_mtrl_formula,
		u_bednet.fabrics2_mtrl_cost,
		u_bednet.if_side_iron,
		u_bednet.side_iron_lossrate,
		u_bednet.side_iron_price,
		u_bednet.side_iron_mtrl_formula,
		u_bednet.side_iron_mtrl_cost,
		u_bednet.side_iron_hr_formula,
		u_bednet.side_iron_hr_cost,
		u_bednet.cnail_price,
		u_bednet.cnail_mtrl_formula,
		u_bednet.cnail_mtrl_cost,
		u_bednet.cnail_hr_formula,
		u_bednet.cnail_hr_cost,
		u_bednet.sponge_mtrlid,
		u_bednet.sponge_thickness,
		u_bednet.sponge_height,
		u_bednet.sponge_price,
		u_bednet.sponge_mtrl_formula,
		u_bednet.sponge_mtrl_cost,
		u_bednet.sponge_hr_formula,
		u_bednet.sponge_hr_cost,
		u_bednet.sponge_tc_mtrlid,
		u_bednet.sponge_tc_thickness,
		u_bednet.sponge_tc_height,
		u_bednet.edge_mtrlid,
		u_bednet.edge_price,
		u_bednet.edge_mtrl_formula,
		u_bednet.edge_mtrl_cost,
		u_bednet.edge_hr_formula,
		u_bednet.edge_hr_cost,
		u_bednet.edge_height,
		u_bednet.iffork,
		u_bednet.fork_qty,
		u_bednet.fork_price,
		u_bednet.fork_mtrl_formula,
		u_bednet.fork_mtrl_cost,
		u_bednet.fork_hr_formula,
		u_bednet.fork_hr_cost,
		u_bednet.if_rsORwa,
		u_bednet.rsORwa_price,
		u_bednet.rsORwa_mtrl_formula,
		u_bednet.rsORwa_mtrl_cost,
		u_bednet.rsORwa_hr_formula,
		u_bednet.rsORwa_hr_cost,
		u_bednet.if_sponge_drilling,
		u_bednet.sponge_drilling_hr_formula,
		u_bednet.sponge_drilling_hr_cost,
		u_bednet.total_hr_cost,
		u_bednet.total_mtrl_cost ,
		u_bednet.total_fees_cost,
		u_bednet.total_cost,
		u_bednet.createtime as createtime ,
		u_bednet.createby as createby,
		u_mtrl_sponge.name as mtrl_sponge_name,
		u_mtrl_sponge_tc.name as mtrl_sponge_tc_name,
		u_mtrl_edge.name as mtrl_edge_name,
		u_mtrl_felt.name as mtrl_felt_name,
		u_mtrl_felt_x.name as mtrl_felt_x_name,
		felt_mtrl_cost,
		felt_mtrl_x_cost,
		sponge_mtrl_tc_cost,
		packet_mtrl_cost,
		u_bednet.felt_mtrlid,
		u_bednet.felt_x_mtrlid,
		u_bednet.nottax_factory_cost,
		u_bednet.nottax_dept_cost,
		u_bednet.dept_cost,
		u_bednet.foreign_cost,
		u_bednet.sum_weight,
		total_cost - sponge_mtrl_cost - felt_mtrl_cost - felt_mtrl_x_cost - packet_mtrl_cost - packet_hr_cost as planprice,
		u_bednet.ifsaleout,
		u_bednet.duo_qv_str,
		u_bednet.if_jb,
		u_bednet.felt_qty,
		u_bednet.felt_x_qty,
		u_bednet.felt_dscrp,
		u_bednet.extras_cost_dscrp,
		u_bednet.packtype,
		u_bednet.packqty,
		u_bednet.packmtrl,
		u_bednet.transport_type,
		u_bednet.commission,
		u_bednet.other_rate,
		u_bednet.fob,
		u_bednet.taxrate,
		u_bednet.extras_cost,
		u_bednet.moneyrate,
		CASE WHEN u_bednet.moneyrate = 1 THEN 0 ELSE 1 END AS if_moneyrate,
		u_bednet.spring_hr_formula,
		u_bednet.cnail_weight_formula,
		u_bednet.edge_weight_formula,
		u_bednet.fabrics1_weight_formula,
		u_bednet.fabrics2_weight_formula,
		u_bednet.felt_hr_formula,
		u_bednet.felt_mtrl_formula,
		u_bednet.felt_weight_formula,
		u_bednet.fork_weight_formula,
		u_bednet.hard_around_weight_formula,
		u_bednet.packet_hr_formula,
		u_bednet.packet_mtrl_formula,
		u_bednet.side_iron_weight_formula,
		u_bednet.sponge_mtrl_tc_formula,
		u_bednet.sponge_weight_formula,
		u_bednet.sponge_weight_tc_formula,
		u_bednet.spring_mtrl_formula,
		u_bednet.spring_weight_formula,
		u_bednet_type.if_pocket_around,
		u_bednet_type.if_hard_around,
		u_bednet.if_stock_up,
		dannum_rate,
		ISNULL(dannum_type, 2) AS dannum_type

		From u_bednet
		left join u_mtrl_price u_mtrl_sponge on   u_bednet.sponge_mtrlid=u_mtrl_sponge.mtrlid
		left join u_mtrl_price u_mtrl_sponge_tc on   u_bednet.sponge_tc_mtrlid=u_mtrl_sponge_tc.mtrlid
		left join u_mtrl_price u_mtrl_edge on   u_bednet.edge_mtrlid=u_mtrl_edge.mtrlid
		left join u_mtrl_price u_mtrl_felt on   u_bednet.felt_mtrlid=u_mtrl_felt.mtrlid
		left join u_mtrl_price u_mtrl_felt_x on   u_bednet.felt_x_mtrlid=u_mtrl_felt_x.mtrlid
		inner join u_bednet_type on u_bednet_type.bednettypeid = u_bednet.bednettypeid
	</selectstr>
	<where>
		<when notnull="@arg_bednetid">
			u_bednet.bednetid = @arg_bednetid
		</when>
		<when notnull="@arg_deptid">
			u_bednet.autotype = 0
		</when>
		<when notnull="@arg_deptid">
			u_bednet.deptid = @arg_deptid
		</when>
		<when notempty="@@arg_arry_outrepstr@@">
			u_bednet.createby IN (@@arg_arry_outrepstr@@) OR ( u_bednet.createby = '' OR u_bednet.createby = '管理员' )
		</when>
		<when notnull="@arg_search">
			u_bednet.bednetcode LIKE '%' + @arg_search + '%' OR u_bednet.bednetname LIKE '%' + @arg_search + '%'
		</when>
		<when notnull="@arg_bednettypeid">
			u_bednet.bednettypeid = @arg_bednettypeid
		</when>
	</where>
	<orderstr>
		bednetid DESC
	</orderstr>
	<displayfields>
		<field field="pid" compute="getrow()"> 序</field>
		<field field="flag" datatype="checkbox">审核</field>
		<field field="deptid" mapper="" ddd="ddd_mattress_dept_choose" align="left">部门</field>
		<field field="bednetcode">床网编码</field>
		<field field="bednetname">床网名称</field>
		<field field="dept_cost" datatype="number">部门售价</field>
		<field field="foreign_cost" datatype="number">外币价</field>
		<field field="bednettypeid" mapper="" ddd="ddd_bednettypeid_choose">
			床网
			类别
		</field>
		<field field="mattress_width" datatype="number">
			床垫
			宽/CM
		</field>
		<field field="mattress_length" datatype="number">
			床垫
			长/CM
		</field>
		<field field="mattress_height" datatype="number">
			床垫
			高/CM
		</field>
		<field field="if_doublenet" datatype="checkbox">
			双网
			？
		</field>
		<field field="if_doublespring" datatype="checkbox">
			双簧
			？
		</field>
		<field field="snake_wire_diameter" datatype="number">
			蛇线
			线径MM
		</field>
		<field field="if_side_iron" datatype="checkbox">
			边铁？
		</field>
		<field field="side_iron_lossrate">
			边铁
			损耗率
		</field>
		<field field="mtrl_sponge_name">
			海绵包边
			物料
		</field>
		<field field="sponge_thickness" dattype="number">
			海绵
			厚度CM
		</field>
		<field field="sponge_height" dattype="number">
			海绵
			高CM
		</field>
		<field field="mtrl_sponge_tc_name">
			填充海绵
			物料
		</field>
		<field field="sponge_tc_thickness" dattype="number">
			填充海绵
			厚度CM
		</field>
		<field field="sponge_tc_height" dattype="number">
			填充海绵
			高CM
		</field>
		<field field="mtrl_edge_name">
			封边
			物料
		</field>
		<field field="edge_height" dattype="number">
			封边高
		</field>
		<field field="mtrl_felt_name">上垫层材料</field>
		<field field="mtrl_felt_x_name">下垫层材料</field>
		<field field="felt_qty" dattype="number">
			数量
		</field>
		<field field="felt_x_qty" dattype="number">
			数量
		</field>
		<field field="felt_dscrp">做法</field>
		<field field="if_jb" datatype="checkbox">卷包</field>
		<field field="iffork" datatype="checkbox">弹叉</field>
		<field field="fork_qty" datatype="number">
			弹叉
			数量
		</field>
		<field field="if_rsorwa" datatype="checkbox">
			胶条？
			包角？
		</field>
		<field field="if_sponge_drilling" datatype="checkbox">
			海绵
			打孔？
		</field>
		<field field="createby">
			登记人
		</field>
		<field field="createtime" datatype="datetime">
			登记时间
		</field>
		<field field="sum_weight" datatype="number">总重量</field>
		<field field="planprice" datatype="number">计划价</field>
		<field field="ifsaleout" datatype="checkbox">床网独立销售</field>
		<field field="packtype">包装方式</field>
		<field field="packqty">包装数量</field>
		<field field="transport_type">运输方式</field>
		<field field="commission">佣金点数</field>
		<field field="other_rate">额外点数</field>
		<field field="fob">FOB</field>
		<field field="taxrate">税率</field>
		<field field="extras_cost">额外费用</field>
		<field field="moneyrate" mapper="u_mattress.if_moneyrate">币种</field>
		<field field="extras_cost_dscrp">额外费用备注</field>
		<field field="duo_qv_str" mapper="u_bednet.bednet_area">多区</field>
		<field field="if_stock_up" datatype="checkbox">备货</field>
	</displayfields>
</select>
