|
@@ -96,11 +96,11 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
public R getExcelHtmlByBuss(Long id) throws Exception {
|
|
public R getExcelHtmlByBuss(Long id) throws Exception {
|
|
//获取表单信息
|
|
//获取表单信息
|
|
AgreementLinkTable linkTable = linkTableService.getById(id);
|
|
AgreementLinkTable linkTable = linkTableService.getById(id);
|
|
-// fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
|
|
|
|
if (StringUtils.isBlank(linkTable.getHtmlUrl())){
|
|
if (StringUtils.isBlank(linkTable.getHtmlUrl())){
|
|
return R.fail("没有获取到表单!");
|
|
return R.fail("没有获取到表单!");
|
|
}
|
|
}
|
|
InputStream fileInputStream = FileUtils.getInputStreamByUrl(linkTable.getHtmlUrl());
|
|
InputStream fileInputStream = FileUtils.getInputStreamByUrl(linkTable.getHtmlUrl());
|
|
|
|
+// InputStream fileInputStream = FileUtils.getInputStreamByUrl("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html");
|
|
|
|
|
|
String htmlString = IoUtil.readToString(fileInputStream);
|
|
String htmlString = IoUtil.readToString(fileInputStream);
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
@@ -225,13 +225,13 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
Long id = tableInfo1.getLong("agreementId");
|
|
Long id = tableInfo1.getLong("agreementId");
|
|
Long areaId = tableInfo1.getLong("areaId");
|
|
Long areaId = tableInfo1.getLong("areaId");
|
|
//中间表tableId与dataId的映射
|
|
//中间表tableId与dataId的映射
|
|
- Map<Long,Long> map = new HashMap<>();
|
|
|
|
|
|
+ Map<Long,Long> linkMap = new HashMap<>();
|
|
//获取表单id与数据id的映射
|
|
//获取表单id与数据id的映射
|
|
List<AgreementLinkTable> linkTables = linkTableService.getByAgreementId(id);
|
|
List<AgreementLinkTable> linkTables = linkTableService.getByAgreementId(id);
|
|
if (linkTables == null || linkTables.size() == 0){
|
|
if (linkTables == null || linkTables.size() == 0){
|
|
throw new ServiceException("暂无表单");
|
|
throw new ServiceException("暂无表单");
|
|
}
|
|
}
|
|
- linkTables.stream().forEach(l->map.put(l.getTableId(),l.getTableDataId()));
|
|
|
|
|
|
+ linkTables.stream().forEach(l->linkMap.put(l.getTableDataId(),l.getTableId()));
|
|
|
|
|
|
for (int i=0; i<dataArray.size();i++) {
|
|
for (int i=0; i<dataArray.size();i++) {
|
|
JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
@@ -247,65 +247,135 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
BigDecimal b2 = new BigDecimal(0);
|
|
BigDecimal b2 = new BigDecimal(0);
|
|
//地面附着物
|
|
//地面附着物
|
|
BigDecimal b3 = new BigDecimal(0);
|
|
BigDecimal b3 = new BigDecimal(0);
|
|
|
|
+ //金额总计
|
|
|
|
+ BigDecimal b4 = new BigDecimal(0);
|
|
|
|
+ //农用地面积
|
|
|
|
+ BigDecimal a1 = new BigDecimal(0);
|
|
|
|
+ //建设用地面积
|
|
|
|
+ BigDecimal a2 = new BigDecimal(0);
|
|
|
|
+ //未利用地面积
|
|
|
|
+ BigDecimal a3 = new BigDecimal(0);
|
|
|
|
+ //总面积
|
|
|
|
+ BigDecimal a4 = new BigDecimal(0);
|
|
//户主姓名(协议名称)
|
|
//户主姓名(协议名称)
|
|
StringBuilder str = new StringBuilder("");
|
|
StringBuilder str = new StringBuilder("");
|
|
- //计算统计值
|
|
|
|
- List<WbsFormElement> elementList = baseMapper.getTableElement(linkTables.stream().map(l -> l.getTableId()).collect(Collectors.toList()));
|
|
|
|
CompensationInfo info = new CompensationInfo();
|
|
CompensationInfo info = new CompensationInfo();
|
|
info.setId(id);
|
|
info.setId(id);
|
|
- //获取当前节点名称
|
|
|
|
- RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
|
|
|
|
- info.setNumber(treeInfo.getAreaName()+"默认编号");
|
|
|
|
|
|
+ //查看当前表单是否配置统计值
|
|
|
|
+ List<WbsFormElement> elementList = baseMapper.getTableElement(linkTables.stream().map(l -> l.getTableId()).collect(Collectors.toList()));
|
|
if (elementList == null || elementList.size() == 0){
|
|
if (elementList == null || elementList.size() == 0){
|
|
info.setName("未找到用户名称");
|
|
info.setName("未找到用户名称");
|
|
info.setLandMoney(b1);
|
|
info.setLandMoney(b1);
|
|
info.setCropsMoney(b2);
|
|
info.setCropsMoney(b2);
|
|
info.setAllMoney(b3);
|
|
info.setAllMoney(b3);
|
|
-
|
|
|
|
}else {
|
|
}else {
|
|
- //获取所有表单填报值
|
|
|
|
- List<TableDataVO> list = baseMapper.getBussDataInfoByDataIds(linkTables.stream().map(l -> l.getTableDataId()).collect(Collectors.toList()));
|
|
|
|
- if (list != null && list.size() > 0) {
|
|
|
|
- //按照表单分组
|
|
|
|
- Map<Long, List<TableDataVO>> listMap = list.stream()
|
|
|
|
|
|
+ //有配置统计值,获取所有表单填报值
|
|
|
|
+ List<TableDataVO> dataList = baseMapper.getBussDataInfoByDataIds(linkTables.stream().map(l -> l.getTableDataId()).collect(Collectors.toList()));
|
|
|
|
+ //表单有填报值
|
|
|
|
+ if (dataList != null && dataList.size() > 0) {
|
|
|
|
+ //按照数据id分组
|
|
|
|
+ Map<Long, List<TableDataVO>> dataMap = dataList.stream()
|
|
.collect(Collectors.groupingBy(TableDataVO::getPKeyId));
|
|
.collect(Collectors.groupingBy(TableDataVO::getPKeyId));
|
|
- for (WbsFormElement element : elementList) {
|
|
|
|
- //获取统计字段
|
|
|
|
- String fId = element.getFId();
|
|
|
|
- String eKey = element.getEKey();
|
|
|
|
- Integer dict = element.getDynamicDict();
|
|
|
|
- Long dataId = map.get(Long.parseLong(fId));
|
|
|
|
- if (listMap.get(dataId) != null && listMap.get(dataId).size() > 0){
|
|
|
|
- //当前表单有保存数据,统计值
|
|
|
|
- List<TableDataVO> dataVOS = listMap.get(dataId);
|
|
|
|
- try {
|
|
|
|
- for (TableDataVO dataVO : dataVOS) {
|
|
|
|
- if (dataVO.getTabKey().contains(eKey)) {
|
|
|
|
- if (dict.equals(1)){
|
|
|
|
- b1 = b1.add(new BigDecimal(dataVO.getTabVal()));
|
|
|
|
- }else if (dict.equals(2)){
|
|
|
|
- b2 = b2.add(new BigDecimal(dataVO.getTabVal()));
|
|
|
|
- }else if (dict.equals(3)){
|
|
|
|
- b3 = b3.add(new BigDecimal(dataVO.getTabVal()));
|
|
|
|
- }else if (dict.equals(4)){
|
|
|
|
- str.append(dataVO.getTabVal()+"、");
|
|
|
|
- }
|
|
|
|
|
|
+ //统计字段按照表单分组
|
|
|
|
+ Map<String, List<WbsFormElement>> elementMap = elementList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(WbsFormElement::getFId));
|
|
|
|
+ //循环有数据的表单
|
|
|
|
+ for (Long dataId : dataMap.keySet()) {
|
|
|
|
+ //通过数据id获取表单,然后通过表单获取配置
|
|
|
|
+ List<WbsFormElement> elements = elementMap.get(linkMap.get(dataId)+"");
|
|
|
|
+ //如果没有统计字段,则跳过
|
|
|
|
+ if (elements == null || elements.size() == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //有统计字段,取出当前表的所有数据
|
|
|
|
+ List<TableDataVO> dataS = dataMap.get(dataId);
|
|
|
|
+ //循环统计字段
|
|
|
|
+ for (WbsFormElement element : elements) {
|
|
|
|
+ Integer dict = element.getDynamicDict();
|
|
|
|
+ if (dict.equals(7)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //获取当前统计字段所有填写的值
|
|
|
|
+ List<TableDataVO> vos = dataS.stream().filter(l -> l.getTabKey().contains(element.getEKey())).collect(Collectors.toList());
|
|
|
|
+ //如果当前统计值没填写数据则直接跳过
|
|
|
|
+ if (vos == null || vos.size() == 0){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //单独计算面积
|
|
|
|
+ if (dict.equals(6)) {
|
|
|
|
+ //统计面积,去找到当前行的地类dict为7
|
|
|
|
+ List<WbsFormElement> collect = elements.stream().filter(l -> l.getDynamicDict().equals(7)).collect(Collectors.toList());
|
|
|
|
+ //获取dict为7的key,如果key不存在则提示未配置土地性质
|
|
|
|
+ if (collect == null || collect.size() == 0){
|
|
|
|
+ throw new ServiceException("未配置地类");
|
|
|
|
+ }
|
|
|
|
+ //获取土地性质的数据,如果不存在数据,或者长度和面积不相等,则提示地类和面积必须同时填写
|
|
|
|
+ List<TableDataVO> typeList = dataS.stream().filter(l -> l.getTabKey().contains(collect.get(0).getEKey())).collect(Collectors.toList());
|
|
|
|
+ if (typeList == null || typeList.size() == 0 || typeList.size() != vos.size()){
|
|
|
|
+ throw new ServiceException("地类和面积必须同时填写");
|
|
|
|
+ }
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+ //把土地性质转换为map,位置为key
|
|
|
|
+ for (TableDataVO t : typeList) {
|
|
|
|
+ String[] s1 = t.getTabKey().split("__");
|
|
|
|
+ String[] s2 = s1[1].split("_");
|
|
|
|
+ map.put(s2[0],t.getTabVal());
|
|
|
|
+ }
|
|
|
|
+ for (TableDataVO vo : vos) {
|
|
|
|
+ String[] s1 = vo.getTabKey().split("__");
|
|
|
|
+ String[] s2 = s1[1].split("_");
|
|
|
|
+ //获取到土地性质
|
|
|
|
+ String type = map.get(s2[0]);
|
|
|
|
+ if ("农用地".equals(type)){
|
|
|
|
+ a1 = a1.add(new BigDecimal(vo.getTabVal()));
|
|
|
|
+ }else if ("建设用地".equals(type)){
|
|
|
|
+ a2 = a2.add(new BigDecimal(vo.getTabVal()));
|
|
|
|
+ }else if ("未利用地".equals(type)){
|
|
|
|
+ a3 = a3.add(new BigDecimal(vo.getTabVal()));
|
|
|
|
+ }else {
|
|
|
|
+ throw new ServiceException("土地性质为:"+type);
|
|
}
|
|
}
|
|
|
|
+ a4 = a4.add(new BigDecimal(vo.getTabVal()));
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //当前统计值
|
|
|
|
+ try {
|
|
|
|
+ if (dict.equals(1)) {
|
|
|
|
+ b1 = b1.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
|
|
|
|
+ } else if (dict.equals(2)) {
|
|
|
|
+ b2 = b2.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
|
|
|
|
+ } else if (dict.equals(3)) {
|
|
|
|
+ b3 = b3.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
|
|
|
|
+ } else if (dict.equals(4)) {
|
|
|
|
+ str.append(StringUtils.join(vos.stream().map(l -> l.getTabVal()).collect(Collectors.toList()), "、") + "、");
|
|
|
|
+ } else if (dict.equals(5)) {
|
|
|
|
+ b4 = b4.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new ServiceException("金额字段不能包含其他字符,请重新填写");
|
|
}
|
|
}
|
|
- }catch (Exception e){
|
|
|
|
- throw new ServiceException("金额字段不能包含其他字符,请重新填写");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //设置名称
|
|
String names = str.toString();
|
|
String names = str.toString();
|
|
if (StringUtils.isNotBlank(names)){
|
|
if (StringUtils.isNotBlank(names)){
|
|
info.setName(names.substring(0, names.length() - 1));
|
|
info.setName(names.substring(0, names.length() - 1));
|
|
}else {
|
|
}else {
|
|
info.setName("未找到用户名称");
|
|
info.setName("未找到用户名称");
|
|
}
|
|
}
|
|
|
|
+ //设置金额
|
|
info.setLandMoney(b1);
|
|
info.setLandMoney(b1);
|
|
info.setCropsMoney(b2.add(b3));
|
|
info.setCropsMoney(b2.add(b3));
|
|
- info.setAllMoney(info.getLandMoney().add(info.getCropsMoney()));
|
|
|
|
|
|
+ if (!info.getLandMoney().add(info.getCropsMoney()).equals(b4)){
|
|
|
|
+ throw new ServiceException("补偿金额合计不对,请校验土地、青苗、等金额之和,是否等于补偿金额合计");
|
|
|
|
+ }
|
|
|
|
+ info.setAllMoney(b4);
|
|
|
|
+ //设置面积
|
|
|
|
+ info.setAreaA(a1);
|
|
|
|
+ info.setAreaB(a2);
|
|
|
|
+ info.setAreaC(a3);
|
|
|
|
+ info.setAreaAll(a4);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//保存协议信息
|
|
//保存协议信息
|
|
@@ -485,6 +555,41 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取当前项目节点下所有补偿协议
|
|
|
|
+ * @param projectId
|
|
|
|
+ * @param areaId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<CompensationInfo> getAllAgreementList(Long projectId, Long areaId) {
|
|
|
|
+ List<CompensationInfo> list = baseMapper.getAllAgreementList(projectId, areaId);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量修改引用状态
|
|
|
|
+ * @param ids
|
|
|
|
+ * @param status
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void batchUpdateStatus(List<Long> ids, int status) {
|
|
|
|
+ baseMapper.batchUpdateStatus(ids,status);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void unSave(Long agreementId) {
|
|
|
|
+ CompensationInfo info = this.getById(agreementId);
|
|
|
|
+ //如果从未保存过,直接删除
|
|
|
|
+ if (StringUtils.isBlank(info.getMergePdfUrl())){
|
|
|
|
+ List<Long> list = Arrays.asList(agreementId);
|
|
|
|
+ //删除中间表数据
|
|
|
|
+ linkTableService.deleteByAgreementIds(list);
|
|
|
|
+ //证明从未保存过直接删除补偿协议
|
|
|
|
+ baseMapper.delete2(agreementId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//获取当前节点的补偿编号
|
|
//获取当前节点的补偿编号
|
|
private String getNumber(Long areaId) {
|
|
private String getNumber(Long areaId) {
|
|
Integer number = baseMapper.getNumber(areaId);
|
|
Integer number = baseMapper.getNumber(areaId);
|