|
@@ -96,7 +96,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
@Override
|
|
|
public R getExcelHtmlByBuss(Long id) throws Exception {
|
|
|
//获取表单信息
|
|
|
- AgreementLinkTable linkTable = linkTableService.getById(id);
|
|
|
+ WbsTreePrivate linkTable = baseMapper.getTableInfo(id);
|
|
|
if (StringUtils.isBlank(linkTable.getHtmlUrl())){
|
|
|
return R.fail("没有获取到表单!");
|
|
|
}
|
|
@@ -111,7 +111,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
Document doc = Jsoup.parse(htmlString);
|
|
|
Element table = doc.select("table").first();
|
|
|
// 添加标题显示
|
|
|
- ProjectInfo projectInfo = baseMapper.getProjectInfo(linkTable.getProjectId());
|
|
|
+ ProjectInfo projectInfo = baseMapper.getProjectInfo(Long.parseLong(linkTable.getProjectId()));
|
|
|
Elements trs = table.select("tr");
|
|
|
for (int i = 1; i < 6; i++) {
|
|
|
Element tr = trs.get(i);
|
|
@@ -140,7 +140,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
//获取表单信息
|
|
|
- AgreementLinkTable linkTable = linkTableService.getById(id);
|
|
|
+ WbsTreePrivate linkTable = baseMapper.getTableInfo(id);
|
|
|
String fileUrl = linkTable.getHtmlUrl();
|
|
|
if (StringUtils.isBlank(fileUrl)){
|
|
|
return R.fail("没有获取到表单!");
|
|
@@ -195,7 +195,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
* 协议表单获取用户保存数据
|
|
|
*/
|
|
|
@Override
|
|
|
- public R getBussDataInfo(Long linkId) {
|
|
|
+ public R getBussDataInfo(Long linkId,Long tableId) {
|
|
|
Map<String, Object> reData = new HashMap<>();
|
|
|
//获取表单数据
|
|
|
List<Map<String, Object>> mapList = baseMapper.getBussDataInfo(linkId);
|
|
@@ -207,10 +207,21 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
}
|
|
|
//需要自动生成的字典集合,项目名称197
|
|
|
List<Integer> buildDict = Arrays.asList(197);
|
|
|
+ String htmlUrl;
|
|
|
+ Long projectId;
|
|
|
//获取当前表单
|
|
|
AgreementLinkTable linkTable = linkTableService.getById(linkId);
|
|
|
+ //如果是新增,中间表是空的,就直接去获取项目下的表单配置
|
|
|
+ if (linkTable == null){
|
|
|
+ WbsTreePrivate wbs = baseMapper.getTableInfo(tableId);
|
|
|
+ htmlUrl = wbs.getHtmlUrl();
|
|
|
+ projectId = Long.parseLong(wbs.getProjectId());
|
|
|
+ }else {
|
|
|
+ htmlUrl = linkTable.getHtmlUrl();
|
|
|
+ projectId = linkTable.getProjectId();
|
|
|
+ }
|
|
|
//获取当前表单配置字典
|
|
|
- List<WbsFormElement> tableElement = baseMapper.getTableElement(Arrays.asList(linkTable.getTableId()));
|
|
|
+ List<WbsFormElement> tableElement = baseMapper.getTableElement(Arrays.asList(tableId));
|
|
|
Map<Integer, List<WbsFormElement>> map = tableElement.stream().collect(Collectors.groupingBy(WbsFormElement::getDynamicDict));
|
|
|
List<Integer> list = tableElement.stream().map(l -> l.getDynamicDict()).collect(Collectors.toList());
|
|
|
//获取当前表单内需要自动生成的字典
|
|
@@ -219,7 +230,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
if (list.size() > 0) {
|
|
|
Document doc = null;
|
|
|
try {
|
|
|
- doc = Jsoup.parse(new File(linkTable.getHtmlUrl()), "utf-8");
|
|
|
+ doc = Jsoup.parse(new File(htmlUrl), "utf-8");
|
|
|
// doc = Jsoup.parse(new File("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html"), "utf-8");
|
|
|
} catch (IOException e) {
|
|
|
throw new ServiceException("解析表单html出错");
|
|
@@ -242,7 +253,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
switch (dict){
|
|
|
case 197 :
|
|
|
//项目名称
|
|
|
- String projectName = jdbcTemplate.queryForObject("select project_name from m_project_info where id = " + linkTable.getProjectId(), String.class);
|
|
|
+ String projectName = jdbcTemplate.queryForObject("select project_name from m_project_info where id = " + projectId, String.class);
|
|
|
reData.put(key,projectName);
|
|
|
break;
|
|
|
}
|
|
@@ -256,7 +267,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public R saveBussData(JSONObject dataInfo) throws Exception {
|
|
|
+ public R saveBussData(JSONObject dataInfo){
|
|
|
JSONArray dataArray = new JSONArray();
|
|
|
if (dataInfo.containsKey("dataInfo")) { //节点保存
|
|
|
JSONObject jsonObject = dataInfo.getJSONObject("dataInfo");
|
|
@@ -267,6 +278,61 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
JSONObject tableInfo1 = dataArray.getJSONObject(0);
|
|
|
Long id = tableInfo1.getLong("agreementId");
|
|
|
Long areaId = tableInfo1.getLong("areaId");
|
|
|
+ Long projectId = tableInfo1.getLong("projectId");
|
|
|
+ Integer agreeType = Math.toIntExact(tableInfo1.getLong("type"));
|
|
|
+ //如果id为null证明从来没保存过,先新增
|
|
|
+ if (id == null){
|
|
|
+ //补偿id
|
|
|
+ Long agreeId = SnowFlakeUtil.getId();
|
|
|
+ //先新增中间表
|
|
|
+ List<WbsTreePrivate> tables = baseMapper.getTables(projectId, agreeType);
|
|
|
+ //ExcelId与中间表id的映射
|
|
|
+ Map<Long,Long> map = new HashMap<>();
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
+ map.put(jsonObject.getLong("tableId"),jsonObject.getLong("linkId"));
|
|
|
+ }
|
|
|
+ List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
|
|
|
+ AgreementLinkTable table = new AgreementLinkTable();
|
|
|
+ table.setTableId(Long.parseLong(l.getInitTableId()));
|
|
|
+ table.setProjectId(projectId);
|
|
|
+ table.setTableDataId(SnowFlakeUtil.getId());
|
|
|
+ if (map.get(Long.parseLong(l.getInitTableId())) != null){
|
|
|
+ table.setId(map.get(Long.parseLong(l.getInitTableId())));
|
|
|
+ }else {
|
|
|
+ table.setId(SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ table.setAgreementId(agreeId);
|
|
|
+ table.setPrivateId(l.getId());
|
|
|
+ table.setSort(l.getSort());
|
|
|
+ table.setExcelId(l.getExcelId());
|
|
|
+ table.setHtmlUrl(l.getHtmlUrl());
|
|
|
+ table.setTableName(l.getNodeName());
|
|
|
+ return table;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ id = agreeId;
|
|
|
+ linkTableService.saveBatch(linkTables);
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
+ jsonObject.put("linkId",map.get(jsonObject.getLong("tableId")));
|
|
|
+ }
|
|
|
+ //再保存协议
|
|
|
+ CompensationInfo info = new CompensationInfo();
|
|
|
+ info.setId(agreeId);
|
|
|
+ info.setName("默认名称");
|
|
|
+ //获取当前节点名称
|
|
|
+ RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
|
|
|
+ //获取编号
|
|
|
+ String num = getNumber(areaId);
|
|
|
+ info.setNumber(treeInfo.getAreaName()+num);
|
|
|
+ info.setAreaId(areaId);
|
|
|
+ info.setProjectId(projectId);
|
|
|
+ info.setType(agreeType);
|
|
|
+ info.setLandMoney(new BigDecimal(0));
|
|
|
+ info.setCropsMoney(new BigDecimal(0));
|
|
|
+ info.setAllMoney(new BigDecimal(0));
|
|
|
+ this.save(info);
|
|
|
+ }
|
|
|
//中间表tableId与dataId的映射
|
|
|
Map<Long,Long> linkMap = new HashMap<>();
|
|
|
//获取表单id与数据id的映射
|
|
@@ -276,14 +342,18 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
}
|
|
|
linkTables.stream().forEach(l->linkMap.put(l.getTableDataId(),l.getTableId()));
|
|
|
|
|
|
- for (int i=0; i<dataArray.size();i++) {
|
|
|
- JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
- //删除原来保存的数据
|
|
|
- baseMapper.deleteOldData(jsonObject.getLong("linkId"));
|
|
|
- this.SaveOneTabInfo(jsonObject);
|
|
|
+ try {
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
+ //删除原来保存的数据
|
|
|
+ baseMapper.deleteOldData(jsonObject.getLong("linkId"));
|
|
|
+ this.SaveOneTabInfo(jsonObject);
|
|
|
+ }
|
|
|
+ //合并PDF
|
|
|
+ this.mergePdfs(id);
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new ServiceException("合并PDF出现异常");
|
|
|
}
|
|
|
- //合并PDF
|
|
|
- this.mergePdfs(id);
|
|
|
//地类补偿金额
|
|
|
BigDecimal b1 = new BigDecimal(0);
|
|
|
//青苗
|
|
@@ -450,7 +520,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
}
|
|
|
//保存协议信息
|
|
|
this.updateById(info);
|
|
|
- return R.success("保存成功");
|
|
|
+ return R.data(200,id,"保存成功");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -498,6 +568,9 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
@Override
|
|
|
public R updateCopeTab(Long id) {
|
|
|
AgreementLinkTable linkTable = linkTableService.getById(id);
|
|
|
+ if (linkTable == null){
|
|
|
+ throw new ServiceException("请先保存一次表单再复制");
|
|
|
+ }
|
|
|
AgreementLinkTable table = new AgreementLinkTable();
|
|
|
BeanUtils.copyProperties(linkTable,table);
|
|
|
table.setId(null);
|
|
@@ -514,53 +587,33 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
@Override
|
|
|
public IPage<CompensationInfo> page(Query query, CompensationInfo info) {
|
|
|
//查看列表先删除之前未保存的补偿协议
|
|
|
- List<Long> ids = baseMapper.getPdfIsNull(info.getProjectId());
|
|
|
- if (ids != null && ids.size() > 0){
|
|
|
- linkTableService.deleteByAgreementIds(ids);
|
|
|
- baseMapper.deleteBatch(ids);
|
|
|
- }
|
|
|
+// List<Long> ids = baseMapper.getPdfIsNull(info.getProjectId());
|
|
|
+// if (ids != null && ids.size() > 0){
|
|
|
+// linkTableService.deleteByAgreementIds(ids);
|
|
|
+// baseMapper.deleteBatch(ids);
|
|
|
+// }
|
|
|
IPage<CompensationInfo> iPage = new Page<>(query.getCurrent(),query.getSize());
|
|
|
return baseMapper.page(iPage,info);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
- public Long add(Long projectId, Long areaId, Integer type) {
|
|
|
- //新增复制
|
|
|
- Long agreeId = SnowFlakeUtil.getId();
|
|
|
- //先新增中间表,再复制
|
|
|
+ public List<AgreementLinkTable> add(Long projectId, Long areaId, Integer type) {
|
|
|
+ //获取列表
|
|
|
List<WbsTreePrivate> tables = baseMapper.getTables(projectId, type);
|
|
|
List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
|
|
|
AgreementLinkTable table = new AgreementLinkTable();
|
|
|
table.setTableId(Long.parseLong(l.getInitTableId()));
|
|
|
table.setProjectId(projectId);
|
|
|
- table.setTableDataId(SnowFlakeUtil.getId());
|
|
|
- table.setId(SnowFlakeUtil.getId());
|
|
|
- table.setAgreementId(agreeId);
|
|
|
table.setPrivateId(l.getId());
|
|
|
table.setSort(l.getSort());
|
|
|
+ table.setId(SnowFlakeUtil.getId());
|
|
|
table.setExcelId(l.getExcelId());
|
|
|
table.setHtmlUrl(l.getHtmlUrl());
|
|
|
table.setTableName(l.getNodeName());
|
|
|
return table;
|
|
|
}).collect(Collectors.toList());
|
|
|
- linkTableService.saveBatch(linkTables);
|
|
|
- //再保存协议
|
|
|
- CompensationInfo info = new CompensationInfo();
|
|
|
- info.setId(agreeId);
|
|
|
- info.setName("默认名称");
|
|
|
- //获取当前节点名称
|
|
|
- RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
|
|
|
- //获取编号
|
|
|
- String num = getNumber(areaId);
|
|
|
- info.setNumber(treeInfo.getAreaName()+num);
|
|
|
- info.setAreaId(areaId);
|
|
|
- info.setProjectId(projectId);
|
|
|
- info.setType(type);
|
|
|
- info.setLandMoney(new BigDecimal(0));
|
|
|
- info.setCropsMoney(new BigDecimal(0));
|
|
|
- info.setAllMoney(new BigDecimal(0));
|
|
|
- this.save(info);
|
|
|
- return agreeId;
|
|
|
+ return linkTables;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -625,7 +678,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
public void unSave(Long agreementId) {
|
|
|
CompensationInfo info = this.getById(agreementId);
|
|
|
//如果从未保存过,直接删除
|
|
|
- if (StringUtils.isBlank(info.getMergePdfUrl())){
|
|
|
+ if (info != null && StringUtils.isBlank(info.getMergePdfUrl())){
|
|
|
List<Long> list = Arrays.asList(agreementId);
|
|
|
//删除中间表数据
|
|
|
linkTableService.deleteByAgreementIds(list);
|
|
@@ -965,7 +1018,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
|
return R.fail("未获取到清表信息");
|
|
|
}
|
|
|
if (DataInfo == null) {
|
|
|
- DataInfo = (Map<String, Object>) getBussDataInfo(id).getData();
|
|
|
+ DataInfo = (Map<String, Object>) getBussDataInfo(id,linkTable.getTableId()).getData();
|
|
|
}
|
|
|
|
|
|
//获取excel流 和 html流
|