opt:add:新增手持软废直接出库功能;rev:1.合同台账优化2.厂家质保书优化

This commit is contained in:
2025-04-25 17:17:45 +08:00
parent 6232fbd6d7
commit daa5322121
13 changed files with 684 additions and 13 deletions

View File

@@ -492,7 +492,7 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
String point_code = jsonObject.get("point_code");
String storagevehicle_code = jsonObject.get("storagevehicle_code");
// 手工出库
String bill_type= "010601";
String bill_type= "010302";
JSONObject vehicleObj = WQLObject.getWQLObject("MD_PB_StorageVehicleInfo").query("storagevehicle_code='" + storagevehicle_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(vehicleObj)) {

View File

@@ -16,9 +16,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletResponse;
/**
* @author Liuxy
* @date 2021-12-15
@@ -122,4 +126,11 @@ public class PcsIfPurchaseorderprocController {
public ResponseEntity<Object> receiveQuery(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(pcsIfPurchaseorderprocService.receiveQuery(whereJson,page),HttpStatus.OK);
}
@GetMapping(value = "/download")
@Log("导出合同台账")
@ApiOperation("导出合同台账")
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
pcsIfPurchaseorderprocService.download(pcsIfPurchaseorderprocService.ledgerQueryDownloadQuery(whereJson), response);
}
}

View File

@@ -106,4 +106,18 @@ public interface PcsIfPurchaseorderprocService {
* @param whereJson /
*/
void saveRemark(JSONObject whereJson);
/**
* 合同台账导出查询
* @param whereJson 、
* @return 、
*/
List<JSONObject> ledgerQueryDownloadQuery(Map whereJson);
/**
* 合同台账
* @param ledgerQueryDownloadQuery 、
* @param response 、
*/
void download(List<JSONObject> ledgerQueryDownloadQuery, HttpServletResponse response) throws IOException;
}

View File

