Merge remote-tracking branch 'origin/master'

This commit is contained in:
jjLv 2024-11-13 10:18:30 +08:00
commit 63407704a7
15 changed files with 812 additions and 119 deletions

View File

@ -193,6 +193,12 @@
<artifactId>commons-compress</artifactId>
<version>1.22</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
</dependencies>
</project>

View File

@ -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"; //外部单位协议
}

View File

@ -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<String,Object> 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;
// }
}

View File

@ -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

View File

@ -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;
}

View File

@ -65,4 +65,6 @@ public class LeaseOutDetails extends BaseEntity {
@ApiModelProperty(value = "出库类型 0编码出库 1数量出库 2成套出库")
private Integer manageType;
@ApiModelProperty(value = "数量出库-出库数量")
private Long inputNum;
}

View File

@ -61,4 +61,6 @@ public interface LeaseApplyDetailsMapper {
public int deleteLeaseApplyDetailsByIds(Long[] ids);
public int deleteLeaseApplyDetailsByParentIds(Long[] ids);
List<LeaseApplyDetails> getByParentId(Long parentId);
}

View File

@ -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<TmTask> 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);
}

View File

@ -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());

View File

@ -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<LeaseOutDetails> 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<TmTask> 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<LeaseApplyDetails> 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<TmTask> 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;
}
}

View File

@ -123,6 +123,9 @@ public class Type extends BaseEntity {
@ApiModelProperty(value = "丢失赔偿价")
private BigDecimal payPrice;
@ApiModelProperty(value = "???价")
private BigDecimal finalPrice;
/** 税率 */
@ApiModelProperty(value = "税率")
private BigDecimal taxRatio;

View File

@ -19,6 +19,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="companyId" column="company_id" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by, update_time, remark, company_id
</sql>
<sql id="selectLeaseApplyDetailsVo">
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
</sql>
@ -127,4 +132,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
)
</delete>
<select id="getByParentId" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from lease_apply_details
where parent_id = #{parentId}
</select>
</mapper>

View File

