| | |
| | | <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.InsOrder"> |
| | | <id property="id" column="id" jdbcType="INTEGER"/> |
| | | <result property="entrustCode" column="entrust_code" jdbcType="VARCHAR"/> |
| | | <result property="outEntrustCode" column="out_entrust_code" jdbcType="VARCHAR"/> |
| | | <result property="custom" column="custom" jdbcType="VARCHAR"/> |
| | | <result property="company" column="company" jdbcType="VARCHAR"/> |
| | | <result property="code" column="code" jdbcType="VARCHAR"/> |
| | |
| | | <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/> |
| | | <result property="state" column="state" jdbcType="INTEGER"/> |
| | | <result property="remark" column="remark" jdbcType="VARCHAR"/> |
| | | <result property="rule" column="rule" jdbcType="VARCHAR"/> |
| | | <result property="otcCode" column="otc_code" jdbcType="VARCHAR"/> |
| | | <result property="createUser" column="create_user" jdbcType="INTEGER"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateUser" column="update_user" jdbcType="INTEGER"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | <result property="revocationInsProductIds" column="revocation_ins_product_ids"/> |
| | | <result property="isRevocation" column="is_revocation"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="OrderThingDto" type="com.yuanchu.mom.dto.OrderThingDto"> |
| | |
| | | <association property="children" resultMap="SampleDefectsChildrenMap" javaType="java.util.List"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="SampleOrderDto" type="com.yuanchu.mom.dto.SampleOrderDto"> |
| | | <id property="id" column="id" jdbcType="INTEGER"/> |
| | | <result property="entrustCode" column="entrust_code" jdbcType="VARCHAR"/> |
| | | <result property="outEntrustCode" column="out_entrust_code" jdbcType="VARCHAR"/> |
| | | <result property="custom" column="custom" jdbcType="VARCHAR"/> |
| | | <result property="company" column="company" jdbcType="VARCHAR"/> |
| | | <result property="code" column="code" jdbcType="VARCHAR"/> |
| | | <result property="type" column="type" jdbcType="INTEGER"/> |
| | | <result property="appointed" column="appointed" jdbcType="TIMESTAMP"/> |
| | | <result property="state" column="state" jdbcType="INTEGER"/> |
| | | <result property="remark" column="remark" jdbcType="VARCHAR"/> |
| | | <result property="rule" column="rule" jdbcType="VARCHAR"/> |
| | | <result property="otcCode" column="otc_code" jdbcType="VARCHAR"/> |
| | | <result property="createUser" column="create_user" jdbcType="INTEGER"/> |
| | | <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
| | | <result property="updateUser" column="update_user" jdbcType="INTEGER"/> |
| | | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
| | | <result property="revocationInsProductIds" column="revocation_ins_product_ids"/> |
| | | <result property="assign" column="assign"/> |
| | | <result property="sampleNum" column="sample_num"/> |
| | | <result property="insProgress" column="insProgress"/> |
| | | <result property="sampleCode" column="sample_code"/> |
| | | <result property="motorNumber" column="motor_number"/> |
| | | <result property="sampleName" column="sample_name"/> |
| | | <result property="sampleModel" column="sample_model"/> |
| | | <result property="name" column="name"/> |
| | | <collection property="reportDtos" ofType="com.yuanchu.mom.dto.ReportDto" resultMap="reportDto"/> |
| | | </resultMap> |
| | | <resultMap id="reportDto" type="com.yuanchu.mom.dto.ReportDto"> |
| | | <result property="reportId" column="report_id"/> |
| | | <result property="url" column="url"/> |
| | | <result property="urlS" column="urlS"/> |
| | | <result property="codeUrl" column="codeUrl"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectInsOrderPage" resultMap="SampleOrderDto"> |
| | | select *from (select a.* , |
| | | ir.id report_id, |
| | | ir.url, |
| | | ir.url_s, |
| | | ir.sample_code as codeUrl |
| | | from ( |
| | | SELECT |
| | | io.*, |
| | | isau.user_id assign, |
| | | sample_counts.sample_num, |
| | | CONCAT(ROUND(approved_product_counts.approved_count / total_product_counts.total_count * 100, 2), '%') AS |
| | | insProgress, |
| | | GROUP_CONCAT(DISTINCT isa.sample_code SEPARATOR ',') AS sample_code, |
| | | GROUP_CONCAT(DISTINCT isa.motor_number SEPARATOR ',') AS motor_number, |
| | | GROUP_CONCAT(DISTINCT isa.sample SEPARATOR ' ') AS sample_name, |
| | | GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, |
| | | u.name |
| | | FROM |
| | | ins_order io |
| | | LEFT JOIN |
| | | ins_sample isa ON io.id = isa.ins_order_id |
| | | LEFT JOIN |
| | | ins_sample_user isau ON isau.ins_sample_id = io.id |
| | | LEFT JOIN |
| | | user u ON io.create_user = u.id |
| | | LEFT JOIN |
| | | (SELECT ins_order_id, COUNT(*) AS sample_num |
| | | FROM ins_sample |
| | | WHERE id in(select id1 from (select is2.id id1 ,ip.id from ins_sample is2 left join ins_product ip on is2.id = |
| | | ip.ins_sample_id where ip.id is not null)s ) |
| | | GROUP BY ins_order_id) sample_counts ON io.id = sample_counts.ins_order_id |
| | | LEFT JOIN |
| | | (SELECT ins_sample.ins_order_id, COUNT(*) AS total_count |
| | | FROM ins_product |
| | | JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id |
| | | WHERE ins_product.state = 1 |
| | | GROUP BY ins_sample.ins_order_id) total_product_counts ON io.id = total_product_counts.ins_order_id |
| | | LEFT JOIN |
| | | (SELECT ins_sample.ins_order_id, COUNT(*) AS approved_count |
| | | FROM ins_product |
| | | JOIN ins_sample ON ins_product.ins_sample_id = ins_sample.id |
| | | WHERE ins_product.state = 1 AND ins_product.ins_result IS NOT NULL |
| | | GROUP BY ins_sample.ins_order_id) approved_product_counts ON io.id = approved_product_counts.ins_order_id |
| | | WHERE |
| | | 1=1 |
| | | <if test="laboratory!=null and laboratory!=''"> |
| | | AND io.laboratory=#{laboratory} |
| | | </if> |
| | | GROUP BY io.id,type |
| | | order by type desc,io.id desc |
| | | ) a |
| | | LEFT JOIN |
| | | (SELECT r.id, r.ins_order_id, is_ratify, url, url_s,sample_code FROM ins_report r left join ins_sample isa on r.ins_sample_id = isa.id WHERE is_ratify = 1) ir ON a.id = |
| | | ir.ins_order_id )b |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | <resultMap id="SampleDefectsChildrenMap" type="com.yuanchu.mom.vo.SampleDefectsChildrenVo"> |
| | | <result column="entrust_code" property="entrust_code"/> |
| | | <result column="inspection_item" property="inspection_item"/> |
| | | <result column="name" property="name"/> |
| | | <result column="create_time" property="create_time"/> |
| | | </resultMap> |
| | | <select id="selectInsOrderParameter" resultType="com.yuanchu.mom.pojo.InsOrder"> |
| | | select * |
| | | from ( |
| | | select |
| | | id, |
| | | appointed, |
| | | user_id, |
| | | create_user, |
| | | otc_code, |
| | | code, |
| | | custom, |
| | | update_user, |
| | | update_time, |
| | | type, |
| | | entrust_code, |
| | | company, |
| | | remark, |
| | | create_time, |
| | | state |
| | | from ins_order |
| | | ) a |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | <select id="selectInsOrderPage" resultType="com.yuanchu.mom.dto.SampleOrderDto"> |
| | | select * |
| | | from ( |
| | | SELECT |
| | | io.*, |
| | | ir.id report_id, |
| | | ir.url, |
| | | ir.url_s, |
| | | (select count(*) from ins_sample isa2 |
| | | where isa2.ins_order_id = io.id) sample_num, |
| | | concat(ROUND((select count(*) from ins_order_state ios |
| | | where ins_state = 5 and ios.ins_order_id = io.id) / (select count(*) from ins_order_state ios2 |
| | | where ios2.ins_order_id = io.id) * 100, 2), '%') insProgress, |
| | | group_concat(distinct isa.sample_code,' ') sample_code, |
| | | group_concat(distinct isa.sample,' ') sample_name, |
| | | group_concat(distinct isa.model,' ') sample_model |
| | | FROM |
| | | ins_order io |
| | | LEFT JOIN ins_sample isa ON io.id = isa.ins_order_id |
| | | LEFT JOIN ( SELECT id, ins_order_id, is_ratify, url,url_s FROM ins_report WHERE is_ratify = 1 ) ir ON io.id = |
| | | ir.ins_order_id |
| | | GROUP BY |
| | | io.id |
| | | ) a |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | <select id="getLaboratoryCode" resultType="java.lang.String"> |
| | | select laboratory_number |
| | | from laboratory |
| | |
| | | <select id="selectSampleAndProductByOrderId" resultType="com.yuanchu.mom.dto.SampleProductDto2"> |
| | | select * |
| | | from ( |
| | | select i.id,isa.sample_code,isa.sample,isa.model,isa.ins_state,ip.state,ip.unit,ip.inspection_item,ip.inspection_item_subclass, |
| | | ip.son_laboratory,ip.inspection_item_type,ip.inspection_value_type,ip.ask,ip.`last_value`,ip.ins_result,ipr.equip_value |
| | | select |
| | | i.id,isa.sample_code,isa.sample,isa.model,isa.ins_state,ip.id |
| | | insProductId,ip.state,ip.unit,ip.inspection_item,ip.inspection_item_subclass, |
| | | ip.son_laboratory,ip.inspection_item_type,ip.inspection_value_type,ip.tell,ip.`last_value`,ip.ins_result,ipr.equip_value |
| | | from ins_sample isa |
| | | left join ins_order i on isa.ins_order_id = i.id |
| | | left join ins_product ip on isa.id = ip.ins_sample_id |
| | | left join ins_product_result ipr on ip.id = ipr.ins_product_id |
| | | where ip.state = 1 |
| | | and i.id=#{id} |
| | | ) a |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | |
| | | </select> |
| | | <select id="selectCostStatistics" resultType="com.yuanchu.mom.dto.CostStatisticsDto"> |
| | | select * from ( |
| | | SELECT |
| | | i.id, |
| | | SELECT A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name`, |
| | | COUNT(1) num, |
| | | ROUND(SUM(A.price),2) price |
| | | FROM (SELECT i.id, |
| | | i.entrust_code, |
| | | i.create_time, |
| | | isa.sample, |
| | | isa.model, |
| | | c.price, |
| | | c.cost, |
| | | c.inspection_item, |
| | | u.company, |
| | | u.`name`, |
| | | i.create_user, |
| | | c.ins_sample_id |
| | | FROM |
| | | ins_order i |
| | | ins_sample_id, |
| | | sum(c.price * times) price, |
| | | GROUP_CONCAT(distinct c.inspection_item SEPARATOR ',') inspection_item, |
| | | i.company, |
| | | u.`name` |
| | | FROM ins_order i |
| | | LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id |
| | | LEFT JOIN `user` u ON u.id = i.user_id |
| | | LEFT JOIN (select SUM(b.price) price, sum(b.man_hour) cost,b.ins_sample_id,GROUP_CONCAT(b.inspection_item2 |
| | | SEPARATOR ',') |
| | | inspection_item from (select *,GROUP_CONCAT(inspection_item |
| | | SEPARATOR ',') inspection_item2 from ins_product where state = 1 GROUP BY ins_sample_id,man_hour_group) b GROUP |
| | | BY b.ins_sample_id) c ON c.ins_sample_id = isa.id |
| | | ) a |
| | | left join custom cus on cus.id = u.company |
| | | LEFT JOIN (select ip.ins_sample_id, |
| | | ip.inspection_item, |
| | | ip.inspection_item_subclass, |
| | | ip.price, |
| | | sum(aowh.output_work_time) times |
| | | from ins_product ip |
| | | left join auxiliary_output_working_hours aowh on ip.id = aowh.ins_product_id |
| | | where state = 1 |
| | | and ins_result is not null |
| | | and ins_result != 2 |
| | | and template_id IS NOT NULL |
| | | group by ip.ins_sample_id, |
| | | ip.inspection_item, |
| | | ip.inspection_item_subclass, |
| | | ip.price) c ON c.ins_sample_id = isa.id |
| | | where (i.state = 4) |
| | | and c.ins_sample_id IS not NULL |
| | | group by i.id, |
| | | i.entrust_code, |
| | | i.create_time, |
| | | isa.sample, |
| | | isa.model, |
| | | i.company, |
| | | ins_sample_id, |
| | | u.`name`) A |
| | | GROUP BY A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name` |
| | | ) B |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | <select id="selectDeviceList" resultType="java.util.Map"> |
| | | select device_name,specification_model,management_number,DATE_ADD(date_format(last_calibration_date, '%Y-%m-%d'),INTERVAL calibration_date month) latest_traceability |
| | | select device_name,specification_model,management_number,<!--DATE_ADD(date_format(last_calibration_date, |
| | | '%Y-%m-%d'),INTERVAL calibration_date month)--> date_format(next_calibration_date,'%Y-%m-%d') |
| | | latest_traceability |
| | | from device |
| | | where device.management_number in |
| | | <foreach collection="names" index="index" open="(" separator="," close=")" item="val"> |
| | |
| | | <update id="upInsOrderParameter" parameterType="com.yuanchu.mom.pojo.InsOrder"> |
| | | UPDATE ins_order |
| | | <set> |
| | | <if test="appointed!=null and appointed!='' ">appointed=#{appointed},</if> |
| | | <if test="userId!=null ">user_id=#{userId},</if> |
| | | <if test="createUser!=null ">create_user=#{createUser}</if> |
| | | <if test="otcCode!=null ">otc_code=#{otcCode}</if> |
| | | <if test="code!=null ">code=#{code}</if> |
| | | <if test="custom!=null ">custom=#{custom}</if> |
| | | <if test="updateUser!=null ">update_user=#{updateUser}</if> |
| | | <if test="updateTime!=null ">update_time=#{updateTime}</if> |
| | | <if test="type!=null ">type=#{type}</if> |
| | | <if test="entrustCode!=null ">entrust_code=#{entrustCode}</if> |
| | | <if test="company!=null ">company=#{company}</if> |
| | | <if test="remark!=null ">remark=#{remark}</if> |
| | | <if test="createTime!=null ">create_time=#{createTime}</if> |
| | | <if test="state!=null ">state=#{state}</if> |
| | | <if test="appointed!=null and appointed!='' "> |
| | | appointed=#{appointed}, |
| | | </if> |
| | | <if test="userId!=null "> |
| | | user_id=#{userId}, |
| | | </if> |
| | | <if test="createUser!=null "> |
| | | create_user=#{createUser} |
| | | </if> |
| | | <if test="otcCode!=null "> |
| | | otc_code=#{otcCode} |
| | | </if> |
| | | <if test="code!=null "> |
| | | code=#{code} |
| | | </if> |
| | | <if test="custom!=null "> |
| | | custom=#{custom} |
| | | </if> |
| | | <if test="updateUser!=null "> |
| | | update_user=#{updateUser} |
| | | </if> |
| | | <if test="updateTime!=null "> |
| | | update_time=#{updateTime} |
| | | </if> |
| | | <if test="type!=null "> |
| | | type=#{type} |
| | | </if> |
| | | <if test="entrustCode!=null "> |
| | | entrust_code=#{entrustCode} |
| | | </if> |
| | | <if test="company!=null "> |
| | | company=#{company} |
| | | </if> |
| | | <if test="remark!=null "> |
| | | remark=#{remark} |
| | | </if> |
| | | <if test="createTime!=null "> |
| | | create_time=#{createTime} |
| | | </if> |
| | | <if test="state!=null "> |
| | | state=#{state} |
| | | </if> |
| | | </set> |
| | | <where> |
| | | id=#{id} |
| | | </where> |
| | | </update> |
| | | <update id="updateStatus"> |
| | | update ins_order |
| | | set state=3 |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | <select id="selectSampleDefects" resultMap="selectSampleDefectsMap"> |
| | |
| | | ) temp |
| | | </select> |
| | | <select id="getEnumLabelByValue" resultType="java.lang.String"> |
| | | select label from `center-lims`.enums |
| | | select label |
| | | from `center-lims`.enums |
| | | where value = #{value} |
| | | </select> |
| | | <select id="getStandardMethodCode" resultType="java.lang.String"> |
| | | select code from `center-lims`.standard_method |
| | | where id = #{id} |
| | | <select id="selLaboratoryCode" resultType="java.lang.String"> |
| | | select laboratory_code |
| | | from laboratory |
| | | where laboratory_name = #{laboratory} |
| | | </select> |
| | | <select id="selectReportModelByOrderId" resultType="java.util.Map"> |
| | | select distinct id, name |
| | | from standard_template |
| | | where id in (select template_id |
| | | from ins_product |
| | | where son_laboratory = #{laboratory} |
| | | and ins_sample_id in |
| | | (select id from ins_sample where ins_order_id = #{id})) |
| | | </select> |
| | | |
| | | <select id="selectCostStatistics2" resultType="com.yuanchu.mom.dto.CostStatisticsDto"> |
| | | select * from ( |
| | | SELECT A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name`, |
| | | COUNT(1) num, |
| | | ROUND(SUM(A.price),2) price |
| | | FROM (SELECT i.id, |
| | | i.entrust_code, |
| | | i.create_time, |
| | | isa.sample, |
| | | isa.model, |
| | | ins_sample_id, |
| | | sum(c.price * times) price, |
| | | GROUP_CONCAT(distinct c.inspection_item SEPARATOR ',') inspection_item, |
| | | i.company, |
| | | u.`name` |
| | | FROM ins_order i |
| | | LEFT JOIN ins_sample isa ON isa.ins_order_id = i.id |
| | | LEFT JOIN `user` u ON u.id = i.user_id |
| | | left join custom cus on cus.id = u.company |
| | | LEFT JOIN (select ip.ins_sample_id, |
| | | ip.inspection_item, |
| | | ip.inspection_item_subclass, |
| | | ip.price, |
| | | sum(aowh.output_work_time) times |
| | | from ins_product ip |
| | | left join auxiliary_output_working_hours aowh on ip.id = aowh.ins_product_id |
| | | where state = 1 |
| | | and ins_result is not null |
| | | and ins_result != 2 |
| | | and template_id IS NOT NULL |
| | | group by ip.ins_sample_id, |
| | | ip.inspection_item, |
| | | ip.inspection_item_subclass, |
| | | ip.price) c ON c.ins_sample_id = isa.id |
| | | where (i.state = 4) |
| | | and c.ins_sample_id IS not NULL |
| | | group by i.id, |
| | | i.entrust_code, |
| | | i.create_time, |
| | | isa.sample, |
| | | isa.model, |
| | | i.company, |
| | | ins_sample_id, |
| | | u.`name`) A |
| | | GROUP BY A.id, |
| | | A.entrust_code, |
| | | A.create_time, |
| | | A.sample, |
| | | A.model, |
| | | A.inspection_item, |
| | | A.company, |
| | | A.`name` |
| | | ) B |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="seldepLimsId" resultType="java.lang.String"> |
| | | select name |
| | | from department_lims |
| | | where id = #{depLimsId} |
| | | </select> |
| | | |
| | | <select id="selectById2" resultType="com.yuanchu.mom.pojo.InsOrder"> |
| | | select ins_order.*, user.id prepareUserId |
| | | from ins_order |
| | | join user on prepare_user = name |
| | | where ins_order.id = #{id} |
| | | </select> |
| | | </mapper> |