This commit is contained in:
jinling.yang
2023-12-07 10:52:09 +08:00
9 changed files with 237 additions and 55 deletions

View File

@@ -135,7 +135,7 @@ td.o_required_modifier {
.text-truncate {
overflow: unset !important;
text-overflow: unset !important;
white-space: unset !important;
white-space: nowrap!important;
}
.o_list_renderer .o_list_table tbody > tr > td:not(.o_list_record_selector):not(.o_handle_cell):not(.o_list_button):not(.o_list_record_remove) {
@@ -370,9 +370,16 @@ div:has(.o_required_modifier) > label::before {
top: 40px;
left: 168px;
padding: 0;
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
.row {
width: 50%;
margin: 0;
>div {
padding: 0;
width: unset;
margin-right: 10px;
}
}
}

View File

@@ -23,7 +23,7 @@ html .o_web_client > .o_action_manager > .o_action {
}
.o_form_view {
background-color: unset !important;
//background-color: unset !important;
min-height: unset !important;
}

View File

@@ -34,20 +34,48 @@ class FunctionalCuttingToolEntity(models.Model):
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')],
string='状态', store=True, default='正常')
current_location_id = fields.Many2one('stock.location', string='当前位置', readonly=True)
current_location = fields.Char('位置', compute='_compute_current_location_id')
image = fields.Binary('图片', readonly=True)
# @api.depends('current_location_id')
# def _compute_location_num(self):
# """
# 计算库存位置数量
# """
# for obj in self:
# if obj.current_location_id:
# if obj.current_location_id.name in ('组装后', '刀具房'):
# obj.tool_room_num = 1
# obj.line_edge_knife_library_num = 0
# obj.machine_knife_library_num = 0
#
@api.depends('barcode_id')
def _compute_current_location_id(self):
for record in self:
if record.barcode_id.quant_ids:
print(record.barcode_id.quant_ids)
for quant_id in record.barcode_id.quant_ids:
if quant_id.inventory_quantity_auto_apply > 0:
print(quant_id)
record.current_location_id = quant_id.location_id
record.current_location = quant_id.location_id.name
print(record.current_location_id)
if record.current_location_id:
record.get_location_num()
else:
record.current_location_id = False
record.current_location = False
def get_location_num(self):
"""
计算库存位置数量
"""
for obj in self:
if obj.current_location_id:
if obj.current_location_id.name in ['刀具房']:
obj.tool_room_num = 1
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
elif "线边刀库" in obj.current_location_id.name:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 1
obj.machine_knife_library_num = 0
elif "机内刀库" in obj.current_location_id.name:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 1
else:
obj.tool_room_num = 0
obj.line_edge_knife_library_num = 0
obj.machine_knife_library_num = 0
@api.model
def _read_group_mrs_cutting_tool_type_id(self, categories, domain, order):
@@ -144,13 +172,13 @@ class FunctionalToolWarning(models.Model):
diameter = fields.Integer(string='刀具直径(mm)')
knife_tip_r_angle = fields.Float(string='刀尖R角(mm)')
# 其他信息
install_tool_time = fields.Datetime("刀具组装时间")
install_tool_time = fields.Datetime("刀具组装时间", related='functional_tool_name_id.tool_loading_time')
on_board_time = fields.Datetime('上机装刀时间')
max_lifetime_value = fields.Integer(string='最大寿命值(min)')
alarm_value = fields.Integer(string='报警值(min)')
used_value = fields.Integer(string='已使用值(min)')
functional_tool_status = fields.Selection([('正常', '正常'), ('报警', '报警'), ('已拆除', '已拆除')], string='状态')
alarm_time = fields.Char('报警时间')
alarm_time = fields.Datetime('报警时间')
dispose_user = fields.Char('处理人')
dispose_time = fields.Char('处理时间')
dispose_func = fields.Char('处理方法/措施', readonly=False)
@@ -160,6 +188,29 @@ class FunctionalToolWarning(models.Model):
machine_table_name_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(machine_table_name_ids)
def create_tool_warning_record(self, obj):
"""
机台换刀申请报警状态时,创建功能刀具预警记录
"""
if obj:
for tool in obj.get('tool_changing_apply_id'):
self.env['sf.functional.tool.warning'].create({
'production_line_id': tool.production_line_id.id,
'maintenance_equipment_id': tool.maintenance_equipment_id.id,
'machine_tool_code': tool.machine_tool_code,
'machine_table_type_id': tool.machine_table_type_id.id,
'cutter_spacing_code_id': tool.cutter_spacing_code_id.id,
'functional_tool_name_id': tool.functional_tool_name_id.id,
'barcode_id': tool.barcode_id.id,
'diameter': tool.diameter,
'knife_tip_r_angle': tool.knife_tip_r_angle,
'max_lifetime_value': tool.max_lifetime_value,
'alarm_value': tool.alarm_value,
'used_value': tool.used_value,
'functional_tool_status': tool.functional_tool_status,
'alarm_time': fields.Datetime.now(),
})
class StockMoveLine(models.Model):
_inherit = 'stock.move.line'
@@ -191,10 +242,10 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
tool_stock_num = fields.Integer(string='刀具房数量')
side_shelf_num = fields.Integer(string='线边刀库数量')
on_tool_stock_num = fields.Integer(string='机内刀库数量')
tool_stock_total = fields.Integer(string='当前库存量', readonly=True, compute='_compute_tool_stock_total')
tool_stock_total = fields.Integer(string='当前库存量', readonly=True)
min_stock_num = fields.Integer('最低库存量')
max_stock_num = fields.Integer('最高库存量')
batch_replenishment_num = fields.Integer('批次补货量')
batch_replenishment_num = fields.Integer('批次补货量', readonly=True, compute='_compute_batch_replenishment_num')
unit = fields.Char('单位')
image = fields.Binary('图片')
@@ -228,29 +279,45 @@ class RealTimeDistributionOfFunctionalTools(models.Model):
mrs_cutting_tool_type_ids = categories._search([], order=order, access_rights_uid=SUPERUSER_ID)
return categories.browse(mrs_cutting_tool_type_ids)
@api.depends('tool_stock_num', 'side_shelf_num', 'on_tool_stock_num')
def _compute_tool_stock_total(self):
for record in self:
if record:
record.tool_stock_total = record.tool_stock_num + record.side_shelf_num + record.on_tool_stock_num
@api.depends('sf_functional_cutting_tool_entity_ids')
def _compute_batch_replenishment_num(self):
for tool in self:
if tool:
tool.get_stock_num(tool)
# 计算当前库存量
tool.tool_stock_total = tool.tool_stock_num + tool.side_shelf_num + tool.on_tool_stock_num
# 如果当前库存量小于最低库存量,计算批次补货量
if tool.tool_stock_total < tool.min_stock_num:
tool.batch_replenishment_num = tool.max_stock_num - tool.tool_stock_total
else:
tool.batch_replenishment_num = 0
# @api.depends('tool_stock_total', 'min_stock_num', 'max_stock_num')
# def _compute_batch_replenishment_num(self):
# for record in self:
# if record.tool_stock_total < record.min_stock_num:
# record.batch_replenishment_num = record.max_stock_num - record.tool_stock_total
def get_stock_num(self, tool):
"""
计算刀具房数量、线边刀库数量、机内刀库数量
"""
if tool:
tool.tool_stock_num = 0
tool.side_shelf_num = 0
tool.on_tool_stock_num = 0
if tool.sf_functional_cutting_tool_entity_ids:
for cutting_tool in tool.sf_functional_cutting_tool_entity_ids:
if cutting_tool.tool_room_num > 0:
tool.tool_stock_num += 1
elif cutting_tool.line_edge_knife_library_num > 0:
tool.side_shelf_num += 1
elif cutting_tool.machine_knife_library_num > 0:
tool.on_tool_stock_num += 1
def create_or_edit_safety_stock(self, vals, sf_functional_cutting_tool_entity_ids):
"""
根据传入的信息新增或者更新功能刀具安全库存的信息
"""
print(vals)
# 根据功能刀具名称、直径或尖刀R角、粗/中/精查询该功能刀具是否已经存在
record = self.env['sf.real.time.distribution.of.functional.tools'].search(
[('name', '=', vals['name']), ('sf_cutting_tool_type_id', '=', vals['sf_cutting_tool_type_id']),
('diameter', '=', vals['diameter']), ('knife_tip_r_angle', '=', vals['knife_tip_r_angle']),
('coarse_middle_thin', '=', vals['coarse_middle_thin'])])
print(record)
if len(record) > 0:
for obj in record:
obj.write({'sf_functional_cutting_tool_entity_ids': [(4, sf_functional_cutting_tool_entity_ids.id)]})
@@ -357,6 +424,9 @@ class MachineTableToolChangingApply(models.Model):
('cutter_spacing_code_id', '=', self.cutter_spacing_code_id.id)
])
# 创建功能刀具预警记录
self.env['sf.functional.tool.warning'].create_tool_warning_record({'tool_changing_apply_id': self})
# 新建组装任务
sf_functional_tool_assembly = self.env['sf.functional.tool.assembly'].create({
'functional_tool_name': self.functional_tool_name,
@@ -538,6 +608,8 @@ class FunctionalToolAssembly(models.Model):
alarm_value = fields.Integer(string='报警值(min)', readonly=True)
used_value = fields.Integer(string='已使用值(min)', readonly=True)
image = fields.Binary('图片', readonly=True)
@api.model
def _read_group_functional_tool_type_ids(self, categories, domain, order):
"""读取分组自定义以便在看板视图中显示所有的类别,即使它们为空"""

View File

@@ -26,6 +26,7 @@
<field name="functional_tool_status"/>
<field name="current_location_id" invisible="True"/>
<field name="current_location" invisible="True"/>
<field name="sf_cutting_tool_type_id" invisible="True"/>
</tree>
</field>
@@ -147,6 +148,7 @@
<field name="alarm_value"/>
<field name="used_value"/>
<field name="current_location_id"/>
<field name="current_location" invisible="1"/>
</group>
<group>
<field name="tool_loading_length"/>
@@ -213,7 +215,7 @@
<field name="name">sf.functional.tool.warning.tree</field>
<field name="model">sf.functional.tool.warning</field>
<field name="arch" type="xml">
<tree string="功能刀具预警" create="1" edit="1" delete="1" editable="bottom">
<tree string="功能刀具预警" create="0" edit="0" delete="0" editable="bottom">
<field name="production_line_id" optional="hide"/>
<field name="maintenance_equipment_id" optional="hide"/>
<field name="machine_tool_code"/>
@@ -260,6 +262,8 @@
<field name="production_line_id" invisible="True"/>
<searchpanel>
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
<field name="maintenance_equipment_id" icon="fa-building" enable_counters="1"/>
<field name="cutter_spacing_code_id" icon="fa-building" enable_counters="1"/>
<field name="functional_tool_status" icon="fa-building" enable_counters="1"/>
</searchpanel>
</search>
@@ -953,6 +957,9 @@
<field name="sf_cam_work_order_program_knife_plan_id"
attrs="{'invisible': [('sf_cam_work_order_program_knife_plan_id','=',False)]}"/>
</group>
<group>
<field name="image" nolabel="1" widget="image"/>
</group>
</group>
<notebook>
<page string="组装信息" attrs="{'invisible': [('assemble_status', '=' ,'0')]}">

View File

@@ -193,6 +193,8 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
alarm_value = fields.Integer(string='报警值(min)', readonly=True)
used_value = fields.Integer(string='已使用值(min)', readonly=True)
image = fields.Binary('图片')
# 功能刀具组装信息
# 整体式刀具型号
integral_code_id = fields.Many2one('stock.lot', string='整体式刀具序列号',
@@ -483,6 +485,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'hiding_length': self.hiding_length,
'assemble_status': '1',
'tool_loading_person': self.env.user.name,
'image': self.image,
'tool_loading_time': fields.Datetime.now()
}
@@ -515,7 +518,7 @@ class FunctionalToolAssemblyOrder(models.TransientModel):
'cut_time': self.cut_time,
'cut_length': self.cut_length,
'cut_number': self.cut_number,
'current_location_id': stock_lot.quant_ids.location_id.ids[-1],
'image': self.image,
}

View File

@@ -169,6 +169,9 @@
<field name="machine_tool_name_id"/>
<field name="cutter_spacing_code_id"/>
</group>
<group>
<field name="image" nolabel="1" widget="image"/>
</group>
</group>
<group string="功能刀具申请信息">
<group>

View File

@@ -221,7 +221,15 @@ export default AbstractModel.extend({
this.ganttData.groupedBy = this.defaultGroupBy;
}
}
const time = sessionStorage.getItem('time')
const scale = sessionStorage.getItem('scale')
if(time) {
this._setRange(moment(time), scale);
console.log('进入自定义时间')
}
return this._fetchData().then(() => {
sessionStorage.removeItem('time')
sessionStorage.removeItem('scale')
// The 'reload' function returns a promise which resolves with the
// handle to pass to the 'get' function to access the data. In this
// case, we don't want to pass any argument to 'get' (see its API).

View File

@@ -8,7 +8,6 @@ var Widget = require('web.Widget');
const pyUtils = require('web.py_utils');
let pyUtilsContext = null;
const fieldUtils = require('web.field_utils');
var QWeb = core.qweb;
var _t = core._t;
@@ -22,6 +21,9 @@ var GanttRow = Widget.extend({
'click': '_onRowSidebarClicked',
'click .o_gantt_cell_buttons > div > .o_gantt_cell_add': '_onButtonAddClicked',
'click .o_gantt_cell_buttons > div > .o_gantt_cell_plan': '_onButtonPlanClicked',
'mousewheel .o_gantt_hoverable': '_onColMouseWheel',
'click .o_gantt_hoverable': '_onColClicked',
},
NB_GANTT_RECORD_COLORS: 12,
LEVEL_LEFT_OFFSET: 16, // 16 px per level
@@ -144,7 +146,7 @@ var GanttRow = Widget.extend({
}
this._super();
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
@@ -261,18 +263,18 @@ var GanttRow = Widget.extend({
_adaptPills: function () {
var self = this;
var dateStartField = this.state.dateStartField;
console.log("dateStartField",dateStartField)
// console.log("dateStartField",dateStartField)
var dateStopField = this.state.dateStopField;
console.log("dateStopField",dateStopField)
// console.log("dateStopField",dateStopField)
var ganttStartDate = this.state.startDate;
console.log("ganttStartDate",ganttStartDate)
// console.log("ganttStartDate",ganttStartDate)
var ganttStopDate = this.state.stopDate;
console.log("ganttStopDate",ganttStopDate)
// console.log("ganttStopDate",ganttStopDate)
this.pills.forEach(function (pill) {
var pillStartDate = self._convertToUserTime(pill[dateStartField]);
console.log("pillStartDate",pillStartDate)
// console.log("pillStartDate",pillStartDate)
var pillStopDate = self._convertToUserTime(pill[dateStopField]);
console.log("pillStopDate",pillStopDate)
// console.log("pillStopDate",pillStopDate)
if (pillStartDate < ganttStartDate) {
pill.startDate = ganttStartDate;
pill.disableStartResize = true;
@@ -469,19 +471,19 @@ var GanttRow = Widget.extend({
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
left = pill.startDate.diff(pill.startDate.clone().startOf('day'), 'minutes') % (shift_time * 60);
console.log('left', left)
// console.log('left', left)
pill.leftMargin = (left / (shift_time * 60)) * 100;
console.log('pill.leftMargin', pill.leftMargin)
// console.log('pill.leftMargin', pill.leftMargin)
diff = pill.stopDate.diff(pill.startDate, 'minutes');
console.log('diff', diff)
// console.log('diff', diff)
var gapSize = pill.stopDate.diff(pill.startDate, 'hours') - shift_time; // Eventually compensate border(s) width
console.log('gapSize', gapSize)
// console.log('gapSize', gapSize)
widthPill = (diff / (shift_time * 60)) * 100;
console.log('widthPill', widthPill)
// console.log('widthPill', widthPill)
margin = pill.aggregatedPills ? 0 : 4;
console.log('margin', margin)
// console.log('margin', margin)
pill.width = gapSize > 0 ? `calc(${widthPill}% + ${gapSize}px - ${margin}px)` : `calc(${widthPill}% - ${margin}px)`;
console.log('pill.width', pill.width)
// console.log('pill.width', pill.width)
break;
// left = pill.startDate.diff(pill.startDate.clone().startOf('hour'), 'minutes');
@@ -711,16 +713,16 @@ var GanttRow = Widget.extend({
this.pills.forEach(function (currentPill) {
var skippedSlots = [];
slotsToFill.some(function (currentSlot) {
console.log('currentPill.startDate1111111111', currentPill)
// console.log('currentPill.startDate1111111111', currentPill)
// console.log('currentSlot.stop2222222222222', currentSlot.stop)
var fitsInThisSlot = currentPill.startDate < currentSlot.stop;
console.log('fitsInThisSlot', fitsInThisSlot)
// console.log('fitsInThisSlot', fitsInThisSlot)
if (fitsInThisSlot) {
currentSlot.pills.push(currentPill);
console.log('currentSlot.pills', currentSlot.pills)
// console.log('currentSlot.pills', currentSlot.pills)
} else {
skippedSlots.push(currentSlot);
console.log('skippedSlots', skippedSlots)
// console.log('skippedSlots', skippedSlots)
}
return fitsInThisSlot;
});
@@ -813,7 +815,7 @@ var GanttRow = Widget.extend({
stop: slotStop,
pills: [],
});
console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
// console.log('啊啊啊啊this啊啊啊啊.啊啊啊啊slots啊啊啊啊', this.slots)
}
},
/**
@@ -1161,6 +1163,8 @@ var GanttRow = Widget.extend({
* @param {MouseEvent} ev
*/
_onButtonAddClicked: function (ev) {
ev.stopPropagation()
ev.cancelBubble
var date = moment($(ev.currentTarget).closest('.o_gantt_cell').data('date'));
this.trigger_up('add_button_clicked', {
date: date,
@@ -1174,6 +1178,8 @@ var GanttRow = Widget.extend({
* @param {MouseEvent} ev
*/
_onButtonPlanClicked: function (ev) {
ev.stopPropagation()
ev.cancelBubble
var date = moment($(ev.currentTarget).closest('.o_gantt_cell').data('date'));
this.trigger_up('plan_button_clicked', {
date: date,
@@ -1246,6 +1252,8 @@ var GanttRow = Widget.extend({
* @param {MouseEvent} ev
*/
_onPillClicked: function (ev) {
ev.stopPropagation()
ev.cancelBubble
if (!this.isGroup) {
this.trigger_up('pill_clicked', {
target: $(ev.currentTarget),
@@ -1288,6 +1296,80 @@ var GanttRow = Widget.extend({
}
}
},
// _getTimeSlot(scale = 'day', date = new Date()) {
// if(scale == 'day') {
// return [date, date]
// } else if(scale == 'week') {
//
// const week = new Date(date).getDay()
// const before = week - 1
// const after = 7 - week
// return [+new Date(date) - (before * 86400000), +new Date(date) + (after * 86400000)]
// } else if(scale == 'month') {
//
// const year = new Date(date).getFullYear()
// const month = new Date(date).getMonth() + 1
// const monthDay = new Date(year, month, 0).getDate()
// const before = new Date(year + '/' + (month < 10 ? '0' + month : month) + '/01')
// const after = new Date(year + '/' + (month < 10 ? '0' + month : month) + '/' +monthDay)
// return [before, after]
// } else {
//
// const year = new Date(date).getFullYear()
// return [year + '/01/01', year + '/12/31']
// }
// },
_onColClicked(e) {
if(sessionStorage.getItem('scale')) return
const scale = ['day', 'week', 'month', 'year']
const index = scale.indexOf(this.viewInfo.state.scale)
const dom = $('.o_gantt_button_scale.btn.btn-secondary.active').prev()
const nextScale = scale[index - 1]
if(!nextScale) return;
sessionStorage.setItem('scale', nextScale)
sessionStorage.setItem('time', e.target.dataset.date )
if(dom) {
dom.click()
}
},
/**
* 鼠标滚动
*
* @private
*/
_onColMouseWheel: function (e) {
if(sessionStorage.getItem('scale')) return
const scale = ['day', 'week', 'month', 'year']
let direction
if(e.originalEvent.wheelDelta) { //判断浏览器IE谷歌滑轮事件
direction = e.originalEvent.wheelDelta > 0
} else { //Firefox滑轮事件
direction = e.originalEvent.detail > 0
}
const index = scale.indexOf(this.viewInfo.state.scale)
if(direction) { // 滚轮向上滑动
const dom = $('.o_gantt_button_scale.btn.btn-secondary.active').prev()
const nextScale = scale[index - 1]
if(!nextScale) return;
sessionStorage.setItem('scale', nextScale)
// sessionStorage.setItem('time', JSON.stringify(this._getTimeSlot(nextScale, e.target.dataset.date)))
sessionStorage.setItem('time', e.target.dataset.date || e.currentTarget.dataset.date)
if(dom) {
dom.click()
}
} else { // 滚轮向下滑动
const dom = $('.o_gantt_button_scale.btn.btn-secondary.active').next()
const nextScale = scale[index + 1]
if(!nextScale) return;
sessionStorage.setItem('scale', nextScale)
sessionStorage.setItem('time', e.target.dataset.date || e.currentTarget.dataset.date)
// sessionStorage.setItem('time', JSON.stringify(this._getTimeSlot(nextScale, e.target.dataset.date)))
if(dom) {
dom.click()
}
}
}
});
return GanttRow;

View File

@@ -77,13 +77,13 @@
<t t-if="widget.state.scale in formats" t-esc="slot.format(formats[widget.state.scale])"/>
<small t-else="">
<t t-if="slot.format('k') == 24">
<div>班(00:00-08:00)</div>
<div>班(00:00-08:00)</div>
</t>
<t t-if="slot.format('k') == 8">
<div>班(08:00-16:00)</div>
<div>班(08:00-16:00)</div>
</t>
<t t-if="slot.format('k') == 16">
<div>晚班(16:00-00:00)</div>
<div>晚班(16:00-24:00)</div>
</t>
<!-- <b t-esc="slot.format('k')"/> -->
<!-- <span class="d-block d-xl-inline-block" t-esc="slot.format('a')"/> -->