<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
		SELECT
		bednetmxid,
		bednetid,
		spring_qty_width,
		spring_qty_length,
		bednet_height,
		wire_mtrlid,
		u_bednetmx.springid,
		ISNULL(vv_spring.name, '') 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,
		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
		From u_bednetmx
		left outer join (
			SELECT u_spring.springid,
			CASE
				WHEN springname <> '' THEN springname
				WHEN u_springtype.springtypecode <> '' THEN 
					rtrim(u_springtype.springtypecode)  + '/'+
					left(rtrim(cast(u_spring.height_original as char(10))),2) + '/'+
					left(rtrim(cast(u_spring.height as char(10))),2) + '/'+
					left(rtrim(cast(u_spring.caliber  as char(10))),4) + '/'+
					left(rtrim(cast(u_spring.center_diameter  as char(10))),3) + '/'+
					left(rtrim(cast(u_spring.cyclenum  as char(10))),1) + '/'+
					left(rtrim(cast(u_spring.line_diameter as char(10))),3) + '-'+
					left(rtrim(cast(u_spring.hardness as char(10))),5)
				ELSE 
					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) 
				END as name
		FROM u_spring
		INNER JOIN u_springtype ON u_springtype.springtypeid = u_spring.springtypeid
		) 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
	</selectstr>
	<where>
		<when notnull="@arg_bednetid">
			u_bednetmx.bednetid = @arg_bednetid
		</when>
	</where>
	<displayfields>
		<field field="pid" compute="getrow()">序</field>
		<field field="springname" ddd="dddw_spring">
			弹簧
		</field>
		<field field="spring_qty_width" datatype="number">
			弹簧排列
			个数-宽
		</field>
		<field field="spring_qty_length" datatype="number">
			弹簧排列
			个数-长
		</field>
		<field field="bednet_height" datatype="number">
			床网高
			CM
		</field>
		<field field="wire_mtrlid" mapper="u_bednetmx.mtrl0" ddd="dddw_mtrl0">
			拉丝网
			线径物料
		</field>
		<field field="if_part" datatype="checkbox">
			多区
			袋装
		</field>
		<field field="if_15strip" datatype="checkbox">
			15分
			布条？
		</field>
		<field field="if_pocket_around" datatype="checkbox">
			四周
			口袋？
		</field>
		<field field="pocket_around_springname" ddd="dddw_spring">
			四周口袋
			弹簧
		</field>
		<field field="pocket_around_row">
			四周口袋
			排数
		</field>
		<field field="if_hard_around" datatype="checkbox">
			四周
			加硬？
		</field>
		<field field="hard_around_springid">
			四周加硬
			弹簧
		</field>
		<field field="hard_around_row" datatype="number">
			四周加硬
			排数
		</field>
		<field field="fabrics1_mtrlid">入袋无纺布</field>
		<field field="fabrics2_mtrlid">底面无纺布</field>
		<field field="if_side_iron" datatype="checkbox">
			边铁
			？
		</field>
		<field field="side_iron_qty" datatype="number">
			边铁
			条数
		</field>
	</displayfields>
</select>
