Commit 5486dfcd authored by wanghang's avatar wanghang

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	topsun/src/main/java/com/huigou/topsun/proofing/service/impl/ProofingMakeServiceImpl.java
parents 21076f4a 0c18246f
var gridManager = null;
$(document).ready(function() {
initializateUI();
loadCodeRuleListGrid();
});
function initializateUI() {
//UICtrl.layout("#layout", {leftWidth: 3});
UICtrl.layout("#layout",{leftWidth: 50});
}
function loadCodeRuleListGrid() {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
updateHandler: function(){
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", {
columns: [
{ display: "产品名称", name: "productName", width: 140, minWidth: 60, type: "string", align: "left" },
{ display: "产品类别", name: "productCategoryId", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "产品状态", name: "productStatus", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "产品计量单位", name: "productUnit", width: 100, minWidth: 60, type: "string", align: "left" },
{ display: "样品编号", name: "productSampleCode", width: 150, minWidth: 60, type: "string", align: "left" },
{ display: "品牌名称", name: "brandName", width: 100, minWidth: 60, type: "string", align: "left" },
{ display: "产品类型", name: "prodcutType", width: 140, minWidth: 60, type: "datetime", align: "left" }
],
dataAction: "server",
url: web_app.name + '/product/findProduct.ajax',
parms: {
page: 0,
size: 30
},
pageSize: 20,
usePager: true,
toolbar: toolbarOptions,
width: "100%",
height: "100%",
heightDiff: -8,
checkbox: true,
fixedCellHeight: true,
selectRowButtonOnly: true,
onDblClickRow : function(data, rowindex, rowobj) {
updateHandler(data);
}
});
UICtrl.setSearchAreaToggle(gridManager);
}
function updateHandler(data) {
var id = data.productId;
if (!id) {
id = DataUtil.getUpdateRowId(gridManager);
if (!id) {
return;
}
}
var url=DataUtil.composeURLByParam('/product/forwardProductDetail.do',{ data: JSON.stringify(data) });
UICtrl.addTabItem({tabid:'viewFlowChart' + id, text:"产品信息",url:url});
// debugger;
// UICtrl.addTabItem({
// tabid: 'viewFlowChart' + id,
// text: "产品信息",
// url: web_app.name + '/bizFlowChart/showViewFlowchart.load?businessProcessId=' + id
// });
}
<%--
Created by IntelliJ IDEA.
User: qinzhenguan
Date: 2023/11/29
Time: 17:18
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@taglib uri="/WEB-INF/taglib.tld" prefix="x"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>Title</title>
<x:base include="layout,dialog,grid,tree,combox,commonTree" />
<x:script src='/system/opm/js/OpmUtil.js'/>
<x:script src='/biz/topsun/common/purchaseCommon.js'/>
<x:script src='/biz/topsun/product/product.js'/>
</head>
<body>
<%-- <div position="top">--%>
<%-- <form class="hg-form" method="post" action="" id="submitForm">--%>
<%-- <div class="hg-form-cols">--%>
<%-- <x:hidden name="id" id="functionsId"/>--%>
<%-- <div class="hg-form-row">--%>
<%-- <x:inputC name="code" required="true" label="tech.field.resourceCode" maxLength="64" match="englishCode"/>--%>
<%-- <x:inputC name="name" required="true" label="common.field.name" maxLength="32"/>--%>
<%-- <x:inputC name="checkBeanName" required="false" label="权限校验Bean" maxLength="64" match="englishCode"/>--%>
<%-- </div>--%>
<%-- <div class="hg-form-row">--%>
<%-- <x:textareaC name="remark" required="false" label="common.field.remark" maxLength="128" rows="2" labelCol="2" fieldCol="10"/>--%>
<%-- </div>--%>
<%-- </div>--%>
<%-- <div class="hg-form-row" style="text-align: right;padding-top:5px;">--%>
<%-- <x:button value="保 存" icon="fa-save" onclick="doSaveMain(this.form)"/>&nbsp;&nbsp;--%>
<%-- <x:button value="预 览" icon="fa-list-alt" onclick="doView(this.form)"/>&nbsp;&nbsp;--%>
<%-- <x:button value="关 闭" icon="fa-times" onclick="doClose()"/>&nbsp;&nbsp;--%>
<%-- </div>--%>
<%-- <div class="clearfix"></div>--%>
<%-- </form>--%>
<%-- </div>--%>
<div position="center" title="产品管理">
<div id="productListGrid" style="margin: 2px;"></div>
</div>
</body>
</html>
$(document).ready(function() {
initializateSelectC();
});
function initializateSelectC() {
$('#productId').searchbox({
type: "product",
name: "productCode",
onChange: function (value, data) {
}
});
}
function loadDataTest() {
console.log("loadData")
var params = new URLSearchParams(document.location.search);
var paramsData = JSON.parse(params.get("data"));
Public.ajax(web_app.name + "/product/loadProductDetail.ajax", {
productId: paramsData.productId
}, function (data) {
debugger;
var selectedCategory = data.selectedCategory;
$("#selectedCategory").ligerComboBox({
textField: 'productCategoryName',
valueField: 'productCategoryId',
columns: [
{ header: 'ID', name: 'productCategoryId', width: 20 },
{ header: '名字', name: 'productCategoryName' }
],
data: selectedCategory,
selectBoxWidth: 200
});
});
}
<%--
Created by IntelliJ IDEA.
User: qinzhenguan
Date: 2023/11/30
Time: 15:02
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@taglib uri="/WEB-INF/taglib.tld" prefix="x"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<head>
<x:base include="layout,dialog,grid,tree,combox,commonTree" />
<x:script src='/biz/topsun/product/productDetail.js'/>
</head>
<form class="hg-form" method="post" action="" id="submitForm">
<x:hidden name="productDetailId" />
<x:hidden name="productId"/>
<div class="hg-form-cols">
<div labelCol="15"> </div>
</div>
<div class="hg-form-row">
<x:title title="基本属性" name="group" hideTable="#info" />
<x:inputC name="productId" required="true" label="产品编码" labelCol="2" maxLength="64" fieldCol="4" />
<x:inputC name="productName" required="true" label="产品名称" labelCol="2" maxLength="64" fieldCol="4" />
<x:selectC name="productCategoryId" required="false" label="产品类别ID" id="selectedCategory" labelCol="2"/>
<%-- <x:inputC name="productCategoryId" required="true" label="产品类别ID" wrapper="select" labelCol="2" maxLength="64"--%>
<%-- fieldCol="4" />--%>
<x:inputC name="productUnit" required="false" label="单位" labelCol="2" maxLength="32" fieldCol="4" />
<x:inputC name="productSampleCode" required="false" label="样品编号" labelCol="2" maxLength="32" fieldCol="4" />
<x:inputC name="brandName" required="false" label="品牌名称" labelCol="2" maxLength="32" fieldCol="4" />
<x:title title="" name="group" hideTable="#info" />
</div>
<form2>
</form2>
<form3>
</form3>
<div class="blank_div clearfix"></div>
<x:title title="工序设置" name="group" hideTable="#info" />
<div id="processListGrid" style="margin: 2px;"></div>
</form>
</html>
......@@ -18,7 +18,7 @@ import org.springframework.stereotype.Controller;
*/
@ControllerMapping("/leave")
@Controller
public class LeaveController extends CommonController {
class LeaveController extends CommonController {
@Autowired
private LeaveApplication leaveApplication;
......
package com.huigou.topsun.easySearch.controller;
package com.huigou.topsun.demo.controller;
import com.huigou.topsun.resource.service.ResourceFiledService;
import com.huigou.topsun.technology.application.ProcessApplication;
......
......@@ -3,6 +3,8 @@ package com.huigou.topsun.product.application;
import com.huigou.topsun.product.domain.Product;
import org.springframework.data.domain.Page;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
......@@ -20,7 +22,7 @@ public interface ProductApplication {
* @author qinzhenguan
* @create: 2023/11/29 9:34
*/
Page<Product> findProductPage(int page, int size);
ArrayList<Map<String, Object>> findProductPage(int page, int size);
/**
* description 获取产品所有信息
......
......@@ -46,11 +46,18 @@ public class ProductApplicationImpl implements ProductApplication {
private final ProductFaceColorRepository faceColorRepository;
@Override
public Page<Product> findProductPage(int page, int size) {
PageRequest pageRequest = new PageRequest(page, size);
Page<Product> productPage = productRepository.findAll(pageRequest);
productPage.getContent().stream().map(Product::toString).forEach(System.out::println);
return productPage;
public ArrayList<Map<String, Object>> findProductPage(int page, int size) {
// PageRequest pageRequest = new PageRequest(page, size);
// Page<Product> productPage = productRepository.findAll(pageRequest);
// mapList.getContent().stream().map(Product::toString).forEach(System.out::println);
ArrayList<Product> productPage = (ArrayList<Product>) productRepository.findAll();
ObjectMapper mapper = new ObjectMapper();
ArrayList<Map<String, Object>> mapList = (ArrayList<Map<String, Object>>) mapper.convertValue(productPage, List.class);
// convert = mapList.stream().collect(Collectors.toMap(index -> index, Function.identity(),
// (oldV, newV) -> oldV));
return mapList;
}
/**
......@@ -64,7 +71,7 @@ public class ProductApplicationImpl implements ProductApplication {
public Map<String, Object> queryDetailAll(int productId) {
Map<String, Object> resultMap = new HashMap<>();
ProductDetail productDetail = detailRepository.findByProductIdEquals((long)productId);
resultMap.put("detai", productDetail);
resultMap.put("detail", productDetail);
// EntityManager manager = JPAUtils.getEntityManger();
// manager.getTransaction().begin();
// manager.flush();
......@@ -77,12 +84,12 @@ public class ProductApplicationImpl implements ProductApplication {
ArrayList<ProductCategory> categorys = (ArrayList<ProductCategory>)categoryRepository.findAll();
// --------------------------------- 详情查询 ---------------------------------
ProductTypesetConf typesetConf = typesetConfRepository.findByProductIdEquals(Long.toString(productId));
System.err.println(Long.toString(productId));
ProductLooked looked = lookedRepository.findByProductId(Long.toString(productId));
ProductPublishedConf publishedConf = publishedConfRepository.findByProductIdEquals(Long.toString(productId));
ProductLoss loss = lossRepository.findByProductIdEquals(Long.toString(productId));
ProductMaterial material = materialRepository.findByProductIdEquals(Long.toString(productId));
String strProductId = Long.toString(productId);
ProductTypesetConf typesetConf = typesetConfRepository.findByProductId(strProductId);
ProductLooked looked = lookedRepository.findByProductId(strProductId);
ProductPublishedConf publishedConf = publishedConfRepository.findByProductId(strProductId);
ProductLoss loss = lossRepository.findByProductId(strProductId);
ArrayList<ProductMaterial> material = (ArrayList<ProductMaterial>) materialRepository.findByProductId(strProductId);
resultMap.put("typesetConf", typesetConf);
resultMap.put("looked", looked);
resultMap.put("publishedConf", publishedConf);
......@@ -104,17 +111,74 @@ public class ProductApplicationImpl implements ProductApplication {
resultMap.put("backColor", backColor);
}
}
ObjectMapper mapper = new ObjectMapper();
resultMap.put("selectedBrand", mapper.convertValue(brands, List.class));
resultMap.put("selectedFactory", mapper.convertValue(factorys, List.class));
resultMap.put("selectedColor", mapper.convertValue(colors, List.class));
resultMap.put("selectedCategory", mapper.convertValue(categorys, List.class));
// resultMap.put("selectedBrand", convertToMap(Brand.class, "brandName", "brandId", brands));
// resultMap.put("selectedFactory", convertToMap(Factory.class, "factoryName", "factoryId", factorys));
// resultMap.put("selectedColor", convertToMap(Color.class, "colorName", "colorId", colors));
// resultMap.put("selectedCategory", convertToMap(ProductCategory.class, "productCategoryId",
// "productCategoryName", categorys));
return resultMap;
}
/**
* description
* @param clazz Bean
* @param displayProperty 需要显示的属性
* @param valueProperty 连接的属性
* @param list 需要转换的 List
* @return java.util.Map<java.lang.Object, java.lang.Object>
* @author qinzhenguan
* @create: 2023/12/1 16:09
*/
public Map<Object, Object> convertToMap(Class<?> clazz, String displayProperty, String valueProperty,
List<?> list) {
Set<String> set = new HashSet();
set.add(displayProperty);
set.add(valueProperty);
if(checkClassesAndProperties(clazz, set, list.size())) {
ObjectMapper mapper = new ObjectMapper();
List<Map<String, Object>> mapList = mapper.convertValue(list, List.class);
return mapList.stream().collect(Collectors.toMap(map -> map.get(displayProperty), map -> map.get(valueProperty),
(oldV, newV) -> oldV));
}
return null;
}
Map<Object, Object> selectedBrand = convertToMap(Brand.class, "brandName", brands);
Map<Object, Object> selectedFactory = convertToMap(Factory.class, "factoryName", factorys);
Map<Object, Object> selectedColor = convertToMap(Color.class, "colorId", colors);
Map<Object, Object> selectedProductCategory = convertToMap(ProductCategory.class, "productCategoryId", categorys);
resultMap.put("selectedBrand", selectedBrand);
resultMap.put("selectedFactory", selectedFactory);
resultMap.put("selectedColor", selectedColor);
resultMap.put("selectedProductCategory", selectedProductCategory);
return resultMap;
/**
* description 只检查传入属性是否合法
* @param clazz Bean
* @param set 需要检查的 Propertys
* @param listSize 需要检查的 ListSize
* @return java.lang.Boolean true of false
* @author qinzhenguan
* @create: 2023/12/1 15:58
*/
public Boolean checkClassesAndProperties(Class<?> clazz, Set<String> set, int listSize) {
if(listSize == 0) {
System.err.println("[checkClassesAndProperties] : List< "+clazz.getName()+" > 需要转换的列表没有元素。请检查~!");
return false;
}
Field[] fields = clazz.getDeclaredFields();
Method[] methods = clazz.getDeclaredMethods();
for(String item : set) {
Field field = Arrays.stream(fields).filter(f -> item.equals(f.getName())).findFirst().orElse(null);
if(field == null) {
System.err.println("[checkClassesAndProperties] : " + clazz.getName() + " 无法找到 : " + item + " " +
"该属性。请检查~!");
return false;
}
Method method = Arrays.stream(methods)
.filter(m -> m.getName().toLowerCase().contains("get" + item.toLowerCase())).findFirst().orElse(null);
if (method == null) {
System.err.println("[checkClassesAndProperties] : " + item + " 该属性无法找到构造方法。请检查~!");
return false;
}
}
return true;
}
/**
......@@ -131,11 +195,11 @@ public class ProductApplicationImpl implements ProductApplication {
}
/**
* description 转换成 Map
* description 转换成 Map 保留映射
* @param clazz Bean
* @param propertyName 连接的 property
* @param list 需要转换的 List
* @param isBean 是否需要转换为实体
* @param isBean 是否需要转换为实体 (当前应用不需要返回实体)
* @return java.util.Map<java.lang.Object, java.lang.Object>
* @author qinzhenguan
* @create: 2023/11/29 11:34
......@@ -174,7 +238,7 @@ public class ProductApplicationImpl implements ProductApplication {
}
/**
* description 检查传入参数是否合法
* description 检查传入参数是否合法 并返回构造方法
*
* @param clazz Bean
* @param propertyName property
......
package com.huigou.topsun.product.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.DictUtil;
import com.huigou.topsun.base.coderule.domain.model.CodeRuleKind;
import com.huigou.topsun.product.domain.Product;
import com.huigou.topsun.product.application.ProductApplication;
import com.huigou.topsun.resource.vo.ResourceFiledVo;
import org.springframework.data.domain.Page;
import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.client.CommonController;
......@@ -9,6 +14,9 @@ import com.huigou.util.SDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
......@@ -23,27 +31,76 @@ public class ProductController extends CommonController {
@Autowired
private ProductApplication productService;
@Override
protected String getPagePath() {
return "/biz/topsun/product/";
}
/**
* description
* @author qinzhenguan
* @date 2023/11/27 11:49
* @return null
*/
public String findProduct() {//需要特定返回值
public String findProduct() {//需要特定类型返回值
SDO sdo = this.getSDO();
int page = sdo.getInteger("page");
int size = sdo.getInteger("size");
Page<Product> productPage = productService.findProductPage(page, size);
return toResult(productPage);
// int page = sdo.getInteger("page");
// int size = sdo.getInteger("size");
ArrayList<Map<String,Object>> productPage = productService.findProductPage(0, 30);
HashMap<Object, Object> map = new HashMap<>();
map.put("Rows",productPage);
return toResult(map);
}
public String queryDetailAll() {
SDO sdo = this.getSDO();
int productId = sdo.getInteger("productId");
Map<String, Object> map = productService.queryDetailAll(productId);
String productId = sdo.getString("id");
Map<String, Object> map = productService.queryDetailAll(Integer.parseInt(productId));
return toResult(map);
}
public String forwardProduct() {
// 通过此方法可以查看系统配置的 字典 的数据结构
DictUtil.getDictionaryList("technologyType");
Map<String, Object> map4 = new HashMap<>();
map4.put("六六六", "666");
map4.put("七七七", "777");
map4.put("八八八", "888");
this.putAttribute("selectedCategory", map4);
return forward("product");
}
public String forwardProductDetail() {
ObjectMapper mapper = new ObjectMapper();
SDO sdo = this.getSDO();
Map param = null;
try {
param = mapper.readValue(sdo.getString("data"), Map.class);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
String productId= param.get("productId")+"";
Map<String, Object> resultMap = productService.queryDetailAll(Integer.parseInt(productId));
if(resultMap.get("detail") != null) {
resultMap.putAll(mapper.convertValue(resultMap.get("detail"), Map.class));
}
return forward("productDetail", param);
}
public String loadProductDetail() {
ObjectMapper mapper = new ObjectMapper();
SDO sdo = this.getSDO();
String productId = sdo.getString("productId");
Map<String, Object> resultMap = productService.queryDetailAll(Integer.parseInt(productId));
if(resultMap.get("detail") != null) {
resultMap.putAll(mapper.convertValue(resultMap.get("detail"), Map.class));
}
return toResult(resultMap);
}
}
\ No newline at end of file
......@@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
* @Description:
*/
public interface ProductLossRepository extends JpaRepository<ProductLoss,String> {
ProductLoss findByProductIdEquals(String productId) ;
ProductLoss findByProductId(String productId);
}
......@@ -3,11 +3,13 @@ package com.huigou.topsun.product.repository;
import com.huigou.topsun.product.domain.ProductMaterial;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
/**
* @Auther: xin.lu
* @Date: 2023/11/22/10:46
* @Description:
*/
public interface ProductMaterialRepository extends JpaRepository<ProductMaterial,String> {
ProductMaterial findByProductIdEquals(String productId);
List<ProductMaterial> findByProductId(String productId);
}
......@@ -9,7 +9,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
* @Description:
*/
public interface ProductPublishedConfRepository extends JpaRepository<ProductPublishedConf,String> {
ProductPublishedConf findByProductIdEquals(String productId);
ProductPublishedConf findByProductId(String productId);
ProductPublishedConf getProductPublishedConfByProductId(String productId);
}
......@@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
* @Description:
*/
public interface ProductTypesetConfRepository extends JpaRepository<ProductTypesetConf,String> {
ProductTypesetConf findByProductIdEquals(String productId);
ProductTypesetConf findByProductId(String productId);
}
package com.huigou.topsun.proofing.service.impl;
import com.huigou.topsun.product.domain.ProductLooked;
import com.huigou.topsun.product.domain.ProductPublishedConf;
import com.huigou.topsun.product.repository.ProductLookedRepository;
import com.huigou.topsun.product.repository.ProductPublishedConfRepository;
import com.huigou.topsun.proofing.domain.model.ProofingApply;
import com.huigou.topsun.proofing.domain.model.ProofingMake;
import com.huigou.topsun.proofing.domain.vo.ProofingMakeVo;
import com.huigou.topsun.proofing.repository.ProofingApplyRepository;
import com.huigou.topsun.proofing.repository.ProofingMakeRepository;
import com.huigou.topsun.proofing.service.ProofingMakeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ProofingMakeServiceImpl implements ProofingMakeService {
@Autowired
ProofingMakeRepository proofingMakeRepository;
@Autowired
ProofingApplyRepository proofingApplyRepository;
@Autowired
ProductLookedRepository productLookedRepository;
@Autowired
ProductPublishedConfRepository productPublishedConfRepository;
public List<ProofingMakeVo> getProofingMakeVoList(){
List<ProofingMake> makeAll = proofingMakeRepository.findAll();
List<ProofingMakeVo> makeVoList = new ArrayList<>();
for (ProofingMake proofingMake : makeAll) {
ProofingApply proofingApply = proofingApplyRepository.findByProofingApplyId(proofingMake.getProofingApplyId());
ProofingMakeVo proofingMakeVo = getProofingMakeVo(proofingMake, proofingApply);
makeVoList.add(proofingMakeVo);
}
return makeVoList;
}
@Override
public ProofingMakeVo getProofingMakeVoById(String proofingMakeId) {
ProofingMake proofingMake = proofingMakeRepository.findOne(proofingMakeId);
ProofingApply proofingApply = proofingApplyRepository.findByProofingApplyId(proofingMake.getProofingApplyId());
ProductLooked productLooked = productLookedRepository.findByProductId(proofingApply.getProductId());
ProductPublishedConf productPublishedConf = productPublishedConfRepository.getProductPublishedConfByProductId(proofingApply.getProductId());
return this.getProofingMakeVo(proofingApply,proofingMake,productLooked,productPublishedConf);
}
/**
* 分解ProofingMake
* @param proofingMake
*/
@Override
public void saveProofingMakeVo(ProofingMake proofingMake) {
proofingMakeRepository.save(proofingMake);
}
@Override
public void deleteProofingMakeVo(String proofingMakeId) {
proofingMakeRepository.delete(proofingMakeId);
}
/**
* 生成ProofingMakeVo类
* @return 填充过数据后的ProofingMakeVo
*/
public ProofingMakeVo getProofingMakeVo(Object... objs){
ProofingMakeVo proofingMakeVo = new ProofingMakeVo();
for (Object obj : objs) {
if(obj!=null){
BeanUtils.copyProperties(obj, proofingMakeVo);
}
}
return proofingMakeVo;
}
}
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