select id, material_code, material_name, specification, model, unit,
CASE
WHEN CAST(actual_quantity_issued AS CHAR) LIKE '%.0000' THEN FLOOR(actual_quantity_issued)
ELSE actual_quantity_issued
END AS actual_quantity_issued,delivery_warehouse, ck_number, document_remarks,
document_type, inventory_organization, receiving_tissue, inventory_direction, date_of_delivery, materials_requisition_department,
material_taker, business_type, owner_type, owner, document_status, detailed_remarks, create_by_id, create_by, create_time,
update_by_id, update_by, update_time, del_flag,product_code,product_name,product_model,product_specification,material_type,process,order_number,production_order_number from fjqydb.material_retention_log
SELECT
mrl.id,
mrl.material_code,
mrl.material_name,
mrl.specification,
mrl.model,
mrl.unit,
CASE
WHEN CAST( mrl.actual_quantity_issued AS CHAR ) LIKE '%.0000' THEN
FLOOR( mrl.actual_quantity_issued ) ELSE mrl.actual_quantity_issued
END AS actual_quantity_issued,
mrl.delivery_warehouse,
mrl.ck_number,
mrl.document_remarks,
mrl.document_type,
mrl.inventory_organization,
mrl.receiving_tissue,
mrl.inventory_direction,
mrl.date_of_delivery,
mrl.materials_requisition_department,
mrl.material_taker,
mrl.business_type,
mrl.owner_type,
mrl.OWNER,
mrl.document_status,
mrl.detailed_remarks,
mrl.create_by_id,
mrl.create_by,
mrl.create_time,
mrl.update_by_id,
mrl.update_by,
mrl.update_time,
mrl.del_flag,
mrl.product_code,
mrl.product_name,
mrl.product_model,
mrl.product_specification,
mrl.material_type,
mrl.process,
mrl.order_number,
mrl.production_order_number
FROM
fjqydb.material_retention_log AS mrl
LEFT JOIN fjqydb.plan_task_details AS ptd ON ptd.demand_document = mrl.production_order_number
insert into fjqydb.material_retention_log
material_code,
material_name,
specification,
model,
unit,
actual_quantity_issued,
delivery_warehouse,
ck_number,
document_remarks,
document_type,
inventory_organization,
receiving_tissue,
inventory_direction,
date_of_delivery,
materials_requisition_department,
material_taker,
business_type,
owner_type,
owner,
document_status,
detailed_remarks,
create_by_id,
create_by,
create_time,
update_by_id,
update_by,
update_time,
del_flag,
product_code,
product_name,
prouuct_model,
product_specification,
order_number,
production_order_number,
#{materialCode},
#{materialName},
#{specification},
#{model},
#{unit},
#{actualQuantityIssued},
#{deliveryWarehouse},
#{ckNumber},
#{documentRemarks},
#{documentType},
#{inventoryOrganization},
#{receivingTissue},
#{inventoryDirection},
#{dateOfDelivery},
#{materialsRequisitionDepartment},
#{materialTaker},
#{businessType},
#{ownerType},
#{owner},
#{documentStatus},
#{detailedRemarks},
#{createById},
#{createBy},
#{createTime},
#{updateById},
#{updateBy},
#{updateTime},
#{delFlag},
#{productCode},
#{productName},
#{prouuctModel},
#{productSpecification}
#{orderNumber},
#{productionOrderNumber},
INSERT INTO fjqydb.material_retention_log
material_code,
material_name,
specification,
model,
unit,
actual_quantity_issued,
delivery_warehouse,
ck_number,
document_remarks,
document_type,
inventory_organization,
receiving_tissue,
inventory_direction,
date_of_delivery,
materials_requisition_department,
material_taker,
business_type,
owner_type,
owner,
document_status,
detailed_remarks,
create_by_id,
create_by,
create_time,
update_by_id,
update_by,
update_time,
del_flag,
product_code,
product_name,
product_model,
product_specification,
material_type,
flow_sequence_number,
process,
order_number,
production_order_number,
mesprocess
VALUES
#{item.materialCode},
#{item.materialName},
#{item.specification},
#{item.model},
#{item.unit},
#{item.actualQuantityIssued},
#{item.deliveryWarehouse},
#{item.ckNumber},
#{item.documentRemarks},
#{item.documentType},
#{item.inventoryOrganization},
#{item.receivingTissue},
#{item.inventoryDirection},
#{item.dateOfDelivery},
#{item.materialsRequisitionDepartment},
#{item.materialTaker},
#{item.businessType},
#{item.ownerType},
#{item.owner},
#{item.documentStatus},
#{item.detailedRemarks},
#{item.createById},
#{item.createBy},
#{item.createTime},
#{item.updateById},
#{item.updateBy},
#{item.updateTime},
#{item.delFlag},
#{item.productCode},
#{item.productName},
#{item.productModel},
#{item.productSpecification},
#{item.materialType},
#{item.flowSequenceNumber},
#{item.process},
#{item.orderNumber},
#{item.productionOrderNumber},
#{item.mesprocess},
update fjqydb.material_retention_log
material_code = #{materialCode},
material_name = #{materialName},
specification = #{specification},
model = #{model},
unit = #{unit},
actual_quantity_issued = #{actualQuantityIssued},
delivery_warehouse = #{deliveryWarehouse},
ck_number = #{ckNumber},
document_remarks = #{documentRemarks},
document_type = #{documentType},
inventory_organization = #{inventoryOrganization},
receiving_tissue = #{receivingTissue},
inventory_direction = #{inventoryDirection},
date_of_delivery = #{dateOfDelivery},
materials_requisition_department = #{materialsRequisitionDepartment},
material_taker = #{materialTaker},
business_type = #{businessType},
owner_type = #{ownerType},
owner = #{owner},
document_status = #{documentStatus},
detailed_remarks = #{detailedRemarks},
create_by_id = #{createById},
create_by = #{createBy},
create_time = #{createTime},
update_by_id = #{updateById},
update_by = #{updateBy},
update_time = #{updateTime},
del_flag = #{delFlag},
product_code = #{productCode}
product_name = #{productName}
product_model = #{productModel}
product_specification = #{productSpecification}
where id = #{id}
delete from fjqydb.material_retention_log where id = #{id}
delete from fjqydb.material_retention_log where id in
#{id}