<?xml version="1.0" encoding="utf-8" ?>
<select>
	<selectstr>
		SELECT
			springid,
			line_diameter,
			Height,
			caliber,
			center_diameter,
			cyclenum,
			gram_weight,
			u_spring.dscrp,
			u_spring.createtime,
			u_spring.createby,
			u_spring.springtypeid,
			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 springname,
			u_spring.comperssion_rate,
			u_springtype.springtypecode,
			u_spring.height_original,
			CASE 
				WHEN hardness <= 8 THEN '软'
				WHEN hardness <= 11 THEN '中软'
				WHEN hardness <= 15 THEN '适中'
				WHEN hardness <= 20 THEN '中硬'
			ELSE '硬'
			END AS hardness_level
		From u_spring
		INNER JOIN u_springtype ON u_springtype.springtypeid = u_spring.springtypeid
	</selectstr>
	<where>
		<when notempty="@arg_line_diameter" arg_line_diameter!="-1">
			line_diameter LIKE '%' + @arg_line_diameter + '%'
		</when>
		<when notempty="@arg_height" arg_height!="-1">
			Height=@arg_height
		</when>
		<when notempty="@arg_caliber" arg_caliber!="-1">
			caliber=@arg_caliber
		</when>
		<when notempty="@arg_center_diameter" arg_center_diameter!="-1">
			center_diameter=@arg_center_diameter
		</when>
		<when notempty="@arg_cyclenum" arg_cyclenum!="-1">
			cyclenum=@arg_cyclenum
		</when>
		<when notempty="@arg_bedtypeid" arg_bedtypeid!="-1">
			bedtypeid=@arg_bedtypeid
		</when>
		<when notnull="@arg_springtypeid" arg_springtypeid!="-1">
			u_spring.springtypeid=@arg_springtypeid
		</when>
		<when>
			his_typeid=1
		</when>
		<when notnull="@arg_newspring" arg_newspring!="0">
			u_spring.springtypeid > 20
		</when>
		<when notnull="@arg_search">
			u_spring.line_diameter LIKE '%' + @arg_search + '%' OR
			u_spring.height LIKE '%' + @arg_search + '%' OR
			u_spring.caliber LIKE '%' + @arg_search + '%' OR
			u_spring.center_diameter LIKE '%' + @arg_search + '%' OR
			u_spring.cyclenum LIKE '%' + @arg_search + '%'
		</when>
	</where>
	<displayfields>
		<field field="pid" compute="getrow()">序</field>
		<field field="springname">弹簧名称</field>
		<field field="springtypeid" mapper="" width="100">弹簧分类</field>
		<field field="springtypecode" width="50">类型编码</field>
		<field field="hardness_level" width="50">软硬程度</field>
		<field field="line_diameter" datatype="number">线径MM</field>
		<field field="height" datatype="number">高度CM</field>
		<field field="height_original" datatype="number">入袋前高度CM</field>
		<field field="caliber" datatype="number">口经CM</field>
		<field field="center_diameter" datatype="number">中心直径CM</field>
		<field field="cyclenum" datatype="number">圈数</field>
		<field field="gram_weight" datatype="number">克重KG</field>
		<field field="dscrp">备注</field>
		<field field="createby">等记人</field>
		<field field="createtime" datatype="datetime">登记时间</field>
	</displayfields>
</select>