@ -30,41 +30,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="leaseType" column="lease_type" />
<result property="estimateLeaseTime" column="estimate_lease_time" />
<result property="costBearingParty" column="cost_bearing_party" />
<result property="leaseProject" column="pro_name" />
<result property="leaseUnit" column="unit_name" />
<result property="agreementCode" column="agreement_code" />
</resultMap>
<sql id="selectLeaseApplyInfoVo">
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
</sql>
<select id="selectLeaseApplyInfoList" parameterType="com.bonus.material.lease.domain.LeaseApplyInfo" resultMap="LeaseApplyInfoResult">
<include refid="selectLeaseApplyInfoVo"/>
<where>
<if test="code != null and code != ''"> and code = #{code}</if>
<if test="taskId != null "> and task_id = #{taskId}</if>
<if test="leasePerson != null and leasePerson != ''"> and lease_person = #{leasePerson}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="companyAuditBy != null "> and company_audit_by = #{companyAuditBy}</if>
<if test="companyAuditTime != null "> and company_audit_time = #{companyAuditTime}</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''"> and company_audit_remark = #{companyAuditRemark}</if>
<if test="deptAuditBy != null "> and dept_audit_by = #{deptAuditBy}</if>
<if test="deptAuditTime != null "> and dept_audit_time = #{deptAuditTime}</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''"> and dept_audit_remark = #{deptAuditRemark}</if>
<if test="directAuditBy != null "> and direct_audit_by = #{directAuditBy}</if>
<if test="directAuditTime != null "> and direct_audit_time = #{directAuditTime}</if>
<if test="directAuditRemark != null and directAuditRemark != ''"> and direct_audit_remark = #{directAuditRemark}</if>
<if test="companyId != null "> and company_id = #{companyId}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="directId != null "> and direct_id = #{directId}</if>
<if test="leaseType != null and leaseType != ''"> and lease_type = #{leaseType}</if>
<if test="estimateLeaseTime != null "> and estimate_lease_time = #{estimateLeaseTime}</if>
<if test="costBearingParty != null and costBearingParty != ''"> and cost_bearing_party = #{costBearingParty}</if>
<if test="code != null and code != ''"> and lai.code = #{code}</if>
<if test="taskId != null "> and lai.task_id = #{taskId}</if>
<if test="leasePerson != null and leasePerson != ''"> and lai.lease_person = #{leasePerson}</if>
<if test="phone != null and phone != ''"> and lai.phone = #{phone}</if>
<if test="type != null and type != ''"> and lai.type = #{type}</if>
<if test="companyAuditBy != null "> and lai.company_audit_by = #{companyAuditBy}</if>
<if test="companyAuditTime != null "> and lai.company_audit_time = #{companyAuditTime}</if>
<if test="companyAuditRemark != null and companyAuditRemark != ''"> and lai.company_audit_remark = #{companyAuditRemark}</if>
<if test="deptAuditBy != null "> and lai.dept_audit_by = #{deptAuditBy}</if>
<if test="deptAuditTime != null "> and lai.dept_audit_time = #{deptAuditTime}</if>
<if test="deptAuditRemark != null and deptAuditRemark != ''"> and lai.dept_audit_remark = #{deptAuditRemark}</if>
<if test="directAuditBy != null "> and lai.direct_audit_by = #{directAuditBy}</if>
<if test="directAuditTime != null "> and lai.direct_audit_time = #{directAuditTime}</if>
<if test="directAuditRemark != null and directAuditRemark != ''"> and lai.direct_audit_remark = #{directAuditRemark}</if>
<if test="companyId != null "> and lai.company_id = #{companyId}</if>
<if test="status != null and status != ''"> and lai.status = #{status}</if>
<if test="directId != null "> and lai.direct_id = #{directId}</if>
<if test="leaseType != null and leaseType != ''"> and lai.lease_type = #{leaseType}</if>
<if test="estimateLeaseTime != null "> and lai.estimate_lease_time = #{estimateLeaseTime}</if>
<if test="costBearingParty != null and costBearingParty != ''"> and lai.cost_bearing_party = #{costBearingParty}</if>
</where>
</select>
<select id="selectLeaseApplyInfoById" parameterType="Long" resultMap="LeaseApplyInfoResult">
<include refid="selectLeaseApplyInfoVo"/>
where id = #{id}
where lai.id = #{id}
</select>
<insert id="insertLeaseApplyInfo" parameterType="com.bonus.material.lease.domain.LeaseApplyInfo" useGeneratedKeys="true" keyProperty="id">

View File

