<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
SELECT bednetmx_partid
	,u_bednetmx_spring.bednetmxid
	,u_bednetmx_spring.springid
	,ISNULL(vv_spring.name, '') AS springname
	,u_bednetmx_spring.spring_qty_width
	,u_bednetmx_spring.spring_qty_length
	,u_bednetmx_spring.fabrics1_mtrl_cost
	,u_bednetmx_spring.spring_mtrl_cost
	,u_bednetmx_spring.spring_mtrl_cost_replace_formula
	,u_bednetmx_spring.spring_weight_replace_formula
FROM u_bednetmx_spring
LEFT JOIN u_bednetmx ON u_bednetmx.bednetmxid = u_bednetmx_spring.bednetmxid
LEFT 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_spring.springid
	</selectstr>
	<where>
		<when notnull="@arg_bednetmxid">
			u_bednetmx_spring.bednetmxid = @arg_bednetmxid
		</when>
		<when notnull="@arg_bednetid">
			u_bednetmx.bednetid = @arg_bednetid
		</when>
	</where>
	<displayfields>
		<field field="pid" compute="getrow()">
			序
		</field>
		<field field="springname">
			弹簧
		</field>
		<field field="spring_qty_width" datatype="integer">
			弹簧排列
			个数-宽
		</field>
		<field field="spring_qty_length" datatype="integer">
			弹簧排列
			个数-长
		</field>
		<field field="spring_mtrl_cost" usermode_notequals="1">弹簧材料总成本</field>
		<field field="spring_mtrl_cost_replace_formula" usermode_notequals="1">弹簧材料总成本替换公式</field>
		<field field="spring_weight_replace_formula" usermode_notequals="1">钢丝重量替换公式</field>
	</displayfields>
</select>
