rev:更新

This commit is contained in:
2024-05-13 18:07:55 +08:00
parent 86c05ad7a8
commit 4b54222103
17 changed files with 363 additions and 232 deletions

View File

@@ -30,7 +30,7 @@ import java.util.Map;
/**
* <p>
* 前端控制器
* 前端控制器
* </p>
*
* @author generator
@@ -41,14 +41,14 @@ import java.util.Map;
@SaIgnore
public class BmFormStrucController {
private static Map<String,String> BASE_FORM = MapOf.of("biz_id","业务单据单据id"
,"biz_code","业务单据编号"
,"biz_date","业务单据日期"
,"biz_status","业务单据状态"
,"material_id","物料id"
,"qty","数量"
,"unit_id","单位"
,"vehicle_code","载具");
private static Map<String, String> BASE_FORM = MapOf.of("biz_id", "业务单据单据id"
, "biz_code", "业务单据编号"
, "biz_date", "业务单据日期"
, "biz_status", "业务单据状态"
, "material_id", "物料id"
, "qty", "数量"
, "unit_id", "单位"
, "vehicle_code", "载具");
@Autowired
IBmFormStrucService iBmFormStrucService;
@@ -56,13 +56,15 @@ public class BmFormStrucController {
IPmFormDataService iPmFormDataService;
@GetMapping
public ResponseEntity<Object> queryAll(FormStrucQuery query, PageQuery pageQuery){
public ResponseEntity<Object> queryAll(FormStrucQuery query, PageQuery pageQuery) {
//iBmFormStrucService.queryAll(query, pageQuery);
//参数判读,参数解析,调用参数入库
Page<BmFormStruc> page = iBmFormStrucService.page(pageQuery.build(), query.build());
return new ResponseEntity<>(TableDataInfo.build(page),HttpStatus.OK);
//Page<BmFormStruc> page = iBmFormStrucService.page(pageQuery.build(), query.build());
return new ResponseEntity<>(iBmFormStrucService.queryAll(query, pageQuery), HttpStatus.OK);
}
@PostMapping
public ResponseEntity<Object> save(@RequestBody JSONObject param){
public ResponseEntity<Object> save(@RequestBody JSONObject param) {
//参数判读,参数解析,调用参数入库
BmFormStruc formStruc = param.toJavaObject(BmFormStruc.class);
formStruc.setCreate_time(DateUtil.now());
@@ -71,76 +73,77 @@ public class BmFormStrucController {
iBmFormStrucService.save(formStruc);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/delete")
public ResponseEntity<Object> delete(List<String> types){
public ResponseEntity<Object> delete(List<String> types) {
//参数判读,参数解析,调用参数入库
int dataCount = iPmFormDataService.count(new QueryWrapper<PmFormData>().in("form_type", types));
if (dataCount>0){
if (dataCount > 0) {
throw new BadRequestException("当前表单存在业务数据,不允许删除");
}
iBmFormStrucService.remove(new QueryWrapper<BmFormStruc>().in("form_type", types));
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/getTypes")
public ResponseEntity<Object> getTypes(){
public ResponseEntity<Object> getTypes() {
//参数判读,参数解析,调用参数入库
List<Map<String, Object>> select = iBmFormStrucService.listMaps(new QueryWrapper<BmFormStruc>().select("form_type", "form_name").groupBy("form_type"));
List<Map> list = new ArrayList<>();
for (Map<String, Object> map : select) {
list.add(MapOf.of("lable",map.get("form_name"),"value",map.get("form_type")));
list.add(MapOf.of("lable", map.get("form_name"), "value", map.get("form_type")));
}
return new ResponseEntity<>(list,HttpStatus.OK);
return new ResponseEntity<>(list, HttpStatus.OK);
}
/**
* @ONLY:动态表单表头信息
* 数据结构:{"type":xxx,"name":xxx,"desc":xxx,"item":{"desc":"描述"}}
* @ONLY:动态表单表头信息 数据结构:{"type":xxx,"name":xxx,"desc":xxx,"item":{"desc":"描述"}}
*/
@GetMapping("/formColumns/{form_type}")
public ResponseEntity<Object> formColumns(@PathVariable String form_type){
public ResponseEntity<Object> formColumns(@PathVariable String form_type) {
//参数判读,参数解析,调用参数入库
List<Map> items = new ArrayList<>();
BmFormStruc form_struc = iBmFormStrucService.getOne(new QueryWrapper<BmFormStruc>().eq("form_type", form_type));
if (form_struc!=null){
if (form_struc != null) {
JSONObject form_param = form_struc.getForm_param();
for (String key : form_param.keySet()) {
items.add(MapOf.of("lable",form_param.get(key),"value",key));
items.add(MapOf.of("lable", form_param.get(key), "value", key));
}
}
return new ResponseEntity<>(items,HttpStatus.OK);
return new ResponseEntity<>(items, HttpStatus.OK);
}
/**
* @ONLY:只用于获取表单同步配置接口
* @param form_type
* @return
* @ONLY:只用于获取表单同步配置接口
*/
@GetMapping("/tableColumns/{form_type}")
public ResponseEntity<Object> tableColumns(@PathVariable String form_type){
public ResponseEntity<Object> tableColumns(@PathVariable String form_type) {
//参数判读,参数解析,调用参数入库
BmFormStruc form_struc = iBmFormStrucService.getOne(new QueryWrapper<BmFormStruc>().eq("form_type", form_type));
HashMap result = MapOf.of("has_child",form_struc.getHas_child(),"form_type", form_struc.getForm_type(), "form_name", form_struc.getForm_name(), "form_desc", form_struc.getForm_desc());
HashMap result = MapOf.of("has_child", form_struc.getHas_child(), "form_type", form_struc.getForm_type(), "form_name", form_struc.getForm_name(), "form_desc", form_struc.getForm_desc());
JSONObject form_param = form_struc.getForm_param();
form_param.putAll(BASE_FORM);
List<Map> items = new ArrayList<>();
for (String key : form_param.keySet()) {
items.add(MapOf.of("lable",form_param.get(key),"value",key));
items.add(MapOf.of("lable", form_param.get(key), "value", key));
}
if (form_struc.getHas_child()){
if (form_struc.getHas_child()) {
List<Map> dtl_items = new ArrayList<>();
BmFormStruc child_struc = iBmFormStrucService.getOne(new QueryWrapper<BmFormStruc>().eq("parent_id", form_struc.getId()));
if (child_struc == null){
throw new BadRequestException("当前表单配置异常:无子表配置信息");
BmFormStruc child_struc = iBmFormStrucService.getOne(new QueryWrapper<BmFormStruc>().eq("parent_id", form_struc.getForm_type()));
if (child_struc != null) {
JSONObject child_param = child_struc.getForm_param();
child_param.putAll(BASE_FORM);
for (String key : child_param.keySet()) {
dtl_items.add(MapOf.of("lable", form_param.get(key), "value", key));
}
result.put("dtl_item", dtl_items);
}
JSONObject child_param = child_struc.getForm_param();
child_param.putAll(BASE_FORM);
for (String key : child_param.keySet()) {
dtl_items.add(MapOf.of("lable",child_param.get(key),"value",key));
}
result.put("dtl_item",dtl_items);
}
result.put("item",items);
return new ResponseEntity<>(result,HttpStatus.OK);
result.put("item", items);
return new ResponseEntity<>(result, HttpStatus.OK);
}
}

View File

@@ -1,7 +1,9 @@
package org.nl.wms.config_manage.form_struc.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.nl.common.domain.entity.PageQuery;
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
import org.nl.wms.config_manage.form_struc.service.dto.FormStrucQuery;
/**
* <p>
@@ -14,4 +16,6 @@ import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
public interface IBmFormStrucService extends IService<BmFormStruc> {
BmFormStruc getFormType(String form_type);
Object queryAll(FormStrucQuery query, PageQuery pageQuery);
}

View File

@@ -6,7 +6,10 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.Data;
@@ -22,7 +25,7 @@ import lombok.EqualsAndHashCode;
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "bm_form_struc",autoResultMap = true)
@TableName(value = "bm_form_struc", autoResultMap = true)
public class BmFormStruc implements Serializable {
private static final long serialVersionUID = 1L;
@@ -108,17 +111,22 @@ public class BmFormStruc implements Serializable {
* 自定义表单字段存json:{"dept":"部门","empp":"员工"}
*/
@TableField(typeHandler = FastjsonTypeHandler.class)
private JSONObject form_param;
private JSONObject form_param = new JSONObject();
/**
* 是否含有明细表单
*/
private Boolean has_child;
/**
* 关联上级表单id
*/
private String parent_id;
@TableField(exist = false)
private List<BmFormStruc> children = new ArrayList<>();
@TableField(exist = false)
private Boolean hasChildren = false;
}

View File

@@ -31,7 +31,8 @@ public class FormStrucQuery extends BaseQuery<BmFormStruc> {
@Override
public void paramMapping() {
this.doP.put("search", QParam.builder().k(new String[]{"form_name"}).type(QueryTEnum.LK).build());
// this.doP.put("parent_id", QParam.builder().k(new String[]{"parent_id"}).type(QueryTEnum.NULL_OR_EMPTY).build());
this.doP.put("form_type", QParam.builder().k(new String[]{"form_type"}).type(QueryTEnum.LK).build());
}
}

View File

@@ -1,16 +1,28 @@
package org.nl.wms.config_manage.form_struc.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.entity.PageQuery;
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
import org.nl.wms.config_manage.form_struc.service.dao.mapper.BmFormStrucMapper;
import org.nl.wms.config_manage.form_struc.service.IBmFormStrucService;
import org.nl.wms.config_manage.form_struc.service.dto.FormStrucQuery;
import org.nl.wms.flow_manage.flow.service.deployment.dao.ActReProcdef;
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 服务实现类
* 服务实现类
* </p>
*
* @author generator
@@ -21,9 +33,32 @@ public class BmFormStrucServiceImpl extends ServiceImpl<BmFormStrucMapper, BmFor
@Override
public BmFormStruc getFormType(String form_type) {
if (!StringUtils.isEmpty(form_type)){
return this.getOne(new QueryWrapper<BmFormStruc>().eq("form_type",form_type));
if (!StringUtils.isEmpty(form_type)) {
return this.getOne(new QueryWrapper<BmFormStruc>().eq("form_type", form_type));
}
return null;
}
@Override
public Object queryAll(FormStrucQuery query, PageQuery page) {
LambdaQueryWrapper<BmFormStruc> lqw = new LambdaQueryWrapper<>();
lqw.isNull(BmFormStruc::getParent_id);
Page<BmFormStruc> executionPage = this.page(page.build(), lqw);
List<BmFormStruc> records = executionPage.getRecords();
this.findChildren(records);
return TableDataInfo.build(executionPage);
}
private void findChildren(List<BmFormStruc> records) {
for (BmFormStruc record : records) {
LambdaQueryWrapper<BmFormStruc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BmFormStruc::getParent_id, record.getForm_type());
List<BmFormStruc> list = this.list(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
record.setHasChildren(true);
record.setChildren(list);
this.findChildren(list);
}
}
}
}

View File

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.nl.common.TableDataInfo;
import org.nl.common.domain.entity.PageQuery;
import org.nl.wms.config_manage.form_struc.service.dao.BmFormStruc;
import org.nl.wms.flow_manage.flow.service.deployment.IActReProcdefService;
import org.nl.wms.flow_manage.flow.service.deployment.dao.ActReProcdef;
import org.nl.wms.flow_manage.flow.service.execution.dao.ActRuExecution;
@@ -40,25 +41,49 @@ public class ActRuExecutionServiceImpl extends ServiceImpl<ActRuExecutionMapper,
lqw.isNull(ActRuExecution::getParent_id);
Page<ActRuExecution> executionPage = this.page(page.build(), lqw);
List<ActRuExecution> records = executionPage.getRecords();
this.findChildren(records);
// for (ActRuExecution record : records) {
// LambdaQueryWrapper<ActRuExecution> lambdaQueryWrapper = new LambdaQueryWrapper<>();
// lambdaQueryWrapper.eq(ActRuExecution::getParent_id, record.getProc_inst_id());
// List<ActRuExecution> list = this.list(lambdaQueryWrapper);
// ActReProcdef procdef = procdefService.getById(record.getDeployment_id());
// if (ObjectUtil.isNotEmpty(procdef)) {
// record.setDeployment_name(procdef.getName());
// }
// if (CollectionUtil.isNotEmpty(list)) {
// for (ActRuExecution execution : list) {
// ActReProcdef procdefChildren = procdefService.getById(execution.getDeployment_id());
// if (ObjectUtil.isNotEmpty(procdefChildren)) {
// execution.setDeployment_name(procdefChildren.getName());
// }
// }
// record.setHasChildren(true);
// record.setChildren(list);
// }
// }
return TableDataInfo.build(executionPage);
}
private void findChildren(List<ActRuExecution> records) {
for (ActRuExecution record : records) {
LambdaQueryWrapper<ActRuExecution> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActRuExecution::getParent_id, record.getProc_inst_id());
List<ActRuExecution> list = this.list(lambdaQueryWrapper);
ActReProcdef procdef = procdefService.getById(record.getDeployment_id());
if (ObjectUtil.isNotEmpty(procdef)){
if (ObjectUtil.isNotEmpty(procdef)) {
record.setDeployment_name(procdef.getName());
}
if (CollectionUtil.isNotEmpty(list)) {
for (ActRuExecution execution : list) {
ActReProcdef procdefChildren = procdefService.getById(execution.getDeployment_id());
if (ObjectUtil.isNotEmpty(procdefChildren)){
if (ObjectUtil.isNotEmpty(procdefChildren)) {
execution.setDeployment_name(procdefChildren.getName());
}
}
record.setHasChildren(true);
record.setChildren(list);
this.findChildren(list);
}
}
return TableDataInfo.build(executionPage);
}
}

View File

@@ -33,20 +33,18 @@ public class PmFormDataController {
private IPmFormDataService formDataService;
@GetMapping()
public ResponseEntity<Object> queryAll(FormDataQuery query, PageQuery page){
Page<PmFormData> result = formDataService.page(page.build(), query.build());
return new ResponseEntity<>(TableDataInfo.build(result),HttpStatus.CREATED);
public ResponseEntity<Object> queryAll(FormDataQuery query, PageQuery page) {
// Page<PmFormData> result = formDataService.page(page.build(), query.build());
// Object o = formDataService.queryAll(query,page);
return new ResponseEntity<>(formDataService.queryAll(query, page), HttpStatus.CREATED);
}
@GetMapping("/sync/{type}")
public ResponseEntity<Object> sync(@RequestParam String type, String formDtl){
public ResponseEntity<Object> sync(@RequestParam String type, String formDtl) {
//参数判读,参数解析,调用参数入库
formDataService.syncFormData("type",formDtl);
formDataService.syncFormData("type", formDtl);
return new ResponseEntity<>(HttpStatus.CREATED);
}
}

View File

@@ -11,5 +11,5 @@ import org.nl.wms.pm_manage.form_data.service.dao.PmFormData;
@Data
public class FormDataQuery extends BaseQuery<PmFormData> {
private String from_type;
private String form_type;
}

View File

@@ -9,7 +9,7 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:wms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
username: ${DB_USER:root}
password: ${DB_PWD:123456}
password: ${DB_PWD:password}
# 初始连接数
initial-size: 5