@@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.ext.erp.service.WmsToErpService;
import org.nl.utils.FileUtil;
import org.nl.utils.PageUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
@@ -30,6 +31,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
@@ -418,8 +422,14 @@ public class PcsIfPurchaseorderprocServiceImpl implements PcsIfPurchaseorderproc
erp.put("norigtaxmny", erp.getString("norigtaxmny"));
// 未到货重量
erp.put("qty_zt", erp.getString("qty_zt"));
// 处理状态: 合同未到货重量 = 0则为【完成】合同未到货重量 <> 0则为【采购中】
erp.put("proc_status", erp.getString("qty_zt").equals("0") ? "完成" : "采购中");
// 处理状态: 合同未到货重量 = 0则为【完成】 合同未到货重量 = 合同重量则为【生成】;否则为【采购中】
if (erp.getString("qty_zt").equals("0")) {
erp.put("proc_status","完成");
} else if (erp.getDoubleValue("qty_zt") == erp.getDoubleValue("qty_ht")) {
erp.put("proc_status","生成");
} else {
erp.put("proc_status","在途");
}
// 账龄取供应商【honour_days】字段
JSONObject jsonSupp = suppList.stream()
@@ -447,6 +457,13 @@ public class PcsIfPurchaseorderprocServiceImpl implements PcsIfPurchaseorderproc
resultList.add(erp);
}
// 判断是否有处理状态查询条件
if (ObjectUtil.isNotEmpty(MapUtil.getStr(whereJson, "proc_status"))) {
resultList = resultList.stream()
.filter(row -> row.getString("proc_status").equals(MapUtil.getStr(whereJson, "proc_status")))
.collect(Collectors.toList());
}
// 根据签订时间排序(倒序)
resultList = resultList.stream()
.sorted(Comparator.comparing(row -> row.getString("subscribedate"),Comparator.reverseOrder()))
@@ -457,7 +474,62 @@ public class PcsIfPurchaseorderprocServiceImpl implements PcsIfPurchaseorderproc
PageUtil.toPage(page.getPageNumber(), page.getPageSize(), resultList),
resultList.size()
);
return json;
return calculateTotal(json,resultList);
}
/**
* 合同台账计算合计
* @param json 分页数据
* @param resultList 全部数据集合
*/
private Map<String, Object> calculateTotal(Map<String, Object> json, List<JSONObject> resultList) {
// 格式化
List<JSONObject> content = JSON.parseArray(json.get("content").toString(), JSONObject.class);
// 计算合同重量
double qty_ht = resultList.stream()
.map(row -> NumberUtil.round(row.getDoubleValue("qty_ht"), 3))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.doubleValue();
// 计算合同金额
double norigtaxmny = resultList.stream()
.map(row -> NumberUtil.round(row.getDoubleValue("norigtaxmny"), 3))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.doubleValue();
// 计算合同未到货重量
double qty_zt = resultList.stream()
.map(row -> NumberUtil.round(row.getDoubleValue("qty_zt"), 3))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.doubleValue();
// 计算账龄
double honour_days = resultList.stream()
.map(row -> NumberUtil.round(row.getDoubleValue("honour_days"), 3))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.doubleValue();
// 合计重量
double allqty = resultList.stream()
.map(row -> NumberUtil.round(row.getDoubleValue("allqty"), 3))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.doubleValue();
// 合计金额
double all_valmoney = resultList.stream()
.map(row -> NumberUtil.round(row.getDoubleValue("all_valmoney"), 3))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.doubleValue();
JSONObject param = new JSONObject();
param.put("subscribedate", "合计");
param.put("qty_ht", qty_ht);
param.put("norigtaxmny", norigtaxmny);
param.put("qty_zt", qty_zt);
param.put("honour_days", honour_days);
param.put("allqty", allqty);
param.put("all_valmoney", all_valmoney);
content.add(param);
json.put("content",content);
return json ;
}
@Override
@@ -486,6 +558,149 @@ public class PcsIfPurchaseorderprocServiceImpl implements PcsIfPurchaseorderproc
tab.update(jsonObject);
}
@Override
public List<JSONObject> ledgerQueryDownloadQuery(Map whereJson) {
// 供应商表
WQLObject suppTab = WQLObject.getWQLObject("md_cs_supplierbase");
// 采购订单接口处理表
WQLObject procTab = WQLObject.getWQLObject("pcs_if_purchaseorderproc");
String material_code = MapUtil.getStr(whereJson, "material_code");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "88");
map.put("begin_time", MapUtil.getStr(whereJson, "begin_time"));
map.put("end_time", MapUtil.getStr(whereJson, "end_time"));
map.put("iszero", MapUtil.getStr(whereJson, "iszero"));
if (!ObjectUtil.isEmpty(material_code)) {
//处理转义字符
if (material_code.contains("\\")) {
material_code = material_code.replace("\\", "\\\\\\");
}
map.put("material_code", "%" + material_code + "%");
}
String contract_no = MapUtil.getStr(whereJson, "contract_no");
String supp_name = MapUtil.getStr(whereJson, "supp_name");
if (!ObjectUtil.isEmpty(contract_no)) {
map.put("contract_no", "%" + contract_no + "%");
}
if (!ObjectUtil.isEmpty(supp_name)) {
map.put("supp_name", "%" + supp_name + "%");
}
// 查询erp合同信息
List<JSONObject> erpList = WQL.getWO("QERP").setDbname("dataSource1").addParamMap(map).process().getResultJSONArray(0).toJavaList(JSONObject.class);
// 查询所有供应商
List<JSONObject> suppList = suppTab.query("is_used = '1' and is_delete = '0'")
.getResultJSONArray(0).toJavaList(JSONObject.class);
// 根据合同编码找所有采购订单
String vbillcode_in = erpList.stream()
.map(row -> row.getString("vbillcode"))
.collect(Collectors.joining("','"));
List<JSONObject> procList = procTab.query("contract_no IN ('" + vbillcode_in + "') AND dr = '0'")
.getResultJSONArray(0).toJavaList(JSONObject.class);
// 根据采购订单id查询所有有效的到货通知单明细
String proc_id_in = procList.stream()
.map(row -> row.getString("id"))
.collect(Collectors.joining("','"));
List<JSONObject> dtlList = WQL.getWO("QPCS_IF_PURCHASEORDERPROC02").addParam("flag", "14").addParam("proc_id", "('" + proc_id_in + "')")
.process().getResultJSONArray(0).toJavaList(JSONObject.class);
// 处理erp返回数据
List<JSONObject> resultList = new ArrayList<>();
for (JSONObject erp : erpList) {
// 签订时间
erp.put("subscribedate", erp.getString("subscribedate"));
// 合同编码
erp.put("contract_no", erp.getString("vbillcode"));
// 供应商
erp.put("supp_name", erp.getString("name"));
// 物料编码
erp.put("material_code", erp.getString("item_code"));
// 物料名称
erp.put("material_name", erp.getString("item_name"));
// 单价含税
erp.put("price_tax", erp.getString("norigtaxprice"));
// 合同重量
erp.put("qty_ht", erp.getString("qty_ht"));
// 合同金额
erp.put("norigtaxmny", erp.getString("norigtaxmny"));
// 未到货重量
erp.put("qty_zt", erp.getString("qty_zt"));
// 处理状态: 合同未到货重量 = 0则为【完成】 合同未到货重量 = 合同重量则为【生成】;否则为【采购中】
if (erp.getString("qty_zt").equals("0")) {
erp.put("proc_status","完成");
} else if (erp.getDoubleValue("qty_zt") == erp.getDoubleValue("qty_ht")) {
erp.put("proc_status","生成");
} else {
erp.put("proc_status","采购中");
}
// 账龄取供应商【honour_days】字段
JSONObject jsonSupp = suppList.stream()
.filter(row -> row.getString("ext_id").equals(erp.getString("cvendorid")))
.findFirst().orElse(null);
if (ObjectUtil.isEmpty(jsonSupp)) {
throw new BadRequestException("外部标志为【"+erp.getString("cvendorid")+"】的供应商不存在或未启用!");
}
erp.put("honour_days", jsonSupp.getString("honour_days"));
// 合计重量1.根据此【合同编码】和【物料编码】找采购订单 2.根据采购订单【标识】找到所有到货通知单明细数量的和
String procId_contains = procList.stream()
.filter(row -> row.getString("contract_no").equals(erp.getString("vbillcode"))
&& row.getString("item_id").equals(erp.getString("item_id"))
)
.map(row -> row.getString("id"))
.collect(Collectors.joining("','"));
double allqty = dtlList.stream()
.filter(row -> procId_contains.contains(row.getString("source_billdtl_id")))
.map(row -> row.getDoubleValue("receive_qty"))
.reduce(Double::sum).orElse(0.00);
// 合计金额:合计重量 * 含税单价
erp.put("allqty", allqty);
erp.put("all_valmoney", NumberUtil.mul(allqty, erp.getDoubleValue("norigtaxprice")));
resultList.add(erp);
}
// 判断是否有处理状态查询条件
if (ObjectUtil.isNotEmpty(MapUtil.getStr(whereJson, "proc_status"))) {
resultList = resultList.stream()
.filter(row -> row.getString("proc_status").equals(MapUtil.getStr(whereJson, "proc_status")))
.collect(Collectors.toList());
}
// 根据签订时间排序(倒序)
resultList = resultList.stream()
.sorted(Comparator.comparing(row -> row.getString("subscribedate"),Comparator.reverseOrder()))
.collect(Collectors.toList());
return resultList;
}
@Override
public void download(List<JSONObject> ledgerQueryDownloadQuery, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (int i = 0; i < ledgerQueryDownloadQuery.size(); i++) {
JSONObject jo = ledgerQueryDownloadQuery.get(i);
Map<String, Object> dtl_map = new LinkedHashMap<>();
dtl_map.put("签订时间", jo.getString("subscribedate"));
dtl_map.put("合同编码", jo.getString("contract_no"));
dtl_map.put("处理状态", jo.getString("proc_status"));
dtl_map.put("供应商", jo.getString("supp_name"));
dtl_map.put("物料编码", jo.getString("material_code"));
dtl_map.put("物料名称", jo.getString("material_name"));
dtl_map.put("单价含税", NumberUtil.round(jo.getDoubleValue("price_tax"), 3));
dtl_map.put("合同重量", NumberUtil.round(jo.getDoubleValue("qty_ht"), 3));
dtl_map.put("合同金额", NumberUtil.round(jo.getDoubleValue("norigtaxmny"), 3));
dtl_map.put("合同未到货重量", NumberUtil.round(jo.getDoubleValue("qty_zt"), 3));
dtl_map.put("账龄", jo.getString("honour_days"));
dtl_map.put("合计重量", NumberUtil.round(jo.getDoubleValue("allqty"), 3));
dtl_map.put("合计金额", NumberUtil.round(jo.getDoubleValue("all_valmoney"), 3));
list.add(dtl_map);
}
FileUtil.downloadExcel(list, response);
}
public static long getDaySize(String start_datetime, String end_datetime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();

View File

@@ -222,6 +222,7 @@
mst.receive_code,
LEFT(mst.input_time,10) as input_time,
dtl.receive_qty,
dtl.pcsn,
dtl.receive_qty * oder.PRICE_TAX AS valmoney,
DATE_ADD(LEFT(mst.input_time,10),INTERVAL supp.honour_days DAY) AS plan_date
FROM

View File

@@ -123,6 +123,13 @@ public class FactorywarrantymstController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("复核")
@ApiOperation("复核")
@PostMapping("/checkData")
public ResponseEntity<Object> checkData(@RequestBody JSONObject whereJson) {
return new ResponseEntity<>(factorywarrantymstService.checkData(whereJson),HttpStatus.OK);
}
@PostMapping({"/pictures/{inspection_id}"})
@ApiOperation("质保书上传")
public ResponseEntity<Object> upload(@RequestParam MultipartFile file, @PathVariable String inspection_id) {

View File

@@ -89,4 +89,9 @@ public interface FactorywarrantymstService {
void confirm(JSONObject whereJson);
/**
* 复核
* @param whereJson 、
*/
JSONObject checkData(JSONObject whereJson);
}

View File

@@ -5,6 +5,7 @@ package org.nl.wms.ql.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
@@ -512,6 +513,24 @@ public class FactorywarrantymstServiceImpl implements FactorywarrantymstService
}
}
@Override
public JSONObject checkData(JSONObject whereJson) {
JSONObject result = new JSONObject();
WQLObject tab = WQLObject.getWQLObject("ql_test_factorywarrantydtl");
JSONObject json = tab.query("inspection_id = '" + whereJson.getString("inspection_id") + "' AND inspection_item_id = '1510155749437870083'").uniqueResult(0);
// 比较
boolean is_check = false;
if (NumberUtil.round(whereJson.getDoubleValue("value"), 4).doubleValue() != NumberUtil.round(json.getDoubleValue("value"), 4).doubleValue()) {
result.put("value",NumberUtil.round(json.getDoubleValue("value"), 4).doubleValue());
} else {
is_check = true;
}
result.put("is_check", is_check);
return result;
}
@Override
public Map<String, Object> localStorage(Map whereJson, Pageable page) {
HashMap<String, String> map = new HashMap<>(whereJson);