Commit 4e3fc840 authored by Fuzy's avatar Fuzy

修正

parent 9037e6dc
......@@ -88,94 +88,54 @@ public class ActSuppliesAccountServiceImpl implements IActSuppliesAccountService
* @return
*/
private static List<ActDispensing> getActDispensing(List<ActDispensing> actDispensings) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("accsubjectchart", "1896891590924304390");
jsonObject.put("pk_org", "1685820920723669151");
for (ActDispensing actDispensing : actDispensings) {
String[] names = actDispensing.getName().split("_");
int len = names.length;
jsonObject.put("names", names[len - 1]);
ReturnResult returnResult = VoucherUtils.callVoucherQuery(jsonObject, "/yonbip/fi/fipub/accsubject/querysubjectapi");
ArrayList data = returnResult.getData();
JSONObject object = (JSONObject) data.get(0);
JSONObject accsubjectchart = object.getJSONObject("accsubjectchart");
JSONObject accSubjects = (JSONObject) accsubjectchart.get("accSubjects");
accSubjects.forEach((a, b) -> {
JSONObject jsonObject1 = (JSONObject) b;
if (actDispensing.getName().equals(jsonObject1.getString("displayname"))) {
actDispensing.setAccountingCode(jsonObject1.getString("code"));
JSONArray bodies = jsonObject1.getJSONArray("bodies");
if (actDispensing.getAccountingNameA() != null && actDispensing.getAccountingNameA().split("-").length == 2) {
String[] split = actDispensing.getAccountingNameA().split("-");
boolean dimensionext_name = IntStream.range(0, bodies.size())
.mapToObj(bodies::getJSONObject)
.map(v -> v.getString("dimensionext_name"))
.anyMatch(v -> split[0].equals(v));
if (dimensionext_name) {
JSONObject object1 = new JSONObject();
object1.put("pageIndex", "1");
object1.put("pageSize", "1000");
object1.put("name", split[1]);
ReturnResult returnResult1 = VoucherUtils.callVoucherQuery(jsonObject, "/yonbip/digitalModel/customerdoc/list");
JSONObject o = (JSONObject) returnResult1.getData().get(0);
JSONArray recordList = o.getJSONArray("recordList");
Optional<String> first = IntStream.range(0, recordList.size())
.mapToObj(recordList::getJSONObject)
.filter(v -> v.getString("custdocdefid_name").equals(split[0]))
.map(v -> v.getString("code"))
.findFirst();
first.ifPresent(actDispensing::setAccountingIdA);
}
}
if (actDispensing.getAccountingNameB() != null && actDispensing.getAccountingNameB().split("-").length == 2) {
String[] split = actDispensing.getAccountingNameB().split("-");
boolean dimensionext_name = IntStream.range(0, bodies.size())
.mapToObj(bodies::getJSONObject)
.map(v -> v.getString("dimensionext_name"))
.anyMatch(v -> split[0].equals(v));
if (dimensionext_name) {
JSONObject object1 = new JSONObject();
object1.put("pageIndex", "1");
object1.put("pageSize", "1000");
object1.put("name", split[1]);
ReturnResult returnResult1 = VoucherUtils.callVoucherQuery(jsonObject, "/yonbip/digitalModel/customerdoc/list");
JSONObject o = (JSONObject) returnResult1.getData().get(0);
JSONArray recordList = o.getJSONArray("recordList");
Optional<String> first = IntStream.range(0, recordList.size())
.mapToObj(recordList::getJSONObject)
.filter(v -> v.getString("custdocdefid_name").equals(split[0]))
.map(v -> v.getString("code"))
JSONObject object = new JSONObject();
object.put("accsubjectchart", "1896891590924304390");
object.put("pk_org", "1685820920723669151");
object.put("codes", actDispensing.getR());
ReturnResult returnResult = VoucherUtils.callVoucherQuery(object, "/yonbip/fi/fipub/accsubject/querysubjectapi");
JSONObject o = (JSONObject) returnResult.getData().get(0);
JSONObject data = o.getJSONObject("accsubjectchart");
JSONObject accSubjects = data.getJSONObject("accSubjects");
for (Map.Entry<String, Object> stringObjectEntry : accSubjects.entrySet()) {
JSONArray jsonObject = (JSONArray) stringObjectEntry.getValue();
Optional<JSONObject> code = IntStream.range(0, jsonObject.size())
.mapToObj(jsonObject::getJSONObject)
.filter(v -> actDispensing.getR().equals(v.getString("code")))
.findFirst();
first.ifPresent(actDispensing::setAccountingIdB);
}
}
if (actDispensing.getAccountingNameC() != null && actDispensing.getAccountingNameC().split("-").length == 2) {
String[] split = actDispensing.getAccountingNameC().split("-");
boolean dimensionext_name = IntStream.range(0, bodies.size())
.mapToObj(bodies::getJSONObject)
.map(v -> v.getString("dimensionext_name"))
.anyMatch(v -> split[0].equals(v));
if (dimensionext_name) {
JSONObject object1 = new JSONObject();
object1.put("pageIndex", "1");
object1.put("pageSize", "1000");
object1.put("name", split[1]);
ReturnResult returnResult1 = VoucherUtils.callVoucherQuery(jsonObject, "/yonbip/digitalModel/customerdoc/list");
JSONObject o = (JSONObject) returnResult1.getData().get(0);
JSONArray recordList = o.getJSONArray("recordList");
Optional<String> first = IntStream.range(0, recordList.size())
if (code.isPresent()) {
JSONArray bodies = code.get().getJSONArray("bodies");
for (int i = 0; i < bodies.size(); i++) {
JSONObject json = (JSONObject) bodies.get(i);
String name = json.getString("dimensionext_name");
if ("物料基本分类".equals(name)) {
actDispensing.setAccountingIdA("物料基本分类,FM060305");
}
if ("财务核算部门".equals(name)) {
ReturnResult cw0027 = getReturnResult("CW0027_yql", "/yonbip/digitalModel/customerdoc/list");
JSONObject obj = (JSONObject) cw0027.getData().get(0);
JSONArray recordList = obj.getJSONArray("recordList");
Optional<JSONObject> first = IntStream.range(0, recordList.size())
.mapToObj(recordList::getJSONObject)
.filter(v -> v.getString("custdocdefid_name").equals(split[0]))
.map(v -> v.getString("code"))
.filter(v -> actDispensing.getMaterial().equals(v.getJSONObject("name").getString("zh_CN")))
.findFirst();
first.ifPresent(actDispensing::setAccountingIdC);
if (first.isPresent()){
actDispensing.setAccountingIdB("财务核算部门," + first.get().getString("code"));
}
}
return;
}
});
}
return null;
}
}
return actDispensings;
}
private static ReturnResult getReturnResult(String value, String url) {
JSONObject object = new JSONObject();
object.put("pageIndex", "1");
object.put("pageSize", "1000");
object.put("custdocdefcode", value);
return VoucherUtils.callVoucherQuery(object, url);
}
/**
......
......@@ -57,11 +57,7 @@ public class WagesConversionController extends BaseController {
}
@GetMapping("/recentFormulas/{id}")
public AjaxResult recentFormulas(@PathVariable("id") String mineId){
Object o = wagesConversionService.recentFormulas(mineId);
if (o!=null){
return new AjaxResult(200, "成功", o);
}
return new AjaxResult(500, (String) o, null);
public AjaxResult recentFormulas(@PathVariable("id") String mineId) {
return wagesConversionService.recentFormulas(mineId);
}
}
package com.ruoyi.system.service;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.model.wages.dao.WagesConversionData;
import com.ruoyi.system.model.wages.dto.WagesParamsDto;
import com.ruoyi.system.model.wages.vo.WagesConversionDataVO;
......@@ -19,5 +20,5 @@ public interface WagesConversionService {
WagesConversionData selectWagesConversionDataById(int id);
Object recentFormulas(String mineId);
AjaxResult recentFormulas(String mineId);
}
package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.mapper.WagesConversionMapper;
import com.ruoyi.system.model.wages.dao.WagesConversionData;
import com.ruoyi.system.model.wages.dto.WagesParamsDto;
......@@ -51,23 +52,23 @@ public class WagesConversionServiceImpl implements WagesConversionService {
}
@Override
public Object recentFormulas(String mineId) {
public AjaxResult recentFormulas(String mineId) {
List<WagesConversionDataVO> list = wagesConversionMapper.selectWagesValueAndDate(mineId);
list.removeAll(Collections.singleton(null));
boolean b1 = list.parallelStream().anyMatch(v -> v.getYearMonth() == null || v.getYearMonth().indexOf("-") <= 0);
if (b1) return "数据库中数据存在日期错误";
if (b1) return new AjaxResult(500, "数据库中数据存在日期错误", null);
Optional<Integer> max = list.parallelStream().map(v -> Integer.parseInt(v.getYearMonth().split("-")[0])).max((a, b) -> a - b);
List<WagesConversionDataVO> collect;
if (max.isPresent()) {
collect = list.parallelStream().filter(v -> v.getYearMonth().split("-")[0].equals(max.get() + "")).collect(Collectors.toList());
} else {
return "数据库中没有数据";
return new AjaxResult(500, "数据库中没有数据", null);
}
if (collect.size() != 0) {
collect = collect.parallelStream().sorted((a, b) -> Integer.parseInt(b.getYearMonth().split("-")[1]) - Integer.parseInt(a.getYearMonth().split("-")[1])).collect(Collectors.toList());
return collect.get(0).getValue();
return new AjaxResult(200, "成功", collect.get(0).getValue());
}
return "数据库中数据错误";
return new AjaxResult(500, "数据库中数据错误", null);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment