|
@@ -8,6 +8,7 @@ import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
import cn.ezhizao.project.business.domain.*;
|
|
|
import cn.ezhizao.project.business.service.*;
|
|
|
+import cn.ezhizao.project.system.service.ISysConfigService;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
@@ -68,15 +69,21 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
@Resource
|
|
|
private IBizLotTechnologicalProcessDetailService bizLotTechnologicalProcessDetailService;
|
|
|
@Value("${file.excelTemplate.url}")
|
|
|
- private String templatePath;
|
|
|
+ private String templatePath;
|
|
|
+ @Resource
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
|
/**
|
|
|
* 查询报工列表
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
@Log(title = "查询报工列表", businessType = BusinessType.SELECT)
|
|
|
- public TableDataInfo list(BizProcessInspecion bizProcessInspecion) {
|
|
|
+ public TableDataInfo list(BizProcessInspecion bizProcessInspecion) throws NoSuchFieldException, IllegalAccessException {
|
|
|
startPage();
|
|
|
+ String config = configService.selectConfigByKey("switch_data_source");
|
|
|
+ if ("true".equals(config)) {
|
|
|
+ setTenantId(bizProcessInspecion);
|
|
|
+ }
|
|
|
//查询当前生产子计划的批次报工列表
|
|
|
List<BizProcessInspecion> list = bizProcessInspecionService.getVerifyList(bizProcessInspecion);
|
|
|
List<BizDaywork> dayworks = bizDayworkService.query().in("id", list.isEmpty() ? Collections.singletonList(0L) : list.stream().map(BizProcessInspecion::getDayworkId).collect(Collectors.toList())).list();
|
|
@@ -120,6 +127,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 判断是否按炉结算 假设按炉结算则返回该炉的所有质检单id
|
|
|
+ *
|
|
|
* @param bizProcessInspecion 选中的质检单
|
|
|
* @return 该炉所有质检单
|
|
|
*/
|
|
@@ -142,15 +150,16 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
return AjaxResult.success(Collections.singletonList(bizProcessInspecion.getId()));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@PostMapping("/checkMultiplyFurnace")
|
|
|
@Log(title = "检查炉号", businessType = BusinessType.SELECT)
|
|
|
public AjaxResult checkMultiplyFurnace(@RequestBody List<BizProcessInspecion> bizProcessInspecionList) {
|
|
|
List<Long> outsourcedOrderIds = bizProcessInspecionList.stream().map(BizProcessInspecion::getOutsourceOrderId).collect(Collectors.toList());
|
|
|
List<BizOutsourcedOrder> bizOutsourcedOrderList = bizOutsourcedOrderService.query().in("id", outsourcedOrderIds).list();
|
|
|
- List<BizOutsourcedOrderDetail> detailList = bizOutsourcedOrderDetailService.query().in("master_id",outsourcedOrderIds).list();
|
|
|
+ List<BizOutsourcedOrderDetail> detailList = bizOutsourcedOrderDetailService.query().in("master_id", outsourcedOrderIds).list();
|
|
|
List<BizProcessInspecion> processInspecionLists = bizProcessInspecionService.query().in("outsource_order_detail_id", detailList.stream().map(BizOutsourcedOrderDetail::getId).collect(Collectors.toList())).isNull("recheck_date").eq("status", 1).list();
|
|
|
- for (BizOutsourcedOrder v : bizOutsourcedOrderList){
|
|
|
- if(v.getSettlementType().equals("2")){
|
|
|
+ for (BizOutsourcedOrder v : bizOutsourcedOrderList) {
|
|
|
+ if (v.getSettlementType().equals("2")) {
|
|
|
// 结算方式为按炉结算
|
|
|
// 获取该外协单的所有明细
|
|
|
List<BizOutsourcedOrderDetail> details = detailList.stream().filter(l -> l.getMasterId().equals(v.getId())).collect(Collectors.toList());
|
|
@@ -190,7 +199,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
l.setMaterialLoss(materialLoss);
|
|
|
});
|
|
|
String template = "processInspectionTemplate";
|
|
|
- String templateFilePath = templatePath + template + ".xlsx";
|
|
|
+ String templateFilePath = templatePath + template + ".xlsx";
|
|
|
List<Map<String, Object>> exportList = new ArrayList<>();
|
|
|
list.forEach(l -> {
|
|
|
Arrays.stream(l.getProcessNames().split(",")).forEach(v -> {
|
|
@@ -278,7 +287,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
// 判断当有报工明细没有炉号信息则输出错误
|
|
|
JSONArray array = jsonObject.getJSONArray("data");
|
|
|
List<BizOutsourceBalanceAccount> returnArray = array.toList(BizOutsourceBalanceAccount.class);
|
|
|
- if(returnArray.stream().anyMatch(v -> v.getBizMaterialBase() == null || v.getBizMaterialBaseInfo() == null)) {
|
|
|
+ if (returnArray.stream().anyMatch(v -> v.getBizMaterialBase() == null || v.getBizMaterialBaseInfo() == null)) {
|
|
|
throw new RuntimeException("有产品没有材料信息");
|
|
|
}
|
|
|
List<BizOutsourceBalanceAccount> addList = new ArrayList<>();
|
|
@@ -357,8 +366,8 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
item.setPlanAmount(BigDecimal.ONE.multiply(freightPrice).multiply(BigDecimal.ONE.add(item.getTaxRate().divide(BigDecimal.valueOf(100), 6, RoundingMode.HALF_UP))).setScale(4, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
bizOutsourcedOrderDetails.forEach(l -> {
|
|
|
- BizOutsourceBalanceAccount item = addList.stream().filter(e -> e.getOutsourceOrderDetailId().equals(l.getId())).collect(Collectors.toList()).get(0);
|
|
|
- item.setFreightAmount(item.getSupplier().getFreightDeductUnitPrice().multiply(BigDecimal.valueOf(item.getCarrierNum())));
|
|
|
+ BizOutsourceBalanceAccount item = addList.stream().filter(e -> e.getOutsourceOrderDetailId().equals(l.getId())).collect(Collectors.toList()).get(0);
|
|
|
+ item.setFreightAmount(item.getSupplier().getFreightDeductUnitPrice().multiply(BigDecimal.valueOf(item.getCarrierNum())));
|
|
|
});
|
|
|
} else {
|
|
|
// 八成用不上,但是假设出现多选审核就可能用得上了。
|
|
@@ -423,7 +432,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
private JSONObject requestMaterialInfo(List<BizOutsourceBalanceAccount> balanceAccounts, String authorization) {
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Authorization", authorization);
|
|
|
- String result = HttpUtils.sentPostJson(p2Url + "business/outsourceBalance/getSettlementInfo", new JSONArray(balanceAccounts).toString(), headers);
|
|
|
+ String result = HttpUtils.sentPostJson(p2Url + "business/outsourceBalance/getSettlementInfo", new JSONArray(balanceAccounts).toString(), headers);
|
|
|
System.out.println(result);
|
|
|
// 添加结算记录
|
|
|
return new JSONObject(result);
|
|
@@ -518,7 +527,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
// throw new RuntimeException("找不到外协厂数据,请联系管理员");
|
|
|
// }
|
|
|
balanceAccount.setSurfaceTreatment(l.getSupplier().getSurfaceTreatment());
|
|
|
- if(flag.get()) {
|
|
|
+ if (flag.get()) {
|
|
|
balanceAccount.setCarrierNum(bizOutsourcedOrderDetail.getNewCarrierCount());
|
|
|
flag.set(false);
|
|
|
}
|
|
@@ -540,7 +549,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
BigDecimal processPrice = balanceAccount.getProcessPrice() == null ? BigDecimal.ZERO : balanceAccount.getProcessPrice();
|
|
|
|
|
|
// 废品单价
|
|
|
- if (l.getSupplier().getSurfaceTreatment().equals("N")){
|
|
|
+ if (l.getSupplier().getSurfaceTreatment().equals("N")) {
|
|
|
System.out.println("废品价类别:" + l.getSupplier().getWastePriceCategory());
|
|
|
System.out.println("最近采购单价:" + l.getBizMaterialBase().getZjunprc());
|
|
|
// 没表面处理时
|
|
@@ -568,7 +577,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
balanceAccount.setMaterialLossAmount(BigDecimal.valueOf(balanceAccount.getMaterialLoss()).multiply(wastePrice.multiply(BigDecimal.valueOf(120).divide(BigDecimal.valueOf(100), 6, RoundingMode.HALF_UP))).multiply(BigDecimal.ONE.add(BigDecimal.valueOf(l.getSupplier().getTaxRatio()).divide(BigDecimal.valueOf(100), 6, RoundingMode.HALF_UP))).setScale(4, RoundingMode.HALF_UP));
|
|
|
} else {
|
|
|
// 有时
|
|
|
- if(l.getSupplier().getWastePriceCategory().equals("21")) {
|
|
|
+ if (l.getSupplier().getWastePriceCategory().equals("21")) {
|
|
|
// 废品价计算类别='21' 废品加工单价=round(产品单价(inc10100.unprc) - 加工单价 ,4)
|
|
|
balanceAccount.setWastePrice(l.getProduct().getUnprc().subtract(processPrice).setScale(4, RoundingMode.HALF_UP));
|
|
|
} else if (l.getSupplier().getWastePriceCategory().equals("22")) {
|
|
@@ -676,7 +685,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
|
|
|
// 表面表示是否有表面处理
|
|
|
balanceAccount.setSurfaceTreatment(l.getSupplier().getSurfaceTreatment());
|
|
|
- if(flag.get()) {
|
|
|
+ if (flag.get()) {
|
|
|
balanceAccount.setCarrierNum(bizOutsourcedOrderDetail.getNewCarrierCount());
|
|
|
flag.set(false);
|
|
|
}
|
|
@@ -698,7 +707,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
BigDecimal processPrice = balanceAccount.getProcessPrice() == null ? BigDecimal.ZERO : balanceAccount.getProcessPrice();
|
|
|
|
|
|
// 废品单价
|
|
|
- if (l.getSupplier().getSurfaceTreatment().equals("N")){
|
|
|
+ if (l.getSupplier().getSurfaceTreatment().equals("N")) {
|
|
|
// 没表面处理时
|
|
|
if (l.getSupplier().getWastePriceCategory().equals("11")) {
|
|
|
// 废品价计算类别='11' round(实际投料量 * 原料最近采购单价[inv10100.zjunprc实时变更],4)
|
|
@@ -723,7 +732,7 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
balanceAccount.setMaterialLossAmount(BigDecimal.valueOf(balanceAccount.getMaterialLoss()).multiply(wastePrice.multiply(BigDecimal.valueOf(120).divide(BigDecimal.valueOf(100), 6, RoundingMode.HALF_UP))).multiply(BigDecimal.ONE.add(BigDecimal.valueOf(l.getSupplier().getTaxRatio()).divide(BigDecimal.valueOf(100), 6, RoundingMode.HALF_UP))).setScale(2, RoundingMode.HALF_UP));
|
|
|
} else {
|
|
|
// 有时
|
|
|
- if(l.getSupplier().getWastePriceCategory().equals("21")) {
|
|
|
+ if (l.getSupplier().getWastePriceCategory().equals("21")) {
|
|
|
// 废品价计算类别='21' 废品加工单价=round(产品单价(inc10100.unprc) - 加工单价 ,4)
|
|
|
balanceAccount.setWastePrice(l.getProduct().getUnprc().subtract(processPrice).setScale(4, RoundingMode.HALF_UP));
|
|
|
} else if (l.getSupplier().getWastePriceCategory().equals("22")) {
|
|
@@ -747,18 +756,19 @@ public class BizBeforeCheckoutVerifyController extends BaseController {
|
|
|
});
|
|
|
return addList;
|
|
|
}
|
|
|
+
|
|
|
private void delBalanceCheckout(List<BizProcessInspecion> inspections) {
|
|
|
List<String> settledLotCodes = new ArrayList<>();
|
|
|
// 删除结算记录
|
|
|
- List<BizOutsourceBalanceAccount> balanceAccounts = bizOutsourceBalanceAccountService.query().in("process_inspection_id", inspections.isEmpty()? Collections.singletonList(0L): inspections.stream().map(BizProcessInspecion::getId).collect(Collectors.toList())).list();
|
|
|
- for(BizOutsourceBalanceAccount b : balanceAccounts){
|
|
|
- if(b.getStatus().equals(1)) {
|
|
|
- if(!settledLotCodes.contains(b.getLotCode())){
|
|
|
+ List<BizOutsourceBalanceAccount> balanceAccounts = bizOutsourceBalanceAccountService.query().in("process_inspection_id", inspections.isEmpty() ? Collections.singletonList(0L) : inspections.stream().map(BizProcessInspecion::getId).collect(Collectors.toList())).list();
|
|
|
+ for (BizOutsourceBalanceAccount b : balanceAccounts) {
|
|
|
+ if (b.getStatus().equals(1)) {
|
|
|
+ if (!settledLotCodes.contains(b.getLotCode())) {
|
|
|
settledLotCodes.add(b.getLotCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(!settledLotCodes.isEmpty()){
|
|
|
+ if (!settledLotCodes.isEmpty()) {
|
|
|
String lotCode = String.join(", ", settledLotCodes);
|
|
|
throw new RuntimeException(lotCode + "批次外协已结算,请取消结算");
|
|
|
}
|