<?xml version="1.0" encoding="utf-8" ?>
<select>
  <selectstr>
SELECT
	u_spring.springid, 
	u_spring.line_diameter, 
	u_spring.height, 
	u_spring.height_original, 
	u_spring.caliber, 
	u_spring.center_diameter, 
	u_spring.cyclenum, 
	u_spring.gram_weight, 
	u_spring.dscrp, 
	u_spring.createtime, 
	u_spring.createby, 
	u_spring.tempqty, 
	u_spring.bedtypeid, 
	u_spring.his_typeid, 
	u_spring.springtypeid, 
	u_spring.flag, 
	u_spring.inuse, 
	u_spring.modemp, 
	u_spring.moddate, 
	u_spring.free_height, 
	u_spring.actual_height, 
	u_spring.hardness, 
	u_spring.hardness_indentation_1, 
	u_spring.hardness_indentation_2, 
	u_spring.hardness_indentation_4, 
	u_spring.arrangement_width, 
	u_spring.arrangement_height, 
	u_spring.roll_width, 
	u_spring.roll_length, 
	u_spring.comperssion_rate,
	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_springtype.springtypecode,
	u_springtype.springtypename,
	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>
			u_spring.his_typeid = 1
		</when>
		<when notnull="@springtypeid">
			u_spring.springtypeid = @springtypeid
		</when>
		<when notnull="@bedtypeid">
			u_spring.bedtypeid = @bedtypeid
		</when>
		<when notnull="@cyclenum">
			u_spring.cyclenum = @cyclenum
		</when>
		<when notnull="@center_diameter">
			u_spring.center_diameter = @center_diameter
		</when>
		<when notnull="@caliber">
			u_spring.caliber = @caliber
		</when>
		<when notnull="@height">
			u_spring.height = @height
		</when>
		<when notnull="@line_diameter">
			u_spring.line_diameter = @line_diameter
		</when>
  </where>
  <displayfields>
    <field field="pid" compute="getrow()">序</field>
    <field field="springname">弹簧名称</field>
	<field field="springtypename">弹簧类型</field>
    <field field="springtypecode">类型编码</field>
    <field field="hardness_level">软硬程度</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="bedtypeid" mapper="">床网类型</field>
    <field field="springtypeid" mapper="">弹簧分类</field>
    <field field="dscrp">备注</field>
    <field field="createby">等记人</field>
    <field field="createtime" datatype="datetime">登记时间</field>
    <field field="flag" datatype="checkbox">审核</field>
    <field field="inuse" datatype="checkbox">禁用</field>
    <field field="modemp">修改人</field>
    <field field="moddate" datatype="datetime">修改时间</field>
    <field field="free_height" datatype="number">自由高度</field>
    <field field="actual_height" datatype="number">实际高度</field>
    <field field="hardness" datatype="number">硬度</field>
    <field field="hardness_indentation_1" datatype="number">压陷硬度10%</field>
    <field field="hardness_indentation_2" datatype="number">压陷硬度20%</field>
    <field field="hardness_indentation_4" datatype="number">压陷硬度40%</field>
    <field field="arrangement_width" datatype="number">排列宽</field>
    <field field="arrangement_height" datatype="number">排列长</field>
    <field field="roll_width" datatype="number">卷排列宽</field>
    <field field="roll_length" datatype="number">卷排列长</field>
    <field field="comperssion_rate" datatype="number">压缩比</field>
  </displayfields>
</select>
