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/controller/LeaseApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java
index 965e4390..2121b8dc 100644
--- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java
+++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseApplyInfoController.java
@@ -1,30 +1,22 @@
package com.bonus.material.lease.controller;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
+import com.bonus.common.core.utils.poi.ExcelUtil;
+import com.bonus.common.core.web.controller.BaseController;
+import com.bonus.common.core.web.domain.AjaxResult;
+import com.bonus.common.core.web.page.TableDataInfo;
+import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
-import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
+import com.bonus.material.lease.domain.LeaseApplyInfo;
+import com.bonus.material.lease.service.ILeaseApplyInfoService;
import com.bonus.material.task.domain.vo.TmTaskRequestVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import com.bonus.common.log.annotation.SysLog;
-import com.bonus.common.security.annotation.RequiresPermissions;
-import com.bonus.material.lease.domain.LeaseApplyInfo;
-import com.bonus.material.lease.service.ILeaseApplyInfoService;
-import com.bonus.common.core.web.controller.BaseController;
-import com.bonus.common.core.web.domain.AjaxResult;
-import com.bonus.common.core.utils.poi.ExcelUtil;
-import com.bonus.common.core.web.page.TableDataInfo;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
/**
* 领料任务Controller
diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyInfo.java
index b84a04e3..1e530b86 100644
--- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyInfo.java
+++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyInfo.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
+import lombok.EqualsAndHashCode;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
@@ -16,9 +17,11 @@ import com.bonus.common.core.web.domain.BaseEntity;
*/
+@EqualsAndHashCode(callSuper = false)
@Data
@ToString
public class LeaseApplyInfo extends BaseEntity {
+
private static final long serialVersionUID = 1L;
/** ID */
@@ -127,5 +130,14 @@ public class LeaseApplyInfo extends BaseEntity {
@ApiModelProperty(value = "费用承担方(01项目03分包)")
private String costBearingParty;
+ @ApiModelProperty(value = "租赁工程")
+ private String leaseProject;
+
+ @ApiModelProperty(value = "租赁单位")
+ private String leaseUnit;
+
+ @ApiModelProperty(value = "协议号")
+ private String agreementCode;
+
}
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..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
@@ -1,7 +1,13 @@
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.settlement.domain.SltAgreementInfo;
+import com.bonus.material.task.domain.TmTask;
+import org.apache.ibatis.annotations.Param;
/**
* 领料出库详细Mapper接口
@@ -57,4 +63,55 @@ 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);
+
+ /** 插入领料出库详情表 -- 根据字段选择注入 */
+ 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/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..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
@@ -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;
+
/**
* 查询领料出库详细
*
@@ -53,11 +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;
-// }
- leaseOutDetailsMapper.insertLeaseOutDetails(bean);
+ AjaxResult ajaxResult = submitOut(bean);
+ if (ajaxResult.isError()) {
+ return ajaxResult;
+ }
}
return AjaxResult.success();
}
@@ -107,79 +126,218 @@ 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("出库成功");
-// }
-//
-// 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) {
+ @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";
+ 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;
-// } else {
-// res = 1;
-// }
// }
// }
-// 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 {
+ // 普通机具减少 (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/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml
index 3f1cdf14..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
@@ -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/LeaseApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml
index 8767ffd8..fb99462b 100644
--- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml
+++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml
@@ -30,41 +30,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
- select id, code, task_id, lease_person, phone, type, company_audit_by, company_audit_time, company_audit_remark, dept_audit_by, dept_audit_time, dept_audit_remark, direct_audit_by, direct_audit_time, direct_audit_remark, create_by, create_time, update_by, update_time, remark, company_id, status, direct_id, lease_type, estimate_lease_time, cost_bearing_party from lease_apply_info
+ select
+ lai.id, lai.code, lai.task_id, lai.lease_person, lai.phone, lai.type, lai.company_audit_by,
+ lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
+ lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
+ lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
+ lai.status, lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party,
+ bu.unit_name, bp.pro_name, bai.agreement_code
+ from
+ lease_apply_info lai
+ left join
+ tm_task_agreement tta on lai.task_id = tta.task_id
+ left join
+ bm_agreement_info bai on tta.agreement_id = bai.agreement_id
+ left join
+ bm_unit bu on bu.unit_id = bai.unit_id
+ left join
+ bm_project bp on bp.pro_id = bai.project_id
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..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
@@ -107,4 +107,269 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
+
+
+
+
+
+
+
+
+
+
+
+
+ update tm_task
+ set task_status = #{status},
+ update_time = NOW()
+ where task_id = #{taskId}
+
+
+
+
+
+
+
+ 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
+ parent_id = #{record.parentId} and type_id = #{record.typeId}
+
+
+
+
+
+ UPDATE
+ lease_apply_details
+ SET
+ status = '2'
+ WHERE
+ parent_id = #{record.parentId} and type_id = #{record.typeId}
+
\ No newline at end of file
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"