@ -107,4 +107,269 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<select id="getMachineStatus" resultType="java.lang.String">
select ma_status
from ma_machine
where ma_id = #{maId}
</select>
<select id="getOutboundNum" resultType="com.bonus.material.lease.domain.LeaseOutDetails">
SELECT pre_num AS preNum,
pre_num - IFNULL(al_num, 0) AS nums
FROM lease_apply_details
WHERE id = #{id} AND (pre_num - IFNULL(al_num, 0)) > 0
</select>
<select id="getTaskId" resultType="java.lang.String">
select task_id
from lease_apply_info
where id = #{parentId}
</select>
<select id="getmaChineByCt" resultType="java.lang.Integer">
SELECT
CASE mt.manage_type
WHEN 0 THEN
IFNULL(subquery0.num, 0)
ELSE
IFNULL(mt.num, 0)
END as num
FROM ma_type mt
left join (SELECT mt.type_id,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
count(mm.ma_id) num
FROM ma_machine mm
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE mm.ma_code is not null and mm.ma_status in (15)
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
WHERE mt.del_flag = '0' and mt.type_id = #{typeId}
</select>
<select id="getMaTypeDetails" resultType="com.bonus.material.task.domain.TmTask">
SELECT
mws2.type_id AS typeId,
mws2.part_num AS partNum
FROM
ma_type mt1
LEFT JOIN ma_whole_set mws2 ON mt1.type_id = mws2.parent_id
WHERE
mt1.type_id = #{typeId}
</select>
<update id="updateTaskStatus">
update tm_task
set task_status = #{status},
update_time = NOW()
where task_id = #{taskId}
</update>
<select id="selectByTypeId" resultType="com.bonus.material.ma.domain.Type">
select * from ma_type WHERE
type_id = #{record.typeId}
</select>
<select id="getCountOfCodeMachine" resultType="java.lang.Integer">
select count(mm.ma_id)
FROM ma_type mt
left join ma_machine mm on mm.type_id=mt.type_id
WHERE
mm.type_id = #{record.typeId}
and mm.ma_code is not null
and mm.ma_status in (15)
and mt.`level` = 4
and mt.del_flag = '0'
</select>
<insert id="insertSelective">
insert into lease_out_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
parent_id,
</if>
<if test="typeId!= null">
type_id,
</if>
<if test="maId!= null">
ma_id,
</if>
<if test="outNum!= null">
out_num,
</if>
<if test="outType!= null">
out_type,
</if>
<if test="createBy!= null">
create_by,
</if>
<if test="updateBy!= null">
update_by,
</if>
<if test="remark!= null">
remark,
</if>
<if test="companyId!= null">
company_id,
</if>
<if test="carCode!= null">
car_code,
</if>
create_time,
update_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId!= null">
#{parentId},
</if>
<if test="typeId!= null">
#{typeId},
</if>
<if test="maId!= null">
#{maId},
</if>
<if test="outNum!= null">
#{outNum},
</if>
<if test="outType!= null">
#{outType},
</if>
<if test="createBy!= null">
#{createBy},
</if>
<if test="updateBy!= null">
#{updateBy},
</if>
<if test="remark!= null">
#{remark},
</if>
<if test="companyId!= null">
#{companyId},
</if>
<if test="carCode!= null">
#{carCode},
</if>
NOW(),
NOW()
</trim>
</insert>
<update id="updateMaTypeStockNum">
UPDATE
ma_type
SET
num = num - #{record.outNum} ,update_time = NOW()
WHERE
type_id = #{record.typeId}
</update>
<update id="updateMaMachineStatus">
UPDATE
ma_machine
SET
ma_status = '16',create_time = NOW()
<where>
type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''">
and ma_id = #{record.maId}
</if>
</where>
</update>
<select id="getSltAgreementInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
id,
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId,
num AS num,
start_time AS startTime,
end_time AS endTime,
status AS status,
lease_id AS leaseId,
back_id AS backId,
lease_price AS leasePrice,
buy_price AS buyPrice,
company_id AS companyId
FROM
slt_agreement_info
WHERE
lease_id = #{parentId}
AND
type_id = #{typeId}
AND
ma_id IS NULL
AND
status = '0'
AND
DATE(start_time) = CURDATE();
</select>
<update id="updSltInfo">
update slt_agreement_info
set num = #{num},
update_time = now()
where id = #{id}
</update>
<select id="getAgreementId" resultType="java.lang.String">
select agreement_id
from tm_task_agreement
where task_id = #{taskId}
</select>
<select id="getMaType" resultType="com.bonus.material.ma.domain.Type">
select lease_price as leasePrice,
rent_price as rentPrice,
buy_price as buyPrice,
pay_price as payPrice,
company_id as companyId
from ma_type
where type_id = #{typeId} and del_flag = 0
</select>
<select id="getProtocol" resultType="java.lang.String">
select protocol
from bm_agreement_info
where agreement_id = #{agreementId}
</select>
<insert id="insSltInfo">
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());
</insert>
<update id="updateLeaseApplyDetailsOutNum">
UPDATE
lease_apply_details
SET
al_num = IF(al_num IS NULL, #{record.outNum}, al_num + #{record.outNum}),
<if test="record.updateBy != null and record.updateBy!= '' ">
update_by = #{record.updateBy},
</if>
update_time = now(),
status = '1'
WHERE
parent_id = #{record.parentId} and type_id = #{record.typeId}
</update>
<select id="getLeaseApplyDetails" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
ifnull( pre_num, 0 ) AS preNum,
ifnull( audit_num, 0 ) AS auditNum,
ifnull( al_num, 0 ) AS alNum
FROM
lease_apply_details
WHERE
parent_id = #{record.parentId}
AND type_id = #{record.typeId}
</select>
<update id="updateLeaseApplyDetails">
UPDATE
lease_apply_details
SET
status = '2'
WHERE
parent_id = #{record.parentId} and type_id = #{record.typeId}
</update>
</mapper>

View File

@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
select max(month_order) from tm_task
select COALESCE(max(month_order), 0) from tm_task
where
month(create_time) = #{month} and year(create_time) = #{year}
<if test="taskType != null and taskType !=''">