Commit 095a809e authored by 赵啸非's avatar 赵啸非

添加解析表单

parent 45ba34a9
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 数据类型(number.数字,string.字符串,arrays.数组,obj.对象)枚举类
*
* @author zxfei
*/
public enum DataTypeEnum {
数字("数字", "number"),
字符串("字符串", "string"),
数组("数组", "arrays"),
对象("对象", "obj");
private String value;
private String desc;
DataTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static DataTypeEnum getByValue(String value) {
for (DataTypeEnum dataTypeEnum : DataTypeEnum.values()) {
if (dataTypeEnum.getValue() == value) {
return dataTypeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (DataTypeEnum item : DataTypeEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 是否允许为空,(0.否,1.是)枚举类
*
* @author zxfei
*/
public enum FieldNullEnum {
(0, "否"),
(1, "是");
private Integer value;
private String desc;
FieldNullEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static FieldNullEnum getByValue(Integer value) {
for (FieldNullEnum fieldNullEnum : FieldNullEnum.values()) {
if (fieldNullEnum.getValue() == value) {
return fieldNullEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (FieldNullEnum item : FieldNullEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 字段类型(input.单行输入框,textarea.多行输入框,SELECT.下拉选项框,date.日期选择框,checkbox.多项选择框)枚举类
*
* @author zxfei
*/
public enum FieldTypeEnum {
单行输入框("单行输入框", "input"),
多行输入框("多行输入框", "textarea"),
下拉选项框("下拉选项框", "SELECT"),
单项选择框("单项选择框", "radio"),
日期选择框("日期选择框", "date"),
多项选择框("多项选择框", "checkbox"),
横向列表("横向列表", "list"),
表格("表格", "table");
private String value;
private String desc;
FieldTypeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static FieldTypeEnum getByValue(String value) {
for (FieldTypeEnum fieldTypeEnum : FieldTypeEnum.values()) {
if (fieldTypeEnum.getValue() == value) {
return fieldTypeEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(String... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (FieldTypeEnum item : FieldTypeEnum.values()) {
try {
boolean hasE = false;
for (String e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.common.code;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 字段是否列表显示(0.否,1.是)枚举类
*
* @author zxfei
*/
public enum IsListEnum {
(0, "否"),
(1, "是");
private Integer value;
private String desc;
IsListEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
public Integer getValue() {
return this.value;
}
public String getDesc() {
return this.desc;
}
public static IsListEnum getByValue(Integer value) {
for (IsListEnum isListEnum : IsListEnum.values()) {
if (isListEnum.getValue() == value) {
return isListEnum;
}
}
return null;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public static Map<String, String> getEnumMap(Integer... eItem) {
Map<String, String> resultMap = new LinkedHashMap<>();
for (IsListEnum item : IsListEnum.values()) {
try {
boolean hasE = false;
for (Integer e : eItem) {
if (item.getValue() == e) {
hasE = true;
break;
}
}
if (!hasE) {
resultMap.put(item.getValue() + "", item.getDesc());
}
} catch (Exception ex) {
}
}
return resultMap;
}
}
\ No newline at end of file
package com.mortals.xhx.module.datum.dao;
import com.mortals.framework.dao.ICRUDDao;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import java.util.List;
/**
* 填单用户信息字段Dao
* 填单用户信息字段 DAO接口
*
* @author zxfei
* @date 2024-04-23
*/
public interface DatumInfoFieldDao extends ICRUDDao<DatumInfoFieldEntity,Long>{
}
package com.mortals.xhx.module.datum.dao.ibatis;
import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.datum.dao.DatumInfoFieldDao;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List;
/**
* 填单用户信息字段DaoImpl DAO接口
*
* @author zxfei
* @date 2024-04-23
*/
@Repository("datumInfoFieldDao")
public class DatumInfoFieldDaoImpl extends BaseCRUDDaoMybatis<DatumInfoFieldEntity,Long> implements DatumInfoFieldDao {
}
package com.mortals.xhx.module.datum.model;
import java.util.List;
import java.util.ArrayList;
import java.math.BigDecimal;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.datum.model.vo.DatumInfoFieldVo;
import lombok.Data;
/**
* 填单用户信息字段实体对象
*
* @author zxfei
* @date 2024-04-23
*/
@Data
public class DatumInfoFieldEntity extends DatumInfoFieldVo {
private static final long serialVersionUID = 1L;
/**
* 填单打印id
*/
private Long datumPrintId;
/**
* 字段编码
*/
private String fieldCode;
/**
* 字段名称
*/
private String fieldName;
/**
* 字段类型(input.单行输入框,textarea.多行输入框,SELECT.下拉选项框,date.日期选择框,checkbox.多项选择框)
*/
private String fieldType;
/**
* 字段类型值,当字段类型为多选,单选时候,预设复选值
*/
private String fieldTypeValue;
/**
* 数据类型(number.数字,string.字符串,arrays.数组,obj.对象)
*/
private String dataType;
/**
* 字段值
*/
private String fieldValue;
/**
* 字段默认值
*/
private String defaultValue;
/**
* 数据长度,默认128
*/
private Integer fieldLen;
/**
* 是否允许为空,(0.否,1.是)
*/
private Integer fieldNull;
/**
* 字段是否列表显示(0.否,1.是)
*/
private Integer isList;
/**
* 排序号
*/
private Integer fieldOrderNo;
/**
* 备注
*/
private String remark;
/**
* 身份证号
*/
private String idCard;
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof DatumInfoFieldEntity) {
DatumInfoFieldEntity tmp = (DatumInfoFieldEntity) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public void initAttrValue(){
this.datumPrintId = null;
this.fieldCode = "";
this.fieldName = "";
this.fieldType = "";
this.fieldTypeValue = "";
this.dataType = "";
this.fieldValue = "";
this.defaultValue = "";
this.fieldLen = 0;
this.fieldNull = 0;
this.isList = 0;
this.fieldOrderNo = 0;
this.remark = "";
this.idCard = "";
}
}
\ No newline at end of file
package com.mortals.xhx.module.datum.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.mortals.framework.annotation.Excel;
import java.math.BigDecimal;
import java.util.Date;
/**
* 填单用户信息字段视图对象
*
* @author zxfei
* @date 2024-04-23
*/
@Data
public class DatumInfoFieldVo extends BaseEntityLong {
/** 序号,主键,自增长列表 */
private List <Long> idList;
}
\ No newline at end of file
package com.mortals.xhx.module.datum.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import com.mortals.xhx.module.datum.dao.DatumInfoFieldDao;
import com.mortals.xhx.module.datum.model.DatumInfoFieldQuery;
import com.mortals.xhx.module.matter.model.MatterDatumPrintEntity;
import com.mortals.xhx.module.matter.model.MatterDatumPrintQuery;
import java.util.List;
/**
* DatumInfoFieldService
* <p>
* 填单用户信息字段 service接口
*
* @author zxfei
* @date 2024-04-23
*/
public interface DatumInfoFieldService extends ICRUDService<DatumInfoFieldEntity, Long> {
DatumInfoFieldDao getDao();
/**
* 解析保存表单字段
*
* @param matterDatumPrintEntity
* @param context
* @return
*/
Rest<List<DatumInfoFieldEntity>> parseFormContent(MatterDatumPrintEntity matterDatumPrintEntity, Context context);
/**
* 去除重复列表
*
* @param datumInfoFieldQuery
* @param context
* @return
*/
Rest<List<DatumInfoFieldEntity>> distinctList(DatumInfoFieldQuery datumInfoFieldQuery, Context context);
}
\ No newline at end of file
package com.mortals.xhx.module.datum.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.OrderCol;
import com.mortals.xhx.common.code.ComponentEnum;
import com.mortals.xhx.common.code.DataTypeEnum;
import com.mortals.xhx.common.code.FieldTypeEnum;
import com.mortals.xhx.module.datum.model.DatumInfoFieldQuery;
import com.mortals.xhx.module.matter.model.MatterDatumPrintEntity;
import com.mortals.xhx.module.matter.model.MatterDatumPrintQuery;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.datum.dao.DatumInfoFieldDao;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import com.mortals.xhx.module.datum.service.DatumInfoFieldService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* DatumInfoFieldService
* 填单用户信息字段 service实现
*
* @author zxfei
* @date 2024-04-23
*/
@Service("datumInfoFieldService")
@Slf4j
public class DatumInfoFieldServiceImpl extends AbstractCRUDServiceImpl<DatumInfoFieldDao, DatumInfoFieldEntity, Long> implements DatumInfoFieldService {
@Override
public Rest<List<DatumInfoFieldEntity>> parseFormContent(MatterDatumPrintEntity matterDatumPrintEntity, Context context) {
JSONObject json = JSON.parseObject(matterDatumPrintEntity.getFormContent());
List<DatumInfoFieldEntity> infoFieldlist = new ArrayList<DatumInfoFieldEntity>();
for (String key : json.keySet()) {
DatumInfoFieldEntity infoField = new DatumInfoFieldEntity();
infoField.setDatumPrintId(matterDatumPrintEntity.getId());
infoField.setIdCard(matterDatumPrintEntity.getIdCard());
//通过key类型判断属性类型
List<String> split = StrUtil.split(key, "_");
String value = json.getString(key);
//单行输入框
boolean input = StrUtil.startWith(key, ComponentEnum.INPUT.getValue());
if (input && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.单行输入框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.字符串.getDesc());
}
//文本输入框
boolean texxarea = StrUtil.startWith(key, ComponentEnum.TEXTAREA.getValue());
if (texxarea && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.多项选择框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.字符串.getDesc());
}
//单选框
boolean radio = StrUtil.startWith(key, ComponentEnum.RADIO.getValue());
if (radio && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.单项选择框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.字符串.getDesc());
}
//下拉选项框
boolean select = StrUtil.startWith(key, ComponentEnum.SELECT.getValue());
if (select && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.单项选择框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.字符串.getDesc());
}
//复选框
boolean checkBok = StrUtil.startWith(key, ComponentEnum.CHECKBOX.getValue());
if (checkBok && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.多项选择框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.数组.getDesc());
}
//时间
boolean date = StrUtil.startWith(key, ComponentEnum.DATE.getValue());
if (date && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.日期选择框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.字符串.getDesc());
}
//横向列表
boolean list = StrUtil.startWith(key, ComponentEnum.LIST.getValue());
if (list && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.横向列表.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.数组.getDesc());
}
//表格
boolean table = StrUtil.startWith(key, ComponentEnum.DYNAMIC_TABLE.getValue());
if (table && split.size() > 2) {
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.表格.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.数组.getDesc());
}
infoFieldlist.add(infoField);
}
return Rest.ok("解析保存成功!", infoFieldlist);
}
@Override
public Rest<List<DatumInfoFieldEntity>> distinctList(DatumInfoFieldQuery datumInfoFieldQuery, Context context) {
datumInfoFieldQuery.setOrderColList(Arrays.asList(new OrderCol("createTime", OrderCol.DESCENDING)));
Map<String, List<DatumInfoFieldEntity>> collect = this.find(datumInfoFieldQuery, context).stream().collect(Collectors.groupingBy(x -> x.getFieldName()));
List<DatumInfoFieldEntity> distiinctList = collect.entrySet().stream().map(item -> {
List<DatumInfoFieldEntity> value = item.getValue();
if (!ObjectUtils.isEmpty(value)) {
return value.get(0);
} else {
return null;
}
}).filter(f -> f != null).collect(Collectors.toList());
return Rest.ok("获取列表成功!",distiinctList);
}
public static void main(String[] args) {
String json = "{\n" +
" \"ck_1_类别_<新参保登记-暂停登记-注销登记-拆分-合并-分立>\": [\n" +
" \"新参保登记\"\n" +
" ],\n" +
" \"i_2_单位名称\": \"蜻蜓和\",\n" +
" \"i_3_现统一社会信用代码\": \"34534543\",\n" +
" \"i_4_姓名\": \"hjs\",\n" +
" \"i_5_联系电话\": \"18282787877\",\n" +
" \"i_6_身份证号码\": \"51192319991118605X\",\n" +
" \"i_7_开户行\": \"1234213123\",\n" +
" \"i_8_户名\": \"hjg\",\n" +
" \"i_9_银行账号\": \"6745645645\",\n" +
" \"i_10_姓名\": \"hjs\",\n" +
" \"i_11_手机号码\": \"16434534534543\",\n" +
" \"i_12_联系电话\": \"23423423432\",\n" +
" \"ck_13_参保险种_<职工基本医疗保险-生育保险-补充医疗保险->其他(___________)\": [\n" +
" \"职工基本医疗保险\"\n" +
" ],\n" +
" \"date_14_参保起始时间\": \"2023 年 02 月 22 日\",\n" +
" \"date_15_日期\": \"2023 年 02 月 14 日\"\n" +
"}";
JSONObject jsonObject = JSON.parseObject(json);
String string = jsonObject.getString("ck_13_参保险种_<职工基本医疗保险-生育保险-补充医疗保险->其他(___________)");
System.out.println(string);
}
}
\ No newline at end of file
package com.mortals.xhx.module.datum.web;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.datum.model.DatumInfoFieldQuery;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.matter.model.MatterDatumPrintEntity;
import com.mortals.xhx.module.matter.model.MatterDatumPrintQuery;
import com.mortals.xhx.module.matter.service.MatterDatumPrintService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import com.mortals.xhx.module.datum.service.DatumInfoFieldService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
import com.mortals.xhx.common.code.*;
/**
* 填单用户信息字段
*
* @author zxfei
* @date 2024-04-23
*/
@RestController
@RequestMapping("datum/info/field")
public class DatumInfoFieldController extends BaseCRUDJsonBodyMappingController<DatumInfoFieldService, DatumInfoFieldEntity, Long> {
@Autowired
private ParamService paramService;
@Autowired
private MatterDatumPrintService datumPrintService;
public DatumInfoFieldController() {
super.setModuleDesc("填单用户信息字段");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "fieldType", FieldTypeEnum.getEnumMap());
this.addDict(model, "dataType", DataTypeEnum.getEnumMap());
this.addDict(model, "fieldNull", FieldNullEnum.getEnumMap());
this.addDict(model, "isList", IsListEnum.getEnumMap());
super.init(model, context);
}
/**
* 解析保存用户所有表单
*
* @param query
* @return
*/
@PostMapping(value = "parseForm")
@UnAuth
public Rest<Object> parseForm(@RequestBody DatumInfoFieldEntity query) {
Map<String, Object> model = new HashMap<>();
Context context = this.getContext();
String busiDesc = "解析保存" + this.getModuleDesc();
try {
List<MatterDatumPrintEntity> datumPrintEntities = datumPrintService.find(new MatterDatumPrintQuery());
for (MatterDatumPrintEntity datumPrintEntity : datumPrintEntities) {
if (!ObjectUtils.isEmpty(datumPrintEntity.getFormContent())) {
Rest<List<DatumInfoFieldEntity>> rest = this.service.parseFormContent(datumPrintEntity, context);
if (rest.getCode() == YesNoEnum.YES.getValue() && !ObjectUtils.isEmpty(rest.getData())) {
this.service.save(rest.getData());
}
}
}
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(request, busiDesc, model, e);
return Rest.fail(e.getMessage());
}
return Rest.ok(model);
}
/**
* 去重列表
*
* @param query
* @return
*/
@PostMapping(value = "distinctList")
@UnAuth
public Rest<Object> distinctList(@RequestBody DatumInfoFieldQuery query) {
Map<String, Object> model = new HashMap<>();
Context context = this.getContext();
String busiDesc = "查询" + this.getModuleDesc();
try {
Rest<List<DatumInfoFieldEntity>> rest = this.service.distinctList(query, context);
model.put(KEY_RESULT_DATA, rest.getData());
recordSysLog(request, busiDesc + " 【成功】");
} catch (Exception e) {
this.doException(request, busiDesc, model, e);
return Rest.fail(e.getMessage());
}
this.init(model, context);
return Rest.ok(model);
}
}
\ No newline at end of file
package com.mortals.xhx.module.matter.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.model.PageInfo;
import com.mortals.xhx.base.system.upload.service.UploadService;
import com.mortals.xhx.common.code.DataTypeEnum;
import com.mortals.xhx.common.code.FieldTypeEnum;
import com.mortals.xhx.common.utils.WordUtil;
import com.mortals.xhx.module.datum.model.DatumInfoFieldEntity;
import com.mortals.xhx.module.datum.service.DatumInfoFieldService;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
......@@ -22,6 +29,7 @@ import com.mortals.xhx.module.matter.model.MatterDatumPrintEntity;
import com.mortals.xhx.module.matter.service.MatterDatumPrintService;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -40,7 +48,8 @@ public class MatterDatumPrintServiceImpl extends AbstractCRUDServiceImpl<MatterD
private MatterService matterService;
@Autowired
private DeviceService deviceService;
@Autowired
private DatumInfoFieldService datumInfoFieldService;
@Value("${upload.path}")
private String filePath;
......@@ -62,7 +71,7 @@ public class MatterDatumPrintServiceImpl extends AbstractCRUDServiceImpl<MatterD
}
entity.setOrderId(IdUtil.simpleUUID());
String rootPath = this.filePath.endsWith("/") ? this.filePath : this.filePath + "/";
// Integer pageByDoc = WordUtil.getPageByDoc(rootPath + entity.getDocPath());
// Integer pageByDoc = WordUtil.getPageByDoc(rootPath + entity.getDocPath());
entity.setPrintPage(1);
if (!ObjectUtils.isEmpty(entity.getDeviceCode())) {
......@@ -88,4 +97,53 @@ public class MatterDatumPrintServiceImpl extends AbstractCRUDServiceImpl<MatterD
});
}
@Override
protected void saveAfter(MatterDatumPrintEntity entity, Context context) throws AppException {
super.saveAfter(entity, context);
//拆解数据
if (!ObjectUtils.isEmpty(entity.getFormContent())) {
JSONObject json = JSON.parseObject(entity.getFormContent());
List<DatumInfoFieldEntity> infoFieldlist = new ArrayList<DatumInfoFieldEntity>();
for (String key : json.keySet()) {
DatumInfoFieldEntity infoField = new DatumInfoFieldEntity();
infoField.setDatumPrintId(entity.getId());
infoField.setIdCard(entity.getIdCard());
//通过key类型判断属性类型
boolean input = StrUtil.startWith(key, "i_");
List<String> split = StrUtil.split(key, "_");
if (input) {
if(split.size()>2){
String value = json.getString(key);
infoField.setFieldCode(split.get(2));
infoField.setFieldName(split.get(2));
infoField.setFieldType(FieldTypeEnum.单行输入框.getDesc());
infoField.setFieldValue(value);
infoField.setDataType(DataTypeEnum.字符串.getDesc());
}
infoFieldlist.add(infoField);
}
}
}
}
public static void main(String[] args) {
String key="ck_1_类别_<新参保登记-暂停登记-注销登记-拆分-合并-分立>";
List<String> split = StrUtil.split(key, "_");
System.out.println(split.size());
System.out.println(split.get(0));
}
}
\ No newline at end of file
###登录
POST {{baseUrl}}/login/login
Content-Type: application/json
{
"loginName":"admin",
"password":"admin",
"securityCode":"8888"
}
> {%
client.global.set("SmsSet_id", JSON.parse(response.body).data.id);
client.global.set("authToken", JSON.parse(response.body).data.token);
%}
###填单用户信息字段列表
POST {{baseUrl}}/datum/info/field/list
Content-Type: application/json
{
"page":1,
"size":10
}
###填单用户信息字段更新与保存
POST {{baseUrl}}/datum/info/field/save
Authorization: {{authToken}}
Content-Type: application/json
{
"datumPrintId":123,
"fieldCode":"Go419T",
"fieldName":"cOmJsn",
"fieldType":"twv1sd",
"fieldTypeValue":"Mm9CzA",
"dataType":"EO6eK3",
"fieldValue":"Xm1fkc",
"defaultValue":"tPh8wF",
"fieldLen":887,
"fieldNull":852,
"isList":892,
"fieldOrderNo":389,
"remark":"jQRnYL",
}
> {%
client.global.set("DatumInfoField_id", JSON.parse(response.body).data.id);
%}
###填单用户信息字段查看
GET {{baseUrl}}/datum/info/field/info?id={{DatumInfoField_id}}
Accept: application/json
###填单用户信息字段编辑
GET {{baseUrl}}/datum/info/field/edit?id={{DatumInfoField_id}}
Accept: application/json
###填单用户信息字段删除
GET {{baseUrl}}/datum/info/field/delete?id={{DatumInfoField_id}}
Authorization: {{authToken}}
Accept: application/json
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