Commit 4e3fc840 authored by Fuzy's avatar Fuzy

修正

parent 9037e6dc
...@@ -88,94 +88,54 @@ public class ActSuppliesAccountServiceImpl implements IActSuppliesAccountService ...@@ -88,94 +88,54 @@ public class ActSuppliesAccountServiceImpl implements IActSuppliesAccountService
* @return * @return
*/ */
private static List<ActDispensing> getActDispensing(List<ActDispensing> actDispensings) { 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) { for (ActDispensing actDispensing : actDispensings) {
String[] names = actDispensing.getName().split("_"); JSONObject object = new JSONObject();
int len = names.length; object.put("accsubjectchart", "1896891590924304390");
jsonObject.put("names", names[len - 1]); object.put("pk_org", "1685820920723669151");
ReturnResult returnResult = VoucherUtils.callVoucherQuery(jsonObject, "/yonbip/fi/fipub/accsubject/querysubjectapi"); object.put("codes", actDispensing.getR());
ArrayList data = returnResult.getData(); ReturnResult returnResult = VoucherUtils.callVoucherQuery(object, "/yonbip/fi/fipub/accsubject/querysubjectapi");
JSONObject object = (JSONObject) data.get(0); JSONObject o = (JSONObject) returnResult.getData().get(0);
JSONObject accsubjectchart = object.getJSONObject("accsubjectchart"); JSONObject data = o.getJSONObject("accsubjectchart");
JSONObject accSubjects = (JSONObject) accsubjectchart.get("accSubjects"); JSONObject accSubjects = data.getJSONObject("accSubjects");
accSubjects.forEach((a, b) -> { for (Map.Entry<String, Object> stringObjectEntry : accSubjects.entrySet()) {
JSONObject jsonObject1 = (JSONObject) b; JSONArray jsonObject = (JSONArray) stringObjectEntry.getValue();
if (actDispensing.getName().equals(jsonObject1.getString("displayname"))) { Optional<JSONObject> code = IntStream.range(0, jsonObject.size())
actDispensing.setAccountingCode(jsonObject1.getString("code")); .mapToObj(jsonObject::getJSONObject)
JSONArray bodies = jsonObject1.getJSONArray("bodies"); .filter(v -> actDispensing.getR().equals(v.getString("code")))
if (actDispensing.getAccountingNameA() != null && actDispensing.getAccountingNameA().split("-").length == 2) { .findFirst();
String[] split = actDispensing.getAccountingNameA().split("-"); if (code.isPresent()) {
boolean dimensionext_name = IntStream.range(0, bodies.size()) JSONArray bodies = code.get().getJSONArray("bodies");
.mapToObj(bodies::getJSONObject) for (int i = 0; i < bodies.size(); i++) {
.map(v -> v.getString("dimensionext_name")) JSONObject json = (JSONObject) bodies.get(i);
.anyMatch(v -> split[0].equals(v)); String name = json.getString("dimensionext_name");
if (dimensionext_name) { if ("物料基本分类".equals(name)) {
JSONObject object1 = new JSONObject(); actDispensing.setAccountingIdA("物料基本分类,FM060305");
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"))
.findFirst();
first.ifPresent(actDispensing::setAccountingIdB);
} }
} if ("财务核算部门".equals(name)) {
if (actDispensing.getAccountingNameC() != null && actDispensing.getAccountingNameC().split("-").length == 2) { ReturnResult cw0027 = getReturnResult("CW0027_yql", "/yonbip/digitalModel/customerdoc/list");
String[] split = actDispensing.getAccountingNameC().split("-"); JSONObject obj = (JSONObject) cw0027.getData().get(0);
boolean dimensionext_name = IntStream.range(0, bodies.size()) JSONArray recordList = obj.getJSONArray("recordList");
.mapToObj(bodies::getJSONObject) Optional<JSONObject> first = IntStream.range(0, recordList.size())
.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) .mapToObj(recordList::getJSONObject)
.filter(v -> v.getString("custdocdefid_name").equals(split[0])) .filter(v -> actDispensing.getMaterial().equals(v.getJSONObject("name").getString("zh_CN")))
.map(v -> v.getString("code"))
.findFirst(); .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 { ...@@ -57,11 +57,7 @@ public class WagesConversionController extends BaseController {
} }
@GetMapping("/recentFormulas/{id}") @GetMapping("/recentFormulas/{id}")
public AjaxResult recentFormulas(@PathVariable("id") String mineId){ public AjaxResult recentFormulas(@PathVariable("id") String mineId) {
Object o = wagesConversionService.recentFormulas(mineId); return wagesConversionService.recentFormulas(mineId);
if (o!=null){
return new AjaxResult(200, "成功", o);
}
return new AjaxResult(500, (String) o, null);
} }
} }
package com.ruoyi.system.service; 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.dao.WagesConversionData;
import com.ruoyi.system.model.wages.dto.WagesParamsDto; import com.ruoyi.system.model.wages.dto.WagesParamsDto;
import com.ruoyi.system.model.wages.vo.WagesConversionDataVO; import com.ruoyi.system.model.wages.vo.WagesConversionDataVO;
...@@ -10,14 +11,14 @@ import java.util.List; ...@@ -10,14 +11,14 @@ import java.util.List;
* 2024/5/11 * 2024/5/11
*/ */
public interface WagesConversionService { public interface WagesConversionService {
void save(WagesConversionDataVO wagesConversionDataVO); void save(WagesConversionDataVO wagesConversionDataVO);
List<WagesConversionData> selectWagesConversionDataList(WagesParamsDto wagesParamsDto); List<WagesConversionData> selectWagesConversionDataList(WagesParamsDto wagesParamsDto);
void update(WagesConversionData wagesConversionData); void update(WagesConversionData wagesConversionData);
WagesConversionData selectWagesConversionDataById(int id); WagesConversionData selectWagesConversionDataById(int id);
Object recentFormulas(String mineId); AjaxResult recentFormulas(String mineId);
} }
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.mapper.WagesConversionMapper; import com.ruoyi.system.mapper.WagesConversionMapper;
import com.ruoyi.system.model.wages.dao.WagesConversionData; import com.ruoyi.system.model.wages.dao.WagesConversionData;
import com.ruoyi.system.model.wages.dto.WagesParamsDto; import com.ruoyi.system.model.wages.dto.WagesParamsDto;
...@@ -51,23 +52,23 @@ public class WagesConversionServiceImpl implements WagesConversionService { ...@@ -51,23 +52,23 @@ public class WagesConversionServiceImpl implements WagesConversionService {
} }
@Override @Override
public Object recentFormulas(String mineId) { public AjaxResult recentFormulas(String mineId) {
List<WagesConversionDataVO> list = wagesConversionMapper.selectWagesValueAndDate(mineId); List<WagesConversionDataVO> list = wagesConversionMapper.selectWagesValueAndDate(mineId);
list.removeAll(Collections.singleton(null)); list.removeAll(Collections.singleton(null));
boolean b1 = list.parallelStream().anyMatch(v -> v.getYearMonth() == null || v.getYearMonth().indexOf("-") <= 0); 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); Optional<Integer> max = list.parallelStream().map(v -> Integer.parseInt(v.getYearMonth().split("-")[0])).max((a, b) -> a - b);
List<WagesConversionDataVO> collect; List<WagesConversionDataVO> collect;
if (max.isPresent()) { if (max.isPresent()) {
collect = list.parallelStream().filter(v -> v.getYearMonth().split("-")[0].equals(max.get() + "")).collect(Collectors.toList()); collect = list.parallelStream().filter(v -> v.getYearMonth().split("-")[0].equals(max.get() + "")).collect(Collectors.toList());
} else { } else {
return "数据库中没有数据"; return new AjaxResult(500, "数据库中没有数据", null);
} }
if (collect.size() != 0) { 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()); 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