Commit 039e7074 authored by 覃振观's avatar 覃振观 👶

23-12-18: 下班前提交

parent 255035d2
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
function mapping(dataMapping, rawData) { function mapping(dataMapping, rawData) {
window.dataSet = {}; window.dataSet = {};
window.dataSet.tempId = 950366; window.dataSet.tempId = 950366;
debugger;
if(!rawData) { if(!rawData) {
window.dataSet.isInsert = true; window.dataSet.isInsert = true;
var rawData = {}; var rawData = {};
...@@ -22,6 +23,7 @@ function mapping(dataMapping, rawData) { ...@@ -22,6 +23,7 @@ function mapping(dataMapping, rawData) {
if(propertyNames instanceof Array) { if(propertyNames instanceof Array) {
// Form 时执行此逻辑 // Form 时执行此逻辑
tryForEach(propertyNames,(item) => { tryForEach(propertyNames,(item) => {
if(!entityData) { entityData = {}; }
if(typeof item === "string") { if(typeof item === "string") {
if(!isExist(entityData, item, beanName)) { throw {}; } if(!isExist(entityData, item, beanName)) { throw {}; }
associate(entityData, item, item, beanName,mapper, returnData); associate(entityData, item, item, beanName,mapper, returnData);
...@@ -37,8 +39,15 @@ function mapping(dataMapping, rawData) { ...@@ -37,8 +39,15 @@ function mapping(dataMapping, rawData) {
throw {}; throw {};
} }
}); });
} else if(propertyNames instanceof Object) { } else if(propertyNames instanceof Object) {
// Grid 时执行此逻辑 // Grid 时执行此逻辑
if(window.dataSet.isInsert) {
rawData[beanName] = {};
rawData[beanName].raw = {};
rawData[beanName].compares = {};
rawData[beanName].ids = [];
return;
}
let listMap = {}, ids = [], rowId = ''; //tryForEach 变量作用域注意 let listMap = {}, ids = [], rowId = ''; //tryForEach 变量作用域注意
entityData.forEach(rowData => { entityData.forEach(rowData => {
debugger; debugger;
...@@ -46,11 +55,10 @@ function mapping(dataMapping, rawData) { ...@@ -46,11 +55,10 @@ function mapping(dataMapping, rawData) {
listMap[rowId] = rowData; listMap[rowId] = rowData;
ids.push(rowId); ids.push(rowId);
tryForEach(propertyNames.columns, (property) => { tryForEach(propertyNames.columns, (property) => {
mapper[property] = []; mapper[property] = {};
let data = {}; let data = {};
data['key'] = rowId;
data['beanName'] = beanName; data['beanName'] = beanName;
mapper[property].push(data) mapper[property][rowId] = data;
}); });
}) })
rawData[beanName] = {}; rawData[beanName] = {};
...@@ -115,7 +123,7 @@ function isExist(obj, property, objName) { ...@@ -115,7 +123,7 @@ function isExist(obj, property, objName) {
} else { } else {
if(!objName) { objName = 'rawData'; } if(!objName) { objName = 'rawData'; }
// 这里注意,后端返回的类名是否与映射配置一致 // 这里注意,后端返回的类名是否与映射配置一致
if(!obj[property]) { if(obj[property] === undefined) {
console.error('No data for name of ' + property + ' in ' + objName + ' !'); console.error('No data for name of ' + property + ' in ' + objName + ' !');
return false; return false;
} }
...@@ -149,17 +157,26 @@ function listeningGrid(elId, options) { ...@@ -149,17 +157,26 @@ function listeningGrid(elId, options) {
data.Rows = ''; data.Rows = '';
} else { data.Rows = options.data.raw; } } else { data.Rows = options.data.raw; }
options.data = data; options.data = data;
// ------------------ 编辑框打开前记录当前行 ------------------
const originalOnBeforeEdit = options.onBeforeEdit; const originalOnBeforeEdit = options.onBeforeEdit;
options.onBeforeEdit = function(editParm){ options.onBeforeEdit = function(editParm){
originalOnBeforeEdit.call(this, editParm); originalOnBeforeEdit.call(this, editParm);
let domIds = editParm.column.__domid.split('|'), recordId = editParm.record.__id; let domIds = editParm.column.__domid.split('|'), recordId = editParm.record.__id, colName = editParm.column.name;
let parentDomId = domIds[0]+'|'+2+'|'+recordId; // +'|'+domIds[2]; let parentDomId = domIds[0]+'|'+2+'|'+recordId; // +'|'+domIds[2];
let rowDOM; let rowDOM;
if(!(rowDOM = document.getElementById(domIds[0]+'|'+2+'|'+recordId))) { if(!(rowDOM = document.getElementById(parentDomId))) {
rowDOM = document.getElementById(domIds[0]+'|'+1+'|'+recordId) parentDomId = domIds[0]+'|'+1+'|'+recordId;
rowDOM = document.getElementById(parentDomId)
} }
debugger; let mapper = window.dataMapping.mapper;
let rowId = rowDOM.childNodes[0].childNodes[0].innerText; let rowId = rowDOM.childNodes[0].childNodes[0].innerText;
let mapperEntry = mapper[colName];
if(!mapperEntry[rowId]) {
console.error("dataMapping 中,无法找到该 DOMId 的映射。请检查!");
} else {
mapperEntry[rowId]['rowId'] = parentDomId;
mapperEntry[rowId]['rowIndex'] = editParm.rowindex;
}
} }
const toolbar = options.toolbar; const toolbar = options.toolbar;
if(toolbar) { if(toolbar) {
...@@ -169,29 +186,46 @@ function listeningGrid(elId, options) { ...@@ -169,29 +186,46 @@ function listeningGrid(elId, options) {
const originalOnClick = but.click; const originalOnClick = but.click;
but.click = function() { but.click = function() {
originalOnClick.call(this); originalOnClick.call(this);
debugger;
let mappingEntry = Object.entries(window.dataMapping); let mappingEntry = Object.entries(window.dataMapping);
tryForEach(mappingEntry, entry => { tryForEach(mappingEntry, entry => {
let beanName = entry[0]; let beanName = entry[0];
if(elId.indexOf(beanName) > 0) { if(elId.indexOf(beanName) >= 0) {
let idProperty = entry[1].id; let idProperty = entry[1].id;
if(!idProperty) { if(!idProperty) {
console.error("若需要监听 GridData ,必须在映射配置指定 ID !请检查。"); console.error("若需要监听 GridData ,必须在映射配置指定 ID !请检查。");
throw {}; throw {};
} }
let mapper = window.dataMapping.mapper; let mapper = window.dataMapping.mapper;
let rowId = window.dataSet.tempId += 1 let rowId = window.dataSet.tempId += 1
let data = {}, mapperData = {}; let data = {}, mapperData = {};
mapperData[rowId] = beanName;
mapper[idProperty].push(mapperData);
window.dataSet.newData[beanName].ids.push(rowId);
// ------------- 设置 mapper -------------
debugger;
tryForEach(entry[1].columns, property => { tryForEach(entry[1].columns, property => {
mapperData['beanName'] = beanName;
if(!mapper[property]) {
mapper[property] = {};
}
mapper[property][rowId] = mapperData;
data[property] = ''; data[property] = '';
}); });
data[idProperty] = rowId; data[idProperty] = rowId;
// ------------- 设置 compares -------------
if(!window.dataSet.newData[beanName]) {
window.dataSet.newData[beanName] = {};
}
if(!window.dataSet.newData[beanName].compares){
window.dataSet.newData[beanName].compares = {};
}
window.dataSet.newData[beanName].compares[rowId] = data; window.dataSet.newData[beanName].compares[rowId] = data;
debugger;
// ------------- 设置 ids -------------
if(!window.dataSet.newData[beanName].ids) {
window.dataSet.newData[beanName].ids = [];
}
window.dataSet.newData[beanName].ids.push(rowId);
UICtrl.addGridRow(gridManager, data); UICtrl.addGridRow(gridManager, data);
} }
...@@ -226,27 +260,30 @@ function inputEventListener() { ...@@ -226,27 +260,30 @@ function inputEventListener() {
* @param event * @param event
*/ */
function listenerContent(event) { function listenerContent(event) {
const property = event.target.getAttribute('name'); const property = event.target.getAttribute('name'), editId = event.target.id;
const beanMapping = window.dataMapping.mapper[property]; const beanMapping = window.dataMapping.mapper[property];
debugger;
if(!beanMapping) { if(!beanMapping) {
console.error("The configuration was not found in the 'dataMapping' : '"+property+"'") console.error("The configuration was not found in the 'dataMapping' : '"+property+"'")
} }
let newData = window.dataSet.newData; let newData = window.dataSet.newData;
let control = getControlType(beanMapping);
// Grid 时执行此逻辑 // Grid 时执行此逻辑
if(beanMapping instanceof Array) { if(control === 'grid') {
tryForEach(beanMapping, row => { let inputIds = editId.split('_');
let rowEntry = Object.entries(row); debugger;
debugger; tryForEach(Object.entries(beanMapping), mapperEntry => {
tryForEach(rowEntry, entry => { let mapperVal = mapperEntry[1], mapperKey = mapperEntry[0];
let rowNum = entry[0], beanName = entry[1]; if(mapperVal.rowIndex === inputIds[2] * 1) {
newData[beanName].compares[rowNum][event.target.getAttribute('name')] = event.target.value; newData[mapperVal.beanName].compares[mapperKey][event.target.getAttribute('name')] = event.target.value;
console.log('Input value changed:', event.target.value); console.log('Input value changed:', event.target.value);
}) }
}) })
return; return;
} }
// Form 时执行此逻辑 // Form 时执行此逻辑
if(beanMapping instanceof Object) { if(control === 'form') {
let mappings = Object.entries(beanMapping); let mappings = Object.entries(beanMapping);
tryForEach(mappings, (entry) => { tryForEach(mappings, (entry) => {
let beanName = entry[0]; let beanName = entry[0];
...@@ -257,6 +294,17 @@ function listenerContent(event) { ...@@ -257,6 +294,17 @@ function listenerContent(event) {
} }
} }
function getControlType(beanMapping) {
let control;
// 这里根据 grid 与 form 的 mapper 数据结构差异判定。 需要优化
if(Object.entries(beanMapping)[0][1]['beanName']) {
control = 'grid';
} else {
control = 'form';
}
return control;
}
/** /**
* 添加 DOM 监听 * 添加 DOM 监听
* @param eleId 监听的 root 元素 ID * @param eleId 监听的 root 元素 ID
...@@ -338,9 +386,10 @@ function checkUpdata() { ...@@ -338,9 +386,10 @@ function checkUpdata() {
} }
}); });
} }
return ;
} }
}) })
return dataSet.upData;
} }
/** /**
......
...@@ -11,15 +11,12 @@ function initializateUI() { ...@@ -11,15 +11,12 @@ function initializateUI() {
function loadCodeRuleListGrid() { function loadCodeRuleListGrid() {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({ var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(){
addHandler();
},
updateHandler: function(){ updateHandler: function(){
updateHandler(); updateHandler();
} }
// , getPurchaseCode:{id:'getPurchaseCode',text:'测试采购编号',img:'fa-link',click:function(){
// testGetNextCode('purchase');
// }}
// , getContractCode:{id:'getContractCode',text:'测试合同编号',img:'fa-link',click:function(){
// testGetNextCode('contract');
// }}
}); });
gridManager = UICtrl.grid("#productListGrid", { gridManager = UICtrl.grid("#productListGrid", {
columns: [ columns: [
...@@ -68,13 +65,14 @@ function updateHandler(data) { ...@@ -68,13 +65,14 @@ function updateHandler(data) {
} }
var url=DataUtil.composeURLByParam('/product/forwardProductDetail.do',{ data: JSON.stringify(data) }); var url=DataUtil.composeURLByParam('/product/forwardProductDetail.do',{ data: JSON.stringify(data) });
UICtrl.addTabItem({tabid:'viewFlowChart' + id, text:"产品信息",url:url}); UICtrl.addTabItem({tabid:'viewFlowChart' + id, text:"产品信息",url:url});
// debugger; }
// UICtrl.addTabItem({
// tabid: 'viewFlowChart' + id,
// text: "产品信息",
// url: web_app.name + '/bizFlowChart/showViewFlowchart.load?businessProcessId=' + id
// });
function addHandler() {
let data = {};
data.productId = 0;
var url=DataUtil.composeURLByParam('/product/forwardProductDetail.do',{ data: JSON.stringify(data) });
UICtrl.addTabItem({tabid:'viewFlowChart' + new Date().getTime(), text:"新增产品",url:url});
} }
...@@ -34,50 +34,8 @@ function deleteHandler(){ ...@@ -34,50 +34,8 @@ function deleteHandler(){
}); });
} }
function faceGrid(elId, data) {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(){
},
updateHandler: function(){
updateHandler();
},
deleteHandler: () => {
gridManager.deleteSelectedRow();
},
});
var gridManager = listeningGrid(elId, {
columns: [
{ display: "颜色名称", name: "productFaceColorId", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'text',
required: true
}},
{ display: "油墨覆盖率(%)", name: "coverageRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } }
],
toolbar: toolbarOptions,
dataType: "local",
data: data, // data 数据结构 data: ("Rows": [ {}, {} ])
enabledEdit: true,
checkbox: true,
usePager: false,
width: "100%",
height: 150,
onAfterEdit: function(editParm) {
// 后备方案: 表格遍历完成时
},
onBeforeEdit : function(editParm) {
console.log('original run onBeforeEdit()');
},
onDblClickRow : function(data, rowindex, rowobj) {
}
});
}
function save() { function save() {
checkUpdata(); let upData = checkUpdata();
debugger;
let upData = window.dataSet.upData;
if(!upData) { return; } if(!upData) { return; }
Public.ajax(web_app.name + "/product/saveOrUpdataOnAllDetail.ajax", { Public.ajax(web_app.name + "/product/saveOrUpdataOnAllDetail.ajax", {
data: JSON.stringify(upData) data: JSON.stringify(upData)
...@@ -113,8 +71,16 @@ function loadDataTest() { ...@@ -113,8 +71,16 @@ function loadDataTest() {
var showData = mapping(dataMapping, data.rawData); var showData = mapping(dataMapping, data.rawData);
$('#submitForm').formSet(showData); $('#submitForm').formSet(showData);
var fronData = {}; var fronData = {};
debugger;
if(window.dataSet.isInsert) {
data.rawData = {};
data.rawData.fronColors = {};
data.rawData.backColors = {};
data.rawData.processed = {};
}
faceGrid("#fronColorsGrid", data.rawData.fronColors); faceGrid("#fronColorsGrid", data.rawData.fronColors);
faceGrid("#backColorsGrid", data.rawData.backColors); faceGrid("#backColorsGrid", data.rawData.backColors);
processedGrid('#processedGrid', data.rawData.processed);
inputEventListener(); inputEventListener();
}); });
} }
...@@ -134,6 +100,10 @@ var dataMapping = { ...@@ -134,6 +100,10 @@ var dataMapping = {
ProductDetail: [ ProductDetail: [
{"factoryName": "factoryName"} {"factoryName": "factoryName"}
], ],
ProductTechnology: [
"beerPlateNo", "goldPlateNo" , "dieCutPlateNo", "copperpResinLateNo", "netPlateNo",
"productTechnologyRequire", "packageStyle", "packageStyle", "physicalTest"
],
ProductLooked: [ ProductLooked: [
"productLength" "productLength"
, "productWidth" , "productWidth"
...@@ -145,8 +115,94 @@ var dataMapping = { ...@@ -145,8 +115,94 @@ var dataMapping = {
fronColors: { fronColors: {
id: "productFaceColorId", id: "productFaceColorId",
columns: [ "productFaceColorId", "coverageRate" ] columns: [ "productFaceColorId", "coverageRate" ]
},
backColors: {
id: "productFaceColorId",
columns: [ "productFaceColorId", "coverageRate" ]
},
processed: {
id: "productTechnologyId",
columns: [ "productionSequence", "processName", "isScheduleProcess", "isFinishedProcess", "processRemark", "finishedTime", "signed" ]
} }
}
function faceGrid(elId, data) {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(){
},
updateHandler: function(){
updateHandler();
},
deleteHandler: () => {
gridManager.deleteSelectedRow();
},
});
var gridManager = listeningGrid(elId, {
columns: [
{ display: "颜色名称", name: "productFaceColorId", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'text',
required: true
}},
{ display: "油墨覆盖率(%)", name: "coverageRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } }
],
toolbar: toolbarOptions,
dataType: "local",
data: data, // data 数据结构 data: ("Rows": [ {}, {} ])
enabledEdit: true,
checkbox: true,
usePager: false,
width: "100%",
height: 150,
onAfterAddRow: function(rowdata) {
debugger;
},
onBeforeEdit : function(editParm) {
console.log('original run onBeforeEdit()');
},
onDblClickRow : function(data, rowindex, rowobj) {
}
});
}
function processedGrid(elId, data) {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(){
},
updateHandler: function(){
updateHandler();
},
deleteHandler: () => {
gridManager.deleteSelectedRow();
},
});
var gridManager = listeningGrid(elId, {
columns: [
{ display: "生成顺序", name: "productionSequence", width: 140, minWidth: 60, type: "string", align: "left"},
{ display: "工序名称", name: "processName", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "是否排期工序", name: "isScheduleProcess", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "是否完成工序", name: "isFinishedProcess", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "工艺备注", name: "processRemark", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "完成时间", name: "finishedTime", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "签字", name: "signed", width: 120, minWidth: 60, type: "string", align: "left" },
],
toolbar: toolbarOptions,
dataType: "local",
data: data, // data 数据结构 data: ("Rows": [ {}, {} ])
enabledEdit: true,
checkbox: true,
usePager: false,
width: "100%",
height: 150,
onAfterEdit: function(editParm) {
// 后备方案: 表格遍历完成时
},
onBeforeEdit : function(editParm) {
console.log('original run onBeforeEdit()');
},
onDblClickRow : function(data, rowindex, rowobj) {
}
});
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<html> <html>
<head> <head>
<title>Title</title> <title>Title</title>
<x:base include="layout,dialog,grid,tree,combox,commonTree" /> <x:base include="layout,dialog,grid,tree,combox,commonTree, date" />
<x:script src='/javaScript/common.js'/> <x:script src='/javaScript/common.js'/>
<x:script src='/lib/jquery/jquery.contextmenu.js'/> <x:script src='/lib/jquery/jquery.contextmenu.js'/>
<x:script src='/system/bpm/BpmUtil.js'/> <x:script src='/system/bpm/BpmUtil.js'/>
...@@ -77,6 +77,8 @@ ...@@ -77,6 +77,8 @@
<div class="ui-tab-content" style="padding: 2px; padding-right: 0;"> <div class="ui-tab-content" style="padding: 2px; padding-right: 0;">
<div class="layout" id='detailFormDiv'> <div class="layout" id='detailFormDiv'>
<x:inputC name="factoryName" required="true" label="制造工厂" labelCol="2" maxLength="64" fieldCol="4" /> <x:inputC name="factoryName" required="true" label="制造工厂" labelCol="2" maxLength="64" fieldCol="4" />
<x:inputC name="date" wrapper="date" required="true" label="日期" labelCol="2" maxLength="64"
fieldCol="4" />
<%-- <x:inputC name="customerName" required="true" label="客户名称" labelCol="2" maxLength="64" fieldCol="4" />--%> <%-- <x:inputC name="customerName" required="true" label="客户名称" labelCol="2" maxLength="64" fieldCol="4" />--%>
<x:title title="外观描述" name="group" hideTable="#info" /> <x:title title="外观描述" name="group" hideTable="#info" />
<x:inputC name="productLength" required="true" label="长度" labelCol="2" maxLength="64" fieldCol="4" /> <x:inputC name="productLength" required="true" label="长度" labelCol="2" maxLength="64" fieldCol="4" />
...@@ -87,14 +89,34 @@ ...@@ -87,14 +89,34 @@
<div id="layout" style="height: 280px; display: contents;"> <div id="layout" style="height: 280px; display: contents;">
<div position="left" title="正面颜色" > <div position="left" title="正面颜色" >
<div id="fronColorsGrid" style="margin: 2px;"></div> <div id="fronColorsGrid" style="margin: 2px; height: 280px;"></div>
</div> </div>
<div position="right" title="反面颜色"> <div position="right" title="反面颜色">
<div id="backColorsGrid" style="margin: 2px;"></div> <div id="backColorsGrid" style="margin: 2px; height: 280px;"></div>
</div> </div>
</div> </div>
<x:inputC name="beerPlateNo" required="false" label="啤版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="goldPlateNo" required="false" label="烫金版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="dieCutPlateNo" required="false" label="模切版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="copperpResinLateNo" required="false" label="铜版及树脂版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="netPlateNo" required="false" label="网版编号" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="productTechnologyName" required="false" label="制程工艺" labelCol="2" fieldCol="7"
maxLength="64" />
<x:inputC name="productProperty" required="false" label="产品性质" labelCol="1" fieldCol="2" maxLength="64" />
<div position="center" title="产品工序">
<div id="processedGrid" style="margin: 2px;"></div>
</div>
<x:inputC name="productTechnologyRequire" required="false" label="工艺要求" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="packageStyle" required="false" label="包装方式" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="packageStyle" required="false" label="包装方式" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="physicalTest" required="false" label="物性测试" labelCol="1" fieldCol="2" maxLength="64" />
<x:title title="产品材质" name="group" hideTable="#info" /> <x:title title="产品材质" name="group" hideTable="#info" />
</div> </div>
...@@ -104,6 +126,9 @@ ...@@ -104,6 +126,9 @@
</div> </div>
</div> </div>
</div> </div>
</form> </form>
<div id="toolBarCenter" class="panel-footerX" > <div id="toolBarCenter" class="panel-footerX" >
......
...@@ -54,6 +54,8 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -54,6 +54,8 @@ public class ProductApplicationImpl implements ProductApplication {
private final ProductFaceRepository faceRepository; private final ProductFaceRepository faceRepository;
private final ProductFaceColorRepository faceColorRepository; private final ProductFaceColorRepository faceColorRepository;
private final ProductTechnologyRepository technologyRepository;
private final ProductProcessRepository processRepository;
@Override @Override
public ArrayList<Map<String, Object>> findProductPage(int page, int size) { public ArrayList<Map<String, Object>> findProductPage(int page, int size) {
...@@ -79,6 +81,7 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -79,6 +81,7 @@ public class ProductApplicationImpl implements ProductApplication {
Map<String, Object> resultMap = new HashMap<>(200); Map<String, Object> resultMap = new HashMap<>(200);
Long productId = product.getProductId(); Long productId = product.getProductId();
ProductDetail productDetail = detailRepository.findByProductId(productId); ProductDetail productDetail = detailRepository.findByProductId(productId);
ProductTechnology productTechnology = technologyRepository.findByProductId(productId);
// --------------------------------- 类别查询 --------------------------------- // --------------------------------- 类别查询 ---------------------------------
ArrayList<Brand> brands = (ArrayList<Brand>)brandRepository.findAll(); ArrayList<Brand> brands = (ArrayList<Brand>)brandRepository.findAll();
...@@ -95,6 +98,7 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -95,6 +98,7 @@ public class ProductApplicationImpl implements ProductApplication {
entitys.add(lookedRepository.findByProductId(productId)); entitys.add(lookedRepository.findByProductId(productId));
entitys.add(publishedConfRepository.findByProductId(productId)); entitys.add(publishedConfRepository.findByProductId(productId));
entitys.add(productDetail); entitys.add(productDetail);
entitys.add(productTechnology == null ? new ProductTechnology() : productTechnology);
entitys.add(product); entitys.add(product);
entitys.add(loss); entitys.add(loss);
entitys.add(material); entitys.add(material);
...@@ -124,6 +128,30 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -124,6 +128,30 @@ public class ProductApplicationImpl implements ProductApplication {
(ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId()); (ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId());
assemble.put("backFace", backFace); assemble.put("backFace", backFace);
assemble.put("backColors", backColors == null ? new ArrayList<>() : backColors); assemble.put("backColors", backColors == null ? new ArrayList<>() : backColors);
} else {
ProductFaceColor fc = new ProductFaceColor();
fc.setProductFaceColorId(111L);
fc.setColorId(1L);
ArrayList<ProductFaceColor> fronColors = new ArrayList<>();
fronColors.add(fc);
assemble.put("backColors", fronColors);
}
}
// --------------------------------- 工序查询 ---------------------------------
if(productTechnology != null) {
if(productTechnology.getProductTechnologyId() != null) {
ArrayList<ProductProcess> processesed =
(ArrayList<ProductProcess>) processRepository.findByProductTechnologyId(productTechnology.getProductTechnologyId());
assemble.put("processed", processesed == null ? new ArrayList<>() : processesed);
} else {
ProductProcess fc = new ProductProcess();
fc.setProductProcessId(111L);
fc.setProductProcessId(1L);
ArrayList<ProductProcess> processed = new ArrayList<>();
processed.add(fc);
assemble.put("processed", processed);
} }
} }
...@@ -203,7 +231,6 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -203,7 +231,6 @@ public class ProductApplicationImpl implements ProductApplication {
} }
// 这里要获取所有的属性名, 保存对应关系, 属性: 所属实体类; // 这里要获取所有的属性名, 保存对应关系, 属性: 所属实体类;
//map.putAll(mapper.convertValue(item, new TypeReference<Map<? extends String, ?>>() {})); //map.putAll(mapper.convertValue(item, new TypeReference<Map<? extends String, ?>>() {}));
} }
return map; return map;
} }
......
...@@ -64,8 +64,7 @@ public class ProductController extends CommonController { ...@@ -64,8 +64,7 @@ public class ProductController extends CommonController {
public String forwardProductDetail() { public String forwardProductDetail() {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
SDO sdo = this.getSDO(); SDO sdo = this.getSDO();
String str = "{\"productId\":1,\"productName\":\"1\",\"productCategoryId\":1,\"productStatus\":\"1\"," + String str = sdo.getString("data");
"\"productUnit\":\"1\",\"productSampleCode\":\"1\",\"brandName\":\"1\",\"productType\":\"1\",\"productCode\":\"1\",\"productSizeGroupId\":\"1\",\"isOnlyCode\":\"1\",\"isBodyColor\":\"1\",\"isDisable\":\"1\",\"isBuildBom\":\"1\",\"confirmDate\":\"2023-12-01 02:52:50\",\"comfirmPerson\":\"1\",\"isFreeInspection\":\"1\",\"isNoQualityLoss\":\"1\",\"sampleOrderNo\":\"1\",\"stockNo\":\"1\",\"stockName\":\"1\",\"fileNo\":\"1\",\"__id\":\"r1001\",\"__previd\":-1,\"__index\":0,\"__status\":\"nochanged\",\"__nextid\":\"r1002\"}";
HashMap<String, Object> param; HashMap<String, Object> param;
try { try {
param = objectMapper.readValue(str, new TypeReference<HashMap<String, Object>>() {}); param = objectMapper.readValue(str, new TypeReference<HashMap<String, Object>>() {});
...@@ -85,7 +84,10 @@ public class ProductController extends CommonController { ...@@ -85,7 +84,10 @@ public class ProductController extends CommonController {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
Map<String, Object> resultMap = productService.queryDetailAll(product); Map<String, Object> resultMap = new HashMap<>();
if(product.getProductId() != 0) {
resultMap = productService.queryDetailAll(product);
}
return toResult(resultMap); return toResult(resultMap);
} }
......
...@@ -4,6 +4,8 @@ import java.io.Serializable; ...@@ -4,6 +4,8 @@ import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import javax.persistence.*; import javax.persistence.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
...@@ -12,11 +14,21 @@ import org.apache.commons.lang3.builder.ToStringBuilder; ...@@ -12,11 +14,21 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
* @author Tison * @author Tison
* 产品工艺 * 产品工艺
*/ */
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.ALWAYS)
@JsonIgnoreProperties(ignoreUnknown = true)
@Entity @Entity
@Table(name = "product_technology") @Table(name = "product_technology")
public class ProductTechnology implements Serializable { public class ProductTechnology implements Serializable {
public ProductTechnology() {
setDefaultValues();
}
public void setDefaultValues() {
// 设置默认值
this.productId = 0L;
}
/** /**
* 产品工艺id * 产品工艺id
*/ */
......
package com.huigou.topsun.product.repository;
import com.huigou.topsun.product.domain.ProductProcess;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @author qinzhenguan
*/
public interface ProductProcessRepository extends JpaRepository<ProductProcess, Long> {
List<ProductProcess> findByProductTechnologyId(Long productTechnologyId);
}
\ No newline at end of file
package com.huigou.topsun.product.repository;
import com.huigou.topsun.product.domain.ProductTechnology;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author qinzhenguan
*/
public interface ProductTechnologyRepository extends JpaRepository<ProductTechnology, Long> {
ProductTechnology findByProductId(Long productId);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment