From 4e3520aa3d834cb76e9265e6d67212b824005353 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 13 Nov 2024 09:30:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E9=A2=86=E6=96=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bonus-common-biz/pom.xml | 6 + .../biz/constant/MaterialConstants.java | 4 + .../bonus/common/biz/utils/HttpHelper.java | 159 ++++++++++++++ .../lease/domain/LeaseOutDetails.java | 2 + .../lease/mapper/LeaseApplyDetailsMapper.java | 2 + .../lease/mapper/LeaseOutDetailsMapper.java | 21 ++ .../impl/LeaseApplyInfoServiceImpl.java | 1 + .../impl/LeaseOutDetailsServiceImpl.java | 197 ++++++++++++++++-- .../lease/LeaseApplyDetailsMapper.xml | 13 ++ .../material/lease/LeaseOutDetailsMapper.xml | 75 +++++++ 10 files changed, 461 insertions(+), 19 deletions(-) create mode 100644 bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java diff --git a/bonus-common-biz/pom.xml b/bonus-common-biz/pom.xml index 2a557ec6..4a6dedbf 100644 --- a/bonus-common-biz/pom.xml +++ b/bonus-common-biz/pom.xml @@ -193,6 +193,12 @@ commons-compress 1.22 + + + org.apache.httpcomponents + httpmime + 4.5.6 + diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java index 2179ff29..d7c57863 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java @@ -55,4 +55,8 @@ public class MaterialConstants { /** 领料单号的开头字母 */ public static final String LEASE_TASK_TYPE_LABEL = "L"; + public static final String INNER_PROTOCAL = "1"; //内部单位协议 + + public static final String OUTER_PROTOCAL = "2"; //外部单位协议 + } diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java new file mode 100644 index 00000000..48524e27 --- /dev/null +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/HttpHelper.java @@ -0,0 +1,159 @@ +package com.bonus.common.biz.utils; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +public class HttpHelper { + + public static String sendHttpPost(String url, String JSONBody) throws Exception { + System.out.println("JSONBody-=========:" + JSONBody); + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost httpPost = new HttpPost(url); + httpPost.addHeader("Content-Type", "application/json; charset=UTF-8"); + httpPost.setEntity(new StringEntity(JSONBody,StandardCharsets.UTF_8)); + CloseableHttpResponse response = httpClient.execute(httpPost); + HttpEntity entity = response.getEntity(); + String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8); + response.close(); + httpClient.close(); + return responseContent; + } + + public static String sendHttpPost(String url,String token,String content,String intelligentAppKey) throws Exception { + System.out.println("JSONBody-=========:" + content); + try (CloseableHttpClient client = HttpClients.createDefault()) { + HttpPost post = new HttpPost(url); + post.setHeader("token", token); + post.setHeader("appKey", intelligentAppKey); + MultipartEntityBuilder builder = MultipartEntityBuilder.create(); + builder.addBinaryBody("params", content.getBytes()); + post.setEntity(builder.build()); + + CloseableHttpResponse response = client.execute(post); + HttpEntity entity = response.getEntity(); + String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8); + response.close(); + return responseContent; + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + + public static String doPost(String urlString,String param) { + HttpURLConnection connection = null; + InputStream is = null; + OutputStream os = null; + BufferedReader br = null; + String result = null; + try { + URL url = new URL(urlString); + // 通过远程url连接对象打开连接 + connection = (HttpURLConnection) url.openConnection(); + // 设置连接请求方式 + connection.setRequestMethod("POST"); + // 设置连接主机服务器超时时间:15000毫秒 + connection.setConnectTimeout(15000); + // 设置读取主机服务器返回数据超时时间:60000毫秒 + connection.setReadTimeout(60000); + + // 默认值为:false,当向远程服务器传送数据/写数据时,需要设置为true + connection.setDoOutput(true); + // 默认值为:true,当前向远程服务读取数据时,设置为true,该参数可有可无 + connection.setDoInput(true); + // 设置传入参数的格式:请求参数应该是 name1=value1&name2=value2 的形式。 + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + // 设置鉴权信息:Authorization: Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0 + connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0"); + // 通过连接对象获取一个输出流 + os = connection.getOutputStream(); + // 通过输出流对象将参数写出去/传输出去,它是通过字节数组写出的 + os.write(param.getBytes()); + // 通过连接对象获取一个输入流,向远程读取 + if (connection.getResponseCode() == 200) { + + is = connection.getInputStream(); + // 对输入流对象进行包装:charset根据工作项目组的要求来设置 + br = new BufferedReader(new InputStreamReader(is, "UTF-8")); + + StringBuffer sbf = new StringBuffer(); + String temp = null; + // 循环遍历一行一行读取数据 + while ((temp = br.readLine()) != null) { + sbf.append(temp); + sbf.append("\r\n"); + } + result = sbf.toString(); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭资源 + if (null != br) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != os) { + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (null != is) { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + // 断开与远程地址url的连接 + connection.disconnect(); + } + return result; + } + +// public static String getIotToken() { +// Map map=new HashMap<>(); +// String redisCode = null; +// map.put("type", UserConstants.IOT_TYPE); +// map.put("from",UserConstants.IOT_FROM); +// map.put("username",UserConstants.IOT_USERNAME); +// //采用md5加密 +// map.put("password",UserConstants.IOT_PASSWORD); +// String param = JSON.toJSONString(map); +// String resultUser = HttpHelper.doPost(HttpStatus.LOGIN_URL,param); +// if (resultUser == null){ +// throw new RuntimeException("返回数据为空!!"); +// } +// JSONObject object = JSONObject.parseObject(resultUser); +// if ("0".equals(object.getString("status"))){ +// redisCode = object.getString("token"); +// }else { +// throw new RuntimeException("返回数据为空!!"); +// } +// return redisCode; +// } + + +} \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseOutDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseOutDetails.java index 300f049d..1dd112ca 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseOutDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseOutDetails.java @@ -65,4 +65,6 @@ public class LeaseOutDetails extends BaseEntity { @ApiModelProperty(value = "出库类型 0编码出库 1数量出库 2成套出库") private Integer manageType; + @ApiModelProperty(value = "数量出库-出库数量") + private Long inputNum; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java index 31fd19b2..2e33122c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java @@ -61,4 +61,6 @@ public interface LeaseApplyDetailsMapper { public int deleteLeaseApplyDetailsByIds(Long[] ids); public int deleteLeaseApplyDetailsByParentIds(Long[] ids); + + List getByParentId(Long parentId); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java index bbb20e8c..9e80ab8e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java @@ -1,7 +1,12 @@ package com.bonus.material.lease.mapper; import java.util.List; + +import com.bonus.material.lease.domain.LeaseApplyDetails; import com.bonus.material.lease.domain.LeaseOutDetails; +import com.bonus.material.ma.domain.Type; +import com.bonus.material.task.domain.TmTask; +import org.apache.ibatis.annotations.Param; /** * 领料出库详细Mapper接口 @@ -57,4 +62,20 @@ public interface LeaseOutDetailsMapper { * @return 结果 */ public int deleteLeaseOutDetailsByIds(Long[] ids); + + String getMachineStatus(LeaseOutDetails record); + + LeaseApplyDetails getOutboundNum(LeaseOutDetails record); + + String getTaskId(Long parentId); + + int getmaChineByCt(LeaseOutDetails record); + + List getMaTypeDetails(LeaseOutDetails record); + + int updateTaskStatus(@Param("taskId") String taskId, @Param("status")int status); + + Type selectByTypeId(@Param("record") LeaseOutDetails record); + + int getCountOfCodeMachine(@Param("record") LeaseOutDetails record); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index 256e26a2..849980b7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -89,6 +89,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { PurchaseTaskStatusEnum.TO_NOTICE.getStatus(), tmTaskRequestVo.getLeaseApplyInfo().getCompanyId(), "1", thisMonthMaxOrder + 1, taskCode); tmTask.setCreateTime(DateUtils.getNowDate()); + tmTask.setCreateBy(SecurityUtils.getUsername()); tmTaskMapper.insertTmTask(tmTask); TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), tmTaskRequestVo.getAgreementId()); tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index 8c099c7c..e03e0137 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -1,9 +1,25 @@ package com.bonus.material.lease.service.impl; +import java.math.BigDecimal; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Objects; + +import com.alibaba.fastjson2.JSONObject; +import com.bonus.common.biz.constant.MaterialConstants; +import com.bonus.common.biz.utils.HttpHelper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; +import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.lease.domain.LeaseApplyDetails; +import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper; +import com.bonus.material.ma.domain.Machine; +import com.bonus.material.ma.domain.Type; +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.task.domain.TmTask; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.bonus.material.lease.mapper.LeaseOutDetailsMapper; @@ -18,10 +34,14 @@ import org.springframework.transaction.annotation.Transactional; * @date 2024-10-16 */ @Service +@Slf4j public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { @Autowired private LeaseOutDetailsMapper leaseOutDetailsMapper; + @Autowired + LeaseApplyDetailsMapper leaseApplyDetailsMapper; + /** * 查询领料出库详细 * @@ -57,7 +77,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { // if (ajaxResult.isError()) { // return ajaxResult; // } - leaseOutDetailsMapper.insertLeaseOutDetails(bean); + //leaseOutDetailsMapper.insertLeaseOutDetails(bean); } return AjaxResult.success(); } @@ -145,7 +165,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { // if (res == 0) { // throw new RuntimeException("出库失败,插入结算记录失败"); // } -// record.setPostStoreNum(getStorageNum(record)); +// //record.setPostStoreNum(getStorageNum(record)); // } else { // return AjaxResult.error("领料出库失败,机具库存不足"); // } @@ -157,29 +177,168 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { // } // return AjaxResult.success("出库成功"); // } -// -// private int checkRepeatSubmit(LeaseOutDetails record) { -// String maStatus = "15"; -// int res = 0; -// if (record.getManageType() == 1 || record.getManageType() == 2) { -// // 如果是数量出库校验待出库数量 -// LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record); -// if (details == null) { + + private int checkRepeatSubmit(LeaseOutDetails record) { + String maStatus = "15"; + int res = 0; + if (record.getManageType() == 1 || record.getManageType() == 2) { + // 如果是数量出库校验待出库数量 + LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record); + if (details == null) { + return res; + } else { + res = 1; + } + } else { + // 如果是编码出库判断是否在库 + if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) { + String status = leaseOutDetailsMapper.getMachineStatus(record); + if (!maStatus.equals(status)) { + return res; + } else { + res = 1; + } + } + } + return res; + } + + private int checkStorageNumCt(LeaseOutDetails record) { + int res = 0; + double outNum = 0.1; + if (StringUtils.isNull(record)) { + return res; + } + + if (record.getOutNum() == null || record.getOutNum() < outNum) { + record.setOutNum(0L); + } + //先判断成套机具的库存是否足够 + int num = leaseOutDetailsMapper.getmaChineByCt(record); + if (num < record.getOutNum()) { + return res; + } + //判断(ma_type 设备规格表)中的库存够不够出库的 + List typeIds = leaseOutDetailsMapper.getMaTypeDetails(record); + typeIds.removeIf(item -> item == null); +// for (TmTask typeId : typeIds) { +// MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId); +// machinePart.setPartNum((typeId.getPartNum() * record.getOutNum())); +// if (machinePart.getNum() < machinePart.getPartNum()) { // return res; -// } else { -// res = 1; // } -// } else { -// // 如果是编码出库判断是否在库 -// if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) { -// String status = leaseOutDetailsMapper.getMachineStatus(record); -// if (!maStatus.equals(status)) { -// return res; +// } + return 1; + } + + private int updateTaskStatus(LeaseOutDetails record) { + int res = 0; + // 进行状态判断 + List leaseApplyDetailsList = leaseApplyDetailsMapper.getByParentId(record.getParentId()); + int i = 0; + for (LeaseApplyDetails bean : leaseApplyDetailsList) { + if (Objects.equals(bean.getPreNum(), bean.getAlNum())) { + i++; + } + } + String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId()); + if (i == leaseApplyDetailsList.size()) { + leaseOutDetailsMapper.updateTaskStatus(taskId, 35); + res = 1; + } else { + leaseOutDetailsMapper.updateTaskStatus(taskId, 34); + res = 1; + } + return res; + } + + private int checkStorageNum(LeaseOutDetails record) { + double outNum = 0.1; + if (StringUtils.isNull(record)) { + return 0; + } + + if (record.getOutNum() == null || record.getOutNum() < outNum) { + record.setOutNum(0L); + } + //判断(ma_type 设备规格表)中的库存够不够出库的 + Type maType = leaseOutDetailsMapper.selectByTypeId(record); + if (maType != null) { + if ("0".equals(maType.getManageType())) { + int count = leaseOutDetailsMapper.getCountOfCodeMachine(record); + if (BigDecimal.valueOf(count).compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) { + return 0; + } + } else if ("1".equals(maType.getManageType())) { + if (maType.getStorageNum() == null || maType.getStorageNum().compareTo(record.getOutNum()) < 0) { + return 0; + } + } + } + return 1; + } + +// private int insertRecords(LeaseOutDetails record) { +// int res = 0; +// // 首先更新领料任务详情表的领料数及状态(lease_apply_details) +// res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); +// LeaseApplyDetails leaseApplyDetails = leaseOutDetailsMapper.getLeaseApplyDetails(record); +// if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) { +// leaseOutDetailsMapper.updateLeaseApplyDetails(record); +// } +// if (res > 0) { +// // 插入领料出库明细表(lease_out_details) +// res = leaseOutDetailsMapper.insertSelective(record); +// if (res > 0) { +// if (record.getManageType() == 2) { +// // 成套机具减少 (ma_type 设备规格表)的库存数量 +// res = leaseOutDetailsMapper.updateMaTypeStockNum(record); +// // 成套机具减少 (ma_type 设备规格表)配件的库存数量 +// List typeIds = leaseOutDetailsMapper.getMaTypeDetails(record); +// typeIds.removeIf(item -> item == null); +//// for (TmTask typeId : typeIds) { +//// MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId); +//// machinePart.setPartNum((typeId.getPartNum() * record.getOutNum())); +//// typeId.setNum(machinePart.getNum() - machinePart.getPartNum()); +//// res = leaseOutDetailsMapper.updateMaTypeStockNumCt(typeId); +//// } // } else { -// res = 1; +// // 普通机具减少 (ma_type 设备规格表)的库存数量 +// res = leaseOutDetailsMapper.updateMaTypeStockNum(record); // } +// // 更新 (ma_machine 设备表)的状态 +// leaseOutDetailsMapper.updateMaMachineStatus(record); // } // } // return res; // } +// +// public int insSltInfo(String taskId, LeaseOutDetails record) { +// int res = 0; +// SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record); +// if (sltAgreementInfo != null) { +// Long num = sltAgreementInfo.getNum(); +// Long outNum = record.getOutNum(); +// sltAgreementInfo.setNum(num + outNum); +// res = leaseOutDetailsMapper.updSltInfo(sltAgreementInfo); +// } else { +// String agreementId = leaseOutDetailsMapper.getAgreementId(taskId); +// String protocol = leaseOutDetailsMapper.getProtocol(agreementId); +// Type ma = leaseOutDetailsMapper.getMaType(record.getTypeId()); +// if (StringUtils.isEmpty(protocol)) { +// ma.setFinalPrice(ma.getLeasePrice()); +// } else { +// if (MaterialConstants.INNER_PROTOCAL.equals(protocol)) { +// ma.setFinalPrice(ma.getLeasePrice()); +// } else if (Constants.OUTER_PROTOCAL.equals(protocol)) { +// ma.setFinalPrice(ma.getRentPrice()); +// } else { +// ma.setFinalPrice(ma.getLeasePrice()); +// } +// } +// res = leaseOutDetailsMapper.insSltInfo(record, agreementId, ma); +// } +// return res; +// } + } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index 3f1cdf14..ea5198cf 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -19,6 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + id, parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by, update_time, remark, company_id + + select id, parent_id, type_id, pre_num, audit_num, al_num, status, create_by, create_time, update_by, update_time, remark, company_id from lease_apply_details @@ -127,4 +132,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml index 68624e8e..c9cbeeee 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml @@ -107,4 +107,79 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} + + + + + + + + + + + + + update tm_task + set task_status = #{status}, + update_time = NOW() + where task_id = #{taskId} + + + + + \ No newline at end of file From ec9e196433dfa49b417791f99eb69dce38565cb7 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 13 Nov 2024 09:44:07 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=A2=86=E6=96=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lease/mapper/LeaseOutDetailsMapper.java | 36 +++ .../impl/LeaseOutDetailsServiceImpl.java | 232 +++++++++--------- .../com/bonus/material/ma/domain/Type.java | 3 + .../material/lease/LeaseOutDetailsMapper.xml | 190 ++++++++++++++ 4 files changed, 345 insertions(+), 116 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java index 9e80ab8e..2accf78e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java @@ -5,6 +5,7 @@ import java.util.List; import com.bonus.material.lease.domain.LeaseApplyDetails; import com.bonus.material.lease.domain.LeaseOutDetails; import com.bonus.material.ma.domain.Type; +import com.bonus.material.settlement.domain.SltAgreementInfo; import com.bonus.material.task.domain.TmTask; import org.apache.ibatis.annotations.Param; @@ -78,4 +79,39 @@ public interface LeaseOutDetailsMapper { Type selectByTypeId(@Param("record") LeaseOutDetails record); int getCountOfCodeMachine(@Param("record") LeaseOutDetails record); + + /** 插入领料出库详情表 -- 根据字段选择注入 */ + int insertSelective(LeaseOutDetails record); + + /** + * 减少 (ma_type 设备规格表)的库存数量 + */ + int updateMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails); + + /** + * 修改机具设备(ma_machine表)的状态为:在用 + */ + int updateMaMachineStatus(@Param("record") LeaseOutDetails leaseOutDetails); + + SltAgreementInfo getSltAgreementInfo(LeaseOutDetails record); + + int updSltInfo(SltAgreementInfo sltAgreementInfo); + + String getAgreementId(String taskId); + + Type getMaType(Long typeId); + + String getProtocol(String agreementId); + + int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId,@Param("ma") Type ma); + + /** + * 修改 (lease_apply_details 领料任务详细表)的已领数量 + */ + int updateLeaseApplyDetailsOutNum(@Param("record") LeaseOutDetails leaseOutDetails); + + LeaseApplyDetails getLeaseApplyDetails(@Param("record") LeaseOutDetails record); + + int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record); + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index e03e0137..871e7943 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -73,10 +73,10 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { @Override public AjaxResult insertLeaseOutDetails(List leaseOutDetailsList) { for (LeaseOutDetails bean : leaseOutDetailsList) { -// AjaxResult ajaxResult = submitOut(bean); -// if (ajaxResult.isError()) { -// return ajaxResult; -// } + AjaxResult ajaxResult = submitOut(bean); + if (ajaxResult.isError()) { + return ajaxResult; + } //leaseOutDetailsMapper.insertLeaseOutDetails(bean); } return AjaxResult.success(); @@ -127,56 +127,56 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { * @return 结果 */ //@Override -// @Transactional(rollbackFor = Exception.class) -// public AjaxResult submitOut(LeaseOutDetails record) { -// int res = 0; -// try { -// // 1、判断是否重复提交 -// res = checkRepeatSubmit(record); -// //record.setPreStoreNum(getStorageNum(record)); -// if (res > 0) { -// if ((record.getManageType() == 1 || record.getManageType() == 2) && record.getInputNum() != null) { -// record.setOutNum(record.getInputNum()); -// } -// //2、判断成套机具出库库存是否足够 -// if (record.getManageType() == 2) { -// res = checkStorageNumCt(record); -// if (res == 0) { -// throw new RuntimeException("出库失败,库存不足"); -// } -// } else { -// res = checkStorageNum(record); -// } -// -// if (res > 0) { -// // 3、插入出库记录,修改库存,修改机具状态 -// res = insertRecords(record); -// if (res == 0) { -// throw new RuntimeException("出库失败,更新设备规格库存数量时出错!"); -// } -// // 4、修改任务状态(tm_task) -// res = updateTaskStatus(record); -// if (res == 0) { -// throw new RuntimeException("出库失败,修改任务状态失败"); -// } -// // 5、插入结算记录 -// String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId()); -// res = insSltInfo(taskId, record); -// if (res == 0) { -// throw new RuntimeException("出库失败,插入结算记录失败"); -// } -// //record.setPostStoreNum(getStorageNum(record)); -// } else { -// return AjaxResult.error("领料出库失败,机具库存不足"); -// } -// } else { -// return AjaxResult.error("已领数量大于预领数量或该机具未在库"); -// } -// } catch (Exception e) { -// return AjaxResult.error("出库失败"); -// } -// return AjaxResult.success("出库成功"); -// } + @Transactional(rollbackFor = Exception.class) + public AjaxResult submitOut(LeaseOutDetails record) { + int res = 0; + try { + // 1、判断是否重复提交 + res = checkRepeatSubmit(record); + //record.setPreStoreNum(getStorageNum(record)); + if (res > 0) { + if ((record.getManageType() == 1 || record.getManageType() == 2) && record.getInputNum() != null) { + record.setOutNum(record.getInputNum()); + } + //2、判断成套机具出库库存是否足够 + if (record.getManageType() == 2) { + res = checkStorageNumCt(record); + if (res == 0) { + throw new RuntimeException("出库失败,库存不足"); + } + } else { + res = checkStorageNum(record); + } + + if (res > 0) { + // 3、插入出库记录,修改库存,修改机具状态 + res = insertRecords(record); + if (res == 0) { + throw new RuntimeException("出库失败,更新设备规格库存数量时出错!"); + } + // 4、修改任务状态(tm_task) + res = updateTaskStatus(record); + if (res == 0) { + throw new RuntimeException("出库失败,修改任务状态失败"); + } + // 5、插入结算记录 + String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId()); + res = insSltInfo(taskId, record); + if (res == 0) { + throw new RuntimeException("出库失败,插入结算记录失败"); + } + //record.setPostStoreNum(getStorageNum(record)); + } else { + return AjaxResult.error("领料出库失败,机具库存不足"); + } + } else { + return AjaxResult.error("已领数量大于预领数量或该机具未在库"); + } + } catch (Exception e) { + return AjaxResult.error("出库失败"); + } + return AjaxResult.success("出库成功"); + } private int checkRepeatSubmit(LeaseOutDetails record) { String maStatus = "15"; @@ -278,67 +278,67 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { return 1; } -// private int insertRecords(LeaseOutDetails record) { -// int res = 0; -// // 首先更新领料任务详情表的领料数及状态(lease_apply_details) -// res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); -// LeaseApplyDetails leaseApplyDetails = leaseOutDetailsMapper.getLeaseApplyDetails(record); -// if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) { -// leaseOutDetailsMapper.updateLeaseApplyDetails(record); -// } -// if (res > 0) { -// // 插入领料出库明细表(lease_out_details) -// res = leaseOutDetailsMapper.insertSelective(record); -// if (res > 0) { -// if (record.getManageType() == 2) { -// // 成套机具减少 (ma_type 设备规格表)的库存数量 -// res = leaseOutDetailsMapper.updateMaTypeStockNum(record); -// // 成套机具减少 (ma_type 设备规格表)配件的库存数量 -// List typeIds = leaseOutDetailsMapper.getMaTypeDetails(record); -// typeIds.removeIf(item -> item == null); -//// for (TmTask typeId : typeIds) { -//// MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId); -//// machinePart.setPartNum((typeId.getPartNum() * record.getOutNum())); -//// typeId.setNum(machinePart.getNum() - machinePart.getPartNum()); -//// res = leaseOutDetailsMapper.updateMaTypeStockNumCt(typeId); -//// } -// } else { -// // 普通机具减少 (ma_type 设备规格表)的库存数量 -// res = leaseOutDetailsMapper.updateMaTypeStockNum(record); -// } -// // 更新 (ma_machine 设备表)的状态 -// leaseOutDetailsMapper.updateMaMachineStatus(record); -// } -// } -// return res; -// } -// -// public int insSltInfo(String taskId, LeaseOutDetails record) { -// int res = 0; -// SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record); -// if (sltAgreementInfo != null) { -// Long num = sltAgreementInfo.getNum(); -// Long outNum = record.getOutNum(); -// sltAgreementInfo.setNum(num + outNum); -// res = leaseOutDetailsMapper.updSltInfo(sltAgreementInfo); -// } else { -// String agreementId = leaseOutDetailsMapper.getAgreementId(taskId); -// String protocol = leaseOutDetailsMapper.getProtocol(agreementId); -// Type ma = leaseOutDetailsMapper.getMaType(record.getTypeId()); -// if (StringUtils.isEmpty(protocol)) { -// ma.setFinalPrice(ma.getLeasePrice()); -// } else { -// if (MaterialConstants.INNER_PROTOCAL.equals(protocol)) { -// ma.setFinalPrice(ma.getLeasePrice()); -// } else if (Constants.OUTER_PROTOCAL.equals(protocol)) { -// ma.setFinalPrice(ma.getRentPrice()); -// } else { -// ma.setFinalPrice(ma.getLeasePrice()); -// } -// } -// res = leaseOutDetailsMapper.insSltInfo(record, agreementId, ma); -// } -// return res; -// } + private int insertRecords(LeaseOutDetails record) { + int res = 0; + // 首先更新领料任务详情表的领料数及状态(lease_apply_details) + res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); + LeaseApplyDetails leaseApplyDetails = leaseOutDetailsMapper.getLeaseApplyDetails(record); + if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) { + leaseOutDetailsMapper.updateLeaseApplyDetails(record); + } + if (res > 0) { + // 插入领料出库明细表(lease_out_details) + res = leaseOutDetailsMapper.insertSelective(record); + if (res > 0) { + if (record.getManageType() == 2) { + // 成套机具减少 (ma_type 设备规格表)的库存数量 + res = leaseOutDetailsMapper.updateMaTypeStockNum(record); + // 成套机具减少 (ma_type 设备规格表)配件的库存数量 + List typeIds = leaseOutDetailsMapper.getMaTypeDetails(record); + typeIds.removeIf(item -> item == null); +// for (TmTask typeId : typeIds) { +// MachinePart machinePart = leaseOutDetailsMapper.getMachineParts(typeId); +// machinePart.setPartNum((typeId.getPartNum() * record.getOutNum())); +// typeId.setNum(machinePart.getNum() - machinePart.getPartNum()); +// res = leaseOutDetailsMapper.updateMaTypeStockNumCt(typeId); +// } + } else { + // 普通机具减少 (ma_type 设备规格表)的库存数量 + res = leaseOutDetailsMapper.updateMaTypeStockNum(record); + } + // 更新 (ma_machine 设备表)的状态 + leaseOutDetailsMapper.updateMaMachineStatus(record); + } + } + return res; + } + + public int insSltInfo(String taskId, LeaseOutDetails record) { + int res = 0; + SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record); + if (sltAgreementInfo != null) { + Long num = sltAgreementInfo.getNum(); + Long outNum = record.getOutNum(); + sltAgreementInfo.setNum(num + outNum); + res = leaseOutDetailsMapper.updSltInfo(sltAgreementInfo); + } else { + String agreementId = leaseOutDetailsMapper.getAgreementId(taskId); + String protocol = leaseOutDetailsMapper.getProtocol(agreementId); + Type maType = leaseOutDetailsMapper.getMaType(record.getTypeId()); + if (StringUtils.isEmpty(protocol)) { + maType.setFinalPrice(maType.getLeasePrice()); + } else { + if (MaterialConstants.INNER_PROTOCAL.equals(protocol)) { + maType.setFinalPrice(maType.getLeasePrice()); + } else if (MaterialConstants.OUTER_PROTOCAL.equals(protocol)) { + maType.setFinalPrice(maType.getRentPrice()); + } else { + maType.setFinalPrice(maType.getLeasePrice()); + } + } + res = leaseOutDetailsMapper.insSltInfo(record, agreementId, maType); + } + return res; + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java index 937046b3..d263bf3e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Type.java @@ -123,6 +123,9 @@ public class Type extends BaseEntity { @ApiModelProperty(value = "丢失赔偿价") private BigDecimal payPrice; + @ApiModelProperty(value = "???价") + private BigDecimal finalPrice; + /** 税率 */ @ApiModelProperty(value = "税率") private BigDecimal taxRatio; diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml index c9cbeeee..66b7f69d 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml @@ -182,4 +182,194 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mt.`level` = 4 and mt.del_flag = '0' + + + insert into lease_out_details + + + parent_id, + + + type_id, + + + ma_id, + + + out_num, + + + out_type, + + + create_by, + + + update_by, + + + remark, + + + company_id, + + + car_code, + + create_time, + update_time + + + + #{parentId}, + + + #{typeId}, + + + #{maId}, + + + #{outNum}, + + + #{outType}, + + + #{createBy}, + + + #{updateBy}, + + + #{remark}, + + + #{companyId}, + + + #{carCode}, + + NOW(), + NOW() + + + + + UPDATE + ma_type + SET + num = num - #{record.outNum} ,update_time = NOW() + WHERE + type_id = #{record.typeId} + + + + UPDATE + ma_machine + SET + ma_status = '16',create_time = NOW() + + type_id = #{record.typeId} + + and ma_id = #{record.maId} + + + + + + + + update slt_agreement_info + set num = #{num}, + update_time = now() + where id = #{id} + + + + + + + + insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time) + values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType},now()); + + + + UPDATE + lease_apply_details + SET + al_num = IF(al_num IS NULL, #{record.outNum}, al_num + #{record.outNum}), + + update_by = #{record.updateBy}, + + update_time = now(), + status = '1' + WHERE + parennt_id = #{record.parentId} and type_id = #{record.typeId} + + + + + + UPDATE + lease_apply_details + SET + status = '2' + WHERE + parennt_id = #{record.parentId} and type_id = #{record.typeId} + \ No newline at end of file From e244ebed757bd42f77dce7f9c45fe32d705273d0 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 13 Nov 2024 09:47:36 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=A2=86=E6=96=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lease/service/impl/LeaseOutDetailsServiceImpl.java | 1 - .../mapper/material/lease/LeaseApplyDetailsMapper.xml | 2 +- .../mapper/material/lease/LeaseOutDetailsMapper.xml | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index 871e7943..759fe3d0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -77,7 +77,6 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { if (ajaxResult.isError()) { return ajaxResult; } - //leaseOutDetailsMapper.insertLeaseOutDetails(bean); } return AjaxResult.success(); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index ea5198cf..2c69c8d0 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -138,6 +138,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select from lease_apply_details - where parennt_id = #{parentId} + where parent_id = #{parentId} \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml index 66b7f69d..f2f9ca0f 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml @@ -349,7 +349,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update_time = now(), status = '1' WHERE - parennt_id = #{record.parentId} and type_id = #{record.typeId} + parent_id = #{record.parentId} and type_id = #{record.typeId} @@ -370,6 +370,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SET status = '2' WHERE - parennt_id = #{record.parentId} and type_id = #{record.typeId} + parent_id = #{record.parentId} and type_id = #{record.typeId} \ No newline at end of file From dfdf56a8c8d3ba9035bf5ce6e5ce08e592cd9755 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Wed, 13 Nov 2024 09:57:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E9=A2=86=E6=96=99=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/material/task/TmTaskMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml index d55c533a..6a133034 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskMapper.xml @@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and code = #{code} - and task_id = #{taskId} - and lease_person = #{leasePerson} - and phone = #{phone} - and type = #{type} - and company_audit_by = #{companyAuditBy} - and company_audit_time = #{companyAuditTime} - and company_audit_remark = #{companyAuditRemark} - and dept_audit_by = #{deptAuditBy} - and dept_audit_time = #{deptAuditTime} - and dept_audit_remark = #{deptAuditRemark} - and direct_audit_by = #{directAuditBy} - and direct_audit_time = #{directAuditTime} - and direct_audit_remark = #{directAuditRemark} - and company_id = #{companyId} - and status = #{status} - and direct_id = #{directId} - and lease_type = #{leaseType} - and estimate_lease_time = #{estimateLeaseTime} - and cost_bearing_party = #{costBearingParty} + and lai.code = #{code} + and lai.task_id = #{taskId} + and lai.lease_person = #{leasePerson} + and lai.phone = #{phone} + and lai.type = #{type} + and lai.company_audit_by = #{companyAuditBy} + and lai.company_audit_time = #{companyAuditTime} + and lai.company_audit_remark = #{companyAuditRemark} + and lai.dept_audit_by = #{deptAuditBy} + and lai.dept_audit_time = #{deptAuditTime} + and lai.dept_audit_remark = #{deptAuditRemark} + and lai.direct_audit_by = #{directAuditBy} + and lai.direct_audit_time = #{directAuditTime} + and lai.direct_audit_remark = #{directAuditRemark} + and lai.company_id = #{companyId} + and lai.status = #{status} + and lai.direct_id = #{directId} + and lai.lease_type = #{leaseType} + and lai.estimate_lease_time = #{estimateLeaseTime} + and lai.cost_bearing_party = #{costBearingParty}