Compare commits
7 Commits
192817f8e8
...
845af296ec
| Author | SHA1 | Date |
|---|---|---|
|
|
845af296ec | 2 weeks ago |
|
|
b94141031c | 2 weeks ago |
|
|
3a0ae20694 | 2 weeks ago |
|
|
23209830b5 | 2 weeks ago |
|
|
73efdd4df7 | 2 weeks ago |
|
|
9d968d549f | 2 weeks ago |
|
|
4a682c6963 | 2 weeks ago |
133 changed files with 8700 additions and 463 deletions
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>common</artifactId> |
||||
<groupId>apelet</groupId> |
||||
<version>1.0.0</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>common-botp</artifactId> |
||||
<packaging>jar</packaging> |
||||
<version>1.0.0</version> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>apelet</groupId> |
||||
<artifactId>common-core</artifactId> |
||||
<version>${common-core.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>apelet</groupId> |
||||
<artifactId>common-generator</artifactId> |
||||
<version>1.0.5</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>apelet</groupId> |
||||
<artifactId>common-online</artifactId> |
||||
<version>1.0.6</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>apelet</groupId> |
||||
<artifactId>common-dbutil</artifactId> |
||||
<version>1.0.0</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.swagger.core.v3</groupId> |
||||
<artifactId>swagger-annotations</artifactId> |
||||
<version>2.2.19</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>apelet</groupId> |
||||
<artifactId>common-orm</artifactId> |
||||
<version>1.0.2</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>apelet</groupId> |
||||
<artifactId>common-sequence</artifactId> |
||||
<version>1.0.0</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.jodd</groupId> |
||||
<artifactId>jodd-core</artifactId> |
||||
<version>5.1.6</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.jetbrains</groupId> |
||||
<artifactId>annotations</artifactId> |
||||
<version>24.0.1</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
|
||||
</project> |
||||
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
import apelet.common.botp.service.IBillBaseService; |
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.base.controller.BaseController; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import cn.hutool.core.bean.BeanUtil; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.github.pagehelper.Page; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/28 8:29 |
||||
*/ |
||||
public abstract class BillBaseController<M, V, K extends Serializable> extends BaseController<M, V, K> { |
||||
|
||||
|
||||
|
||||
protected abstract IBillBaseService<M, K> billservice(); |
||||
|
||||
/** |
||||
* 列表接口 |
||||
* @param m |
||||
* @param orderParam |
||||
* @param pageParam |
||||
* @param traceParamDto |
||||
* @return |
||||
*/ |
||||
public ResponseResult<?> listBill(M m, |
||||
MyOrderParam orderParam, |
||||
MyPageParam pageParam, |
||||
TraceParamDto traceParamDto |
||||
) { |
||||
Page<M> pageList = billservice().listBill(m,orderParam,pageParam,traceParamDto); |
||||
long totalCount = pageList.getTotal(); |
||||
MyPageData<M> result = MyPageUtil.makeResponseData(pageList, totalCount); |
||||
|
||||
String tableName = m.getClass().getAnnotation(TableName.class).value(); |
||||
result.setTableName(tableName); |
||||
List<M> dataList = result.getDataList(); |
||||
if (dataList.size()>0){ |
||||
List<M> vos = new ArrayList<>(); |
||||
for (M m1 : dataList) { |
||||
M o = (M) BeanUtil.copyProperties(m1, m.getClass()); |
||||
vos.add(o); |
||||
} |
||||
MyPageData voData = BeanUtil.copyProperties(result, MyPageData.class); |
||||
voData.setDataList(vos); |
||||
voData.setTableName(tableName); |
||||
return ResponseResult.success(voData); |
||||
} |
||||
//正常的返回
|
||||
return ResponseResult.success(result); |
||||
} |
||||
|
||||
/** |
||||
* 单据保存接口,包括保存单据分录 |
||||
* @param m |
||||
* @param crDto |
||||
* @return |
||||
*/ |
||||
public ResponseResult<?> saveBill(M m, @MyRequestBody List<ConvertRelationDto> crDto){ |
||||
billservice().saveBill(m,crDto); |
||||
return ResponseResult.success("新增成功"); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 单据提交接口 ,包括保存单据分录 |
||||
* @param processDefinitionKey 流程标识 |
||||
* @param m 单据实体 |
||||
* @param crDto 关联关系 |
||||
* @return |
||||
*/ |
||||
public ResponseResult<?> submitBill(String processDefinitionKey,M m, @MyRequestBody List<ConvertRelationDto> crDto){ |
||||
billservice().submitBill(processDefinitionKey,m,crDto); |
||||
return ResponseResult.success("提交成功"); |
||||
} |
||||
|
||||
/** |
||||
* 单据提交接口 |
||||
* @param processDefinitionKey 流程标识 |
||||
* @param id 单据id |
||||
* @return |
||||
*/ |
||||
public ResponseResult<?> submitBillKey(String processDefinitionKey,Long id){ |
||||
billservice().submitBillKey(processDefinitionKey,id); |
||||
return ResponseResult.success("提交成功"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 单据详情 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
public ResponseResult<V> detailBill(Long id){ |
||||
M m = billservice().detailBill((K) id); |
||||
if (ObjectUtils.isNotEmpty(m)){ |
||||
//获取vo实体
|
||||
V v = this.convertToVo(m, null); |
||||
return ResponseResult.success(v); |
||||
} |
||||
return (ResponseResult<V>) ResponseResult.success("未查到相应数据,id为"+id); |
||||
} |
||||
|
||||
/** |
||||
* 删除单据,包括分录数据关联删除 |
||||
* @param ids id逗号隔开 |
||||
* @return |
||||
*/ |
||||
public ResponseResult<?> removeBillById(String ids){ |
||||
billservice().removeBillById(ids); |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
} |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
|
||||
import apelet.common.botp.model.ConvertFieldmappingEntry; |
||||
import apelet.common.botp.service.IConvertFieldmappingEntryService; |
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/botp/ConvertFieldmappingEntry") |
||||
public class ConvertFieldmappingEntryController { |
||||
@Autowired |
||||
private IConvertFieldmappingEntryService IConvertFieldmappingEntryService; |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* */ |
||||
@PostMapping(value = "/list") |
||||
public ResponseResult<?> list(@MyRequestBody ConvertFieldmappingEntry convertFieldmappingEntry, |
||||
@MyRequestBody MyOrderParam orderParam, |
||||
@MyRequestBody MyPageParam pageParam) { |
||||
if (pageParam != null) { |
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||
} |
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, ConvertFieldmappingEntry.class); |
||||
List<ConvertFieldmappingEntry> list = |
||||
IConvertFieldmappingEntryService.getConvertFieldmappingEntryListWithRelation(convertFieldmappingEntry,orderBy); |
||||
long totalCount = 0L; |
||||
if (list instanceof Page) { |
||||
totalCount = ((Page<ConvertFieldmappingEntry>) list).getTotal(); |
||||
} |
||||
MyPageData<ConvertFieldmappingEntry> result = MyPageUtil.makeResponseData(list, totalCount); |
||||
//正常的返回
|
||||
return ResponseResult.success(result); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
import apelet.common.botp.model.ConvertPluginEntry; |
||||
import apelet.common.botp.service.IConvertPluginEntryService; |
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/botp/ConvertPluginEntry") |
||||
public class ConvertPluginEntryController { |
||||
@Autowired |
||||
private IConvertPluginEntryService IConvertPluginEntryService; |
||||
|
||||
|
||||
/** |
||||
* 分页查询 |
||||
* */ |
||||
@PostMapping(value = "/list") |
||||
@Schema(description = "list") |
||||
public ResponseResult<?> list(@MyRequestBody ConvertPluginEntry convertPluginEntry, |
||||
@MyRequestBody MyOrderParam orderParam, |
||||
@MyRequestBody MyPageParam pageParam) { |
||||
if (pageParam != null) { |
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||
} |
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, ConvertPluginEntry.class); |
||||
List<ConvertPluginEntry> list = |
||||
IConvertPluginEntryService.getConvertPluginEntryListWithRelation(convertPluginEntry,orderBy); |
||||
long totalCount = 0L; |
||||
if (list instanceof Page) { |
||||
totalCount = ((Page<ConvertPluginEntry>) list).getTotal(); |
||||
} |
||||
MyPageData<ConvertPluginEntry> result = MyPageUtil.makeResponseData(list, totalCount); |
||||
//正常的返回
|
||||
return ResponseResult.success(result); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,155 @@
@@ -0,0 +1,155 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
import apelet.common.botp.model.ConvertRelation; |
||||
import apelet.common.botp.service.IConvertRelationService; |
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.constant.ErrorCodeEnum; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/botp/ConvertRelation") |
||||
public class ConvertRelationController { |
||||
@Autowired |
||||
private IConvertRelationService IConvertRelationService; |
||||
|
||||
@RequestMapping("/transform") |
||||
public ResponseResult<?> transform(JSONObject transformJson) { |
||||
List<String> qq = new ArrayList<>(); |
||||
//转换规则Id
|
||||
String botpId = transformJson.getString("botpId"); |
||||
|
||||
//源单据标识
|
||||
String srcBill = transformJson.getString("srcBill"); |
||||
|
||||
//目标单据标识
|
||||
String destBill = transformJson.getString("destBill"); |
||||
|
||||
//源单据ID
|
||||
String srcBillId = transformJson.getString("srcBillId"); |
||||
|
||||
List<ConvertRelation> transformList = IConvertRelationService.transform(botpId, srcBill, destBill, srcBillId); |
||||
return ResponseResult.success(transformList); |
||||
|
||||
} |
||||
|
||||
|
||||
@RequestMapping("/transformT") |
||||
public ResponseResult<?> transformT(JSONObject transformJson) { |
||||
List<String> qq = new ArrayList<>(); |
||||
//转换规则Id
|
||||
String botpId = transformJson.getString("botpId"); |
||||
|
||||
//源单据标识
|
||||
String srcBill = transformJson.getString("srcBill"); |
||||
|
||||
//目标单据标识
|
||||
String destBill = transformJson.getString("destBill"); |
||||
|
||||
//源单据ID
|
||||
JSONArray srcBillArray = transformJson.getJSONArray("srcBillList"); |
||||
List<String> srcBilList = JSONObject.parseArray(srcBillArray.toJSONString(), String.class); |
||||
List<ConvertRelation> transformList = IConvertRelationService.transformT(botpId, srcBill, destBill, srcBilList); |
||||
return ResponseResult.success(transformList); |
||||
|
||||
} |
||||
|
||||
@RequestMapping("/getConvertRelation") |
||||
public ResponseResult<?> getConvertRelation(String billId, String billType, String traceType) { |
||||
List<Map<String, Object>> convertRelation = IConvertRelationService.getConvertRelation(billId, billType, traceType); |
||||
return ResponseResult.success(convertRelation); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 分页查询 |
||||
*/ |
||||
@PostMapping(value = "/list") |
||||
@Schema(description = "list") |
||||
public ResponseResult<?> list(@MyRequestBody ConvertRelation convertRelation, |
||||
@MyRequestBody MyOrderParam orderParam, |
||||
@MyRequestBody MyPageParam pageParam) { |
||||
if (pageParam != null) { |
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||
} |
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, ConvertRelation.class); |
||||
List<ConvertRelation> list = |
||||
IConvertRelationService.getConvertRuleListWithRelation(convertRelation, orderBy); |
||||
long totalCount = 0L; |
||||
if (list instanceof Page) { |
||||
totalCount = ((Page<ConvertRelation>) list).getTotal(); |
||||
} |
||||
MyPageData<ConvertRelation> result = MyPageUtil.makeResponseData(list, totalCount); |
||||
//正常的返回
|
||||
return ResponseResult.success(result); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增 |
||||
* |
||||
* @param convertRelation 查询参数 |
||||
*/ |
||||
@PostMapping(value = "/add") |
||||
@Schema(description = "新增") |
||||
public ResponseResult<?> add(@MyRequestBody ConvertRelation convertRelation) { |
||||
if (IConvertRelationService.addAll(convertRelation)) { |
||||
return ResponseResult.success("新增成功"); |
||||
} else { |
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 有分录修改 |
||||
* |
||||
* @param convertRelation 查询参数 |
||||
*/ |
||||
@PostMapping(value = "/edit") |
||||
@Schema(description = "修改") |
||||
public ResponseResult<?> edit(@MyRequestBody ConvertRelation convertRelation) { |
||||
if (IConvertRelationService.editAll(convertRelation)) { |
||||
return ResponseResult.success("修改成功"); |
||||
} else { |
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 有分录删除所有数据 |
||||
* |
||||
* @param id |
||||
*/ |
||||
@GetMapping(value = "/removeById") |
||||
@Schema(description = "删除所有数据") |
||||
public ResponseResult<?> removeById(@RequestParam Long id) { |
||||
IConvertRelationService.removeAllById(id); |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
|
||||
@GetMapping(value = "/removeMulti") |
||||
@Schema(description = "删除所有数据") |
||||
public ResponseResult<?> removeById(@RequestParam String ids) { |
||||
for (String id : ids.split(",")) { |
||||
IConvertRelationService.removeAllById(Long.valueOf(id)); |
||||
} |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
import apelet.common.botp.model.ConvertRelationEntry; |
||||
import apelet.common.botp.service.impl.ConvertRelationEntryServiceImpl; |
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.constant.ErrorCodeEnum; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/botp/ConvertRelationEntry") |
||||
public class ConvertRelationEntryController { |
||||
@Autowired |
||||
private ConvertRelationEntryServiceImpl ConvertRelationEntryServiceImpl; |
||||
|
||||
|
||||
/** |
||||
* 分页查询 |
||||
* */ |
||||
@PostMapping(value = "/list") |
||||
@Schema(description = "list") |
||||
public ResponseResult<?> list(@MyRequestBody ConvertRelationEntry convertRelationEntry, |
||||
@MyRequestBody MyOrderParam orderParam, |
||||
@MyRequestBody MyPageParam pageParam) { |
||||
if (pageParam != null) { |
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||
} |
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, ConvertRelationEntry.class); |
||||
List<ConvertRelationEntry> list = |
||||
ConvertRelationEntryServiceImpl.getConvertRuleListWithRelation(convertRelationEntry,orderBy); |
||||
long totalCount = 0L; |
||||
if (list instanceof Page) { |
||||
totalCount = ((Page<ConvertRelationEntry>) list).getTotal(); |
||||
} |
||||
MyPageData<ConvertRelationEntry> result = MyPageUtil.makeResponseData(list, totalCount); |
||||
//正常的返回
|
||||
return ResponseResult.success(result); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增 |
||||
* @param convertRelationEntry 查询参数 |
||||
*/ |
||||
@PostMapping(value = "/add") |
||||
@Schema(description = "新增") |
||||
public ResponseResult<?> add(@MyRequestBody ConvertRelationEntry convertRelationEntry){ |
||||
if (ConvertRelationEntryServiceImpl.addAll(convertRelationEntry)){ |
||||
return ResponseResult.success("新增成功"); |
||||
}else { |
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); |
||||
} |
||||
} |
||||
/** |
||||
* 有分录修改 |
||||
* @param convertRelationEntry 查询参数 |
||||
*/ |
||||
@PostMapping(value = "/edit") |
||||
@Schema(description = "修改") |
||||
public ResponseResult<?> edit(@MyRequestBody ConvertRelationEntry convertRelationEntry){ |
||||
if (ConvertRelationEntryServiceImpl.editAll(convertRelationEntry)){ |
||||
return ResponseResult.success("修改成功"); |
||||
}else { |
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); |
||||
} |
||||
} |
||||
/** |
||||
* 有分录删除所有数据 |
||||
* @param id |
||||
*/ |
||||
@GetMapping(value = "/removeById") |
||||
@Schema(description = "删除所有数据") |
||||
public ResponseResult<?> removeById(@RequestParam Long id){ |
||||
ConvertRelationEntryServiceImpl.removeAllById(id); |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
@GetMapping(value = "/removeMulti") |
||||
@Schema(description = "删除所有数据") |
||||
public ResponseResult<?> removeById(@RequestParam String ids){ |
||||
for (String id : ids.split(",")) { |
||||
ConvertRelationEntryServiceImpl.removeAllById(Long.valueOf(id)); |
||||
} |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,192 @@
@@ -0,0 +1,192 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
import apelet.common.botp.dto.ConvertRelationDelDto; |
||||
import apelet.common.botp.dto.ConvertRelationListDto; |
||||
import apelet.common.botp.dto.TransfromDto; |
||||
import apelet.common.botp.model.AllField; |
||||
import apelet.common.botp.model.ConvertRule; |
||||
import apelet.common.botp.service.IConvertRuleService; |
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.constant.ErrorCodeEnum; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import apelet.common.generator.model.OnlFormHead; |
||||
import apelet.common.generator.vo.OnlFormHeadVo; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/botp/ConvertRule") |
||||
public class ConvertRuleController { |
||||
|
||||
@Autowired |
||||
private IConvertRuleService convertRuleService; |
||||
|
||||
|
||||
@RequestMapping("/allField") |
||||
//查询单据的所有字段
|
||||
public List<AllField> allField(String tableName) { |
||||
List<AllField> allFieldList = convertRuleService.allField(tableName); |
||||
return allFieldList; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 分页查询 |
||||
* */ |
||||
@PostMapping(value = "/list") |
||||
@Schema(description = "list") |
||||
public ResponseResult<?> list(@MyRequestBody ConvertRule convertRule, |
||||
@MyRequestBody MyOrderParam orderParam, |
||||
@MyRequestBody MyPageParam pageParam) { |
||||
if (pageParam != null) { |
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||
} |
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, ConvertRule.class); |
||||
List<ConvertRule> list = |
||||
convertRuleService.getConvertRuleListWithRelation(convertRule,orderBy); |
||||
long totalCount = 0L; |
||||
if (list instanceof Page) { |
||||
totalCount = ((Page<ConvertRule>) list).getTotal(); |
||||
} |
||||
MyPageData<ConvertRule> result = MyPageUtil.makeResponseData(list, totalCount); |
||||
//正常的返回
|
||||
return ResponseResult.success(result); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 新增 |
||||
* @param convertRule 查询参数 |
||||
*/ |
||||
@PostMapping(value = "/add") |
||||
@Schema(description = "新增") |
||||
public ResponseResult<?> add(@MyRequestBody ConvertRule convertRule){ |
||||
if (convertRuleService.addAll(convertRule)){ |
||||
return ResponseResult.success("新增成功"); |
||||
}else { |
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); |
||||
} |
||||
} |
||||
/** |
||||
* 有分录修改 |
||||
* @param convertRule 查询参数 |
||||
*/ |
||||
@PostMapping(value = "/edit") |
||||
@Schema(description = "修改") |
||||
public ResponseResult<?> edit(@MyRequestBody ConvertRule convertRule){ |
||||
if (convertRuleService.editAll(convertRule)){ |
||||
return ResponseResult.success("修改成功"); |
||||
}else { |
||||
return ResponseResult.error(ErrorCodeEnum.INVALID_DATA_MODEL); |
||||
} |
||||
} |
||||
/** |
||||
* 有分录删除所有数据 |
||||
* @param id |
||||
*/ |
||||
@GetMapping(value = "/removeById") |
||||
@Schema(description = "删除所有数据") |
||||
public ResponseResult<?> removeById(@RequestParam Long id){ |
||||
convertRuleService.removeAllById(id); |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
@GetMapping(value = "/removeMulti") |
||||
@Schema(description = "删除所有数据") |
||||
public ResponseResult<?> removeById(@RequestParam String ids){ |
||||
for (String id : ids.split(",")) { |
||||
convertRuleService.removeAllById(Long.valueOf(id)); |
||||
} |
||||
return ResponseResult.success("删除成功"); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 删除关联关系 |
||||
* |
||||
* @param dto 转换规则id |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/removeAllRelation") |
||||
@Schema(description = "删除单据所有关联关系") |
||||
public ResponseResult<?> removeAllRelation(@RequestBody ConvertRelationDelDto dto) { |
||||
convertRuleService.removeAllRelation(dto); |
||||
return ResponseResult.success("删除成功!"); |
||||
} |
||||
|
||||
/** |
||||
* 根据目标单据查询关联关系 |
||||
* |
||||
* @param dto 单id |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/selectAllRelationByTarget") |
||||
@Schema(description = "根据目标单据查询关联关系") |
||||
public ResponseResult<?> selectAllRelationByTarget(@RequestBody ConvertRelationListDto dto) { |
||||
return ResponseResult.success(convertRuleService.selectAllRelationByTarget(dto)); |
||||
} |
||||
|
||||
//模版循环查询分录
|
||||
@GetMapping(value = "/getConvertPluginEntry") |
||||
@Schema(description = "查询分录插件") |
||||
public ResponseResult<?> getChild1(@RequestParam Long id){ |
||||
return ResponseResult.success(convertRuleService.getConvertPluginEntry(id)); |
||||
} |
||||
|
||||
|
||||
@GetMapping(value = "/getConvertFieldmappingEntry") |
||||
@Schema(description = "转换规则字段映射") |
||||
public ResponseResult<?> getChild2(@RequestParam Long id){ |
||||
return ResponseResult.success(convertRuleService.getConvertFieldmappingEntry(id)); |
||||
} |
||||
|
||||
/** |
||||
* 根据源单据查询关联关系 |
||||
* |
||||
* @param dto 单id |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/selectAllRelationBySource") |
||||
@Schema(description = "根据源单据查询关联关系") |
||||
public ResponseResult<?> selectAllRelationBySource(@RequestBody ConvertRelationListDto dto) { |
||||
return ResponseResult.success(convertRuleService.selectAllRelationBySource(dto)); |
||||
} |
||||
/** |
||||
* 下推规则查询 |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
@PostMapping(value = "/getPushBillList") |
||||
@Schema(description = "下推规则查询") |
||||
public ResponseResult<?> getPushBillList(@RequestBody ConvertRelationDelDto dto) { |
||||
return ResponseResult.success(convertRuleService.getPushBillList(dto)); |
||||
} |
||||
|
||||
|
||||
@PostMapping(value = "/transform") |
||||
@Schema(description = "单据转换") |
||||
public ResponseResult<?> transform(@RequestBody TransfromDto dto) { |
||||
|
||||
return ResponseResult.success(convertRuleService.transform(dto.getBotpId() |
||||
,dto.getSrcBill(),dto.getDestBill(),dto.getSrcBillId())); |
||||
} |
||||
|
||||
|
||||
|
||||
@GetMapping(value = "/getRuleTableFiled") |
||||
public ResponseResult<?> getRuleTableFiled (@RequestBody String tableName) { |
||||
|
||||
|
||||
return ResponseResult.success( convertRuleService.getRuleTableFiled(tableName)); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
package apelet.common.botp.controller; |
||||
|
||||
import apelet.common.botp.service.ISysMenuqqService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/botp/SysMenuqq") |
||||
public class SysMenuqqController { |
||||
@Autowired |
||||
private ISysMenuqqService ISysMenuqqService; |
||||
} |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
|
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/28 8:37 |
||||
*/ |
||||
public interface BillBaseDaoMapper<M> extends BaseDaoMapper<M> { |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
|
||||
import apelet.common.botp.model.ConvertFieldmappingEntry; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
|
||||
/** |
||||
* |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
* 转换规则字段映射 |
||||
* xykj_fieldmapping |
||||
*/ |
||||
public interface ConvertFieldmappingEntryMapper extends BaseDaoMapper<ConvertFieldmappingEntry> { |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
|
||||
import apelet.common.botp.model.ConvertPluginEntry; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
|
||||
/** |
||||
* |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
* 分录插件 |
||||
* xykj_entry_plugin |
||||
*/ |
||||
public interface ConvertPluginEntryMapper extends BaseDaoMapper<ConvertPluginEntry> { |
||||
} |
||||
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
|
||||
import apelet.common.botp.model.ConvertRelationEntry; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
|
||||
/** |
||||
* |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
* 单据分录关联关系 |
||||
* xykj_document_entry |
||||
*/ |
||||
public interface ConvertRelationEntryMapper extends BaseDaoMapper<ConvertRelationEntry> { |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
|
||||
import apelet.common.botp.model.ConvertRelation; |
||||
import apelet.common.botp.model.GetSearchList; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
* 单据关联关系 |
||||
* xykj_related_relationships |
||||
*/ |
||||
public interface ConvertRelationMapper extends BaseDaoMapper<ConvertRelation> { |
||||
|
||||
public List<ConvertRelation> transform(String botpId, String srcBill, String destBill, String srcBillId); |
||||
|
||||
public List<ConvertRelation> transformT(String botpId, String srcBill, String destBill, List<String> srcBillList); |
||||
|
||||
//根据联查单据id、单据标识、上查 ,根据单据关联关系表查询关联查询的单据
|
||||
public List<GetSearchList> getConvertRelationOn(@Param("billId")String billId,@Param("billType")String billType); |
||||
|
||||
//根据联查单据id、单据标识、下查 ,根据单据关联关系表查询关联查询的单据
|
||||
public List<GetSearchList> getConvertRelationDown(@Param("billId")String billId,@Param("billType")String billType); |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
import apelet.common.botp.model.AllField; |
||||
import apelet.common.botp.model.ConvertRule; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
* 转换规则存值主表 |
||||
* xykj_ConvertRule |
||||
*/ |
||||
public interface ConvertRuleMapper extends BaseDaoMapper<ConvertRule> { |
||||
//查询返回源单和目标单全部字段
|
||||
public List<AllField> allField(String tableName); |
||||
|
||||
|
||||
} |
||||
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
||||
package apelet.common.generator.dao; |
||||
package apelet.common.botp.dao; |
||||
|
||||
import apelet.common.generator.model.ReverseWritingBusiness; |
||||
|
||||
import apelet.common.botp.model.ReverseWritingBusiness; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
public interface ReverseWritingBusinessMapper extends BaseMapper<ReverseWritingBusiness> { |
||||
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
package apelet.common.generator.dao; |
||||
package apelet.common.botp.dao; |
||||
|
||||
import apelet.common.generator.model.ReverseWritingFormula; |
||||
import apelet.common.botp.model.ReverseWritingFormula; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
public interface ReverseWritingFormulaMapper extends BaseMapper<ReverseWritingFormula> { |
||||
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
package apelet.common.generator.dao; |
||||
package apelet.common.botp.dao; |
||||
|
||||
import apelet.common.generator.model.ReverseWritingRules; |
||||
import apelet.common.botp.model.ReverseWritingRules; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
||||
import java.util.List; |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
package apelet.common.botp.dao; |
||||
|
||||
import apelet.common.botp.model.SysMenuqq; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
|
||||
public interface SysMenuqqMapper extends BaseDaoMapper<SysMenuqq> { |
||||
} |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.botp.dao.ConvertFieldmappingEntryMapper"> |
||||
|
||||
|
||||
|
||||
</mapper> |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.botp.dao.ConvertPluginEntryMapper"> |
||||
|
||||
|
||||
|
||||
</mapper> |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.botp.dao.ConvertRelationEntryMapper"> |
||||
|
||||
|
||||
|
||||
</mapper> |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.botp.dao.ConvertRelationMapper"> |
||||
<select id="transform" parameterType="java.lang.String" resultType="apelet.common.botp.model.ConvertRelation"> |
||||
SELECT * |
||||
FROM convert_relation |
||||
WHERE |
||||
convert_rule_id = #{botpId} and source_number = #{srcBill} and target_number = #{destBill} and source_id = #{srcBillId} |
||||
</select> |
||||
|
||||
<select id="transformT" parameterType="java.lang.String" resultType="apelet.common.botp.model.ConvertRelation"> |
||||
SELECT * |
||||
FROM convert_relation |
||||
WHERE |
||||
convert_rule_id = #{botpId} and source_number = #{srcBill} and target_number = #{destBill} and source_id in #{srcBillList} |
||||
</select> |
||||
<select id="getConvertRelationOn" resultType="apelet.common.botp.model.GetSearchList"> |
||||
select DISTINCT t2.up_interface_type,t2.up_list_interface,t2.id,t2.up_route_interface from convert_relation t1 |
||||
inner join convert_rule t2 on t1.convert_rule_id = t2.id |
||||
inner join onl_form_head t3 on t1.target_number = t3.id |
||||
where t3.table_name=#{billType} and t1.target_id=#{billId}; |
||||
</select> |
||||
<select id="getConvertRelationDown" resultType="apelet.common.botp.model.GetSearchList"> |
||||
select DISTINCT t2.down_interface_type,t2.down_list_interface,t2.id,t2.down_route_interface from convert_relation t1 |
||||
inner join convert_rule t2 on t1.convert_rule_id = t2.id |
||||
inner join onl_form_head t3 on t1.source_number = t3.id |
||||
where t3.table_name=#{billType} and t1.source_id=#{billId}; |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.botp.dao.ConvertRuleMapper"> |
||||
|
||||
<select id="allField" parameterType="java.lang.String" resultType="apelet.common.botp.model.AllField"> |
||||
select id,head_id,field_name,field_remark |
||||
from onl_form_field |
||||
where head_id= |
||||
(select id from onl_form_head where id=#{tableName}) |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
||||
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.generator.dao.ReverseWritingBusinessMapper"> |
||||
<mapper namespace="apelet.common.botp.dao.ReverseWritingBusinessMapper"> |
||||
|
||||
</mapper> |
||||
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.generator.dao.ReverseWritingFormulaMapper"> |
||||
<mapper namespace="apelet.common.botp.dao.ReverseWritingFormulaMapper"> |
||||
|
||||
</mapper> |
||||
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.generator.dao.ReverseWritingRulesMapper"> |
||||
<mapper namespace="apelet.common.botp.dao.ReverseWritingRulesMapper"> |
||||
|
||||
<select id="getTableType" resultType="java.util.Map"> |
||||
SELECT cr.source_entity_id id ,fh.table_name name , fh.tableTxt |
||||
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="apelet.common.botp.dao.SysMenuqqMapper"> |
||||
|
||||
|
||||
|
||||
</mapper> |
||||
@ -0,0 +1,139 @@
@@ -0,0 +1,139 @@
|
||||
package apelet.common.botp.db.object; |
||||
|
||||
import apelet.common.botp.db.util.DbUtil; |
||||
import apelet.common.online.model.constant.FieldFilterType; |
||||
import cn.hutool.core.collection.CollUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import lombok.Data; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/23 14:01 |
||||
*/ |
||||
@Data |
||||
public class DataFilter { |
||||
|
||||
/** |
||||
* 表名 |
||||
*/ |
||||
private String tableName; |
||||
|
||||
/** |
||||
* 数据集合 |
||||
*/ |
||||
private List<DataFilterItem> dataFilterItems = new ArrayList<>(); |
||||
|
||||
|
||||
/** |
||||
* 构建查询条件sql |
||||
* @param paramList |
||||
* @return |
||||
*/ |
||||
public String getWhereClause(List<Object> paramList){ |
||||
StringBuilder where = new StringBuilder(); |
||||
if(dataFilterItems.size() == 0){ |
||||
return ""; |
||||
} |
||||
List<String> normalizedFilters = new LinkedList<>(); |
||||
for (DataFilterItem dataFilterItem:dataFilterItems){ |
||||
|
||||
String filterString = this.makeSubWhereClause(dataFilterItem,this, paramList); |
||||
if (StrUtil.isNotBlank(filterString)) { |
||||
normalizedFilters.add(filterString); |
||||
} |
||||
|
||||
} |
||||
if (CollUtil.isNotEmpty(normalizedFilters)) { |
||||
where.append(DbUtil.WHERE); |
||||
where.append(CollUtil.join(normalizedFilters, DbUtil.AND)); |
||||
} |
||||
|
||||
return where.toString(); |
||||
|
||||
} |
||||
|
||||
private String makeSubWhereClause(DataFilterItem filterItem,DataFilter filter, List<Object> paramList) { |
||||
StringBuilder where = new StringBuilder(256); |
||||
if (filterItem.getFilterType().equals(FieldFilterType.EQUAL_FILTER)) { |
||||
where.append(this.makeWhereLeftOperator(filterItem,filter)); |
||||
where.append(" = ? "); |
||||
paramList.add(filterItem.getParamValue()); |
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.RANGE_FILTER)) { |
||||
where.append(this.makeRangeFilterClause(filterItem, paramList)); |
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.LIKE_FILTER)) { |
||||
where.append(this.makeWhereLeftOperator(filterItem,filter)); |
||||
where.append(" LIKE ? "); |
||||
paramList.add(filterItem.getParamValue()); |
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.IN_LIST_FILTER)) { |
||||
// where.append(this.makeWhereLeftOperator(filterItem));
|
||||
// where.append(" IN ( ");
|
||||
// where.append(StrUtil.repeat("?,", filterItem.getColumnValueList().size()));
|
||||
// where.setLength(where.length() - 1);
|
||||
// where.append(")");
|
||||
// paramList.addAll(filterItem.getColumnValueList());
|
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.MULTI_LIKE)) { |
||||
// where.append("(");
|
||||
// StringBuilder sb = new StringBuilder(128);
|
||||
// sb.append(this.makeWhereLeftOperator(filterItem)).append(" LIKE ? OR ");
|
||||
// String s = StrUtil.repeat(sb.toString(), filterItem.getColumnValueList().size());
|
||||
// where.append(s, 0, s.length() - 4);
|
||||
// where.append(")");
|
||||
// paramList.addAll(filterItem.getColumnValueList());
|
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.NOT_IN_LIST_FILTER)) { |
||||
// where.append(this.makeWhereLeftOperator(filterItem));
|
||||
// where.append(" NOT IN (");
|
||||
// where.append(StrUtil.repeat("?,", filterItem.getColumnValueList().size()));
|
||||
// where.setLength(where.length() - 1);
|
||||
// where.append(")");
|
||||
// paramList.addAll(filterItem.getColumnValueList());
|
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.IS_NULL)) { |
||||
where.append(this.makeWhereLeftOperator(filterItem,filter)); |
||||
where.append(" IS NULL "); |
||||
} else if (filterItem.getFilterType().equals(FieldFilterType.IS_NOT_NULL)) { |
||||
where.append(this.makeWhereLeftOperator(filterItem,filter)); |
||||
where.append(" IS NOT NULL "); |
||||
} |
||||
return where.toString(); |
||||
} |
||||
|
||||
private String makeWhereLeftOperator(DataFilterItem filterItem,DataFilter filter) { |
||||
if (StrUtil.isBlank(filter.getTableName())) { |
||||
return filterItem.getParamName(); |
||||
} |
||||
StringBuilder sb = new StringBuilder(128); |
||||
sb.append(filter.getTableName()).append(".").append(filterItem.getParamName()); |
||||
return sb.toString(); |
||||
} |
||||
|
||||
private String makeRangeFilterClause(DataFilterItem filterItem, List<Object> paramList) { |
||||
StringBuilder where = new StringBuilder(256); |
||||
// if (ObjectUtil.isNotEmpty(filter.getColumnValueStart())) {
|
||||
// where.append(this.makeWhereLeftOperator(filter));
|
||||
// if (BooleanUtil.isTrue(filter.getIsOracleDate())) {
|
||||
// where.append(" >= ").append(filter.getColumnValueStart());
|
||||
// } else {
|
||||
// where.append(" >= ? ");
|
||||
// paramList.add(filter.getColumnValueStart());
|
||||
// }
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(filter.getColumnValueEnd())) {
|
||||
// if (ObjectUtil.isNotEmpty(filter.getColumnValueStart())) {
|
||||
// where.append(DbUtil.AND);
|
||||
// }
|
||||
// where.append(this.makeWhereLeftOperator(filter));
|
||||
// if (BooleanUtil.isTrue(filter.getIsOracleDate())) {
|
||||
// where.append(" <= ").append(filter.getColumnValueEnd());
|
||||
// } else {
|
||||
// where.append(" <= ? ");
|
||||
// paramList.add(filter.getColumnValueEnd());
|
||||
// }
|
||||
// }
|
||||
return where.toString(); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
package apelet.common.botp.db.object; |
||||
|
||||
import apelet.common.online.model.constant.FieldFilterType; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/23 13:53 |
||||
*/ |
||||
@Data |
||||
public class DataFilterItem { |
||||
|
||||
private String paramName; |
||||
|
||||
private String paramValue; |
||||
|
||||
private Integer filterType = FieldFilterType.EQUAL_FILTER; |
||||
|
||||
public DataFilterItem(String paramName,Integer filterType,String paramValue){ |
||||
|
||||
this.paramName = paramName; |
||||
this.paramValue = paramValue; |
||||
this.filterType = filterType; |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
package apelet.common.botp.db.object; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.LinkedList; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 17:07 |
||||
*/ |
||||
@Data |
||||
public class InsertData { |
||||
|
||||
private String columnNames; |
||||
private LinkedList<Object> dataList = new LinkedList(); |
||||
|
||||
} |
||||
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
package apelet.common.botp.db.object; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 17:58 |
||||
*/ |
||||
@Data |
||||
public class ObjectSqlData { |
||||
|
||||
private String sql; |
||||
private List<Object> dataList; |
||||
|
||||
} |
||||
@ -0,0 +1,185 @@
@@ -0,0 +1,185 @@
|
||||
package apelet.common.botp.db.util; |
||||
|
||||
import apelet.common.botp.db.object.ObjectSqlData; |
||||
import apelet.common.dbutil.constant.DblinkType; |
||||
import apelet.common.dbutil.provider.DataSourceProvider; |
||||
import apelet.common.online.exception.OnlineRuntimeException; |
||||
import apelet.common.online.util.OnlineDataSourceUtil; |
||||
import cn.hutool.core.map.MapUtil; |
||||
import com.alibaba.druid.pool.DruidDataSource; |
||||
import com.alibaba.druid.pool.DruidDataSourceFactory; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.cloud.context.config.annotation.RefreshScope; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import javax.sql.DataSource; |
||||
import java.sql.Connection; |
||||
import java.util.*; |
||||
import java.util.concurrent.locks.Lock; |
||||
import java.util.concurrent.locks.ReentrantLock; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/23 17:00 |
||||
*/ |
||||
@Component |
||||
@Slf4j |
||||
@RefreshScope |
||||
public class DbUtil { |
||||
|
||||
public static final String SELECT = "SELECT "; |
||||
public static final String FROM = " FROM "; |
||||
public static final String WHERE = " WHERE "; |
||||
public static final String AND = " AND "; |
||||
|
||||
private final Map<String, DataSource> datasourceMap = MapUtil.newHashMap(); |
||||
|
||||
@Value("${spring.datasource.druid.driverClassName}") |
||||
private String driverClassName; //驱动
|
||||
@Value("${spring.datasource.druid.tenant-admin.url}") |
||||
private String url; //链接
|
||||
@Value("${spring.datasource.druid.tenant-admin.username}") |
||||
private String username; //用户名
|
||||
@Value("${spring.datasource.druid.tenant-admin.password}") |
||||
private String password; //密码i
|
||||
@Value("${spring.datasource.druid.initialSize}") |
||||
private int initialSize; //密码
|
||||
@Value("${spring.datasource.druid.minIdle}") |
||||
private int minPoolSize;//连接池最小连接数。
|
||||
@Value("${spring.datasource.druid.maxActive}") |
||||
private int maxPoolSize;//连接池最大连接数。
|
||||
@Value("${spring.datasource.druid.name}") |
||||
private String name;//连接池最大连接数。
|
||||
|
||||
@Autowired |
||||
private OnlineDataSourceUtil dataSourceUtil; |
||||
|
||||
private final Lock lock = new ReentrantLock(); |
||||
|
||||
|
||||
public DataSourceProvider getDataSourceProvider(){ |
||||
return dataSourceUtil.getProvider(this.getDbType()); |
||||
} |
||||
|
||||
|
||||
public void addNew(ObjectSqlData objectSqlData)throws Exception { |
||||
List<ObjectSqlData> objectSqlDataList = new ArrayList<>(); |
||||
objectSqlDataList.add(objectSqlData); |
||||
doHandle(objectSqlDataList); |
||||
} |
||||
public void addNewBatch(List<ObjectSqlData> objectSqlDataList)throws Exception { |
||||
doHandle(objectSqlDataList); |
||||
} |
||||
|
||||
private void doHandle(List<ObjectSqlData> objectSqlDataList) throws Exception { |
||||
Connection conn = null; |
||||
try { |
||||
conn = getDataSource().getConnection(); |
||||
conn.setAutoCommit(false); |
||||
for (ObjectSqlData s : objectSqlDataList) { |
||||
List<Object> paramList = s.getDataList(); |
||||
dataSourceUtil.execute(conn, s.getSql(), paramList); |
||||
} |
||||
conn.commit(); |
||||
} catch (Exception e) { |
||||
if (conn != null) { |
||||
conn.rollback(); |
||||
} |
||||
log.error(e.getMessage(), e); |
||||
throw new OnlineRuntimeException(e.getMessage()); |
||||
} finally { |
||||
if (conn != null) { |
||||
conn.close(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询数据 |
||||
* @param query sql |
||||
* @param paramList 参数列表 |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
public List<Map<String, Object>> query(String query, List<Object> paramList) throws Exception { |
||||
DataSource dataSource = this.getDataSource(); |
||||
return dataSourceUtil.query(dataSource,query,paramList); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据对象获取关联的数据源。如果不存在会创建该数据库连接池的数据源, |
||||
* 并保存到Map中缓存,下次调用时可直接返回。 |
||||
* |
||||
* |
||||
* @return 关联的数据库连接池的数据源。 |
||||
*/ |
||||
public DataSource getDataSource() throws Exception { |
||||
DataSource dataSource = datasourceMap.get(name); |
||||
if (dataSource != null) { |
||||
return dataSource; |
||||
} |
||||
DataSourceProvider provider = dataSourceUtil.getProvider(getDbType()); |
||||
if (provider == null) { |
||||
throw new Exception("数据库类型错误"); |
||||
} |
||||
DruidDataSource druidDataSource = null; |
||||
lock.lock(); |
||||
try { |
||||
dataSource = datasourceMap.get(name); |
||||
if (dataSource != null) { |
||||
return dataSource; |
||||
} |
||||
Properties properties = new Properties(); |
||||
druidDataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties); |
||||
druidDataSource.setUrl(url); |
||||
druidDataSource.setDriverClassName(driverClassName); |
||||
druidDataSource.setValidationQuery("SELECT 'x'"); |
||||
druidDataSource.setUsername(username); |
||||
druidDataSource.setPassword(password); |
||||
druidDataSource.setInitialSize(initialSize); |
||||
druidDataSource.setMinIdle(minPoolSize); |
||||
druidDataSource.setMaxActive(maxPoolSize); |
||||
druidDataSource.setConnectionErrorRetryAttempts(2); |
||||
druidDataSource.setTimeBetweenConnectErrorMillis(500); |
||||
druidDataSource.setBreakAfterAcquireFailure(true); |
||||
druidDataSource.init(); |
||||
datasourceMap.put(name, druidDataSource); |
||||
return druidDataSource; |
||||
} catch (Exception e) { |
||||
if (druidDataSource != null) { |
||||
druidDataSource.close(); |
||||
} |
||||
log.error("Failed to create DruidDatasource", e); |
||||
throw e; |
||||
} finally { |
||||
lock.unlock(); |
||||
} |
||||
} |
||||
|
||||
|
||||
public int getDbType(){ |
||||
if(driverClassName.contains("mysql")){ |
||||
return DblinkType.MYSQL; |
||||
} |
||||
return 0; |
||||
|
||||
} |
||||
|
||||
|
||||
public int execute(String sql, List<Object> paramList) { |
||||
try { |
||||
Connection connection = getDataSource().getConnection(); |
||||
return dataSourceUtil.execute(connection, sql, paramList); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import apelet.common.core.validator.UpdateGroup; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 删除单据关联关系dto |
||||
*/ |
||||
@Schema(description = "单据关联关系dto") |
||||
@Data |
||||
public class ConvertRelationDelDto { |
||||
/** |
||||
* 转换规则id/单据id。 |
||||
*/ |
||||
@Schema(description = "转换规则id") |
||||
@NotNull(message = "Id不能为空!", groups = {UpdateGroup.class}) |
||||
private String billId; |
||||
|
||||
/** |
||||
* 单据标识。 |
||||
*/ |
||||
@Schema(description = "单据标识") |
||||
@NotBlank(message = "单据标识不能为空!") |
||||
private String billType; |
||||
|
||||
/** |
||||
* 转换规则id |
||||
*/ |
||||
@Schema(description = "转换规则id") |
||||
private List<String> billIdList; |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/19 9:59 |
||||
* @description 关联关系 |
||||
*/ |
||||
@Data |
||||
public class ConvertRelationDto { |
||||
|
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "转换规则id") |
||||
private String convertRuleId; |
||||
|
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
@Schema(description = "源单id") |
||||
private String sourceId; |
||||
|
||||
@Schema(description = "目标单标识") |
||||
private String targetNumber; |
||||
|
||||
@Schema(description = "目标单id") |
||||
private String targetId; |
||||
|
||||
|
||||
|
||||
private List<ConvertRelationEntryDto> convertRelationEntryDtoList; |
||||
|
||||
} |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/19 10:05 |
||||
* @description 转换分录关系 |
||||
*/ |
||||
@Data |
||||
public class ConvertRelationEntryDto { |
||||
|
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "转换规则id") |
||||
private String convertRuleId; |
||||
|
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
@Schema(description = "源单id") |
||||
private String sourceId; |
||||
|
||||
@Schema(description = "源单分录标识") |
||||
private String sourceEntryNumber; |
||||
|
||||
@Schema(description = "源单分录id") |
||||
private String sourceEntryId; |
||||
|
||||
@Schema(description = "目标单标识") |
||||
private String targetNumber; |
||||
|
||||
@Schema(description = "目标单id") |
||||
private String targetId; |
||||
|
||||
@Schema(description = "目标分录标识") |
||||
private String targeEntryNumber; |
||||
|
||||
@Schema(description = "目标分录id") |
||||
private String targeEntryId; |
||||
|
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import apelet.common.core.validator.UpdateGroup; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotBlank; |
||||
import javax.validation.constraints.NotNull; |
||||
|
||||
/** |
||||
* 查询关联关系dto |
||||
*/ |
||||
@Schema(description = "查询关联关系dto") |
||||
@Data |
||||
public class ConvertRelationListDto { |
||||
/** |
||||
* 目标单据ID |
||||
*/ |
||||
@Schema(description = "目标单据ID") |
||||
@NotNull(message = "目标单据ID不能为空!", groups = {UpdateGroup.class}) |
||||
private String destBillId; |
||||
|
||||
/** |
||||
* 目标单据标识。 |
||||
*/ |
||||
@Schema(description = "目标单据标识") |
||||
@NotBlank(message = "目标单据标识不能为空!") |
||||
private String destBillType; |
||||
|
||||
/** |
||||
* 源单单据ID |
||||
*/ |
||||
@Schema(description = "源单单据ID") |
||||
@NotNull(message = "源单单据ID不能为空!", groups = {UpdateGroup.class}) |
||||
private String srcBillId; |
||||
|
||||
/** |
||||
* 源单单据标识。 |
||||
*/ |
||||
@Schema(description = "源单单据标识") |
||||
@NotBlank(message = "源单单据标识不能为空!") |
||||
private String srcBillType; |
||||
|
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import apelet.common.botp.model.ConvertRule; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Data |
||||
@Schema(description = "转换规则存值主表dto") |
||||
public class ConvertRuleDto extends ConvertRule { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@Excel(name = "单据标识", width = 15) |
||||
@Schema(description = "单据标识") |
||||
private String billType; |
||||
|
||||
@Excel(name = "单据名称", width = 15) |
||||
@Schema(description = "单据名称") |
||||
private String billTypeName; |
||||
|
||||
@Excel(name = "单据编辑界面", width = 15) |
||||
@Schema(description = "单据编辑界面") |
||||
private String billEditUI; |
||||
|
||||
@Excel(name = "是否显示编辑界面", width = 15) |
||||
@Schema(description = "是否显示编辑界面") |
||||
private String isShowEdit; |
||||
|
||||
// @Excel(name = "是否显示编辑界面", width = 15)
|
||||
@Schema(description = "表单类型:1:路由表单,2:在线表单") |
||||
private String billEditUIType; |
||||
} |
||||
@ -1,15 +1,16 @@
@@ -1,15 +1,16 @@
|
||||
package apelet.common.generator.dto; |
||||
package apelet.common.botp.dto; |
||||
|
||||
import apelet.common.generator.model.ReverseWritingBusiness; |
||||
import apelet.common.generator.model.ReverseWritingFormula; |
||||
import apelet.common.generator.model.ReverseWritingRules; |
||||
|
||||
import apelet.common.botp.model.ReverseWritingBusiness; |
||||
import apelet.common.botp.model.ReverseWritingFormula; |
||||
import apelet.common.botp.model.ReverseWritingRules; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class ReverseWritingRulesDto extends ReverseWritingRules implements Serializable { |
||||
public class ReverseWritingRulesDto extends ReverseWritingRules implements Serializable { |
||||
|
||||
/** |
||||
* 来源单据名称 |
||||
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import apelet.common.botp.service.execute.entity.BillData; |
||||
import apelet.common.botp.service.execute.entity.BillRelation; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/19 8:38 |
||||
*/ |
||||
@Data |
||||
public class TransformResultDto { |
||||
|
||||
/** |
||||
* 数据 |
||||
*/ |
||||
private BillData billData; |
||||
|
||||
|
||||
/** |
||||
* 关联关系 |
||||
*/ |
||||
private List<BillRelation> billRelationList; |
||||
|
||||
/** |
||||
* 表单状态 |
||||
*/ |
||||
private String formStatus;//1 新增状态 ; 2 保存状态
|
||||
|
||||
/** |
||||
* 表单类型:路由表单,在线表单 |
||||
*/ |
||||
private String formType;//1 路由表单 2 在线表单
|
||||
|
||||
/** |
||||
* 表单页面参数 |
||||
*/ |
||||
private String formVal;;//页面,路由表单路径 ,在线表单formId
|
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
package apelet.common.botp.dto; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotNull; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/26 14:27 |
||||
*/ |
||||
@Data |
||||
@Schema(description = "单据转换dto") |
||||
public class TransfromDto { |
||||
@Schema(description = "转换规则id") |
||||
@NotNull(message = "botpId不能为空!") |
||||
private String botpId; |
||||
@Schema(description = "源单标识") |
||||
@NotNull(message = "源单标识不能为空!") |
||||
private String srcBill; |
||||
@Schema(description = "目标标识") |
||||
@NotNull(message = "目标标识不能为空!") |
||||
private String destBill; |
||||
@Schema(description = "源单id") |
||||
@NotNull(message = "源单id不能为空!") |
||||
private String srcBillId; |
||||
|
||||
} |
||||
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
package apelet.common.botp.mapper; |
||||
|
||||
import apelet.common.core.base.mapper.BaseModelMapper; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/28 8:40 |
||||
*/ |
||||
public interface BillBaseModelMapper<D, M> extends BaseModelMapper<D, M> { |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.base.model.BaseModel; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@Schema(description = "转换规则存值主表") |
||||
@TableName("onl_form_field") |
||||
public class AllField extends BaseModel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Excel(name = "父表id", width = 15) |
||||
@Schema(description = "父表id") |
||||
private Long headId; |
||||
|
||||
@Excel(name = "字段名称", width = 15) |
||||
@Schema(description = "字段名称") |
||||
private String fieldName; |
||||
|
||||
@Excel(name = "字段备注", width = 15) |
||||
@Schema(description = "字段备注") |
||||
private String fieldRemark; |
||||
|
||||
@Excel(name = "字段长度", width = 15) |
||||
@Schema(description = "字段长度") |
||||
private int fieldLength; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.base.model.BaseModel; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/28 8:33 |
||||
*/ |
||||
@Data |
||||
public class BillBaseModel extends BaseModel { |
||||
} |
||||
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.annotation.RelationGlobalDict; |
||||
import apelet.common.core.base.model.BaseModel; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; |
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Data |
||||
@Schema( description = "转换规则字段映射") |
||||
@TableName("convert_fieldmapping_entry") |
||||
public class ConvertFieldmappingEntry extends BaseModel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/**主键*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "逻辑删除标记(1: 正常 -1: 已删除)") |
||||
// @TableLogic
|
||||
@ExcelIgnore |
||||
private Integer deletedFlag; |
||||
|
||||
@Excel(name = "源字段标识", width = 15) |
||||
@Schema(description = "源字段标识") |
||||
private String oldfieldNumber; |
||||
|
||||
@Excel(name = "源字段名称", width = 15) |
||||
@Schema(description = "源字段名称") |
||||
private String oldfieldName; |
||||
|
||||
@Excel(name = "目标字段标识", width = 15) |
||||
@Schema(description = "目标字段标识") |
||||
private String newfieldNumber; |
||||
|
||||
@Excel(name = "目标字段名称", width = 15) |
||||
@Schema(description = "目标字段名称") |
||||
private String newfieldName; |
||||
|
||||
@Excel(name = "计算公式", width = 15) |
||||
@Schema(description = "计算公式") |
||||
private String calculation; |
||||
private String calculationJson; |
||||
|
||||
@Excel(name = "取值方式", width = 15) |
||||
@Schema(description = "取值方式") |
||||
private String valueMethod; |
||||
|
||||
|
||||
@Excel(name = "取值", width = 15) |
||||
@Schema(description = "取值") |
||||
private String cltValue; |
||||
|
||||
@Excel(name = "父表id", width = 15) |
||||
@Schema(description = "父表id") |
||||
private String parentId; |
||||
|
||||
@Excel(name = "合并方式", width = 15) |
||||
@Schema(description = "合并方式(1:直接取 2:求和 3:拼接),默认为1") |
||||
private String mergeMethod; |
||||
|
||||
@Excel(name = "目标分录", width = 15) |
||||
@Schema(description = "目标分录") |
||||
private String entryTarget; |
||||
|
||||
@Excel(name = "执行顺序", width = 15) |
||||
@Schema(description = "执行顺序,数字越小越先执行") |
||||
private Integer serialNumber; |
||||
|
||||
@RelationGlobalDict( |
||||
masterIdField = "parentId", |
||||
dictCode = "parent_id") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> parentIdList; |
||||
|
||||
|
||||
// @RelationOneToOne(
|
||||
// masterIdField = "oldfieldNumber",
|
||||
// slaveModelClass = OnlFormField.class,
|
||||
// slaveIdField = "id")
|
||||
// @TableField(exist = false)
|
||||
// private OnlFormField oldFormField;
|
||||
|
||||
// @RelationOneToOne(
|
||||
// masterIdField = "newfieldNumber",
|
||||
// slaveModelClass = OnlFormField.class,
|
||||
// slaveIdField = "id")
|
||||
// @TableField(exist = false)
|
||||
// private OnlFormField newFormField;
|
||||
|
||||
@RelationGlobalDict(dictCode = "deleted_flag",masterIdField = "deletedFlag") |
||||
@TableField(exist = false) |
||||
private Map<String,Object> deletedFlagMap; |
||||
|
||||
} |
||||
@ -0,0 +1,72 @@
@@ -0,0 +1,72 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.annotation.RelationGlobalDict; |
||||
import apelet.common.core.base.model.BaseModel; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; |
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Data |
||||
@Schema( description = "分录插件") |
||||
@TableName("convert_plugin_entry") |
||||
public class ConvertPluginEntry extends BaseModel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/**主键*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "逻辑删除标记(1: 正常 -1: 已删除)") |
||||
// @TableLogic
|
||||
@ExcelIgnore |
||||
private Integer deletedFlag; |
||||
|
||||
@Excel(name = "启用", width = 15) |
||||
@Schema(description = "启用") |
||||
private String enable; |
||||
|
||||
@Excel(name = "类型", width = 15) |
||||
@Schema(description = "类型") |
||||
private String type; |
||||
|
||||
@Excel(name = "类名", width = 15) |
||||
@Schema(description = "类名") |
||||
private String className; |
||||
|
||||
@Excel(name = "插件名称", width = 15) |
||||
@Schema(description = "插件名称") |
||||
private String pluginName; |
||||
|
||||
@Excel(name = "描述说明", width = 15) |
||||
@Schema(description = "描述说明") |
||||
private String commen; |
||||
|
||||
@Excel(name = "序号", width = 15) |
||||
@Schema(description = "序号") |
||||
private String serialNumber; |
||||
|
||||
@Excel(name = "父表id", width = 15) |
||||
@Schema(description = "父表id") |
||||
private String parentId; |
||||
|
||||
@RelationGlobalDict( |
||||
masterIdField = "parentId", |
||||
dictCode = "parent_id") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> parentIdList; |
||||
|
||||
@RelationGlobalDict(dictCode = "deleted_flag",masterIdField = "deletedFlag") |
||||
@TableField(exist = false) |
||||
private Map<String,Object> deletedFlagMap; |
||||
|
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.base.model.BaseModel; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Data |
||||
@Schema( description = "单据关联关系") |
||||
@TableName("convert_relation") |
||||
public class ConvertRelation extends BaseModel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/**主键*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Excel(name = "转换规则id", width = 15) |
||||
@Schema(description = "转换规则id") |
||||
private String convertRuleId; |
||||
|
||||
@Excel(name = "源单标识", width = 15) |
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
@Excel(name = "源单id", width = 15) |
||||
@Schema(description = "源单id") |
||||
private String sourceId; |
||||
|
||||
@Excel(name = "目标单标识", width = 15) |
||||
@Schema(description = "目标单标识") |
||||
private String targetNumber; |
||||
|
||||
@Excel(name = "目标单id", width = 15) |
||||
@Schema(description = "目标单id") |
||||
private String targetId; |
||||
|
||||
@Excel(name = "`本次实际使用的规则版本", width = 15) |
||||
@Schema(description = "`本次实际使用的规则版本") |
||||
private Integer ruleVersion; |
||||
} |
||||
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.base.model.BaseModel; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Data |
||||
@Schema( description = "单据分录关联关系") |
||||
@TableName("convert_relation_entry") |
||||
public class ConvertRelationEntry extends BaseModel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/**主键*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Excel(name = "转换规则id", width = 15) |
||||
@Schema(description = "转换规则id") |
||||
private String convertRuleId; |
||||
|
||||
@Excel(name = "源单标识", width = 15) |
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
@Excel(name = "源单id", width = 15) |
||||
@Schema(description = "源单id") |
||||
private String sourceId; |
||||
|
||||
@Excel(name = "源单分录标识", width = 15) |
||||
@Schema(description = "源单分录标识") |
||||
private String sourceEntryNumber; |
||||
|
||||
@Excel(name = "源单分录id", width = 15) |
||||
@Schema(description = "源单分录id") |
||||
private String sourceEntryId; |
||||
|
||||
@Excel(name = "目标单标识", width = 15) |
||||
@Schema(description = "目标单标识") |
||||
private String targetNumber; |
||||
|
||||
@Excel(name = "目标单id", width = 15) |
||||
@Schema(description = "目标单id") |
||||
private String targetId; |
||||
|
||||
@Excel(name = "目标分录标识", width = 15) |
||||
@Schema(description = "目标分录标识") |
||||
private String targeEntryNumber; |
||||
|
||||
@Excel(name = "目标分录id", width = 15) |
||||
@Schema(description = "目标分录id") |
||||
private String targeEntryId; |
||||
|
||||
} |
||||
@ -0,0 +1,244 @@
@@ -0,0 +1,244 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.botp.util.Constant; |
||||
import apelet.common.core.annotation.RelationDict; |
||||
import apelet.common.core.annotation.RelationGlobalDict; |
||||
import apelet.common.core.base.model.BaseModel; |
||||
import apelet.common.online.model.OnlineForm; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection; |
||||
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; |
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Data |
||||
@Schema( description = "转换规则存值主表") |
||||
@TableName("convert_rule") |
||||
public class ConvertRule extends BaseModel { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 主键 |
||||
*/ |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "逻辑删除标记(1: 正常 -1: 已删除)") |
||||
// @TableLogic
|
||||
@ExcelIgnore |
||||
private Integer deletedFlag; |
||||
|
||||
@Excel(name = "规则编码", width = 15) |
||||
@Schema(description = "规则编码") |
||||
private String number; |
||||
|
||||
@Excel(name = "规则名称", width = 15) |
||||
@Schema(description = "规则名称") |
||||
private String name; |
||||
|
||||
@Excel(name = "源单", width = 15) |
||||
@Schema(description = "源单") |
||||
private String sourceEntityId; |
||||
|
||||
@Excel(name = "源单表", width = 15) |
||||
@Schema(description = "源单表") |
||||
private String sourceTable; |
||||
|
||||
@Excel(name = "目标单", width = 15) |
||||
@Schema(description = "目标单") |
||||
private String targetEntityId; |
||||
|
||||
@Excel(name = "启动状态", width = 15) |
||||
@Schema(description = "启动状态") |
||||
private String enabled; |
||||
|
||||
@Excel(name = "是否默认", width = 15) |
||||
@Schema(description = "是否默认") |
||||
private String isDefault; |
||||
|
||||
@Excel(name = "下推自动保存", width = 15) |
||||
@Schema(description = "下推自动保存") |
||||
private String autoSave; |
||||
|
||||
@Excel(name = "运行时可见", width = 15) |
||||
@Schema(description = "运行时可见") |
||||
private String visible; |
||||
|
||||
@Excel(name = "上游界面类型", width = 15) |
||||
@Schema(description = "上游界面类型") |
||||
private String upInterfaceType; |
||||
|
||||
@Excel(name = "下游界面类型", width = 15) |
||||
@Schema(description = "下游界面类型") |
||||
private String downInterfaceType; |
||||
|
||||
|
||||
@Excel(name = "上游路由界面", width = 15) |
||||
@Schema(description = "上游路由界面(关联菜单管理)") |
||||
private Long upRouteInterface; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "upRouteInterface", |
||||
equalOneToOneRelationField = "sysMenuqq", |
||||
slaveModelClass = SysMenuqq.class, |
||||
slaveIdField = "menuId", |
||||
slaveNameField = "formRouterName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> upRouteInterfaceMap; |
||||
|
||||
|
||||
@Excel(name = "下游路由界面", width = 15) |
||||
@Schema(description = "下游路由界面(关联菜单管理)") |
||||
private Long downRouteInterface; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "downRouteInterface", |
||||
equalOneToOneRelationField = "sysMenuqq", |
||||
slaveModelClass = SysMenuqq.class, |
||||
slaveIdField = "menuId", |
||||
slaveNameField = "formRouterName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> downRouteInterfaceMap; |
||||
|
||||
|
||||
@Excel(name = "上游在线列表界面", width = 15) |
||||
@Schema(description = "上游在线列表界面(关联在线表单界面(OnlineForm))") |
||||
private Long upListInterface; |
||||
|
||||
|
||||
@RelationDict( |
||||
masterIdField = "upListInterface", |
||||
equalOneToOneRelationField = "onlineForm", |
||||
slaveModelClass = OnlineForm.class, |
||||
slaveIdField = "formId", |
||||
slaveNameField = "formName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> upListInterfaceMap; |
||||
|
||||
|
||||
@Excel(name = "上游在线编辑界面", width = 15) |
||||
@Schema(description = "上游在线编辑界面(关联在线表单界面(OnlineForm))") |
||||
private Long upEditInterface; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "upEditInterface", |
||||
equalOneToOneRelationField = "onlineForm", |
||||
slaveModelClass = OnlineForm.class, |
||||
slaveIdField = "formId", |
||||
slaveNameField = "formName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> upEditInterfaceList; |
||||
|
||||
|
||||
@Excel(name = "下游在线列表界面", width = 15) |
||||
@Schema(description = "下游在线列表界面(关联在线表单界面(OnlineForm))") |
||||
private Long downListInterface; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "downListInterface", |
||||
equalOneToOneRelationField = "onlineForm", |
||||
slaveModelClass = OnlineForm.class, |
||||
slaveIdField = "formId", |
||||
slaveNameField = "formName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> downListInterfaceList; |
||||
|
||||
|
||||
@Excel(name = "下游在线编辑界面", width = 15) |
||||
@Schema(description = "下游在线编辑界面(关联在线表单界面(OnlineForm))") |
||||
private Long downEditInterface; |
||||
|
||||
@Excel(name = "分单策略", width = 15) |
||||
@Schema(description = "分单策略(1:一对一 2:多对一 3:按规则分组合并),默认为1") |
||||
private String splitMergeStrategy; |
||||
|
||||
|
||||
@Excel(name = "分单字段", width = 15) |
||||
@Schema(description = "分单字段") |
||||
private String groupByField; |
||||
|
||||
@Excel(name = "规则启用条件", width = 15) |
||||
@Schema(description = "规则启用条件,,留空 = 始终启用") |
||||
private String enableConditionJson; |
||||
|
||||
@Excel(name = "选单过滤条件", width = 15) |
||||
@Schema(description = "选单过滤策略,留空 = 全部通过") |
||||
private String selectFilterJson; |
||||
|
||||
@Excel(name = "规则版本", width = 15) |
||||
@Schema(description = "规则版本") |
||||
private Integer ruleVersion; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "downEditInterface", |
||||
equalOneToOneRelationField = "onlineForm", |
||||
slaveModelClass = OnlineForm.class, |
||||
slaveIdField = "formId", |
||||
slaveNameField = "formName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> downEditInterfaceList; |
||||
|
||||
|
||||
// @RelationOneToOne(
|
||||
// masterIdField = "id",
|
||||
// slaveModelClass = ConvertRelation.class,
|
||||
// slaveIdField = "convertRuleId")
|
||||
// @TableField(exist = false)
|
||||
// private ConvertRelation convertRelation;
|
||||
|
||||
|
||||
@RelationGlobalDict(dictCode = "deleted_flag", masterIdField = "deletedFlag") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> deletedFlagMap; |
||||
|
||||
@RelationGlobalDict( |
||||
masterIdField = "sourceEntityId", |
||||
dictCode = "sourceEntity_id") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> sourceEntityIdList; |
||||
|
||||
|
||||
@RelationGlobalDict( |
||||
masterIdField = "targetEntityId", |
||||
dictCode = "targetEntity_id") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> targetEntityIdList; |
||||
|
||||
|
||||
@Schema(description = "分录1") |
||||
@TableField(exist = false) |
||||
@ExcelCollection(name = "子数据", orderNum = "17", type = ConvertPluginEntry.class) |
||||
private List<ConvertPluginEntry> convertPluginEntryList; |
||||
|
||||
@Schema(description = "分录2") |
||||
@TableField(exist = false) |
||||
@ExcelCollection(name = "子数据", orderNum = "18", type = ConvertFieldmappingEntry.class) |
||||
private List<ConvertFieldmappingEntry> ConvertFieldmappingEntry; |
||||
|
||||
|
||||
|
||||
public String getDownEditFormVal(){ |
||||
|
||||
if(getDownInterfaceType() != null ){ |
||||
if( downRouteInterfaceMap != null && getDownInterfaceType().equals(Constant.InterfaceType_ROUTE) ){// 下游单据为路由表单
|
||||
return (String)downRouteInterfaceMap.get("formRouterName"); |
||||
}else{//下游单据为在线表单
|
||||
return String.valueOf(downEditInterface); |
||||
} |
||||
}else{ |
||||
return null; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.annotation.RelationDict; |
||||
import apelet.common.online.model.OnlineForm; |
||||
import cn.afterturn.easypoi.excel.annotation.Excel; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Map; |
||||
|
||||
@Data |
||||
@Schema( description = "开发平台主表") |
||||
public class GetSearchList { |
||||
@TableId(type = IdType.ASSIGN_ID) |
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Excel(name = "源单标识", width = 15) |
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
|
||||
@Excel(name = "单据标识", width = 15) |
||||
@Schema(description = "单据标识") |
||||
private String tableName; |
||||
|
||||
@Excel(name = "单据名称", width = 15) |
||||
@Schema(description = "单据名称") |
||||
private String tableTxt; |
||||
|
||||
|
||||
@Excel(name = "下游界面类型", width = 15) |
||||
@Schema(description = "下游界面类型") |
||||
private String downInterfaceType; |
||||
|
||||
@Excel(name = "上游界面类型", width = 15) |
||||
@Schema(description = "上游界面类型") |
||||
private String upInterfaceType; |
||||
|
||||
|
||||
@Excel(name = "上游在线列表界面", width = 15) |
||||
@Schema(description = "上游在线列表界面(关联在线表单界面(OnlineForm))") |
||||
private Long upListInterface; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "upListInterface", |
||||
equalOneToOneRelationField = "onlineForm", |
||||
slaveModelClass = OnlineForm.class, |
||||
slaveIdField = "formId", |
||||
slaveNameField = "formName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> upListInterfaceMap; |
||||
|
||||
|
||||
@Excel(name = "下游在线列表界面", width = 15) |
||||
@Schema(description = "下游在线列表界面(关联在线表单界面(OnlineForm))") |
||||
private Long downListInterface; |
||||
|
||||
@RelationDict( |
||||
masterIdField = "downListInterface", |
||||
equalOneToOneRelationField = "onlineForm", |
||||
slaveModelClass = OnlineForm.class, |
||||
slaveIdField = "formId", |
||||
slaveNameField = "formName") |
||||
@TableField(exist = false) |
||||
private Map<String, Object> downListInterfaceList; |
||||
|
||||
@Excel(name = "上游路由界面", width = 15) |
||||
@Schema(description = "上游路由界面(关联菜单管理)") |
||||
private Long upRouteInterface; |
||||
|
||||
@Excel(name = "下游路由界面", width = 15) |
||||
@Schema(description = "下游路由界面(关联菜单管理)") |
||||
private Long downRouteInterface; |
||||
|
||||
} |
||||
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
||||
package apelet.common.generator.model; |
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.base.model.BaseModel; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
package apelet.common.botp.model; |
||||
|
||||
import apelet.common.core.base.model.BaseModel; |
||||
import com.baomidou.mybatisplus.annotation.*; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
@Schema(description = "菜单管理") |
||||
@TableName(value = "xy_sys_menu") |
||||
public class SysMenuqq extends BaseModel { |
||||
|
||||
/** |
||||
* 主键Id。 |
||||
*/ |
||||
@TableId(value = "menu_id") |
||||
private Long menuId; |
||||
|
||||
/** |
||||
* 父菜单Id,目录菜单的父菜单为null。 |
||||
*/ |
||||
@TableField(value = "parent_id") |
||||
private Long parentId; |
||||
|
||||
/** |
||||
* 菜单显示名称。 |
||||
*/ |
||||
@TableField(value = "menu_name") |
||||
private String menuName; |
||||
|
||||
/** |
||||
* 菜单类型(0: 目录 1: 菜单 2: 按钮 3: UI片段)。 |
||||
*/ |
||||
@TableField(value = "menu_type") |
||||
private Integer menuType; |
||||
|
||||
/** |
||||
* 前端表单路由名称,仅用于menu_type为1的菜单类型。 |
||||
*/ |
||||
@TableField(value = "form_router_name") |
||||
private String formRouterName; |
||||
|
||||
/** |
||||
* 在线表单主键Id,仅用于在线表单绑定的菜单。 |
||||
*/ |
||||
@TableField(value = "online_form_id") |
||||
private Long onlineFormId; |
||||
|
||||
/** |
||||
* 在线表单菜单的权限控制类型,具体值可参考SysOnlineMenuPermType常量对象。 |
||||
*/ |
||||
@TableField(value = "online_menu_perm_type") |
||||
private Integer onlineMenuPermType; |
||||
|
||||
/** |
||||
* 统计页面主键Id,仅用于统计页面绑定的菜单。 |
||||
*/ |
||||
@TableField(value = "report_page_id") |
||||
private Long reportPageId; |
||||
|
||||
/** |
||||
* 仅用于在线表单的流程Id。 |
||||
*/ |
||||
@TableField(value = "online_flow_entry_id") |
||||
private Long onlineFlowEntryId; |
||||
|
||||
/** |
||||
* 菜单显示顺序 (值越小,排序越靠前)。 |
||||
*/ |
||||
@TableField(value = "show_order") |
||||
private Integer showOrder; |
||||
|
||||
/** |
||||
* 菜单图标。 |
||||
*/ |
||||
private String icon; |
||||
|
||||
/** |
||||
* 附加信息。 |
||||
*/ |
||||
@TableField(value = "extra_data") |
||||
private String extraData; |
||||
|
||||
/** |
||||
* 逻辑删除标记字段(1: 正常 -1: 已删除)。 |
||||
*/ |
||||
@TableLogic |
||||
@TableField(value = "deleted_flag") |
||||
private Integer deletedFlag; |
||||
|
||||
/** |
||||
* 表单开发。 |
||||
*/ |
||||
@TableField(value = "bill_exploit") |
||||
private String billExploit; |
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
package apelet.common.botp.plugin; |
||||
|
||||
import apelet.common.botp.plugin.entity.BotpRule; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.core.util.ApplicationContextHolder; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/16 18:01 |
||||
*/ |
||||
public abstract class AbstractTransformPlugIn { |
||||
|
||||
/** |
||||
* 源单据描述 |
||||
*/ |
||||
protected ObjectValue srcBillData; |
||||
/** |
||||
* 目标单据描述 |
||||
*/ |
||||
protected ObjectValue destBillData; |
||||
/** |
||||
* 转换规则 |
||||
*/ |
||||
protected BotpRule rule; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 单据转换后事件,最后执行 |
||||
*/ |
||||
public abstract void afterTransform(); |
||||
|
||||
|
||||
/** |
||||
* 目标字段赋值完毕后事件 |
||||
*/ |
||||
public abstract void afterFieldMapping(); |
||||
|
||||
/** |
||||
* 设置转换上下文变量 |
||||
*/ |
||||
public void setContext(ObjectValue srcBillData, ObjectValue destBillData, BotpRule rule){ |
||||
|
||||
this.srcBillData = srcBillData; |
||||
this.destBillData = destBillData; |
||||
this.rule = rule; |
||||
|
||||
} |
||||
public OrmGenDataSourceUtil ormGenDataSourceUtil(){ |
||||
return ApplicationContextHolder.getBean("ormGenDataSourceUtil"); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
package apelet.common.botp.plugin; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.orm.impl.Selector; |
||||
import apelet.common.orm.impl.SelectorItem; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* 采购申请下推采购订单后回写采购申请分录已订货数量 |
||||
*/ |
||||
public class BackPurReqTransformPlugIn extends AbstractTransformPlugIn{ |
||||
|
||||
@Override |
||||
public void afterTransform() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void afterFieldMapping() { |
||||
//源单据 申请单
|
||||
ObjectCollection srcObjectCollection = |
||||
srcBillData.getObjectCollection("pur_apply_entry"); |
||||
//目标 订单
|
||||
ObjectCollection descObjectCollection = |
||||
destBillData.getObjectCollection("pm_purorderbill_entry"); |
||||
for (int i = 0 ; i < descObjectCollection.size() ; i++){ |
||||
|
||||
//目标单据
|
||||
ObjectValue objectValue = descObjectCollection.getObject(i); |
||||
BigDecimal qty = objectValue.getBigDecimal("qty"); |
||||
Long srcbillentryid = objectValue.getLong("srcbillentryid"); |
||||
//原单据
|
||||
for (int j = 0 ; j < srcObjectCollection.size() ; j++){ |
||||
ObjectValue srcobjv = srcObjectCollection.getObject(j); |
||||
Long srcEntryId = srcobjv.getLong("id"); |
||||
if(srcEntryId==srcbillentryid){ |
||||
ObjectValue purReqObjV = new ObjectValue("pur_apply_entry"); |
||||
purReqObjV.put("id",srcEntryId); |
||||
purReqObjV.put("orderqty",srcobjv.getBigDecimal("orderqty").add(qty)); |
||||
Selector selector = new Selector(); |
||||
selector.getList().add(new SelectorItem("orderqty")); |
||||
try{ |
||||
ormGenDataSourceUtil().update(purReqObjV.getTableName(),purReqObjV,selector); |
||||
}catch (Exception e1){ |
||||
e1.printStackTrace();; |
||||
throw new RuntimeException(e1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
package apelet.common.botp.plugin; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/4/22 11:15 |
||||
*/ |
||||
public class PurorderTransformPlugIn extends AbstractTransformPlugIn{ |
||||
|
||||
|
||||
@Override |
||||
public void afterTransform() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void afterFieldMapping() { |
||||
ObjectCollection objectCollection = |
||||
destBillData.getObjectCollection("pur_order_entry"); |
||||
for (int i = 0 ; i < objectCollection.size() ; i++){ |
||||
|
||||
ObjectValue objectValue = objectCollection.getObject(i); |
||||
BigDecimal qty = objectValue.getBigDecimal("qty"); |
||||
BigDecimal price = objectValue.getBigDecimal("price"); |
||||
BigDecimal amount = qty.multiply(price); |
||||
objectValue.setBigDecimal("amount",amount); |
||||
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,198 @@
@@ -0,0 +1,198 @@
|
||||
package apelet.common.botp.plugin; |
||||
|
||||
import apelet.common.core.exception.MyRuntimeException; |
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.core.util.ApplicationContextHolder; |
||||
import apelet.common.botp.dto.ReverseWritingRulesDto; |
||||
import apelet.common.botp.model.ReverseWritingBusiness; |
||||
import apelet.common.botp.model.ReverseWritingFormula; |
||||
import apelet.common.botp.service.impl.ReverseWritingRulesServiceImpl; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.service.impl.OnlineFormServiceImpl; |
||||
import apelet.common.online.util.Jexl3Util; |
||||
import apelet.common.orm.impl.Selector; |
||||
import apelet.common.orm.impl.SelectorItem; |
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 采购申请下推采购订单后回写采购申请分录已订货数量 |
||||
*/ |
||||
public class ReverseWritingPlugIn extends AbstractTransformPlugIn { |
||||
|
||||
|
||||
private final ReverseWritingRulesServiceImpl reverseWritingRulesService = |
||||
ApplicationContextHolder.getBean(ReverseWritingRulesServiceImpl.class); |
||||
private final OnlineFormServiceImpl onlineFormService = |
||||
ApplicationContextHolder.getBean(OnlineFormServiceImpl.class); |
||||
private final OrmGenDataSourceUtil ormGenDataSourceUtil = |
||||
ApplicationContextHolder.getBean(OrmGenDataSourceUtil.class); |
||||
private final Jexl3Util Jexl3Util = |
||||
ApplicationContextHolder.getBean(Jexl3Util.class); |
||||
|
||||
|
||||
|
||||
@Override |
||||
public void afterTransform() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 源单据 srcBillData |
||||
* 目标单据 destBillData |
||||
*/ |
||||
@Override |
||||
public void afterFieldMapping() { |
||||
try { |
||||
String destBillType = rule.getDestBillType(); |
||||
String sourceBillType = rule.getSourceBillType(); |
||||
List<ReverseWritingRulesDto> rulesList = reverseWritingRulesService.listAll(); |
||||
List<ReverseWritingRulesDto> collect = rulesList.stream() |
||||
.filter(f -> f.getSourceDocuments().toString().equals(sourceBillType) && |
||||
f.getTargetDoc().toString().equals(destBillType) && |
||||
f.getTriggerTiming().equals("1") |
||||
) |
||||
.collect(Collectors.toList()); |
||||
collect.forEach(f -> { |
||||
// 业务规则
|
||||
f.getBusinessList().stream().filter(i -> i.getEnable() == 1).forEach(this::a); |
||||
// 反写公式 根据目标单据数据 -> 修改原单据
|
||||
f.getFormulaList().stream().filter(i -> i.getEnable() == 1).forEach(this::b); |
||||
}); |
||||
}catch (Exception e){ |
||||
throw new MyRuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
void a(ReverseWritingBusiness b) { |
||||
String preconditionsEnglish = b.getPreconditionsEnglish(); |
||||
JSONObject preconditionsJson = JSON.parseObject(b.getPreconditionsJson()); |
||||
String preconditionsField = b.getPreconditionsField(); |
||||
JSONObject jsonObject = JSON.parseObject(preconditionsField); |
||||
Map<String, Object> hashMap = Jexl3Util.getMapValue(jsonObject, destBillData); |
||||
Object expression = Jexl3Util.expression(preconditionsEnglish, hashMap); |
||||
|
||||
Object func = onlineFormService.func(preconditionsEnglish, preconditionsJson, destBillData); |
||||
String established = ""; |
||||
String establishedField = ""; |
||||
String establishedJson = ""; |
||||
if (func instanceof Boolean && func.equals(true)) { |
||||
// 成立
|
||||
established = b.getEstablishedEnglish(); |
||||
establishedField = b.getEstablishedField(); |
||||
establishedJson = b.getEstablishedJson(); |
||||
} else { |
||||
// 不成立
|
||||
established = b.getNotEstablishedEnglish(); |
||||
establishedField = b.getNotEstablishedField(); |
||||
establishedJson = b.getNotEstablishedJson(); |
||||
} |
||||
// Map<String, Object> map = Jexl3Util.getMapValue(JSON.parseObject(establishedField), destBillData);
|
||||
// Jexl3Util.expression(established, map);
|
||||
// 执行操作
|
||||
JSONObject json = JSON.parseObject(establishedJson); |
||||
String expressionTransl = json.getString("expressionTranslation"); |
||||
List<String> split = Arrays.asList(expressionTransl.split("=")); |
||||
String fun = ""; |
||||
for (String s : split) { |
||||
s = s.trim(); |
||||
if (s.startsWith("$") && s.endsWith("$")) { |
||||
fun = s; |
||||
} |
||||
} |
||||
fun = Jexl3Util.getMySplit("\\$(.*?)\\$", fun); |
||||
List<String> funParam = Arrays.asList(Jexl3Util.getMySplit("\\((.*?)\\)", fun).split(",")); |
||||
Object[] objects = Jexl3Util.getFunParam(funParam, destBillData); |
||||
Object o = onlineFormService.executeFunction(json, fun, objects); |
||||
|
||||
// 修改单据
|
||||
List<String> s = Arrays.asList(split.get(0).split("\\.")); |
||||
if (s.get(0).equals(s.get(1))) { |
||||
// 表头
|
||||
destBillData.put(s.get(s.size()-1), o); |
||||
try { |
||||
// ormGenDataSourceUtil.update(destBillData.getTableName(),destBillData,null);
|
||||
} catch (Exception e) { |
||||
throw new MyRuntimeException(e); |
||||
} |
||||
}else{ |
||||
// 分录 TODO 待确定
|
||||
|
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据目标单据数据 -> 修改原单据 |
||||
* @param b |
||||
*/ |
||||
void b(ReverseWritingFormula b) { |
||||
String conditionEnglish = b.getConditionEnglish(); // 条件
|
||||
String conditionField = b.getConditionField(); |
||||
JSONObject conditionJson = JSON.parseObject(b.getConditionJson()); |
||||
|
||||
// JSONObject jsonObject = JSON.parseObject(conditionField);
|
||||
// Map<String, Object> hashMap = Jexl3Util.getMapValue(jsonObject, destBillData);
|
||||
// Object expression = Jexl3Util.expression(conditionEnglish, hashMap);
|
||||
|
||||
Object func = onlineFormService.func(conditionEnglish, conditionJson, srcBillData); |
||||
|
||||
if (Jexl3Util.judgmentFunc(conditionEnglish, func)) { |
||||
// 反写公式
|
||||
String formulaEnglish = b.getFormulaEnglish(); |
||||
JSONObject formulaJson = JSON.parseObject(b.getFormulaJson()); |
||||
Object func1 = onlineFormService.func(formulaEnglish, formulaJson, srcBillData); |
||||
|
||||
|
||||
String formula = b.getFormulaEnglish().replaceAll("\\s", ""); // 公式
|
||||
String[] formulas = formula.split("\\."); |
||||
ObjectCollection o = (ObjectCollection) destBillData.getValues().get(formulas[1]); |
||||
Iterator iterator = o.iterator(); |
||||
while (iterator.hasNext()) { |
||||
ObjectValue next = (ObjectValue) iterator.next(); |
||||
Object destValue = next.getValues().get(formulas[2]) == null ? 0 : next.getValues().get(formulas[2]); |
||||
String sourceSingleField = b.getSourceSingleField().replaceAll("\\s", ""); // 源单字段
|
||||
String[] srcStr = sourceSingleField.split("\\."); |
||||
ObjectCollection o1 = (ObjectCollection) srcBillData.getValues().get(srcStr[1]); |
||||
Iterator iterator2 = o1.iterator(); |
||||
while (iterator2.hasNext()) { |
||||
ObjectValue next2 = (ObjectValue) iterator2.next(); |
||||
if (!ObjectUtil.contains(next2.get("number"), next.get("number"))) { |
||||
continue; |
||||
} |
||||
Object srcValue = next2.getValues().get(srcStr[2]) == null ? 0 : next2.getValues().get(srcStr[2]); |
||||
String a = ""; |
||||
switch (b.getMode()) { // 累加方式 1:累加, 2:扣减, 3:覆盖
|
||||
case "1": { |
||||
a = String.valueOf((Integer.parseInt(srcValue.toString()) + Integer.parseInt(destValue.toString()))); |
||||
break; |
||||
} |
||||
case "2": { |
||||
a = String.valueOf((Integer.parseInt(srcValue.toString()) - Integer.parseInt(destValue.toString()))); |
||||
break; |
||||
} |
||||
case "3": { |
||||
a = destValue.toString(); |
||||
break; |
||||
} |
||||
} |
||||
ObjectValue purReqObjV = new ObjectValue(srcStr[1]); |
||||
purReqObjV.put("id", next2.get("id")); |
||||
purReqObjV.put(srcStr[2], a); |
||||
Selector selector = new Selector(); |
||||
selector.getList().add(new SelectorItem(srcStr[2])); |
||||
try { |
||||
ormGenDataSourceUtil().update(purReqObjV.getTableName(), purReqObjV, selector); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package apelet.common.botp.plugin.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/16 18:01 |
||||
*/ |
||||
@Data |
||||
public class BillEntity { |
||||
|
||||
/** |
||||
* 单据标识 |
||||
*/ |
||||
private String billType; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
package apelet.common.botp.plugin.entity; |
||||
|
||||
import lombok.Data; |
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/16 18:01 |
||||
*/ |
||||
@Data |
||||
public class BotpRule { |
||||
|
||||
/** |
||||
* 规则id |
||||
*/ |
||||
private long id; |
||||
|
||||
/** |
||||
* 规则编码 |
||||
*/ |
||||
private String number; |
||||
|
||||
/** |
||||
* 规则名称 |
||||
*/ |
||||
private String name; |
||||
|
||||
/** |
||||
* 源单标识 |
||||
*/ |
||||
private String sourceBillType; |
||||
|
||||
/** |
||||
* 目标单标识 |
||||
*/ |
||||
private String destBillType; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,80 @@
@@ -0,0 +1,80 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
|
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
import apelet.common.core.object.*; |
||||
import com.github.pagehelper.Page; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 业务单据Service |
||||
* @param <M> |
||||
* @param <K> |
||||
*/ |
||||
public interface IBillBaseService <M, K extends Serializable> extends IBaseService<M, K> { |
||||
|
||||
|
||||
|
||||
/** |
||||
* 单据列表 |
||||
* @param m |
||||
* @param orderParam |
||||
* @param pageParam |
||||
* @param traceParamDto |
||||
* @return 返回分页列表数据 |
||||
*/ |
||||
Page<M> listBill(M m, |
||||
MyOrderParam orderParam, |
||||
MyPageParam pageParam, |
||||
TraceParamDto traceParamDto |
||||
|
||||
); |
||||
|
||||
/** |
||||
* 保存单据 |
||||
* @param m 单据实体 |
||||
* @param crDto 关联关系 |
||||
*/ |
||||
void saveBill(M m, List<ConvertRelationDto> crDto); |
||||
|
||||
|
||||
/** |
||||
* 提交单据,如果有流程标识,提交进入工作流 |
||||
* @param processDefinitionKey |
||||
* @param m |
||||
* @param crDto |
||||
*/ |
||||
void submitBill(String processDefinitionKey,M m, @MyRequestBody List<ConvertRelationDto> crDto); |
||||
|
||||
|
||||
/** |
||||
* 提交单据信息,如果有单据标识,提交进入工作流 |
||||
* @param processDefinitionKey 流程标识 |
||||
* @param id |
||||
*/ |
||||
void submitBillKey(String processDefinitionKey,Long id); |
||||
|
||||
|
||||
/** |
||||
* 查询单据信息,包含分录信息 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
M detailBill(K id); |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 删除单据 |
||||
* @param ids 单据id集合 |
||||
* @return |
||||
*/ |
||||
Integer removeBillById(String ids); |
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.botp.model.ConvertFieldmappingEntry; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
public interface IConvertFieldmappingEntryService extends IBaseService<ConvertFieldmappingEntry,Long> { |
||||
List<ConvertFieldmappingEntry> getConvertFieldmappingEntryRelation(Long id); |
||||
|
||||
List<ConvertFieldmappingEntry> getConvertFieldmappingEntryListWithRelation(ConvertFieldmappingEntry convertFieldmappingEntry, String buildOrderBy); |
||||
|
||||
} |
||||
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.botp.model.ConvertPluginEntry; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
public interface IConvertPluginEntryService extends IBaseService<ConvertPluginEntry,Long> { |
||||
List<ConvertPluginEntry> getConvertPluginEntryRelation(Long id); |
||||
|
||||
List<ConvertPluginEntry> getConvertPluginEntryListWithRelation(ConvertPluginEntry convertPluginEntryFilter, String buildOrderBy); |
||||
} |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.botp.model.ConvertRelationEntry; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
public interface IConvertRelationEntryService extends IBaseService<ConvertRelationEntry,Long> { |
||||
|
||||
Boolean removeAllById(Long id); |
||||
|
||||
Boolean editAll(ConvertRelationEntry convertRelationEntry); |
||||
|
||||
Boolean addAll(ConvertRelationEntry convertRelationEntry); |
||||
|
||||
List<ConvertRelationEntry> getConvertRuleListWithRelation(ConvertRelationEntry convertRelationEntryFilter, String buildOrderBy); |
||||
|
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.botp.model.ConvertRelation; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
public interface IConvertRelationService extends IBaseService<ConvertRelation,Long> { |
||||
|
||||
Boolean removeAllById(Long id); |
||||
|
||||
Boolean editAll(ConvertRelation convertRelation); |
||||
|
||||
Boolean addAll(ConvertRelation convertRelation); |
||||
|
||||
List<ConvertRelation> getConvertRuleListWithRelation(ConvertRelation convertRelationFilter, String buildOrderBy); |
||||
|
||||
|
||||
public List<ConvertRelation> transform(String botpId, String srcBill, String destBill, String srcBillId); |
||||
|
||||
public List<ConvertRelation> transformT(String botpId, String srcBill, String destBill, List<String> srcBillList); |
||||
|
||||
//根据联查单据id、单据标识、上查/下查 ,根据单据关联关系表查询关联查询的单据
|
||||
public List<Map<String,Object>> getConvertRelation(String billId, String billType, String searchType); |
||||
} |
||||
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.botp.dto.ConvertRelationDelDto; |
||||
import apelet.common.botp.dto.ConvertRelationListDto; |
||||
import apelet.common.botp.dto.TransformResultDto; |
||||
import apelet.common.botp.model.*; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
public interface IConvertRuleService extends IBaseService<ConvertRule,Long> { |
||||
//查询全部信息
|
||||
public List<ConvertRule> selectAll(String id); |
||||
|
||||
//查询返回源单和目标单全部字段
|
||||
public List<AllField> allField(String tableName); |
||||
|
||||
Boolean removeAllById(Long id); |
||||
|
||||
Boolean editAll(ConvertRule convertRule); |
||||
|
||||
Boolean addAll(ConvertRule convertRule); |
||||
|
||||
List<ConvertRule> getConvertRuleListWithRelation(ConvertRule convertRuleFilter, String buildOrderBy); |
||||
|
||||
List<ConvertPluginEntry> getConvertPluginEntry(Long id); |
||||
List<ConvertFieldmappingEntry> getConvertFieldmappingEntry(Long id); |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 删除单据关联关系 |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
public boolean removeAllRelation(ConvertRelationDelDto dto); |
||||
|
||||
/** |
||||
* @botpId 转准规则id |
||||
* @srcBill 源单据元数据id |
||||
* @destBill 目标单据元数据id |
||||
* @srcbillId 源单据id |
||||
* @return |
||||
*/ |
||||
public TransformResultDto transform(String botpId, String srcBill, String destBill, String srcBillId); |
||||
|
||||
/** |
||||
* @botpId 转准规则id |
||||
* @srcBill 源单据元数据id |
||||
* @destBill 目标单据元数据id |
||||
* @srcbillId 源单据id集合 |
||||
* @return |
||||
*/ |
||||
public TransformResultDto transform(String botpId, String srcBill, String destBill, Set<String> srcBillList); |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 根据目标单查询关联关系 |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
public List<ConvertRelation> selectAllRelationByTarget(ConvertRelationListDto dto); |
||||
|
||||
/** |
||||
* 根据源单查询关联关系 |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
public List<ConvertRelation> selectAllRelationBySource(ConvertRelationListDto dto); |
||||
|
||||
/** |
||||
* 下推规则查询 |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
public List<Map<String,Object>> getPushBillList(ConvertRelationDelDto dto); |
||||
|
||||
List<Map<String,Object>> getRuleTableFiled(String tableName); |
||||
} |
||||
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
package apelet.common.generator.service; |
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.generator.model.ReverseWritingBusiness; |
||||
import apelet.common.botp.model.ReverseWritingBusiness; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
public interface IReverseWritingBusinessService extends IService<ReverseWritingBusiness> { |
||||
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
||||
package apelet.common.generator.service; |
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.generator.model.ReverseWritingFormula; |
||||
import apelet.common.botp.model.ReverseWritingFormula; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
public interface IReverseWritingFormulaService extends IService<ReverseWritingFormula> { |
||||
@ -1,8 +1,8 @@
@@ -1,8 +1,8 @@
|
||||
package apelet.common.generator.service; |
||||
package apelet.common.botp.service; |
||||
|
||||
|
||||
import apelet.common.generator.dto.ReverseWritingRulesDto; |
||||
import apelet.common.generator.model.ReverseWritingRules; |
||||
import apelet.common.botp.dto.ReverseWritingRulesDto; |
||||
import apelet.common.botp.model.ReverseWritingRules; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
import java.util.List; |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
package apelet.common.botp.service; |
||||
|
||||
import apelet.common.botp.model.AllField; |
||||
import apelet.common.botp.model.SysMenuqq; |
||||
import apelet.common.core.base.service.IBaseService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
public interface ISysMenuqqService extends IBaseService<SysMenuqq,Long> { |
||||
//查询全部信息
|
||||
public List<SysMenuqq> selectAll(String id); |
||||
|
||||
//查询返回源单和目标单全部字段
|
||||
public List<AllField> allField(String tableName); |
||||
|
||||
Boolean removeAllById(Long id); |
||||
|
||||
Boolean editAll(SysMenuqq sysMenuqq); |
||||
|
||||
Boolean addAll(SysMenuqq sysMenuqq); |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,604 @@
@@ -0,0 +1,604 @@
|
||||
package apelet.common.botp.service.execute; |
||||
|
||||
import apelet.common.botp.dao.ConvertRelationEntryMapper; |
||||
import apelet.common.botp.dao.ConvertRelationMapper; |
||||
import apelet.common.botp.db.object.*; |
||||
import apelet.common.botp.db.util.DbUtil; |
||||
import apelet.common.botp.model.*; |
||||
import apelet.common.botp.plugin.entity.BotpRule; |
||||
import apelet.common.botp.service.execute.entity.*; |
||||
import apelet.common.botp.service.execute.mapping.BotpMappingContext; |
||||
import apelet.common.core.config.DataSourceInfo; |
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.core.object.TokenData; |
||||
import apelet.common.dbutil.constant.DblinkType; |
||||
import apelet.common.dbutil.provider.DataSourceProvider; |
||||
import apelet.common.generator.dao.OnlFormFieldMapper; |
||||
import apelet.common.generator.dao.OnlFormHeadMapper; |
||||
import apelet.common.generator.model.OnlFormField; |
||||
import apelet.common.generator.model.OnlFormHead; |
||||
import apelet.common.generator.service.IOnlFormHeadService; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.model.constant.FieldFilterType; |
||||
import apelet.common.orm.impl.Selector; |
||||
import apelet.common.orm.impl.SelectorItem; |
||||
import apelet.common.sequence.wrapper.IdGeneratorWrapper; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.alibaba.fastjson.JSON; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.io.Serializable; |
||||
import java.lang.reflect.Method; |
||||
import java.time.LocalDateTime; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author sunquan |
||||
* @version 1.0 |
||||
* Create by 2024/1/22 16:00 |
||||
*/ |
||||
@Component |
||||
@Slf4j |
||||
public class BotpService { |
||||
|
||||
|
||||
@Autowired |
||||
private ConvertRelationMapper convertRelationMapper; |
||||
@Autowired |
||||
private ConvertRelationEntryMapper convertRelationEntryMapper; |
||||
@Autowired |
||||
private IdGeneratorWrapper idGenerator; |
||||
@Autowired |
||||
private DbUtil dbUtil; |
||||
|
||||
@Autowired |
||||
private OnlFormHeadMapper onlFormHeadMapper; |
||||
@Autowired |
||||
private OnlFormFieldMapper onlFormFieldMapper; |
||||
|
||||
@Autowired |
||||
private OrmGenDataSourceUtil ormGenDataSourceUtil; |
||||
|
||||
@Autowired |
||||
private IOnlFormHeadService onlFormHeadService; |
||||
|
||||
/** |
||||
* @param convertRule 规则 |
||||
* @param convertFieldmappingEntryList 映射分录 |
||||
* @param convertPluginEntryList 插件分录 |
||||
* @param srcFormHead 源元数据 |
||||
* @param destFormHead 目标元数据 |
||||
* @param srcBillId 源单据id |
||||
* @return 返回实体数据 |
||||
*/ |
||||
@Transactional(rollbackFor = Exception.class) |
||||
public BtpTransformResult transform( |
||||
ConvertRule convertRule, |
||||
List<ConvertFieldmappingEntry> convertFieldmappingEntryList, |
||||
List<ConvertPluginEntry> convertPluginEntryList, |
||||
OnlFormHead srcFormHead, |
||||
OnlFormHead destFormHead, |
||||
Set<String> srcBillId) { |
||||
|
||||
String srcTable = srcFormHead.getTableName();//源元数据表名
|
||||
List<ConvertFieldmappingEntry> |
||||
mappingFieldList = |
||||
convertFieldmappingEntryList.stream().filter(item -> StringUtils.isNotEmpty(item.getOldfieldNumber()) |
||||
&& StringUtils.isNotEmpty(item.getNewfieldNumber()) |
||||
).collect(Collectors.toList());//过滤掉没有配置字段映射的行
|
||||
Map<String, MetaTable> selectTableMap = new HashMap<>(); |
||||
Map<String, MetaTable> insertTableMap = new HashMap<>(); |
||||
|
||||
Map<MetaColumn, ConvertColumnConfig> convertColumnConfigs = new HashMap<>(); |
||||
Map<Long, OnlFormHead> tableMap = new HashMap<>(); |
||||
for (ConvertFieldmappingEntry convertFieldmappingEntry : mappingFieldList) {//构建单据转换参数
|
||||
String oldfieldNumber = convertFieldmappingEntry.getOldfieldNumber(); |
||||
String newfieldNumber = convertFieldmappingEntry.getNewfieldNumber(); |
||||
|
||||
String srcTableNumber = null;//源单表名
|
||||
String srcColumnNumber = null;//源单字段
|
||||
if (StringUtils.isNotEmpty(oldfieldNumber)) { |
||||
OnlFormField onlFormField = onlFormFieldMapper.selectById(oldfieldNumber); |
||||
OnlFormHead onlFormHead = tableMap.get(onlFormField.getHeadId()); |
||||
if (onlFormHead == null) { |
||||
onlFormHead = onlFormHeadMapper.selectById(onlFormField.getHeadId()); |
||||
tableMap.put(onlFormField.getHeadId(), onlFormHead); |
||||
} |
||||
srcTableNumber = onlFormHead.getTableName(); |
||||
srcColumnNumber = onlFormField.getFieldName(); |
||||
} else {//配置的源字段为空,则跳过
|
||||
continue; |
||||
} |
||||
|
||||
OnlFormField onlFormField = onlFormFieldMapper.selectById(newfieldNumber); |
||||
OnlFormHead onlFormHead = tableMap.get(onlFormField.getHeadId()); |
||||
if (onlFormHead == null) { |
||||
onlFormHead = onlFormHeadMapper.selectById(onlFormField.getHeadId()); |
||||
tableMap.put(onlFormField.getHeadId(), onlFormHead); |
||||
} |
||||
String destTableNumber = onlFormHead.getTableName(); |
||||
String destColumnNumber = onlFormField.getFieldName(); |
||||
|
||||
MetaColumn srcMainColumn = this.genMetaTable(selectTableMap, srcTableNumber, srcColumnNumber, srcFormHead); |
||||
MetaColumn destMainColumn = this.genMetaTable(insertTableMap, destTableNumber, destColumnNumber, destFormHead); |
||||
|
||||
ConvertColumnConfig convertColumnConfig = new ConvertColumnConfig(); |
||||
convertColumnConfig.setColumnName(srcColumnNumber);//源表字段
|
||||
convertColumnConfig.setTableName(srcTableNumber);//源表
|
||||
convertColumnConfig.setMain(srcMainColumn == null ? false : srcMainColumn.isMain());//是否主表字段
|
||||
convertColumnConfig.setValueMethod(Integer.parseInt(convertFieldmappingEntry.getValueMethod()));//方法
|
||||
convertColumnConfig.setValue(convertFieldmappingEntry.getCltValue());//默认值
|
||||
convertColumnConfig.setValue(convertFieldmappingEntry.getCltValue());//默认值
|
||||
|
||||
if (org.apache.commons.lang3.StringUtils.isNotEmpty(convertFieldmappingEntry.getCalculationJson())) { |
||||
convertColumnConfig.setCalculationFormula(JSON.parseObject(convertFieldmappingEntry.getCalculationJson())); |
||||
} |
||||
convertColumnConfigs.put(destMainColumn, convertColumnConfig); |
||||
|
||||
} |
||||
ObjectValue srcBillData = getBillData(selectTableMap, srcBillId.iterator().next());//源单数据
|
||||
ConvertConfig convertConfig = new ConvertConfig(); |
||||
convertConfig.setSrcMetaTable(selectTableMap.get(srcFormHead.getTableName())); |
||||
convertConfig.setDestMetaTable(insertTableMap.get(destFormHead.getTableName())); |
||||
convertConfig.setColumnConfigMap(convertColumnConfigs); |
||||
|
||||
BtpTransformResult btpTransformResult = this.convertToDestBill(srcBillData, insertTableMap, convertConfig, convertRule);//转换
|
||||
//转换插件
|
||||
executePlugin(srcBillData, btpTransformResult.getBillDataList().getObject(0), convertPluginEntryList, convertRule, "afterFieldMapping");//映射完成执行
|
||||
if (convertRule.getAutoSave().equals("true")) {//转后直接保存单据
|
||||
addNew(btpTransformResult, insertTableMap.get(destFormHead.getTableName())); |
||||
} |
||||
//转换插件
|
||||
executePlugin(srcBillData, btpTransformResult.getBillDataList().getObject(0), convertPluginEntryList, convertRule, "afterTransform");//转换后执行
|
||||
return btpTransformResult; |
||||
} |
||||
|
||||
/** |
||||
* 执行转换规则 |
||||
* |
||||
* @param convertPluginEntryList |
||||
*/ |
||||
private void executePlugin( |
||||
ObjectValue srcObjectValue, |
||||
ObjectValue destObjectValue, |
||||
List<ConvertPluginEntry> convertPluginEntryList//转换规则
|
||||
, ConvertRule convertRule, |
||||
String method |
||||
) { |
||||
BotpRule botpRule = new BotpRule(); |
||||
botpRule.setId(convertRule.getId()); |
||||
botpRule.setName(convertRule.getName()); |
||||
botpRule.setNumber(convertRule.getNumber()); |
||||
botpRule.setSourceBillType(convertRule.getSourceEntityId()); |
||||
botpRule.setDestBillType(convertRule.getTargetEntityId()); |
||||
|
||||
List<ConvertPluginEntry> list = |
||||
convertPluginEntryList.stream().sorted(Comparator.comparing(ConvertPluginEntry::getSerialNumber)).collect(Collectors.toList()); |
||||
for (ConvertPluginEntry sortDto : list) { |
||||
try { |
||||
Class<?> clazz = Class.forName(sortDto.getClassName()); |
||||
Class superClass = clazz.getSuperclass(); |
||||
Class[] parameterTypes = new Class[3]; |
||||
parameterTypes[0] = ObjectValue.class; |
||||
parameterTypes[1] = ObjectValue.class; |
||||
parameterTypes[2] = BotpRule.class; |
||||
Method ctxMethod = superClass.getDeclaredMethod("setContext", parameterTypes); |
||||
|
||||
Object ob = clazz.newInstance(); |
||||
ctxMethod.invoke(ob, srcObjectValue, destObjectValue, botpRule); |
||||
Method exeMethod = superClass.getDeclaredMethod(method); |
||||
exeMethod.invoke(ob); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 新增数据 |
||||
* |
||||
* @param btpTransformResul |
||||
* @param metaTable |
||||
*/ |
||||
private void addNew(BtpTransformResult btpTransformResult, MetaTable metaTable) { |
||||
|
||||
try { |
||||
ObjectValue destBillData = btpTransformResult.getBillDataList().getObject(0); |
||||
ormGenDataSourceUtil.addNew(metaTable.getTableName(), destBillData); |
||||
this.saveRelation(btpTransformResult.getBillRelationList().get(0), destBillData); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
throw new RuntimeException(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
private void saveRelation(BillRelation billRelation, ObjectValue destBillData) { |
||||
|
||||
ConvertRelation convertRelation = new ConvertRelation(); |
||||
convertRelation.setId(billRelation.getId()); |
||||
convertRelation.setConvertRuleId(billRelation.getConvertRuleId()); |
||||
convertRelation.setSourceId(billRelation.getSourceId()); |
||||
convertRelation.setSourceNumber(billRelation.getSourceNumber()); |
||||
convertRelation.setTargetId(String.valueOf(destBillData.getPkValue())); |
||||
convertRelation.setTargetNumber(billRelation.getTargetNumber()); |
||||
convertRelation.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
convertRelation.setCreateTime(new Date()); |
||||
convertRelation.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
convertRelation.setUpdateTime(new Date()); |
||||
convertRelationMapper.insert(convertRelation); |
||||
|
||||
for (BillRelationEntry billRelationEntry : billRelation.getBillRelationEntryList()) { |
||||
ConvertRelationEntry convertRelationEntry = new ConvertRelationEntry(); |
||||
convertRelationEntry.setId(billRelationEntry.getId()); |
||||
convertRelationEntry.setConvertRuleId(billRelationEntry.getConvertRuleId()); |
||||
convertRelationEntry.setSourceEntryId(billRelationEntry.getSourceEntryId()); |
||||
convertRelationEntry.setSourceEntryNumber(billRelationEntry.getSourceEntryNumber()); |
||||
convertRelationEntry.setSourceId(billRelationEntry.getSourceId()); |
||||
convertRelationEntry.setSourceNumber(billRelationEntry.getSourceNumber()); |
||||
convertRelationEntry.setTargeEntryId(billRelationEntry.getTargeEntryId()); |
||||
convertRelationEntry.setTargetId(String.valueOf(destBillData.getPkValue())); |
||||
convertRelationEntry.setTargeEntryNumber(billRelationEntry.getTargeEntryNumber()); |
||||
convertRelationEntry.setTargetNumber(billRelationEntry.getTargetNumber()); |
||||
convertRelationEntry.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
convertRelationEntry.setCreateTime(new Date()); |
||||
convertRelationEntry.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
convertRelationEntry.setUpdateTime(new Date()); |
||||
convertRelationEntryMapper.insert(convertRelationEntry); |
||||
} |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 插入数据 |
||||
* |
||||
* @param tableName |
||||
* @param columnNames |
||||
* @param columnValueList |
||||
*/ |
||||
private ObjectSqlData doInsert(String tableName, String columnNames, List<Object> columnValueList) { |
||||
StringBuilder sql = new StringBuilder(512); |
||||
sql.append("INSERT INTO ").append(tableName).append(" (").append(columnNames).append(") VALUES ("); |
||||
sql.append(StrUtil.repeat("?,", columnValueList.size())); |
||||
sql.setLength(sql.length() - 1); |
||||
sql.append(")"); |
||||
List<Serializable> columnValues = |
||||
columnValueList.stream().map(Serializable.class::cast).collect(Collectors.toList()); |
||||
ObjectSqlData objectSqlData = new ObjectSqlData(); |
||||
objectSqlData.setSql(sql.toString()); |
||||
objectSqlData.setDataList(columnValueList); |
||||
return objectSqlData; |
||||
} |
||||
|
||||
|
||||
private void makeupBillData(Map<String, Object> dataMap) { |
||||
dataMap.put("create_time", LocalDateTime.now()); |
||||
dataMap.put("create_user_id", TokenData.takeFromRequest().getUserId()); |
||||
} |
||||
|
||||
private InsertData makeColumnNames(Map<String, Object> data) { |
||||
InsertData insertData = new InsertData(); |
||||
StringBuilder sb = new StringBuilder(512); |
||||
for (String columnData : data.keySet()) { |
||||
sb.append(columnData).append(","); |
||||
insertData.getDataList().add(data.get(columnData)); |
||||
} |
||||
String columnNames = sb.substring(0, sb.length() - 1); |
||||
insertData.setColumnNames(columnNames); |
||||
return insertData; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* @param srcBillData 源单据数据 |
||||
* @param insertTableMap 目标元数据表,字段 |
||||
* @param convertConfig 规则配置 |
||||
* @return 目标单据数据 |
||||
*/ |
||||
private BtpTransformResult convertToDestBill(ObjectValue srcBillData, Map<String, MetaTable> insertTableMap, ConvertConfig convertConfig, ConvertRule convertRule) { |
||||
|
||||
BtpTransformResult btpTransformResult = initDestBillData(convertConfig, srcBillData, convertRule); |
||||
for (MetaColumn destMetaColumn : convertConfig.getColumnConfigMap().keySet()) { |
||||
ConvertColumnConfig convertColumnConfig = convertConfig.getColumnConfigMap().get(destMetaColumn); |
||||
new BotpMappingContext(convertColumnConfig.getValueMethod()).mapping(btpTransformResult.getBillDataList().getObject(0), destMetaColumn, convertColumnConfig, srcBillData); |
||||
} |
||||
|
||||
return btpTransformResult; |
||||
} |
||||
|
||||
/** |
||||
* 初始化目标数据 |
||||
* |
||||
* @param convertConfig 映射配置 |
||||
* @param srcBillData 源单数据 |
||||
* @return |
||||
*/ |
||||
private BtpTransformResult initDestBillData(ConvertConfig convertConfig, ObjectValue srcBillData, ConvertRule convertRule) { |
||||
try { |
||||
Set<String> destTableSet = new HashSet<>(); |
||||
Set<String> destEntryTableSet = new HashSet<>(); |
||||
String mainTableName = null; |
||||
String entryTableName = null;//源表只取一个分录
|
||||
for (MetaColumn destMetaColumn : convertConfig.getColumnConfigMap().keySet()) { |
||||
ConvertColumnConfig convertColumnConfig = convertConfig.getColumnConfigMap().get(destMetaColumn); |
||||
if (!destMetaColumn.isMain()) { |
||||
destTableSet.add(destMetaColumn.getMetaTable());//目标表表名集合
|
||||
if (convertColumnConfig.getColumnName() != null) {//源字段
|
||||
if (!convertColumnConfig.getTableName().equals(convertConfig.getSrcMetaTable().getTableName())) {//如果配置的不是源表表头,则记录
|
||||
destEntryTableSet.add(destMetaColumn.getMetaTable()); |
||||
} |
||||
} |
||||
entryTableName = convertColumnConfig.getTableName(); |
||||
} else { |
||||
mainTableName = convertColumnConfig.getTableName(); |
||||
} |
||||
} |
||||
ObjectValue destBillData = new ObjectValue(convertConfig.getDestMetaTable().getTableName()); |
||||
List<BillRelationEntry> billRelationEntryList = new ArrayList<>(); |
||||
ConvertColumnConfig convertColumnConfig = null; |
||||
Iterator<ConvertColumnConfig> iterator = convertConfig.getColumnConfigMap().values().iterator(); |
||||
while (iterator.hasNext()) { |
||||
convertColumnConfig = iterator.next(); |
||||
if (convertColumnConfig.getTableName() != null) { |
||||
break; |
||||
} |
||||
} |
||||
OnlFormHead srcOnlFormHead = onlFormHeadService.getHeadTableNameCache(convertColumnConfig.getTableName()); |
||||
// OnlFormHead srcOnlFormHead = onlFormHeadMapper.selectOne((QueryWrapper) (new QueryWrapper<>().eq("table_name", )));
|
||||
for (String tableName : destTableSet) { |
||||
if (destBillData.get(tableName) == null) { |
||||
ObjectCollection dataList = new ObjectCollection(); |
||||
if (destEntryTableSet.contains(tableName)) {//分录字段映射包含分录字段,分录初始化行数为源单分录行数
|
||||
ObjectCollection objectCollection = srcBillData.getObjectCollection(entryTableName); |
||||
for (int i = 0; i < objectCollection.size(); i++) { |
||||
OnlFormHead destOnlFormHead |
||||
= onlFormHeadMapper.selectOne((QueryWrapper) (new QueryWrapper<>().eq("table_name", tableName))); |
||||
ObjectValue entryData = new ObjectValue(tableName); |
||||
entryData.setLong(entryData.getPKField(), idGenerator.nextLongId()); |
||||
BillRelationEntry billRelationEntry = new BillRelationEntry(); |
||||
billRelationEntry.setId(idGenerator.nextLongId()); |
||||
billRelationEntry.setConvertRuleId(String.valueOf(convertRule.getId())); |
||||
billRelationEntry.setSourceEntryId(String.valueOf(objectCollection.getObject(i).get("id"))); |
||||
billRelationEntry.setSourceEntryNumber(String.valueOf(srcOnlFormHead.getId())); |
||||
billRelationEntry.setSourceId(String.valueOf(srcBillData.get("id"))); |
||||
billRelationEntry.setSourceNumber(convertRule.getSourceEntityId()); |
||||
billRelationEntry.setTargeEntryId(String.valueOf(entryData.get("id"))); |
||||
billRelationEntry.setTargetId(String.valueOf(destBillData.get("id"))); |
||||
billRelationEntry.setTargeEntryNumber(String.valueOf(destOnlFormHead.getId())); |
||||
billRelationEntry.setTargetNumber(convertRule.getTargetEntityId()); |
||||
billRelationEntry.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
billRelationEntry.setCreateTime(new Date()); |
||||
billRelationEntry.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
billRelationEntry.setUpdateTime(new Date()); |
||||
billRelationEntryList.add(billRelationEntry); |
||||
dataList.addObject(entryData); |
||||
} |
||||
} else { |
||||
ObjectValue entryData = new ObjectValue(tableName); |
||||
entryData.setLong(entryData.getPKField(), idGenerator.nextLongId()); |
||||
dataList.addObject(entryData); |
||||
} |
||||
destBillData.putObjectCollection(tableName, dataList); |
||||
} |
||||
} |
||||
BtpTransformResult btpTransformResult = new BtpTransformResult(); |
||||
btpTransformResult.getBillDataList().addObject(destBillData); |
||||
BillRelation billRelation = new BillRelation(); |
||||
billRelation.setId(idGenerator.nextLongId()); |
||||
billRelation.setConvertRuleId(String.valueOf(convertRule.getId())); |
||||
billRelation.setSourceId(String.valueOf(srcBillData.get("id"))); |
||||
billRelation.setSourceNumber(convertRule.getSourceEntityId()); |
||||
billRelation.setTargetId(String.valueOf(destBillData.get("id"))); |
||||
billRelation.setTargetNumber(convertRule.getTargetEntityId()); |
||||
billRelation.setBillRelationEntryList(billRelationEntryList); |
||||
billRelation.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
billRelation.setCreateTime(new Date()); |
||||
billRelation.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
billRelation.setUpdateTime(new Date()); |
||||
btpTransformResult.getBillRelationList().add(billRelation); |
||||
return btpTransformResult; |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
throw new RuntimeException(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询单据数据 |
||||
* |
||||
* @param selectTableMap |
||||
* @param id 单据id |
||||
* @return |
||||
*/ |
||||
private ObjectValue getBillData(Map<String, MetaTable> selectTableMap, String id) { |
||||
|
||||
Selector selector = new Selector(); |
||||
String vaName = null; |
||||
for (MetaTable metaTable : selectTableMap.values()) { |
||||
metaTable.getMetaColumnList().add(getPkColumn()); |
||||
for (int i = 0; i < metaTable.getMetaColumnList().size(); i++) { |
||||
MetaColumn metaColumn = metaTable.getMetaColumnList().get(i); |
||||
if (metaTable.isMain()) {//主表数据
|
||||
vaName = metaTable.getTableName(); |
||||
selector.getList().add(new SelectorItem(metaColumn.getColumnName())); |
||||
} else {//分录数据
|
||||
selector.getList().add(new SelectorItem(new StringBuilder(metaTable.getTableName()) |
||||
.append(".").append(metaColumn.getColumnName()).toString())); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
return ormGenDataSourceUtil.queryOne(vaName, Long.valueOf(id), selector);//TODO 未处理
|
||||
} |
||||
|
||||
|
||||
/** |
||||
* 查询单据集合 |
||||
* |
||||
* @param table 数据库表 |
||||
* @param selectFields 查询字段 |
||||
* @param id 单据id |
||||
* @return |
||||
*/ |
||||
public List<Map<String, Object>> getDataEntryCol(MetaTable table, String selectFields, String id) { |
||||
DataFilter dataFilter = new DataFilter(); |
||||
DataFilterItem dataFilterItem = new DataFilterItem("parent_id", FieldFilterType.EQUAL_FILTER, id); |
||||
dataFilter.getDataFilterItems().add(dataFilterItem); |
||||
List<Map<String, Object>> dataList = getList(table, selectFields, dataFilter); |
||||
return dataList; |
||||
} |
||||
|
||||
/** |
||||
* 查询单挑数据 |
||||
* |
||||
* @param table 查询元数据库表 |
||||
* @param selectFields 查询字段 |
||||
* @param id 单据id |
||||
* @return 数据集合 |
||||
*/ |
||||
private Map<String, Object> getData(MetaTable table, String selectFields, String id) { |
||||
|
||||
DataFilter dataFilter = new DataFilter(); |
||||
DataFilterItem dataFilterItem = new DataFilterItem("id", FieldFilterType.EQUAL_FILTER, id); |
||||
dataFilter.getDataFilterItems().add(dataFilterItem); |
||||
List<Map<String, Object>> dataList = getList(table, selectFields, dataFilter); |
||||
return dataList.size() == 0 ? null : dataList.get(0); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* @param table 表元数据 |
||||
* @param selectFields 查询字段 |
||||
* @param dataFilter 过滤 |
||||
* @return |
||||
*/ |
||||
private List<Map<String, Object>> getList(MetaTable table, String selectFields, DataFilter dataFilter) { |
||||
StringBuilder sql = new StringBuilder(512); |
||||
sql.append(DbUtil.SELECT).append(selectFields).append(DbUtil.FROM).append(table.getTableName()); |
||||
List<Object> paramList = new ArrayList<>(); |
||||
sql.append(dataFilter.getWhereClause(paramList)); |
||||
try { |
||||
List<Map<String, Object>> dataList = |
||||
dbUtil.query(sql.toString(), paramList); |
||||
return dataList; |
||||
} catch (Exception e) { |
||||
log.error(e.getMessage(), e); |
||||
throw new RuntimeException(e.getMessage()); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
private MetaColumn getPkColumn() { |
||||
|
||||
MetaColumn metaColumn = new MetaColumn(); |
||||
metaColumn.setColumnName("id"); |
||||
metaColumn.setColumnType("bigint"); |
||||
|
||||
return metaColumn; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 封装单据数据库表,字段 |
||||
* |
||||
* @param tableMap |
||||
* @param tableName |
||||
* @param columnName |
||||
*/ |
||||
private MetaColumn genMetaTable(Map<String, MetaTable> tableMap, String tableName, String columnName, OnlFormHead formHead) { |
||||
if (tableName == null) { |
||||
return null; |
||||
} |
||||
MetaTable metaTable = tableMap.get(tableName); |
||||
if (metaTable == null) { |
||||
metaTable = new MetaTable(); |
||||
// metaTable.setFormHeadId();
|
||||
metaTable.setTableName(tableName); |
||||
metaTable.setMetaColumnList(new ArrayList<>()); |
||||
if (tableName.equals(formHead.getTableName())) { |
||||
metaTable.setMain(true); |
||||
} else { |
||||
metaTable.setMain(false); |
||||
} |
||||
tableMap.put(tableName, metaTable); |
||||
} |
||||
|
||||
// TODO: 2024/1/24
|
||||
// metaColumn.setColumnType();
|
||||
MetaColumn metaColumn = new MetaColumn(); |
||||
if (tableName.equals(formHead.getTableName())) { |
||||
metaColumn.setMain(true); |
||||
} else { |
||||
metaColumn.setMain(false); |
||||
} |
||||
metaColumn.setMetaTable(metaTable.getTableName()); |
||||
metaColumn.setColumnName(columnName); |
||||
metaTable.getMetaColumnList().add(metaColumn); |
||||
return metaColumn; |
||||
} |
||||
|
||||
|
||||
private String makeSelectFields(MetaTable table) { |
||||
|
||||
DataSourceProvider provider = dbUtil.getDataSourceProvider(); |
||||
; |
||||
StringBuilder selectFieldBuider = new StringBuilder(512); |
||||
String intString = "SIGNED"; |
||||
if (provider.getDblinkType() == DblinkType.POSTGRESQL) { |
||||
intString = "INT8"; |
||||
} |
||||
// 拼装主表的select fields字段。
|
||||
for (MetaColumn column : table.getMetaColumnList()) { |
||||
|
||||
String columnAliasName = column.getColumnName(); |
||||
if (this.castToInteger(column)) { |
||||
selectFieldBuider |
||||
.append("CAST(") |
||||
.append(table.getTableName()) |
||||
.append(".") |
||||
.append(column.getColumnName()) |
||||
.append(" AS ") |
||||
.append(intString) |
||||
.append(") \"") |
||||
.append(columnAliasName) |
||||
.append("\","); |
||||
} else if ("date".equals(column.getColumnType())) { |
||||
selectFieldBuider |
||||
.append("CAST(") |
||||
.append(table.getTableName()) |
||||
.append(".") |
||||
.append(column.getColumnName()) |
||||
.append(" AS CHAR(10)) \"") |
||||
.append(columnAliasName) |
||||
.append("\","); |
||||
} else { |
||||
selectFieldBuider |
||||
.append(table.getTableName()) |
||||
.append(".") |
||||
.append(column.getColumnName()) |
||||
.append(" \"") |
||||
.append(columnAliasName) |
||||
.append("\","); |
||||
} |
||||
} |
||||
return selectFieldBuider.substring(0, selectFieldBuider.length() - 1); |
||||
} |
||||
|
||||
private boolean castToInteger(MetaColumn column) { |
||||
return "tinyint(1)".equals(column.getColumnType()); |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author sunquan |
||||
* @version 1.0 |
||||
* Create by 2024/1/23 19:20 |
||||
*/ |
||||
@Data |
||||
public class BillData { |
||||
|
||||
private Map<String,Object> headData; |
||||
|
||||
private Map<String,List<Map<String,Object>>> entryData; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/19 10:10 |
||||
*/ |
||||
@Data |
||||
public class BillRelation { |
||||
|
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "转换规则id") |
||||
private String convertRuleId; |
||||
|
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
@Schema(description = "源单id") |
||||
private String sourceId; |
||||
|
||||
@Schema(description = "目标单标识") |
||||
private String targetNumber; |
||||
|
||||
@Schema(description = "目标单id") |
||||
private String targetId; |
||||
|
||||
private Long createUserId; |
||||
|
||||
/** |
||||
* 创建时间。 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 更新者Id。 |
||||
*/ |
||||
private Long updateUserId; |
||||
|
||||
/** |
||||
* 更新时间。 |
||||
*/ |
||||
private Date updateTime; |
||||
|
||||
private List<BillRelationEntry> billRelationEntryList; |
||||
|
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/19 10:10 |
||||
*/ |
||||
@Data |
||||
public class BillRelationEntry { |
||||
|
||||
@Schema(description = "主键") |
||||
private Long id; |
||||
|
||||
@Schema(description = "转换规则id") |
||||
private String convertRuleId; |
||||
|
||||
@Schema(description = "源单标识") |
||||
private String sourceNumber; |
||||
|
||||
@Schema(description = "源单id") |
||||
private String sourceId; |
||||
|
||||
@Schema(description = "源单分录标识") |
||||
private String sourceEntryNumber; |
||||
|
||||
@Schema(description = "源单分录id") |
||||
private String sourceEntryId; |
||||
|
||||
@Schema(description = "目标单标识") |
||||
private String targetNumber; |
||||
|
||||
@Schema(description = "目标单id") |
||||
private String targetId; |
||||
|
||||
@Schema(description = "目标分录标识") |
||||
private String targeEntryNumber; |
||||
|
||||
@Schema(description = "目标分录id") |
||||
private String targeEntryId; |
||||
|
||||
private Long createUserId; |
||||
|
||||
/** |
||||
* 创建时间。 |
||||
*/ |
||||
private Date createTime; |
||||
|
||||
/** |
||||
* 更新者Id。 |
||||
*/ |
||||
private Long updateUserId; |
||||
|
||||
/** |
||||
* 更新时间。 |
||||
*/ |
||||
private Date updateTime; |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import apelet.common.core.object.ObjectCollection; |
||||
import lombok.Data; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/19 10:15 |
||||
* @description 转换结果 |
||||
*/ |
||||
@Data |
||||
public class BtpTransformResult { |
||||
|
||||
private ObjectCollection billDataList = new ObjectCollection(); |
||||
|
||||
private List<BillRelation> billRelationList = new ArrayList<>(); |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* @description |
||||
* Create by 2024/1/23 22:21 |
||||
*/ |
||||
@Data |
||||
public class ConvertColumnConfig { |
||||
|
||||
/** |
||||
* 表名 |
||||
*/ |
||||
private String tableName;//表名 源单
|
||||
|
||||
/** |
||||
* 字段名 |
||||
*/ |
||||
private String columnName;//字段名 源单
|
||||
|
||||
|
||||
/** |
||||
* 取值方式 |
||||
*/ |
||||
private int valueMethod;//1 源字段 2 目标字段
|
||||
|
||||
|
||||
/** |
||||
* 字段值 |
||||
*/ |
||||
private String value; |
||||
|
||||
/** |
||||
* 是否主表 |
||||
*/ |
||||
private boolean isMain; |
||||
|
||||
/** |
||||
* 计算公式 |
||||
*/ |
||||
private JSONObject calculationFormula; |
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author sunquan |
||||
* @version 1.0 |
||||
* @description 单据转换配置 |
||||
* Create by 2024/1/23 22:18 |
||||
*/ |
||||
@Data |
||||
public class ConvertConfig { |
||||
|
||||
/** |
||||
* key 目标字段 val 字段转换配置 |
||||
*/ |
||||
private Map<MetaColumn,ConvertColumnConfig> columnConfigMap ; |
||||
|
||||
/** |
||||
* 源元数据table |
||||
*/ |
||||
private MetaTable srcMetaTable; |
||||
|
||||
/** |
||||
* 目标元数据table |
||||
*/ |
||||
private MetaTable destMetaTable; |
||||
|
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
/** |
||||
* |
||||
* @author sunquan |
||||
* @version 1.0 |
||||
* Create by 2024/1/22 21:04 |
||||
*/ |
||||
@Data |
||||
public class MetaColumn { |
||||
|
||||
/** |
||||
* 字段名称 |
||||
*/ |
||||
private String columnName; |
||||
|
||||
/** |
||||
* 字段类型 |
||||
*/ |
||||
private String columnType; |
||||
|
||||
|
||||
/** |
||||
* 主表 |
||||
*/ |
||||
private String metaTable; |
||||
|
||||
public boolean isMain; |
||||
|
||||
|
||||
|
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hash(columnName, metaTable); |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) return true; |
||||
if (o == null || getClass() != o.getClass()) return false; |
||||
MetaColumn user = (MetaColumn) o; |
||||
return columnName.equals(user.columnName) && metaTable |
||||
.equals(user.getMetaTable()); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
package apelet.common.botp.service.execute.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* |
||||
* @author sunquan |
||||
* @version 1.0 |
||||
* Create by 2024/1/22 21:01 |
||||
*/ |
||||
@Data |
||||
public class MetaTable { |
||||
|
||||
/** |
||||
* 表单元数据id |
||||
*/ |
||||
private String formHeadId; |
||||
|
||||
/** |
||||
* 表单元数据表名 |
||||
*/ |
||||
private String tableName; |
||||
|
||||
/** |
||||
* 字段名 |
||||
*/ |
||||
private List<MetaColumn> metaColumnList; |
||||
|
||||
/** |
||||
* 是否为主表 |
||||
*/ |
||||
private boolean isMain; |
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
package apelet.common.botp.service.execute.mapping; |
||||
|
||||
import apelet.common.botp.service.execute.entity.ConvertColumnConfig; |
||||
import apelet.common.botp.service.execute.entity.MetaColumn; |
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
import apelet.common.core.util.ApplicationContextHolder; |
||||
import apelet.common.online.service.impl.OnlineFormServiceImpl; |
||||
import apelet.common.online.util.Jexl3Util; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 10:46 |
||||
*/ |
||||
public class BotpMappingCalculationFormulaMapping extends BotpMappingStrategy { |
||||
|
||||
private final OnlineFormServiceImpl onlineFormService = |
||||
ApplicationContextHolder.getBean(OnlineFormServiceImpl.class); |
||||
private final Jexl3Util Jexl3Util = |
||||
ApplicationContextHolder.getBean(Jexl3Util.class); |
||||
|
||||
|
||||
|
||||
@Override |
||||
public void mapping(ObjectValue destBillData, MetaColumn destMetaColumn, ConvertColumnConfig convertColumnConfig, ObjectValue srcBillData) { |
||||
ObjectCollection entryDataList = null; |
||||
if (!convertColumnConfig.isMain()) {//源表不为主表
|
||||
entryDataList = srcBillData.getObjectCollection(convertColumnConfig.getTableName()); |
||||
} |
||||
if (destMetaColumn.isMain()) {//目标字段为主表
|
||||
if (convertColumnConfig.getColumnName() != null) {//源
|
||||
if (convertColumnConfig.isMain()) {//源字段为主表
|
||||
JSONObject json = convertColumnConfig.getCalculationFormula(); |
||||
destBillData.put(destMetaColumn.getColumnName(), srcBillData.get(convertColumnConfig.getColumnName())); |
||||
|
||||
destBillData.put(destMetaColumn.getColumnName(), getValue(json, srcBillData)); |
||||
} else {//源字段为附表,取分录第一行
|
||||
if (entryDataList != null && !entryDataList.isEmpty()) { |
||||
destBillData.put(destMetaColumn.getColumnName(), entryDataList.getObject(0).get(convertColumnConfig.getColumnName())); |
||||
// List<Map<String,Object>> = destBillData.getEntryData().get(destMetaColumn.getMetaTable().getTableName());//获取目标分录
|
||||
} |
||||
} |
||||
} |
||||
} else {//目标字段为附表,对应附表分录
|
||||
if (convertColumnConfig.getColumnName() != null) {//源
|
||||
ObjectCollection listMap = destBillData.getObjectCollection(destMetaColumn.getMetaTable()); |
||||
for (int i = 0; i < listMap.size(); i++) { |
||||
if (convertColumnConfig.isMain()) {//源字段为主表,每行分录赋值源单表头字段
|
||||
listMap.getObject(i).put(destMetaColumn.getColumnName(), |
||||
srcBillData.get(convertColumnConfig.getColumnName())); |
||||
} else {//源字段为附表,每行分录赋值目标单字段
|
||||
listMap.getObject(i).put(destMetaColumn.getColumnName(), |
||||
entryDataList.getObject(i).get(convertColumnConfig.getColumnName())); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
Object getValue(JSONObject json, ObjectValue objectValue) { |
||||
String expression = json.getString("expressionTranslation"); |
||||
String fun = Jexl3Util.getMySplit("\\$(.*?)\\$", expression); |
||||
List<String> funParam = Arrays.asList(Jexl3Util.getMySplit("\\((.*?)\\)", fun).split(",")); |
||||
Object[] objects = Jexl3Util.getFunParam(funParam, objectValue); |
||||
return onlineFormService.executeFunction(json, fun, objects); |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
package apelet.common.botp.service.execute.mapping; |
||||
|
||||
import apelet.common.botp.service.execute.entity.ConvertColumnConfig; |
||||
import apelet.common.botp.service.execute.entity.MetaColumn; |
||||
import apelet.common.core.object.ObjectValue; |
||||
|
||||
/** |
||||
* 单据转换映射策略 |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 10:37 |
||||
*/ |
||||
public class BotpMappingContext { |
||||
|
||||
public static final int valueMethod_mapping = 1;//映射
|
||||
public static final int valueMethod_constant = 2;//常量
|
||||
public static final int valueMethod_expression = 3;//计算公式
|
||||
|
||||
|
||||
|
||||
|
||||
public BotpMappingStrategy botpMappingStrategy; |
||||
|
||||
|
||||
public BotpMappingContext(int valueMethod){ |
||||
|
||||
if(valueMethod == BotpMappingContext.valueMethod_mapping){ |
||||
botpMappingStrategy = new BotpMappingStrategyMapping(); |
||||
}else if(valueMethod == BotpMappingContext.valueMethod_constant){ |
||||
botpMappingStrategy = new BotpMappingStrategyConstant(); |
||||
}else if(valueMethod == BotpMappingContext.valueMethod_expression){ |
||||
botpMappingStrategy = new BotpMappingCalculationFormulaMapping(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void mapping(ObjectValue destBillData, MetaColumn destMetaColumn, ConvertColumnConfig convertColumnConfig, ObjectValue srcBillData){ |
||||
botpMappingStrategy.mapping(destBillData,destMetaColumn,convertColumnConfig,srcBillData); |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
package apelet.common.botp.service.execute.mapping; |
||||
|
||||
import apelet.common.botp.service.execute.entity.ConvertColumnConfig; |
||||
import apelet.common.botp.service.execute.entity.MetaColumn; |
||||
import apelet.common.core.object.ObjectValue; |
||||
|
||||
/** |
||||
* @author sunquan |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 10:40 |
||||
*/ |
||||
public abstract class BotpMappingStrategy { |
||||
|
||||
/** |
||||
* 映射转换 |
||||
*/ |
||||
public abstract void mapping(ObjectValue destBillData, MetaColumn destMetaColumn, ConvertColumnConfig convertColumnConfig, ObjectValue srcBillData); |
||||
|
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
package apelet.common.botp.service.execute.mapping; |
||||
|
||||
import apelet.common.botp.service.execute.entity.ConvertColumnConfig; |
||||
import apelet.common.botp.service.execute.entity.MetaColumn; |
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 10:47 |
||||
*/ |
||||
public class BotpMappingStrategyConstant extends BotpMappingStrategy{ |
||||
|
||||
@Override |
||||
public void mapping(ObjectValue destBillData, MetaColumn destMetaColumn, ConvertColumnConfig convertColumnConfig, ObjectValue srcBillData) { |
||||
if(destMetaColumn.isMain()){//目标字段为主表,直接赋值常量
|
||||
destBillData.put( |
||||
destMetaColumn.getColumnName(),convertColumnConfig.getValue()); |
||||
}else{//目标字段为附表,对应附表分录,赋值常量
|
||||
ObjectCollection listMap = destBillData.getObjectCollection(destMetaColumn.getMetaTable()); |
||||
for (int i = 0 ; i < listMap.size() ; i++){ |
||||
listMap.getObject(i).put(destMetaColumn.getColumnName(),convertColumnConfig.getValue()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
package apelet.common.botp.service.execute.mapping; |
||||
|
||||
import apelet.common.botp.service.execute.entity.ConvertColumnConfig; |
||||
import apelet.common.botp.service.execute.entity.MetaColumn; |
||||
import apelet.common.core.object.ObjectCollection; |
||||
import apelet.common.core.object.ObjectValue; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/1/25 10:46 |
||||
*/ |
||||
public class BotpMappingStrategyMapping extends BotpMappingStrategy{ |
||||
|
||||
@Override |
||||
public void mapping(ObjectValue destBillData, MetaColumn destMetaColumn, ConvertColumnConfig convertColumnConfig, ObjectValue srcBillData) { |
||||
ObjectCollection entryDataList = null; |
||||
if( !convertColumnConfig.isMain() ){//源表不为主表
|
||||
entryDataList = srcBillData.getObjectCollection(convertColumnConfig.getTableName()); |
||||
} |
||||
if(destMetaColumn.isMain()){//目标字段为主表
|
||||
if(convertColumnConfig.getColumnName() != null){//源
|
||||
if(convertColumnConfig.isMain()){//源字段为主表
|
||||
destBillData.put(destMetaColumn.getColumnName() |
||||
,srcBillData.get(convertColumnConfig.getColumnName())); |
||||
}else{//源字段为附表,取分录第一行
|
||||
if( entryDataList.size() > 0){ |
||||
if(entryDataList != null){ |
||||
destBillData.put(destMetaColumn.getColumnName(),entryDataList.getObject(0).get(convertColumnConfig.getColumnName())); |
||||
// List<Map<String,Object>> = destBillData.getEntryData().get(destMetaColumn.getMetaTable().getTableName());//获取目标分录
|
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
}else{//目标字段为附表,对应附表分录
|
||||
if(convertColumnConfig.getColumnName() != null) {//源
|
||||
ObjectCollection listMap = destBillData.getObjectCollection(destMetaColumn.getMetaTable()); |
||||
for (int i = 0 ; i < listMap.size() ; i++){ |
||||
if (convertColumnConfig.isMain()) {//源字段为主表,每行分录赋值源单表头字段
|
||||
listMap.getObject(i).put(destMetaColumn.getColumnName() |
||||
,srcBillData.get(convertColumnConfig.getColumnName())); |
||||
}else{//源字段为附表,每行分录赋值目标单字段
|
||||
listMap.getObject(i).put(destMetaColumn.getColumnName(),entryDataList.getObject(i).get(convertColumnConfig.getColumnName())); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,344 @@
@@ -0,0 +1,344 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.botp.model.ConvertRelation; |
||||
import apelet.common.botp.model.ConvertRelationEntry; |
||||
import apelet.common.botp.service.IBillBaseService; |
||||
import apelet.common.botp.service.IConvertRelationEntryService; |
||||
import apelet.common.botp.service.IConvertRelationService; |
||||
import apelet.common.core.annotation.RelationOneToMany; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.core.util.ApplicationContextHolder; |
||||
import apelet.common.core.util.MyModelUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import org.apache.commons.lang3.ObjectUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.ApplicationContext; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.io.Serializable; |
||||
import java.lang.reflect.Constructor; |
||||
import java.lang.reflect.Field; |
||||
import java.lang.reflect.Method; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/28 8:35 |
||||
*/ |
||||
@Service |
||||
public abstract class BillBaseService<M, K extends Serializable> |
||||
extends BaseService<M, K> implements IBillBaseService<M, K> { |
||||
|
||||
@Autowired |
||||
private IConvertRelationService convertRelationService; |
||||
@Autowired |
||||
private IConvertRelationEntryService convertRelationEntryService; |
||||
|
||||
@Override |
||||
protected BaseDaoMapper<M> mapper() { |
||||
return baseMapper; |
||||
} |
||||
|
||||
@Override |
||||
public Page<M> listBill(M m, MyOrderParam orderParam, MyPageParam pageParam, TraceParamDto traceParamDto) { |
||||
|
||||
|
||||
String orderBy = MyOrderParam.buildOrderBy(orderParam, m.getClass()); |
||||
LambdaQueryWrapper<M> queryWrapper = new LambdaQueryWrapper<>(m); |
||||
|
||||
if (StrUtil.isNotBlank(orderBy)) { |
||||
queryWrapper.last(" ORDER BY " + orderBy); |
||||
} |
||||
if (pageParam != null) { |
||||
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize()); |
||||
} |
||||
List<M> resultList = baseMapper.selectList(queryWrapper); |
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return (Page<M>) resultList; |
||||
} |
||||
|
||||
@Override |
||||
public void saveBill(M m, List<ConvertRelationDto> crDtoList) { |
||||
|
||||
try { |
||||
Long id = (Long) getGetMethod(m.getClass(),"id").invoke(m); |
||||
if(ObjectUtils.isEmpty(id)){ |
||||
getSetMethod(m.getClass().getSuperclass(),"createUserId").invoke(m, TokenData.takeFromRequest().getUserId()); |
||||
getSetMethod(m.getClass().getSuperclass(),"createTime").invoke(m, new Date()); |
||||
baseMapper.insert(m); |
||||
Method getMethod = this.getGetMethod(m.getClass(),"id"); |
||||
Long Id = (Long) getMethod.invoke(m); |
||||
this.saveEntry(m,Id); |
||||
}else { |
||||
M isExistObj = baseMapper.selectById(id); |
||||
//查询id是否对应数据 有 更新数据 无 插入数据
|
||||
if (ObjectUtils.isEmpty(isExistObj)) { |
||||
getSetMethod(m.getClass().getSuperclass(),"createUserId").invoke(m, TokenData.takeFromRequest().getUserId()); |
||||
getSetMethod(m.getClass().getSuperclass(),"createTime").invoke(m, new Date()); |
||||
baseMapper.insert(m); |
||||
this.saveEntry(m, id); |
||||
} else { |
||||
getSetMethod(m.getClass().getSuperclass(),"updateUserId").invoke(m, TokenData.takeFromRequest().getUserId()); |
||||
getSetMethod(m.getClass().getSuperclass(),"updateTime").invoke(m, new Date()); |
||||
baseMapper.updateById(m); |
||||
this.saveEntry(m, id); |
||||
} |
||||
} |
||||
|
||||
saveRelation(crDtoList); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void submitBill(String processDefinitionKey, M m, List<ConvertRelationDto> crDto) { |
||||
try { |
||||
//提交的 数据保存或更新
|
||||
this.saveBill(m, crDto); |
||||
//获取对应的id
|
||||
Long id = (Long) getGetMethod(m.getClass(),"id").invoke(m); |
||||
//获取对应service
|
||||
Object serviceImpl = getServiceImpl(m.getClass()); |
||||
Method startWithBusinessKeyMethod = serviceImpl.getClass().getMethod("startWithBusinessKey", String.class, Long.class); |
||||
if (StringUtils.isNotEmpty(processDefinitionKey)){ |
||||
//开启流程
|
||||
startWithBusinessKeyMethod.invoke(serviceImpl,processDefinitionKey,id); |
||||
} |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void submitBillKey(String processDefinitionKey, Long id) { |
||||
|
||||
try { |
||||
Object serviceImpl = getServiceImpl(this.modelClass); |
||||
Method startWithBusinessKeyMethod = serviceImpl.getClass().getMethod("startWithBusinessKey", String.class, Long.class); |
||||
if (StringUtils.isNotEmpty(processDefinitionKey)){ |
||||
//开启流程
|
||||
startWithBusinessKeyMethod.invoke(serviceImpl,processDefinitionKey,id); |
||||
} |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public M detailBill(K id) { |
||||
//查询单据
|
||||
M m = baseMapper.selectById(id); |
||||
if (ObjectUtils.isEmpty(m)){ |
||||
return null; |
||||
} |
||||
try { |
||||
Field[] fields = m.getClass().getDeclaredFields(); |
||||
for (Field field : fields) { |
||||
// 是否引用RelationOneToMany注解
|
||||
if (field.isAnnotationPresent(RelationOneToMany.class)) { |
||||
//获取分录实体class
|
||||
Class<?> entryClass = field.getAnnotation(RelationOneToMany.class).slaveModelClass(); |
||||
//获取对应service
|
||||
ServiceImpl serviceImpl = (ServiceImpl) getServiceImpl(entryClass); |
||||
// Method getListByFilterMethod = serviceImpl.getClass().getMethod("getListByFilter",entryClass);
|
||||
//构建对象
|
||||
Constructor<?> constructor = entryClass.getConstructor(); |
||||
Object o = constructor.newInstance(); |
||||
Method setParentIdMethod = getSetMethod(entryClass,"parentId"); |
||||
setParentIdMethod.invoke(o, id); |
||||
//通过 主表id 获取对应分录数据
|
||||
LambdaQueryWrapper<Object> queryWrapper = new LambdaQueryWrapper<>(o); |
||||
List list = serviceImpl.list(queryWrapper); |
||||
// List list = (List) getListByFilterMethod.invoke(serviceImpl, o);
|
||||
|
||||
Method setMethod = getSetMethod(m.getClass(), field.getName()); |
||||
setMethod.invoke(m,list); |
||||
} |
||||
|
||||
} |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
return m; |
||||
} |
||||
|
||||
@Override |
||||
public Integer removeBillById(String ids) { |
||||
String[] idsplit = ids.split(","); |
||||
for (String id : idsplit) { |
||||
//删除主表数据
|
||||
this.removeById(id); |
||||
try { |
||||
Field[] fields = this.entityClass.getClass().getDeclaredFields(); |
||||
for (Field field : fields) { |
||||
// 是否引用RelationOneToMany注解
|
||||
if (field.isAnnotationPresent(RelationOneToMany.class)) { |
||||
//获取分录实体class
|
||||
Class<?> entryClass = field.getAnnotation(RelationOneToMany.class).slaveModelClass(); |
||||
//获取对应service
|
||||
ServiceImpl serviceImpl = (ServiceImpl) getServiceImpl(entryClass); |
||||
Method removeByMethod = serviceImpl.getClass().getSuperclass().getMethod("removeBy", Serializable.class); |
||||
//构建对象
|
||||
Constructor<?> constructor = entryClass.getConstructor(); |
||||
Object o = constructor.newInstance(); |
||||
Method setParentIdMethod = getSetMethod(entryClass,"parentId"); |
||||
setParentIdMethod.invoke(o, ids); |
||||
//通过 主表id 删除对应分录数据
|
||||
removeByMethod.invoke(serviceImpl, o); |
||||
} |
||||
|
||||
} |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 保存分录 |
||||
* |
||||
* @param m |
||||
* @param parenId |
||||
* @throws Exception |
||||
*/ |
||||
public void saveEntry(M m, Long parenId) throws Exception { |
||||
Field[] fields = m.getClass().getDeclaredFields(); |
||||
for (Field field : fields) { |
||||
// 是否引用RelationOneToMany注解
|
||||
if (field.isAnnotationPresent(RelationOneToMany.class)) { |
||||
String fieldName = field.getName(); |
||||
//获取分录实体class
|
||||
Class<?> aClass = field.getAnnotation(RelationOneToMany.class).slaveModelClass(); |
||||
Method getMethod = this.getGetMethod(m.getClass(), fieldName); |
||||
Object object = getMethod.invoke(m); |
||||
if (object instanceof List) { |
||||
for (Object o : (List) object) { |
||||
Long Id = (Long) getGetMethod(aClass,"id").invoke(o); |
||||
if (ObjectUtils.isEmpty(Id)){ |
||||
getSetMethod(aClass.getSuperclass(),"createUserId").invoke(o, TokenData.takeFromRequest().getUserId()); |
||||
getSetMethod(aClass.getSuperclass(),"createTime").invoke(o, new Date()); |
||||
getSetMethod(aClass,"parentId").invoke(o, parenId); |
||||
ServiceImpl serviceImpl = (ServiceImpl) getServiceImpl(aClass); |
||||
serviceImpl.save(o); |
||||
}else { |
||||
//查询id是否对应数据 有 更新数据 无 插入数据
|
||||
ServiceImpl serviceImpl = (ServiceImpl) getServiceImpl(aClass); |
||||
Object isHaveObj = serviceImpl.getById(Id); |
||||
getSetMethod(aClass.getSuperclass(),"createUserId").invoke(o, TokenData.takeFromRequest().getUserId()); |
||||
getSetMethod(aClass.getSuperclass(),"createTime").invoke(o, new Date()); |
||||
getSetMethod(aClass,"parentId").invoke(o, parenId); |
||||
if (ObjectUtils.isNotEmpty(isHaveObj)) { |
||||
serviceImpl.updateById(o); |
||||
} else { |
||||
serviceImpl.save(o); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
/** |
||||
* 获取get方法 |
||||
* |
||||
* @param clazz |
||||
* @param fieldName |
||||
* @return |
||||
*/ |
||||
private Method getGetMethod(Class<?> clazz, String fieldName) { |
||||
Method method=null; |
||||
StringBuffer sb = new StringBuffer(); |
||||
sb.append("get"); |
||||
sb.append(fieldName.substring(0, 1).toUpperCase()); |
||||
sb.append(fieldName.substring(1)); |
||||
try { |
||||
method= clazz.getMethod(sb.toString()); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
return method; |
||||
} |
||||
|
||||
/** |
||||
* 获取set方法 |
||||
* |
||||
* @param clazz |
||||
* @param fieldName |
||||
* @return |
||||
*/ |
||||
private Method getSetMethod(Class<?> clazz, String fieldName) { |
||||
Method method=null; |
||||
try { |
||||
Class[] parameterTypes = new Class[1]; |
||||
Field field = clazz.getDeclaredField(fieldName); |
||||
parameterTypes[0] = field.getType(); |
||||
StringBuffer sb = new StringBuffer(); |
||||
sb.append("set"); |
||||
sb.append(fieldName.substring(0, 1).toUpperCase()); |
||||
sb.append(fieldName.substring(1)); |
||||
method = clazz.getMethod(sb.toString(), parameterTypes); |
||||
return method; |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 返回对应serviceImpl |
||||
* @param clazz |
||||
* @return |
||||
*/ |
||||
private static Object getServiceImpl(Class<?> clazz) { |
||||
ApplicationContext applicationContext = ApplicationContextHolder.getApplicationContext(); |
||||
String entityName = clazz.getSimpleName(); |
||||
String serviceName = entityName.substring(0, 1).toLowerCase() + entityName.substring(1)+"Service"; |
||||
return applicationContext.getBean(serviceName); |
||||
} |
||||
|
||||
private void saveRelation(List<ConvertRelationDto> crDto) { |
||||
if (crDto != null) { |
||||
List<ConvertRelation> convertRelationList = MyModelUtil.copyCollectionTo(crDto, ConvertRelation.class); |
||||
if (convertRelationList != null && convertRelationList.size() > 0) { |
||||
List<ConvertRelation> insertRelation = new ArrayList<>(); |
||||
for (ConvertRelation convertRelation : convertRelationList) { |
||||
if (!convertRelationService.existId(convertRelation.getId())) { |
||||
insertRelation.add(convertRelation); |
||||
} |
||||
} |
||||
if (insertRelation.size() > 0) { |
||||
convertRelationService.saveBatch(insertRelation); |
||||
} |
||||
|
||||
} |
||||
List<ConvertRelationEntryDto> convertRelationEntryDtoList = new ArrayList<>(); |
||||
for (ConvertRelationDto convertRelationDto : |
||||
crDto) { |
||||
for (ConvertRelationEntryDto convertRelationEntry |
||||
: convertRelationDto.getConvertRelationEntryDtoList()) { |
||||
if (!convertRelationEntryService.existId(convertRelationEntry.getId())) { |
||||
convertRelationEntryDtoList.add(convertRelationEntry); |
||||
} |
||||
} |
||||
} |
||||
List<ConvertRelationEntry> convertRelationEntries = MyModelUtil.copyCollectionTo(convertRelationEntryDtoList, ConvertRelationEntry.class); |
||||
if (convertRelationEntries.size() > 0) { |
||||
convertRelationEntryService.saveBatch(convertRelationEntries); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
|
||||
import apelet.common.botp.dao.ConvertFieldmappingEntryMapper; |
||||
import apelet.common.botp.model.ConvertFieldmappingEntry; |
||||
import apelet.common.botp.service.IConvertFieldmappingEntryService; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import apelet.common.core.object.MyRelationParam; |
||||
import apelet.common.generator.dao.OnlFormHeadMapper; |
||||
import apelet.common.generator.model.OnlFormHead; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Service |
||||
public class ConvertFieldmappingEntryServiceImpl extends BaseService<ConvertFieldmappingEntry,Long> implements IConvertFieldmappingEntryService { |
||||
@Autowired |
||||
private ConvertFieldmappingEntryMapper ConvertFieldmappingEntryMapper; |
||||
|
||||
@Autowired |
||||
private OnlFormHeadMapper onlFormHeadMapper; |
||||
|
||||
|
||||
@Override |
||||
protected BaseDaoMapper<ConvertFieldmappingEntry> mapper() { |
||||
return baseMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertFieldmappingEntry> getConvertFieldmappingEntryRelation(Long id) { |
||||
List<ConvertFieldmappingEntry> resultList = this.list(new LambdaQueryWrapper<ConvertFieldmappingEntry>().eq(ConvertFieldmappingEntry::getParentId, id)); |
||||
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertFieldmappingEntry> getConvertFieldmappingEntryListWithRelation(ConvertFieldmappingEntry convertFieldmappingEntry, String buildOrderBy) { |
||||
LambdaQueryWrapper<ConvertFieldmappingEntry> queryWrapper = new LambdaQueryWrapper<>(convertFieldmappingEntry); |
||||
if (StrUtil.isNotBlank(buildOrderBy)) { |
||||
queryWrapper.last(" ORDER BY " + buildOrderBy); |
||||
} |
||||
List<ConvertFieldmappingEntry> resultList = baseMapper.selectList(queryWrapper); |
||||
//处理返回数据
|
||||
for (int i = 0; i < resultList.size(); i++) { |
||||
ConvertFieldmappingEntry convertFieldmappingEntry1 = resultList.get(i); |
||||
//源单
|
||||
String parentId = convertFieldmappingEntry1.getParentId(); |
||||
OnlFormHead onlFormHeadBys = onlFormHeadMapper.selectById(parentId); |
||||
if (onlFormHeadBys!=null) { |
||||
String tableTxt = onlFormHeadBys.getTableTxt(); |
||||
Map<String, Object> sourceEntityIdMap = new HashMap<>(); |
||||
sourceEntityIdMap.put("parentId", parentId); |
||||
sourceEntityIdMap.put("parentName", tableTxt); |
||||
convertFieldmappingEntry1.setParentIdList(sourceEntityIdMap); |
||||
} |
||||
} |
||||
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
} |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.botp.dao.ConvertPluginEntryMapper; |
||||
import apelet.common.botp.model.ConvertPluginEntry; |
||||
import apelet.common.botp.service.IConvertPluginEntryService; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import apelet.common.core.object.MyRelationParam; |
||||
import apelet.common.generator.dao.OnlFormHeadMapper; |
||||
import apelet.common.generator.model.OnlFormHead; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Service |
||||
public class ConvertPluginEntryServiceImpl extends BaseService<ConvertPluginEntry,Long> implements IConvertPluginEntryService { |
||||
@Autowired |
||||
private ConvertPluginEntryMapper ConvertPluginEntryMapper; |
||||
|
||||
@Autowired |
||||
private OnlFormHeadMapper onlFormHeadMapper; |
||||
|
||||
|
||||
@Override |
||||
protected BaseDaoMapper<ConvertPluginEntry> mapper() { |
||||
return baseMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertPluginEntry> getConvertPluginEntryRelation(Long id) { |
||||
List<ConvertPluginEntry> resultList = this.list(new LambdaQueryWrapper<ConvertPluginEntry>().eq(ConvertPluginEntry::getParentId, id)); |
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public List<ConvertPluginEntry> getConvertPluginEntryListWithRelation(ConvertPluginEntry convertPluginEntryFilter, String buildOrderBy) { |
||||
LambdaQueryWrapper<ConvertPluginEntry> queryWrapper = new LambdaQueryWrapper<>(convertPluginEntryFilter); |
||||
if (StrUtil.isNotBlank(buildOrderBy)) { |
||||
queryWrapper.last(" ORDER BY " + buildOrderBy); |
||||
} |
||||
List<ConvertPluginEntry> resultList = baseMapper.selectList(queryWrapper); |
||||
//处理返回数据
|
||||
for (int i = 0; i < resultList.size(); i++) { |
||||
ConvertPluginEntry convertPluginEntry = resultList.get(i); |
||||
//源单
|
||||
String parentId = convertPluginEntry.getParentId(); |
||||
OnlFormHead onlFormHeadBys = onlFormHeadMapper.selectById(parentId); |
||||
if (onlFormHeadBys!=null) { |
||||
String tableTxt = onlFormHeadBys.getTableTxt(); |
||||
Map<String, Object> sourceEntityIdMap = new HashMap<>(); |
||||
sourceEntityIdMap.put("parentId", parentId); |
||||
sourceEntityIdMap.put("parentName", tableTxt); |
||||
convertPluginEntry.setParentIdList(sourceEntityIdMap); |
||||
} |
||||
} |
||||
|
||||
|
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
} |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.botp.dao.ConvertRelationEntryMapper; |
||||
import apelet.common.botp.model.ConvertRelationEntry; |
||||
import apelet.common.botp.service.IConvertRelationEntryService; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import apelet.common.core.object.MyRelationParam; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Service |
||||
public class ConvertRelationEntryServiceImpl extends BaseService<ConvertRelationEntry,Long> implements IConvertRelationEntryService { |
||||
@Autowired |
||||
private ConvertRelationEntryMapper ConvertRelationEntryMapper; |
||||
|
||||
@Override |
||||
public Boolean removeAllById(Long id) { |
||||
boolean remove = this.removeById(id); |
||||
return remove; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean editAll(ConvertRelationEntry convertRelationEntry) { |
||||
Long id = convertRelationEntry.getId(); |
||||
if (null==id)return false; |
||||
//设置主数据基本信息
|
||||
boolean update = this.updateById(convertRelationEntry); |
||||
//设置分录数据基本信息,重新添加
|
||||
return update; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean addAll(ConvertRelationEntry convertRelationEntry) { |
||||
//设置主数据基本信息
|
||||
boolean save = this.save(convertRelationEntry); |
||||
Long id = convertRelationEntry.getId(); |
||||
if (null==id){ |
||||
return false; |
||||
} |
||||
//设置分录数据基本信息,添加
|
||||
return save; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertRelationEntry> getConvertRuleListWithRelation(ConvertRelationEntry convertRelationEntryFilter, String buildOrderBy) { |
||||
LambdaQueryWrapper<ConvertRelationEntry> queryWrapper = new LambdaQueryWrapper<>(convertRelationEntryFilter); |
||||
if (StrUtil.isNotBlank(buildOrderBy)) { |
||||
queryWrapper.last(" ORDER BY " + buildOrderBy); |
||||
} |
||||
List<ConvertRelationEntry> resultList = baseMapper.selectList(queryWrapper); |
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
|
||||
@Override |
||||
protected BaseDaoMapper<ConvertRelationEntry> mapper() { |
||||
return baseMapper; |
||||
} |
||||
} |
||||
@ -0,0 +1,184 @@
@@ -0,0 +1,184 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.botp.dao.ConvertRelationMapper; |
||||
import apelet.common.botp.model.ConvertRelation; |
||||
import apelet.common.botp.model.GetSearchList; |
||||
import apelet.common.botp.model.SysMenuqq; |
||||
import apelet.common.botp.service.IConvertRelationService; |
||||
import apelet.common.botp.service.ISysMenuqqService; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import apelet.common.core.object.MyRelationParam; |
||||
import apelet.common.online.dao.OnlineFormMapper; |
||||
import apelet.common.online.model.OnlineForm; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Service |
||||
public class ConvertRelationServiceImpl extends BaseService<ConvertRelation, Long> implements IConvertRelationService { |
||||
@Autowired |
||||
private ConvertRelationMapper convertRelationMapper; |
||||
@Autowired |
||||
private OnlineFormMapper onlineFormMapper; |
||||
|
||||
@Override |
||||
public Boolean removeAllById(Long id) { |
||||
boolean remove = this.removeById(id); |
||||
return remove; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean editAll(ConvertRelation convertRelation) { |
||||
Long id = convertRelation.getId(); |
||||
if (null == id) return false; |
||||
//设置主数据基本信息
|
||||
boolean update = this.updateById(convertRelation); |
||||
//设置分录数据基本信息,重新添加
|
||||
return update; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean addAll(ConvertRelation convertRelation) { |
||||
//设置主数据基本信息
|
||||
boolean save = this.save(convertRelation); |
||||
Long id = convertRelation.getId(); |
||||
if (null == id) { |
||||
return false; |
||||
} |
||||
//设置分录数据基本信息,添加
|
||||
return save; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertRelation> getConvertRuleListWithRelation(ConvertRelation convertRelationFilter, String buildOrderBy) { |
||||
LambdaQueryWrapper<ConvertRelation> queryWrapper = new LambdaQueryWrapper<>(convertRelationFilter); |
||||
if (StrUtil.isNotBlank(buildOrderBy)) { |
||||
queryWrapper.last(" ORDER BY " + buildOrderBy); |
||||
} |
||||
List<ConvertRelation> resultList = baseMapper.selectList(queryWrapper); |
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertRelation> transform(String botpId, String srcBill, String destBill, String srcBillId) { |
||||
List<ConvertRelation> transformList = convertRelationMapper.transform(botpId, srcBill, destBill, srcBillId); |
||||
return transformList; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertRelation> transformT(String botpId, String srcBill, String destBill, List<String> srcBillList) { |
||||
List<ConvertRelation> convertRelations = convertRelationMapper.transformT(botpId, srcBill, destBill, srcBillList); |
||||
return convertRelations; |
||||
} |
||||
|
||||
@Autowired |
||||
private ISysMenuqqService sysMenuqqService; |
||||
@Override |
||||
public List<Map<String, Object>> getConvertRelation(String billId, String billType, String searchType) { |
||||
List<GetSearchList> GetSearchList = new ArrayList<>(); |
||||
List<Map<String, Object>> GetSearchListNew = new ArrayList<>(); |
||||
|
||||
if ("1".equals(searchType)) { |
||||
GetSearchList = convertRelationMapper.getConvertRelationOn(billId, billType); |
||||
for (GetSearchList getSearchList : GetSearchList) { |
||||
//通过id查询zz_online_form表数据
|
||||
Long upListInterface = getSearchList.getUpListInterface(); |
||||
|
||||
Map<String, Object> upListInterfaceMap = new HashMap<>(); |
||||
|
||||
String upInterfaceType = getSearchList.getUpInterfaceType(); |
||||
|
||||
upListInterfaceMap.put("billTypeName",null); |
||||
upListInterfaceMap.put("billListUI",null); |
||||
if ("1".equals(upInterfaceType)) { |
||||
SysMenuqq sysMenu = sysMenuqqService.getOne(new LambdaQueryWrapper<SysMenuqq>().eq(SysMenuqq::getMenuId, getSearchList.getUpRouteInterface())); |
||||
if (sysMenu != null){ |
||||
//单据名称--
|
||||
upListInterfaceMap.put("billTypeName", sysMenu.getMenuName()); |
||||
//菜单管理路劲
|
||||
upListInterfaceMap.put("billListUI", sysMenu.getFormRouterName()); |
||||
} |
||||
//单据标识--类型1:路由,2:在线表单
|
||||
upListInterfaceMap.put("billType", "1"); |
||||
|
||||
//界面类型
|
||||
upListInterfaceMap.put("upInterfaceType", "路由表单"); |
||||
GetSearchListNew.add(upListInterfaceMap); |
||||
} else if ("2".equals(upInterfaceType)) { |
||||
OnlineForm onlineForm = onlineFormMapper.selectById(upListInterface); |
||||
//单据标识--类型1:路由,2:在线表单
|
||||
upListInterfaceMap.put("billType", "2"); |
||||
if (onlineForm != null){ |
||||
upListInterfaceMap.put("billTypeName", onlineForm.getFormName()); |
||||
} |
||||
Long formId = onlineForm.getFormId(); |
||||
//界面类型
|
||||
upListInterfaceMap.put("upInterfaceType", "在线表单"); |
||||
//菜单管理路劲
|
||||
upListInterfaceMap.put("billListUI", formId); |
||||
GetSearchListNew.add(upListInterfaceMap); |
||||
} |
||||
} |
||||
} else if ("2".equals(searchType)) { |
||||
GetSearchList = convertRelationMapper.getConvertRelationDown(billId, billType); |
||||
for (GetSearchList getSearchList : GetSearchList) { |
||||
//通过id查询zz_online_form表数据
|
||||
Long downListInterface = getSearchList.getDownListInterface(); |
||||
|
||||
Map<String, Object> downListInterfaceMap = new HashMap<>(); |
||||
|
||||
//单据名称
|
||||
downListInterfaceMap.put("billTypeName", null); |
||||
//菜单管理路劲
|
||||
downListInterfaceMap.put("billListUI", null); |
||||
String downInterfaceType = getSearchList.getDownInterfaceType(); |
||||
if ("1".equals(downInterfaceType)) { |
||||
//单据类型
|
||||
downListInterfaceMap.put("billType", "1"); |
||||
SysMenuqq sysMenu = sysMenuqqService.getOne(new LambdaQueryWrapper<SysMenuqq>().eq(SysMenuqq::getMenuId, getSearchList.getDownRouteInterface())); |
||||
if (sysMenu != null){ |
||||
//路由
|
||||
downListInterfaceMap.put("billListUI", sysMenu.getFormRouterName()); |
||||
//单据名称
|
||||
downListInterfaceMap.put("billTypeName", sysMenu.getMenuName()); |
||||
} |
||||
|
||||
//界面类型
|
||||
downListInterfaceMap.put("upInterfaceType", "路由表单"); |
||||
GetSearchListNew.add(downListInterfaceMap); |
||||
} else if ("2".equals(downInterfaceType)) { |
||||
//单据类型
|
||||
downListInterfaceMap.put("billType", "2"); |
||||
OnlineForm onlineForm = onlineFormMapper.selectById(downListInterface); |
||||
Long formId = onlineForm.getFormId(); |
||||
//界面类型
|
||||
downListInterfaceMap.put("upInterfaceType", "在线表单"); |
||||
if (onlineForm != null){ |
||||
//菜单管理路劲
|
||||
downListInterfaceMap.put("billListUI", formId); |
||||
//单据名称
|
||||
downListInterfaceMap.put("billTypeName", onlineForm.getFormName()); |
||||
} |
||||
GetSearchListNew.add(downListInterfaceMap); |
||||
} |
||||
} |
||||
} |
||||
return GetSearchListNew; |
||||
} |
||||
|
||||
@Override |
||||
protected BaseDaoMapper<ConvertRelation> mapper() { |
||||
return baseMapper; |
||||
} |
||||
} |
||||
@ -0,0 +1,529 @@
@@ -0,0 +1,529 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.botp.dao.ConvertFieldmappingEntryMapper; |
||||
import apelet.common.botp.dao.ConvertPluginEntryMapper; |
||||
import apelet.common.botp.dao.ConvertRuleMapper; |
||||
import apelet.common.botp.dto.*; |
||||
import apelet.common.botp.model.*; |
||||
import apelet.common.botp.service.*; |
||||
import apelet.common.botp.service.execute.BotpService; |
||||
import apelet.common.botp.service.execute.entity.BillData; |
||||
import apelet.common.botp.service.execute.entity.BtpTransformResult; |
||||
import apelet.common.botp.util.Constant; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import apelet.common.core.constant.GlobalDeletedFlag; |
||||
import apelet.common.core.object.*; |
||||
import apelet.common.generator.dao.OnlFormHeadMapper; |
||||
import apelet.common.generator.model.OnlFormField; |
||||
import apelet.common.generator.model.OnlFormHead; |
||||
import apelet.common.generator.service.IOnlFormHeadService; |
||||
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
||||
import apelet.common.online.dao.OnlineFormMapper; |
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import jodd.util.StringUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.jetbrains.annotations.NotNull; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Service |
||||
@Slf4j |
||||
public class ConvertRuleServiceImpl extends BaseService<ConvertRule,Long> implements IConvertRuleService { |
||||
|
||||
@Autowired |
||||
private ConvertRuleMapper convertRuleMapper; |
||||
@Autowired |
||||
private IConvertRelationService convertRelationService; |
||||
@Autowired |
||||
private IConvertRelationEntryService convertRelationEntryService; |
||||
@Autowired |
||||
private IConvertFieldmappingEntryService convertFieldmappingEntryService; |
||||
@Autowired |
||||
private IConvertPluginEntryService convertPluginEntryService; |
||||
|
||||
@Autowired |
||||
private ConvertFieldmappingEntryMapper convertFieldmappingEntryMapper; |
||||
|
||||
@Autowired |
||||
private ConvertPluginEntryMapper convertPluginEntryMapper; |
||||
|
||||
@Autowired |
||||
private OnlFormHeadMapper onlFormHeadMapper; |
||||
|
||||
@Autowired |
||||
private OnlineFormMapper onlineFormMapper; |
||||
|
||||
@Autowired |
||||
private OrmGenDataSourceUtil ormGenDataSourceUtil; |
||||
@Autowired |
||||
private BotpService botpService; |
||||
|
||||
@Override |
||||
public List<ConvertRule> selectAll(String id) { |
||||
return null; |
||||
} |
||||
@Override |
||||
protected BaseDaoMapper<ConvertRule> mapper() { |
||||
return baseMapper; |
||||
} |
||||
|
||||
@Override |
||||
public List<AllField> allField(String tableName) { |
||||
List<AllField> allFieldList = convertRuleMapper.allField(tableName); |
||||
return allFieldList; |
||||
} |
||||
|
||||
|
||||
|
||||
@Override |
||||
public Boolean removeAllById(Long id) { |
||||
boolean remove = this.removeById(id); |
||||
//有分录情况删除
|
||||
if (remove){ |
||||
removeChild(id); |
||||
} |
||||
return remove; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean editAll(ConvertRule convertRule) { |
||||
Long id = convertRule.getId(); |
||||
if (null==id){ |
||||
return false; |
||||
} |
||||
//设置主数据基本信息
|
||||
addOrUpdateBaseData(convertRule,null); |
||||
boolean update = this.updateById(convertRule); |
||||
//删除分录数据
|
||||
removeChild(id); |
||||
//设置分录数据基本信息,重新添加
|
||||
return addChild(convertRule,id); |
||||
} |
||||
|
||||
@Override |
||||
public Boolean addAll(ConvertRule convertRule) { |
||||
//设置主数据基本信息
|
||||
addOrUpdateBaseData(convertRule,null); |
||||
boolean save = this.save(convertRule); |
||||
Long id = convertRule.getId(); |
||||
if (null==id){ |
||||
return false; |
||||
} |
||||
//设置分录数据基本信息,添加
|
||||
return addChild(convertRule,id); |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertRule> getConvertRuleListWithRelation(ConvertRule convertRuleFilter, String buildOrderBy) { |
||||
LambdaQueryWrapper<ConvertRule> queryWrapper = new LambdaQueryWrapper<>(convertRuleFilter); |
||||
if (StrUtil.isNotBlank(buildOrderBy)) { |
||||
queryWrapper.last(" ORDER BY " + buildOrderBy); |
||||
} |
||||
List<ConvertRule> resultList = baseMapper.selectList(queryWrapper); |
||||
//处理返回数据
|
||||
for (int i = 0; i < resultList.size(); i++) { |
||||
ConvertRule convertRule = resultList.get(i); |
||||
//源单
|
||||
String sourceEntityId = convertRule.getSourceEntityId(); |
||||
OnlFormHead onlFormHeadBys = onlFormHeadMapper.selectById(sourceEntityId); |
||||
if (onlFormHeadBys!=null) { |
||||
String tableTxt = onlFormHeadBys.getTableTxt(); |
||||
Map<String, Object> sourceEntityIdMap = new HashMap<>(); |
||||
sourceEntityIdMap.put("sourceEntityId", sourceEntityId); |
||||
sourceEntityIdMap.put("sourceEntityName", tableTxt); |
||||
convertRule.setSourceEntityIdList(sourceEntityIdMap); |
||||
} |
||||
|
||||
//目标单
|
||||
String targetEntityId = convertRule.getTargetEntityId(); |
||||
OnlFormHead onlFormHeadByt = onlFormHeadMapper.selectById(targetEntityId); |
||||
if (onlFormHeadByt!=null) { |
||||
String tableTxt2 = onlFormHeadByt.getTableTxt(); |
||||
Map<String, Object> targetEntityIdMap = new HashMap<>(); |
||||
targetEntityIdMap.put("targetEntityId", targetEntityId); |
||||
targetEntityIdMap.put("targetEntityName", tableTxt2); |
||||
convertRule.setTargetEntityIdList(targetEntityIdMap); |
||||
} |
||||
|
||||
} |
||||
int batchSize = resultList instanceof Page ? 0 : 1000; |
||||
this.buildRelationForDataList(resultList, MyRelationParam.normal(), batchSize); |
||||
return resultList; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertPluginEntry> getConvertPluginEntry(Long id) { |
||||
return convertPluginEntryService.getConvertPluginEntryRelation(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertFieldmappingEntry> getConvertFieldmappingEntry(Long id) { |
||||
return convertFieldmappingEntryService.getConvertFieldmappingEntryRelation(id); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 添加子数据方法 |
||||
*/ |
||||
private Boolean addChild(ConvertRule convertRule,Long id){ |
||||
List<ConvertPluginEntry> child1 = convertRule.getConvertPluginEntryList(); |
||||
if (ObjectUtil.isNotEmpty(child1)){ |
||||
for (ConvertPluginEntry one : child1) { |
||||
addOrUpdateBaseData(one,id); |
||||
convertPluginEntryMapper.insert(one); |
||||
} |
||||
} |
||||
List<ConvertFieldmappingEntry> child2 = convertRule.getConvertFieldmappingEntry(); |
||||
if (ObjectUtil.isNotEmpty(child2)){ |
||||
for (ConvertFieldmappingEntry one : child2) { |
||||
addOrUpdateBaseData(one,id); |
||||
convertFieldmappingEntryMapper.insert(one); |
||||
|
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
|
||||
private void removeChild(Long id){ |
||||
convertPluginEntryService.remove(new LambdaQueryWrapper<ConvertPluginEntry>().eq(ConvertPluginEntry::getParentId,id)); |
||||
convertFieldmappingEntryService.remove(new LambdaQueryWrapper<ConvertFieldmappingEntry>().eq(ConvertFieldmappingEntry::getParentId,id)); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override |
||||
public TransformResultDto transform(String botpId, String srcBill, String destBill, String srcBillId) { |
||||
|
||||
Set<String> srcBillList = new HashSet<>(); |
||||
srcBillList.add(srcBillId); |
||||
|
||||
return transform(botpId,srcBill,destBill,srcBillList); |
||||
} |
||||
|
||||
@Override |
||||
public TransformResultDto transform(String botpId, String srcBill, String destBill, Set<String> srcBillList) { |
||||
ConvertRule convertRule = convertRuleMapper.selectById(botpId);//查询转换规则
|
||||
//查询转换规则字段映射
|
||||
List<ConvertFieldmappingEntry> convertFieldmappingEntryList = convertFieldmappingEntryMapper.selectList( |
||||
new LambdaQueryWrapper<ConvertFieldmappingEntry>() |
||||
.eq(ConvertFieldmappingEntry::getParentId, convertRule.getId())); |
||||
List<ConvertPluginEntry> convertPluginEntryList = convertPluginEntryMapper.selectList( |
||||
new LambdaQueryWrapper<ConvertPluginEntry>() |
||||
.eq(ConvertPluginEntry::getEnable, "true") |
||||
.eq(ConvertPluginEntry::getParentId, convertRule.getId())); |
||||
OnlFormHead srcFormHead = onlFormHeadMapper.selectById(convertRule.getSourceEntityId());//源单元数据
|
||||
OnlFormHead destFormHead = onlFormHeadMapper.selectById(convertRule.getTargetEntityId());//目标单元数据
|
||||
BtpTransformResult btpTransformResult = botpService.transform( |
||||
convertRule, convertFieldmappingEntryList, convertPluginEntryList, srcFormHead, destFormHead, srcBillList); |
||||
TransformResultDto transformResultDto = new TransformResultDto(); |
||||
ObjectValue objectValue = btpTransformResult.getBillDataList().getObject(0); |
||||
transformResultDto.setBillData(convertOvToBillData(objectValue)); |
||||
if (convertRule.getAutoSave().equals("1")) {//自动保存
|
||||
transformResultDto.setFormStatus(Constant.FormStatus_AddNew); |
||||
} else { |
||||
transformResultDto.setFormStatus(Constant.FormStatus_Save); |
||||
} |
||||
transformResultDto.setFormType(convertRule.getDownInterfaceType()); |
||||
if (transformResultDto.getFormType().equals(Constant.InterfaceType_ROUTE)) { |
||||
toCamelCase(transformResultDto.getBillData()); |
||||
} |
||||
return transformResultDto; |
||||
} |
||||
|
||||
private BillData convertOvToBillData(ObjectValue objectValue){ |
||||
|
||||
BillData billData = new BillData(); |
||||
Map<String,Object> headData = new HashMap<>(); |
||||
Map<String,List<Map<String,Object>>> entryDataCol = new HashMap<>(); |
||||
if(objectValue.size() > 0){ |
||||
Iterator it = objectValue.getValues().keySet().iterator(); |
||||
while (it.hasNext()){ |
||||
String fieldKey = (String)it.next(); |
||||
if(objectValue.get(fieldKey) == null){ |
||||
continue; |
||||
} |
||||
if(objectValue.get(fieldKey) instanceof ObjectCollection){ |
||||
ObjectCollection objectCollection = objectValue.getObjectCollection(fieldKey); |
||||
List<Map<String,Object>> entryList = new ArrayList<>(); |
||||
Map<String,Object> entryMap = new HashMap<>(); |
||||
for(int i = 0; i < objectCollection.size() ; i++){ |
||||
ObjectValue entryValue = objectCollection.getObject(i); |
||||
Iterator entryIt = entryValue.getValues().keySet().iterator(); |
||||
while(entryIt.hasNext()){ |
||||
String entryFiledKey = (String)entryIt.next(); |
||||
if(entryValue.get(entryFiledKey) instanceof ObjectValue ){ |
||||
ObjectValue entityValue = (ObjectValue)entryValue.get(entryFiledKey); |
||||
Long pk = entityValue.getPkValue(); |
||||
if(pk == null || pk == 0L){ |
||||
continue; |
||||
} |
||||
entityValue = ormGenDataSourceUtil.queryOne(entityValue.getTableName(),pk); |
||||
if(entityValue == null){ |
||||
continue; |
||||
} |
||||
entryMap.put(entryFiledKey,entityValue.get("id")); |
||||
entryMap.put(entryFiledKey+"_",entityValue.getValues()); |
||||
}else{ |
||||
entryMap.put(entryFiledKey,entryValue.get(entryFiledKey)); |
||||
} |
||||
} |
||||
entryList.add(entryMap); |
||||
} |
||||
entryDataCol.put(fieldKey,entryList); |
||||
}else if(objectValue.get(fieldKey) instanceof ObjectValue){ |
||||
ObjectValue entityValue = (ObjectValue)objectValue.get(fieldKey); |
||||
Long pk = entityValue.getPkValue(); |
||||
if(pk == null || pk == 0L){ |
||||
continue; |
||||
} |
||||
entityValue = ormGenDataSourceUtil.queryOne(entityValue.getTableName(),pk); |
||||
if(entityValue == null){ |
||||
continue; |
||||
} |
||||
headData.put(fieldKey,entityValue.get("id")); |
||||
headData.put(fieldKey+"_",entityValue.getValues()); |
||||
}else{ |
||||
headData.put(fieldKey,objectValue.get(fieldKey)); |
||||
} |
||||
} |
||||
} |
||||
billData.setHeadData(headData); |
||||
billData.setEntryData(entryDataCol); |
||||
|
||||
return billData; |
||||
} |
||||
|
||||
/** |
||||
* 数据集合的键值,转换成驼峰形式 |
||||
* @param billData 数据集 |
||||
*/ |
||||
private void toCamelCase(BillData billData){ |
||||
|
||||
billData.setHeadData(toCamelCase(billData.getHeadData())); |
||||
Map<String,List<Map<String,Object>>> entryData = billData.getEntryData(); |
||||
for (String key:entryData.keySet()){ |
||||
List<Map<String,Object>> dataList = new ArrayList<>(); |
||||
for(Map<String,Object> datamap:entryData.get(key)){ |
||||
dataList.add(toCamelCase(datamap)); |
||||
} |
||||
entryData.put(key,dataList); |
||||
} |
||||
billData.setEntryData(toCamelCase(entryData)); |
||||
|
||||
|
||||
} |
||||
|
||||
private Map toCamelCase(Map dataMap){ |
||||
|
||||
Map aftTransformData = new HashMap<>(); |
||||
Iterator<String> iterator = dataMap.keySet().iterator(); |
||||
while (iterator.hasNext()){ |
||||
String key = iterator.next(); |
||||
aftTransformData.put(StrUtil.toCamelCase(key),dataMap.get(key)); |
||||
} |
||||
return aftTransformData; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public boolean removeAllRelation(ConvertRelationDelDto dto) { |
||||
//删除单据关联关系-主表-> 转换规则id等于billId And (源单标识等于billtype或者目标单标识等于billtype)
|
||||
boolean removeMain = convertRelationService.remove(new LambdaQueryWrapper<ConvertRelation>() |
||||
.eq(ConvertRelation::getConvertRuleId, dto.getBillId()) |
||||
.nested(r -> r.eq(ConvertRelation::getSourceNumber, dto.getBillType()) |
||||
.or().eq(ConvertRelation::getTargetNumber, dto.getBillType()))); |
||||
if (!removeMain) { |
||||
return false; |
||||
} |
||||
//删除分录表
|
||||
boolean removeEntry = convertRelationEntryService.remove(new LambdaQueryWrapper<ConvertRelationEntry>() |
||||
.eq(ConvertRelationEntry::getConvertRuleId, dto.getBillId()) |
||||
.nested(r -> r.eq(ConvertRelationEntry::getSourceNumber, dto.getBillType()) |
||||
.or().eq(ConvertRelationEntry::getTargetNumber, dto.getBillType()) |
||||
) |
||||
); |
||||
if (!removeEntry) { |
||||
return false; |
||||
} |
||||
//删除字段映射表
|
||||
boolean removeEntryField = convertFieldmappingEntryService.remove(new LambdaQueryWrapper<ConvertFieldmappingEntry>() |
||||
.eq(ConvertFieldmappingEntry::getParentId, dto.getBillId())); |
||||
return removeEntryField; |
||||
} |
||||
|
||||
@Override |
||||
public List<ConvertRelation> selectAllRelationByTarget(ConvertRelationListDto dto) { |
||||
return convertRelationService.list(new LambdaQueryWrapper<ConvertRelation>() |
||||
.eq(ConvertRelation::getTargetId, dto.getDestBillId()) |
||||
.eq(ConvertRelation::getTargetNumber, dto.getDestBillType()) |
||||
); |
||||
} |
||||
@Override |
||||
public List<ConvertRelation> selectAllRelationBySource(ConvertRelationListDto dto) { |
||||
return convertRelationService.list(new LambdaQueryWrapper<ConvertRelation>() |
||||
.eq(ConvertRelation::getSourceId, dto.getSrcBillId()) |
||||
.eq(ConvertRelation::getSourceNumber, dto.getSrcBillType()) |
||||
); |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 设置基本参数方法 |
||||
*/ |
||||
private <T>void addOrUpdateBaseData(T t,Long id){ |
||||
if (t instanceof ConvertRule){ |
||||
ConvertRule data = (ConvertRule) t; |
||||
data.setDeletedFlag(GlobalDeletedFlag.NORMAL); |
||||
data.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
data.setUpdateTime(new Date()); |
||||
if (ObjectUtil.isEmpty(data.getCreateTime())){ |
||||
data.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
data.setCreateTime(new Date()); |
||||
} |
||||
} |
||||
else if (t instanceof ConvertPluginEntry){ |
||||
ConvertPluginEntry data = (ConvertPluginEntry) t; |
||||
data.setParentId(String.valueOf(id)); |
||||
if (ObjectUtil.isEmpty(data.getCreateTime())){ |
||||
data.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
data.setCreateTime(new Date()); |
||||
} |
||||
data.setDeletedFlag(GlobalDeletedFlag.NORMAL); |
||||
data.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
data.setUpdateTime(new Date()); |
||||
} |
||||
else if (t instanceof ConvertFieldmappingEntry){ |
||||
ConvertFieldmappingEntry data = (ConvertFieldmappingEntry) t; |
||||
data.setParentId(String.valueOf(id)); |
||||
if (ObjectUtil.isEmpty(data.getCreateTime())){ |
||||
data.setCreateUserId(TokenData.takeFromRequest().getUserId()); |
||||
data.setCreateTime(new Date()); |
||||
} |
||||
data.setDeletedFlag(GlobalDeletedFlag.NORMAL); |
||||
data.setUpdateUserId(TokenData.takeFromRequest().getUserId()); |
||||
data.setUpdateTime(new Date()); |
||||
} |
||||
} |
||||
@Autowired |
||||
private IOnlFormHeadService onlFormHeadService; |
||||
|
||||
@Override |
||||
public List<Map<String, Object>> getPushBillList(ConvertRelationDelDto dto) { |
||||
//查询当前单据作为源单并且已启用的转换规则
|
||||
List<ConvertRule> list = this.list(new LambdaQueryWrapper<ConvertRule>().eq(ConvertRule::getEnabled, "true")); |
||||
//查询单据名称
|
||||
//全量在线表单数据 == 转map当临时表用
|
||||
List<OnlFormHead> allOnlFormHeadsList = onlFormHeadService.list(new LambdaQueryWrapper<OnlFormHead>()); |
||||
//过滤后的数据
|
||||
List<OnlFormHead> filterOnlFormHeadList = allOnlFormHeadsList.stream().filter(a -> StringUtils.equals(a.getTableName(), dto.getBillType())).collect(Collectors.toList()); |
||||
Map<Long, OnlFormHead> longOnlFormHeadMap = allOnlFormHeadsList.stream().collect(Collectors.toMap(OnlFormHead::getId, OnlFormHead -> OnlFormHead, (k1, k2) -> k2)); |
||||
//过滤后的转换规则
|
||||
List<ConvertRule> convertRules = list.stream().filter(e -> filterOnlFormHeadList.stream().map(OnlFormHead::getId).collect(Collectors.toList()).contains(Long.valueOf(e.getSourceEntityId()))).collect(Collectors.toList()); |
||||
//重新封装数据
|
||||
List<ConvertRuleDto> convertRuleDtosList = getConvertRuleDtos( longOnlFormHeadMap, convertRules); |
||||
//封装成前台需要的结构
|
||||
return buildToReturn(convertRuleDtosList); |
||||
} |
||||
|
||||
@Override |
||||
public List<Map<String, Object>> getRuleTableFiled(String tableName) { |
||||
OnlFormHead headTableName = onlFormHeadService.getHeadTableNameCache(tableName); |
||||
List<OnlFormField> onlFormFieldList = headTableName.getOnlFormFieldList(); |
||||
String metaTable = headTableName.getMetaTable(); |
||||
if(StringUtil.isNotBlank(metaTable)){ |
||||
OnlFormHead metaTableHead = onlFormHeadService.getHeadTableNameCache(tableName); |
||||
onlFormFieldList.addAll(metaTableHead.getOnlFormFieldList()); |
||||
} |
||||
List<Map<String, Object>> mapList = onlFormFieldList.stream() |
||||
.map(com.baomidou.mybatisplus.core.toolkit.BeanUtils::beanToMap) |
||||
.collect(Collectors.toList()); |
||||
return mapList; |
||||
} |
||||
|
||||
@NotNull |
||||
private static List<Map<String, Object>> buildToReturn(List<ConvertRuleDto> convertRuleDtosList) { |
||||
Map<String, List<ConvertRuleDto>> stringListMap = convertRuleDtosList.stream().collect(Collectors.groupingBy(ConvertRuleDto::getBillType)); |
||||
//封装成文档定义格式返回
|
||||
List<Map<String, Object>> resultList = new ArrayList<>(); |
||||
stringListMap.forEach((k,v)->{ |
||||
Map<String, Object> hashMap = new HashMap<>(); |
||||
resultList.add(hashMap); |
||||
//单据标识
|
||||
hashMap.put("billType",k); |
||||
//单据名称
|
||||
hashMap.put("billTypeName",v.get(0).getBillTypeName()); |
||||
List<Map<String, Object>> billRuleList = new ArrayList<>(); |
||||
hashMap.put("billRuleList",billRuleList); |
||||
for (ConvertRuleDto convertRuleDto : v) { |
||||
Map<String, Object> billRuleListMap = new HashMap<>(); |
||||
billRuleList.add(billRuleListMap); |
||||
billRuleListMap.put("ruleId",convertRuleDto.getId()); |
||||
billRuleListMap.put("ruleNumber",convertRuleDto.getNumber()); |
||||
billRuleListMap.put("ruleName",convertRuleDto.getName()); |
||||
billRuleListMap.put("billEditUI",convertRuleDto.getBillEditUI()); |
||||
billRuleListMap.put("isShowEdit",convertRuleDto.getIsShowEdit()); |
||||
billRuleListMap.put("billEditUIType",convertRuleDto.getBillEditUIType()); |
||||
} |
||||
}); |
||||
return resultList; |
||||
} |
||||
@Autowired |
||||
private ISysMenuqqService sysMenuqqService; |
||||
|
||||
@NotNull |
||||
private List<ConvertRuleDto> getConvertRuleDtos(Map<Long, OnlFormHead> longOnlFormHeadMap, List<ConvertRule> convertRules) { |
||||
List<ConvertRuleDto> convertRuleDtosList = new ArrayList<>(); |
||||
//重新封装对象
|
||||
convertRules.forEach(e->{ |
||||
ConvertRuleDto convertRuleDto = new ConvertRuleDto(); |
||||
BeanUtils.copyProperties(e , convertRuleDto); |
||||
//单据标识
|
||||
convertRuleDto.setBillType(longOnlFormHeadMap.get(Long.valueOf(e.getTargetEntityId())).getTableName()); |
||||
//单据名称
|
||||
convertRuleDto.setBillTypeName(longOnlFormHeadMap.get(Long.valueOf(e.getTargetEntityId())).getTableTxt()); |
||||
//规则编码
|
||||
convertRuleDto.setNumber(e.getNumber()); |
||||
//规则名称
|
||||
convertRuleDto.setName(e.getName()); |
||||
//是否显示编辑页面
|
||||
convertRuleDto.setIsShowEdit(e.getVisible()); |
||||
//表单编辑页面
|
||||
// convertRuleDto.setBillEditUI(formRouterMap.get(e.getTargetEntityId()));
|
||||
//1路由表单则返回路由页面,2在线表单则返回在线编辑页面
|
||||
if ("1".equals(e.getDownInterfaceType())) { |
||||
SysMenuqq sysMenu = sysMenuqqService.getById(e.getDownRouteInterface()); |
||||
if (sysMenu != null){ |
||||
convertRuleDto.setBillEditUI(sysMenu.getFormRouterName()); |
||||
} |
||||
convertRuleDto.setBillEditUIType("1"); |
||||
}else { |
||||
convertRuleDto.setBillEditUI(String.valueOf(e.getDownEditInterface())); |
||||
convertRuleDto.setBillEditUIType("2"); |
||||
} |
||||
convertRuleDtosList.add(convertRuleDto); |
||||
}); |
||||
return convertRuleDtosList; |
||||
} |
||||
|
||||
|
||||
} |
||||
@ -1,8 +1,9 @@
@@ -1,8 +1,9 @@
|
||||
package apelet.common.generator.service.impl; |
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.generator.dao.ReverseWritingBusinessMapper; |
||||
import apelet.common.generator.model.ReverseWritingBusiness; |
||||
import apelet.common.generator.service.IReverseWritingBusinessService; |
||||
|
||||
import apelet.common.botp.dao.ReverseWritingBusinessMapper; |
||||
import apelet.common.botp.model.ReverseWritingBusiness; |
||||
import apelet.common.botp.service.IReverseWritingBusinessService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
@ -1,8 +1,9 @@
@@ -1,8 +1,9 @@
|
||||
package apelet.common.generator.service.impl; |
||||
package apelet.common.botp.service.impl; |
||||
|
||||
import apelet.common.generator.dao.ReverseWritingFormulaMapper; |
||||
import apelet.common.generator.model.ReverseWritingFormula; |
||||
import apelet.common.generator.service.IReverseWritingFormulaService; |
||||
|
||||
import apelet.common.botp.dao.ReverseWritingFormulaMapper; |
||||
import apelet.common.botp.model.ReverseWritingFormula; |
||||
import apelet.common.botp.service.IReverseWritingFormulaService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
@ -1,13 +1,14 @@
@@ -1,13 +1,14 @@
|
||||
package apelet.common.generator.service.impl; |
||||
|
||||
import apelet.common.generator.dao.ReverseWritingRulesMapper; |
||||
import apelet.common.generator.dto.ReverseWritingRulesDto; |
||||
import apelet.common.generator.model.ReverseWritingBusiness; |
||||
import apelet.common.generator.model.ReverseWritingFormula; |
||||
import apelet.common.generator.model.ReverseWritingRules; |
||||
import apelet.common.generator.service.IReverseWritingBusinessService; |
||||
import apelet.common.generator.service.IReverseWritingFormulaService; |
||||
import apelet.common.generator.service.IReverseWritingRulesService; |
||||
package apelet.common.botp.service.impl; |
||||
|
||||
|
||||
import apelet.common.botp.dao.ReverseWritingRulesMapper; |
||||
import apelet.common.botp.dto.ReverseWritingRulesDto; |
||||
import apelet.common.botp.model.ReverseWritingBusiness; |
||||
import apelet.common.botp.model.ReverseWritingFormula; |
||||
import apelet.common.botp.model.ReverseWritingRules; |
||||
import apelet.common.botp.service.IReverseWritingBusinessService; |
||||
import apelet.common.botp.service.IReverseWritingFormulaService; |
||||
import apelet.common.botp.service.IReverseWritingRulesService; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.beans.BeanUtils; |
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
package apelet.common.botp.service.impl; |
||||
|
||||
|
||||
import apelet.common.botp.dao.SysMenuqqMapper; |
||||
import apelet.common.botp.model.AllField; |
||||
import apelet.common.botp.model.SysMenuqq; |
||||
import apelet.common.botp.service.ISysMenuqqService; |
||||
import apelet.common.core.base.dao.BaseDaoMapper; |
||||
import apelet.common.core.base.service.BaseService; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author admin |
||||
* @since 2024-01-18 10:31:58 |
||||
*/ |
||||
@Service(value="sysMenuqqService") |
||||
@Slf4j |
||||
public class SysMenuqqServiceImpl extends BaseService<SysMenuqq,Long> implements ISysMenuqqService { |
||||
|
||||
@Autowired |
||||
private SysMenuqqMapper sysMenuqqMapper; |
||||
|
||||
|
||||
@Override |
||||
public List<SysMenuqq> selectAll(String id) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<AllField> allField(String tableName) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean removeAllById(Long id) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean editAll(SysMenuqq sysMenuqq) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public Boolean addAll(SysMenuqq sysMenuqq) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
protected BaseDaoMapper<SysMenuqq> mapper() { |
||||
return baseMapper; |
||||
} |
||||
} |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package apelet.common.botp.util; |
||||
|
||||
/** |
||||
* @author Soon |
||||
* @version 1.0 |
||||
* Create by 2024/2/20 17:06 |
||||
*/ |
||||
public class Constant { |
||||
|
||||
public final static String FormStatus_AddNew = "1";//新增状态
|
||||
public final static String FormStatus_Save = "2";//保存状态
|
||||
|
||||
public final static String InterfaceType_ROUTE = "1";//路由表单
|
||||
public final static String InterfaceType_ONLINE = "2";//在线表单
|
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
package ${package.Controller}; |
||||
|
||||
|
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.constant.ErrorCodeEnum; |
||||
import apelet.common.core.object.MyOrderParam; |
||||
import apelet.common.core.object.MyPageData; |
||||
import apelet.common.core.object.MyPageParam; |
||||
import apelet.common.core.object.ResponseResult; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import apelet.tenantadmin.ape.model.ApeBase; |
||||
import apelet.tenantadmin.ape.model.service.IApeBaseService; |
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
<#if restControllerStyle> |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
<#else> |
||||
import org.springframework.stereotype.Controller; |
||||
</#if> |
||||
<#if superControllerClassPackage??> |
||||
import ${superControllerClassPackage}; |
||||
</#if> |
||||
|
||||
/** |
||||
* <p> |
||||
* ${table.comment!} 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author ${author} |
||||
* @since ${date} |
||||
*/ |
||||
<#if restControllerStyle> |
||||
@RestController |
||||
<#else> |
||||
@Controller |
||||
</#if> |
||||
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>") |
||||
<#if kotlin> |
||||
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if> |
||||
<#else> |
||||
<#if superControllerClass??> |
||||
public class ${table.controllerName} extends ${superControllerClass} { |
||||
<#else> |
||||
public class ${table.controllerName} { |
||||
</#if> |
||||
|
||||
} |
||||
</#if> |
||||
@ -0,0 +1,143 @@
@@ -0,0 +1,143 @@
|
||||
package ${package.Controller}; |
||||
|
||||
|
||||
import apelet.common.core.annotation.MyRequestBody; |
||||
import apelet.common.core.constant.ErrorCodeEnum; |
||||
import apelet.common.core.object.MyOrderParam; |
||||
import apelet.common.core.object.MyPageData; |
||||
import apelet.common.core.object.MyPageParam; |
||||
import apelet.common.core.object.ResponseResult; |
||||
import apelet.common.core.util.MyPageUtil; |
||||
import apelet.tenantadmin.ape.model.ApeBase; |
||||
import apelet.tenantadmin.ape.model.service.IApeBaseService; |
||||
import cn.hutool.core.util.ObjectUtil; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.github.pagehelper.Page; |
||||
import com.github.pagehelper.page.PageMethod; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
<#if restControllerStyle> |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
<#else> |
||||
import org.springframework.stereotype.Controller; |
||||
</#if> |
||||
<#if superControllerClassPackage??> |
||||
import ${superControllerClassPackage}; |
||||
</#if> |
||||
|
||||
/** |
||||
* <p> |
||||
* ${table.comment!} 前端控制器 |
||||
* </p> |
||||
* |
||||
* @author ${author} |
||||
* @since ${date} |
||||
*/ |
||||
<#if restControllerStyle> |
||||
@RestController |
||||
<#else> |
||||
@Controller |
||||
</#if> |
||||
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>") |
||||
<#if kotlin> |
||||
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if> |
||||
<#else> |
||||
<#if superControllerClass??> |
||||
public class ${table.controllerName} extends ${superControllerClass} { |
||||
<#else> |
||||
public class ${table.controllerName} { |
||||
|
||||
@Autowired |
||||
private ${table.controllerName}Service ${table.controllerName}Service; |
||||
|
||||
|
||||
/** |
||||
* ${table.controllerName}列表(分页) |
||||
* |
||||
* @param query 查询参数对象 |
||||
* @return |
||||
*/ |
||||
@GetMapping("page") |
||||
public Result page(${table.controllerName}Query query) { |
||||
log.info("${table.controllerName}Controller.page 参数为:" + JsonUtil.toJsonFromObject(query)); |
||||
return Result.success(this.${table.controllerName}Service.page(query)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* ${table.controllerName}列表(不分页) |
||||
* |
||||
* @param query 查询参数对象 |
||||
* @return |
||||
*/ |
||||
@GetMapping("list") |
||||
public Result list(${table.controllerName}Query query) { |
||||
log.info("${table.controllerName}Controller.list 参数为:" + JsonUtil.toJsonFromObject(query)); |
||||
return Result.success(this.${table.controllerName}Service.list(query)); |
||||
} |
||||
|
||||
/** |
||||
* 插入${table.comment} |
||||
* |
||||
* @param dto 待插入的${table.comment} |
||||
* @return |
||||
*/ |
||||
@PostMapping("insert") |
||||
public Result insert(@RequestBody @Validated(Insert.class) ${table.controllerName}Dto dto) { |
||||
log.info("${table.controllerName}Controller.insert 参数为:" + JsonUtil.toJsonFromObject(dto)); |
||||
return Result.success(this.${table.controllerName}Service.save(dto)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据 id 获取${table.controllerName} |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
@GetMapping("selectById") |
||||
public Result selectById(@RequestParam("id") Integer id) { |
||||
Assert.notNull(id, "id 不能为空"); |
||||
|
||||
log.info("${table.controllerName}Controller.selectById 参数为:" + id); |
||||
return Result.success(this.${table.controllerName}Service.getById(id)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据 id 更新${table.controllerName} |
||||
* |
||||
* @param dto |
||||
* @return |
||||
*/ |
||||
@PostMapping("updateById") |
||||
public Result updateById(@RequestBody @Validated(Update.class) ${table.controllerName}Dto dto) { |
||||
Assert.notNull(dto.getId(), "id 不能为空"); |
||||
|
||||
log.info("${table.controllerName}Controller.updateById 参数为:" + JsonUtil.toJsonFromObject(dto)); |
||||
return Result.success(this.${table.controllerName}Service.updateById(dto)); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据 id 删除${table.controllerName} |
||||
* |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
@PostMapping("deleteById") |
||||
public Result deleteById(@RequestParam("id") Integer id) { |
||||
Assert.notNull(id, "id 不能为空"); |
||||
|
||||
log.info("${table.controllerName}Controller.deleteById 参数为:" + id); |
||||
return Result.success(this.${table.controllerName}Service.removeById(id)); |
||||
} |
||||
|
||||
|
||||
|
||||
</#if> |
||||
|
||||
} |
||||
</#if> |
||||
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
package ${package.Entity}; |
||||
|
||||
|
||||
/** |
||||
* <p> |
||||
* 测试自定义DTO模板 ${table.comment!} |
||||
* </p> |
||||
* |
||||
* 测试注入 ${cfg.abc} |
||||
*/ |
||||
|
||||
|
||||
// 自定义的查询内容 |
||||
<#list table.fields as field> |
||||
自定义 abc 内容: ${field.customMap.abc} |
||||
自定义 def 内容: ${field.customMap.def} |
||||
</#list> |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
package ${package.Entity}; |
||||
|
||||
import ${package}.${entity}#if(${moduleName} != "").${moduleName}#end.${className}; |
||||
import lombok.Data; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* <p> |
||||
* 测试自定义DTO模板 ${table.comment!} |
||||
* </p> |
||||
* |
||||
* 测试注入 ${cfg.abc} |
||||
*/ |
||||
|
||||
|
||||
/** |
||||
* @author ${author} |
||||
* @date ${date} |
||||
* @desc ${table.comment} dto |
||||
*/ |
||||
@Data |
||||
@Accessors(chain = true) |
||||
public class ${table.dtoName}Dto extends ${table.dtoName} implements Dto { |
||||
|
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue