select id,task_id, purchase_time, arrival_time, purchaser, create_by, create_time, update_by, update_time, remark, company_id from purchase_check_info
select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_by, pci.create_time,
pci.update_by,
pci.update_time, pci.remark, pci.company_id ,dict.name purchasingStatus,tk.code,su.user_name
purchaserName,tk.task_status taskStatus
from purchase_check_info pci
left join tm_task tk on pci.task_id = tk.task_id
left join (select id,name from sys_dic where p_id = 23) dict on tk.task_status = dict.id
left join sys_user su on pci.purchaser = su.user_id
LEFT JOIN purchase_check_details pcd on pcd.task_id=pci.task_id
where task_type = 23
and (tk.code like concat('%',#{keyWord},'%') or
su.user_name like concat('%',#{keyWord},'%')
)
and pci.purchase_time = #{purchaseTime}
and pci.arrival_time = #{arrivalTime}
and pci.purchaser = #{purchaser}
and pci.company_id = #{companyId}
AND #{typeId} IN (SELECT mt2.type_id
FROM purchase_check_details pcd
LEFT JOIN ma_type mt on mt.type_id=pcd.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
WHERE pcd.task_id = pci.task_id
)
AND ((pci.purchase_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59'))
or (pci.arrival_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')))
GROUP BY pcd.task_id
order by pci.create_time desc
select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_by, pci.create_time,
pci.update_by, pci.update_time, pci.remark, pci.company_id, tk.code
from purchase_check_info pci
left join tm_task tk on pci.task_id = tk.task_id
where pci.task_id = #{taskId}
insert into purchase_check_info
task_id,
purchase_time,
arrival_time,
purchaser,
create_by,
create_time,
update_by,
update_time,
remark,
company_id,
#{taskId},
#{purchaseTime},
#{arrivalTime},
#{purchaser},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{companyId},
update purchase_check_info
purchase_time = #{purchaseTime},
arrival_time = #{arrivalTime},
purchaser = #{purchaser},
create_by = #{createBy},
create_time = #{createTime},
update_by = #{updateBy},
update_time = #{updateTime},
remark = #{remark},
company_id = #{companyId},
where task_id = #{taskId}
update ma_machine set ma_status = #{maStatus} where ma_id = #{maId}
update ma_type set num = #{num} where type_id = #{typeId}
update purchase_macode_info
set status = #{status}
where task_id = #{taskId}
and type_id = #{typeId}
and ma_code = #{maCode}
update
purchase_macode_info
set status='2'
where ma_code = #{maCode}
and task_id = #{taskId}
and type_id = #{typeId}
update purchase_macode_info set status = #{status} where task_id = #{taskId} and ma_code = #{maCode} and type_id = #{typeId}
delete from purchase_check_info where task_id = #{taskId}
delete from purchase_check_info where task_id in
#{taskId}
delete from ma_machine where ma_id = #{maId}
delete from ma_machine_label where ma_id = #{maId}
delete from ma_label_bind where ma_id = #{maId}
select GROUP_CONCAT(type_name) typeName from
(select distinct pcd.task_id, mt1.type_name
from purchase_check_details pcd
left join ma_type mt on pcd.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where pcd.task_id = #{taskId}
and pcd.`status`!=3
) t
GROUP BY task_id
insert into bm_notice_info
task_id,
content,
notice_user,
phone,
model_name,
create_by,
create_time,
update_by,
update_time,
remark,
company_id,
#{taskId},
#{content},
#{noticeUser},
#{phone},
#{modelName},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{companyId},
insert into input_apply_details
task_id,
ma_id,
type_id,
parent_id,
input_num,
input_type,
create_by,
create_time,
update_by,
update_time,
remark,
company_id,
#{taskId},
#{maId},
#{typeId},
#{parentId},
#{inputNum},
#{inputType},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{companyId},
insert into ma_input_record
task_id,
type_id,
ma_id,
input_type,
input_num,
status,
create_by,
create_time,
update_by,
update_time,
remark,
company_id,
#{taskId},
#{typeId},
#{maId},
#{inputType},
#{inputNum},
#{status},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
#{companyId},
select pci.id,pci.task_id, pci.purchase_time, pci.arrival_time, pci.purchaser, pci.create_time, pci.update_by,
pci.update_time, pci.remark, pci.company_id ,dict.name purchasingStatus,tk.code,tk.task_status taskStatus,su.user_name purchaserName,
tk.create_by,
CASE tk.task_status
WHEN 28 THEN
tk.update_time
ELSE
''
END as inputTime,
CASE tk.task_status
WHEN 28 THEN
us.user_name
ELSE
''
END as inputUser
from purchase_check_info pci
left join tm_task tk on pci.task_id = tk.task_id
left join (select id,name from sys_dic where p_id = 50) dict on tk.task_status = dict.id
left join sys_user su on pci.purchaser = su.user_id
LEFT JOIN sys_user us on us.user_id = tk.update_by
LEFT JOIN purchase_check_details pcd on pcd.task_id=pci.task_id
where task_type = 23
and tk.task_status = #{taskStatus}
and tk.task_status in (28,105,106,107,122,123)
and (tk.code like concat('%',#{keyWord},'%') or
su.user_name like concat('%',#{keyWord},'%')
)
and pci.purchase_time = #{purchaseTime}
and pci.arrival_time = #{arrivalTime}
and pci.purchaser = #{purchaser}
and pci.company_id = #{companyId}
AND #{typeId} IN (SELECT mt2.type_id
FROM purchase_check_details pcd
LEFT JOIN ma_type mt on mt.type_id=pcd.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
WHERE pcd.task_id = pci.task_id
)
AND (pci.purchase_time BETWEEN #{startTime} AND #{endTime})
or (pci.arrival_time BETWEEN #{startTime} AND #{endTime})
GROUP BY pcd.task_id
order by pci.id desc
SELECT
tk.CODE,
pci.purchase_time as purchaseTime,
pci.arrival_time as arrivalTime,
su.user_name purchaserName,
mt1.type_name as purchasingTypeName,
mt.type_name AS purchasingTypeCode,
mt.manage_type as manageType,
msi.supplier,
pcd.purchase_num as purchaseNum,
pcd.check_num as checkNum,
dict.NAME AS purchasingStatus,
tk.task_status as taskStatus
FROM
purchase_check_details pcd
LEFT JOIN purchase_check_info pci ON pci.task_id = pcd.task_id
LEFT JOIN tm_task tk ON pci.task_id = tk.task_id
LEFT JOIN ( SELECT id, NAME FROM sys_dic WHERE p_id = 23 ) dict ON tk.task_status = dict.id
LEFT JOIN sys_user su ON pci.purchaser = su.user_id
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
LEFT JOIN ma_supplier_info msi ON msi.supplier_id = pcd.supplier_id
WHERE
task_type = 23
and tk.code like concat('%',#{keyWord},'%')
and pci.purchase_time = #{purchaseTime}
and pci.arrival_time = #{arrivalTime}
and pci.purchaser = #{purchaser}
and pci.company_id = #{companyId}
ORDER BY
pcd.task_id DESC
SELECT pcd.task_id as taskId,
tk.`code`,
pci.purchase_time as purchaseTime,
pci.arrival_time as arrivalTime,
pci.purchaser,
su.user_name purchaserName,
mt1.type_name as purchasingTypeName,
mt.type_name as purchasingTypeCode,
pcd.input_time as inputTime,
su.user_name as inputUser,
pcd.input_status as inputStatus
FROM purchase_check_details pcd
LEFT JOIN purchase_check_info pci on pci.task_id = pcd.task_id
left join tm_task tk on pcd.task_id = tk.task_id
left join sys_user su on pci.purchaser = su.user_id
left join ma_type mt on pcd.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where task_type = 23
and tk.task_status in (26, 28)
and tk.code like concat('%',#{keyWord},'%')
and pci.purchase_time = #{purchaseTime}
and pci.arrival_time = #{arrivalTime}
and pci.purchaser = #{purchaser}
and pci.company_id = #{companyId}
ORDER BY pcd.task_id desc
select pcd.production_time productionTime,
mt.type_name specificationType,
mt1.type_name typeName,
pmi.ma_code maCode,
mm.assets_code assetsCode,
pmi.fix_code fixCode,
pcd.type_id typeId,
pcd.task_id taskId,
mt.code specsCode,
mt1.code typeCode,
CASE
WHEN pmi.ma_code is null THEN
CASE
WHEN pcd.status = 4 THEN 1
WHEN pcd.status = 5 THEN 2
WHEN pcd.status = 6 THEN 3
WHEN pcd.status = 7 THEN 4
ELSE 0
END
ELSE pmi.status
END AS status,
mm.qr_code qrCode,
mm.ma_id maId,
if(pmi.ma_code is not null, 1, pcd.check_num) checkNum
from purchase_check_details pcd
left join purchase_macode_info pmi on pmi.task_id = pcd.task_id and pmi.type_id = pcd.type_id
left join ma_machine mm on pmi.ma_code = mm.ma_code
left join ma_type mt on pcd.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where pcd.task_id = #{taskId}
and pcd.`status`!=3
and (mt.type_name like concat('%',#{dictName},'%') or
mt1.type_name like concat('%',#{dictName},'%'))
order by status
select type_id typeId, type_name, parent_id, status, num, unit_id, manage_type, lease_price, buy_price, pay_price,
level, rated_load, test_load, holding_time, warn_num, del_flag, create_by,
create_time, remark, company_id
from ma_type where type_id = #{typeId}
select count(*) from purchase_check_details where task_id = #{taskId} and status ='1'
SELECT
COUNT(*)
FROM
bm_flow_relation bfr
LEFT JOIN bm_flow bf on bfr.flow_id=bf.id
WHERE
bf.task_type='23'
AND bfr.company_id = #{companyId}
and bfr.`status`='1'
and bf.`status`='1'
SELECT
count(*)
FROM
purchase_check_details
WHERE
task_id = #{taskId} and status =1
SELECT
count(*)
FROM
purchase_check_details
WHERE
task_id = #{taskId} and status != 7 and `status` !=3
SELECT
count(*)
FROM
purchase_macode_info
WHERE
task_id = #{taskId}
AND type_id = #{typeId}
AND `status` = '0'
SELECT
count(*)
FROM
purchase_macode_info
WHERE
task_id = #{taskId}
AND type_id = #{typeId}
AND `status` != '4'