<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
		SELECT
			bednetmxid,
			bednetid,
			spring_qty_width,
			spring_qty_length,
			bednet_height,
			u_bednetmx.springid,
			ISNULL(vv_spring.name, u_bednetmx.springid) as springname,
			if_part,
			if_15strip,
			if_pocket_around,
			pocket_around_springid,
			ISNULL(vv_pocket_spring.name, '') as pocket_around_springname,
			pocket_around_row,
			pocket_around_wire_price,
			pocket_around_spring_cost,
			pocket_around_fabrics_cost,
			if_hard_around,
			hard_around_springid,
			ISNULL(vv_hard_spring.name, '') as hard_around_springname,
			hard_around_row,
			hard_around_wire_price,
			hard_around_mtrl_cost,
			hard_around_hr_cost,
			fabrics1_mtrlid,
			fabrics1_price,
			fabrics1_mtrl_cost,
			fabrics2_mtrlid,
			fabrics2_price,
			fabrics2_mtrl_cost,
			if_side_iron,
			side_iron_qty,
			side_iron_mtrl_cost,
			side_iron_hr_cost,

			pocket_around_spring_cost_replace_formula,
			pocket_around_fabrics_cost_replace_formula,
			hard_around_mtrl_cost_replace_formula,
			hard_around_hr_cost_replace_formula,
			fabrics1_mtrl_cost_replace_formula,
			fabrics2_mtrl_cost_replace_formula,
			side_iron_mtrl_cost_replace_formula,
			side_iron_hr_cost_replace_formula,
			cnail_mtrl_cost_replace_formula,
			cnail_mtrl_cost,
			cnail_hr_cost_replace_formula,
			cnail_hr_cost,
			glue_mtrl_cost_replace_formula,
			glue_mtrl_cost,

			spring_mtrl_cost,
			spring_hr_cost,
			spring_mtrl_cost_replace_formula,
			spring_hr_cost_replace_formula,

			spring_weight_replace_formula,
			u_mtrltype_spring.dannum1_rate,
			u_mtrltype_spring.dannum2_rate,
			u_mtrltype_spring.dannum3_rate,
			u_mtrltype_spring.dannum4_rate
		From u_bednetmx
		left outer join (
			SELECT u_spring.springid,
			left(rtrim(cast(u_spring.line_diameter as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.height as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.caliber  as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.center_diameter  as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.cyclenum  as char(10))),4)   as name
			FROM u_spring
		) vv_spring on vv_spring.springid = u_bednetmx.springid
		left outer join (
			SELECT u_spring.springid,
			left(rtrim(cast(u_spring.line_diameter as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.height as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.caliber  as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.center_diameter  as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.cyclenum  as char(10))),4)   as name
			FROM u_spring
		) as vv_pocket_spring on vv_pocket_spring.springid = u_bednetmx.pocket_around_springid
		left outer join (
			SELECT u_spring.springid,
			left(rtrim(cast(u_spring.line_diameter as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.height as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.caliber  as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.center_diameter  as char(10))),4) + '/'+
			left(rtrim(cast(u_spring.cyclenum  as char(10))),4)   as name
			FROM u_spring
		) as vv_hard_spring on vv_hard_spring.springid = u_bednetmx.hard_around_springid
		CROSS JOIN (
			select dannum1_rate, dannum2_rate, dannum3_rate, dannum4_rate from u_mtrltype where mtrltypeid = 0
		) AS u_mtrltype_spring
	</selectstr>
	<where>
		<when notnull="@arg_bednetid">
			u_bednetmx.bednetid = @arg_bednetid
		</when>
	</where>
	<displayfields>
		<field field="pid" compute="getrow()">序</field>
		<field field="if_part" datatype="checkbox">
			多区
			袋装
		</field>
		<field field="bednet_height" datatype="integer">
			床网高
			CM
		</field>
		<field field="springname" ddd="dddw_spring">
			弹簧
			线径/高度/口径/中心直径/圈数
		</field>
		<field field="spring_qty_width" datatype="integer">
			弹簧排列
			个数-宽
		</field>
		<field field="spring_qty_length" datatype="integer">
			弹簧排列
			个数-长
		</field>
		<!--<field field="wire_mtrlid" mapper="u_bednetmx.mtrl0" ddd="dddw_mtrl0">
			拉丝网
			线径物料
		</field>-->
		<field field="if_side_iron" datatype="checkbox">
			边铁
			？
		</field>
		<field field="side_iron_qty" datatype="integer">
			边铁
			条数
		</field>
		<field field="fabrics2_mtrlid" mapper="u_bednetmx.mtrl2" ddd="dddw_mtrl2">底面无纺布</field>
		<field field="fabrics1_mtrlid" mapper="u_bednetmx.mtrl2" ddd="dddw_mtrl2">入袋无纺布</field>
		<field field="if_pocket_around" datatype="checkbox">
			四周
			口袋？
		</field>
		<field field="pocket_around_springname" ddd="dddw_spring">
			四周口袋
			弹簧
		</field>
		<field field="pocket_around_row" datatype="integer">
			四周口袋
			排数
		</field>
		<field field="if_hard_around" datatype="checkbox">
			四周
			加硬？
		</field>
		<field field="hard_around_springname" ddd="dddw_spring">
			四周加硬
			弹簧
		</field>
		<field field="hard_around_row" datatype="integer">
			四周加硬
			排数
		</field>
		<field field="if_15strip" datatype="checkbox">
			15分
			布条？
		</field>
		<field field="spring_mtrl_cost" datatype="number">弹簧总材料成本</field>
		<field field="spring_hr_cost" datatype="number">弹簧总人力成本</field>
		<field field="pocket_around_wire_price" datatype="number">
			四周口袋
			弹簧钢丝单价
		</field>
		<field field="pocket_around_spring_cost" datatype="number">
			四周口袋
			弹簧成本
		</field>
		<field field="pocket_around_fabrics_cost" datatype="number">
			四周口袋
			无纺布成本
		</field>
		<field field="hard_around_mtrl_cost" datatype="number">
			四周加硬
			材料成本
		</field>
		<field field="hard_around_hr_cost" datatype="number">
			四周加硬
			人力成本
		</field>
		<field field="hard_around_wire_price" datatype="number">
			四周加硬
			弹簧钢丝单价
		</field>
		<field field="fabrics1_mtrl_cost" datatype="number">
			入袋无纺布
			材料成本
		</field>
		<field field="fabrics1_price" datatype="number">
			入袋无纺布
			单价
		</field>
		<field field="fabrics2_price" datatype="number">
			底面无纺布
			单价
		</field>
		<field field="fabrics2_mtrl_cost" datatype="number">
			底面无纺布
			材料成本
		</field>
		<field field="side_iron_mtrl_cost" datatype="number">
			边铁
			材料成本
		</field>
		<field field="side_iron_hr_cost" datatype="number">
			边铁
			人力成本
		</field>
		<field field="glue_mtrl_cost" datatype="number" usermode_notequals="1">胶水材料成本</field>
		<field field="cnail_mtrl_cost" datatype="number" usermode_notequals="1">C钉/夹码材料成本</field>
		<field field="cnail_hr_cost" datatype="number" usermode_notequals="1">C钉/夹码人力成本</field>
		<field field="spring_mtrl_cost_replace_formula" usermode_notequals="1">弹簧总材料成本替换公式</field>
		<field field="spring_hr_cost_replace_formula" usermode_notequals="1">弹簧总人力成本替换公式</field>
		<field field="glue_mtrl_cost_replace_formula" usermode_notequals="1">胶水材料成本替换公式</field>
		<field field="pocket_around_spring_cost_replace_formula" usermode_notequals="1">四周口袋弹簧成本替换公式</field>
		<field field="pocket_around_fabrics_cost_replace_formula" usermode_notequals="1">四周口袋无纺布成本替换公式</field>
		<field field="hard_around_mtrl_cost_replace_formula" usermode_notequals="1">四周加硬材料成本替换公式</field>
		<field field="hard_around_hr_cost_replace_formula" usermode_notequals="1">四周加硬人力成本替换公式</field>
		<field field="fabrics1_mtrl_cost_replace_formula" usermode_notequals="1">入袋无纺布材料成本替换公式</field>
		<field field="fabrics2_mtrl_cost_replace_formula" usermode_notequals="1">底面无纺布材料成本替换公式</field>
		<field field="side_iron_mtrl_cost_replace_formula" usermode_notequals="1">边铁材料成本替换公式</field>
		<field field="side_iron_hr_cost_replace_formula" usermode_notequals="1">边铁人力成本替换公式</field>
		<field field="cnail_mtrl_cost_replace_formula" usermode_notequals="1">C钉/夹码材料成本替换公式</field>
		<field field="cnail_hr_cost_replace_formula" usermode_notequals="1">C钉/夹码人力成本替换公式</field>
	</displayfields>
</select>
