领料优化
This commit is contained in:
parent
ea1840925e
commit
b7545c89ff
|
|
@ -5,8 +5,7 @@ import lombok.Getter;
|
|||
@Getter
|
||||
public enum MaTypeManageTypeEnum {
|
||||
CODE_DEVICE(0, "编码设备"),
|
||||
NUMBER_DEVICE(1, "数量设备"),
|
||||
SET_DEVICE(2, "成套设备");
|
||||
NUMBER_DEVICE(1, "数量设备");
|
||||
|
||||
private final Integer typeId;
|
||||
private final String typeName;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ 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 org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 领料任务详细Mapper接口
|
||||
|
|
@ -63,4 +65,13 @@ public interface LeaseApplyDetailsMapper {
|
|||
int deleteLeaseApplyDetailsByParentIds(Long[] ids);
|
||||
|
||||
List<LeaseApplyDetails> getByParentId(Long parentId);
|
||||
|
||||
/**
|
||||
* 修改 (lease_apply_details 领料任务详细表)的已领数量
|
||||
*/
|
||||
int updateLeaseApplyDetailsOutNum(@Param("record") LeaseOutDetails leaseOutDetails);
|
||||
|
||||
LeaseApplyDetails getLeaseApplyDetails(@Param("record") LeaseOutDetails record);
|
||||
|
||||
int updateLeaseApplyDetailsByLeaseOutRecord(@Param("record") LeaseOutDetails record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,54 +72,25 @@ public interface LeaseOutDetailsMapper {
|
|||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import java.util.Objects;
|
||||
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
||||
import com.bonus.common.biz.enums.MaMachineStatusEnum;
|
||||
import com.bonus.common.biz.enums.MaTypeManageTypeEnum;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
|
|
@ -14,6 +15,8 @@ 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.Type;
|
||||
import com.bonus.material.ma.mapper.MachineMapper;
|
||||
import com.bonus.material.ma.mapper.TypeMapper;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -39,6 +42,11 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
@Autowired
|
||||
LeaseApplyDetailsMapper leaseApplyDetailsMapper;
|
||||
|
||||
@Autowired
|
||||
MachineMapper machineMapper;
|
||||
|
||||
@Autowired
|
||||
TypeMapper typeMapper;
|
||||
/**
|
||||
* 查询领料出库详细
|
||||
*
|
||||
|
|
@ -131,19 +139,11 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
boolean isEnough = checkStorageIsEnough(record);
|
||||
//record.setPreStoreNum(getStorageNum(record));
|
||||
if (isEnough) {
|
||||
if ((record.getManageType() == MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId() ||
|
||||
record.getManageType() == MaTypeManageTypeEnum.SET_DEVICE.getTypeId()) && record.getInputNum() != null) {
|
||||
if ((record.getManageType() == MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId()) && record.getInputNum() != null) {
|
||||
record.setOutNum(record.getInputNum());
|
||||
}
|
||||
//2、判断成套机具出库库存是否足够
|
||||
if (record.getManageType() == MaTypeManageTypeEnum.SET_DEVICE.getTypeId()) {
|
||||
res = checkStorageNumCt(record);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,库存不足");
|
||||
}
|
||||
} else {
|
||||
|
||||
res = checkStorageNum(record);
|
||||
}
|
||||
|
||||
if (res > 0) {
|
||||
// 3、插入出库记录,修改库存,修改机具状态
|
||||
|
|
@ -177,14 +177,14 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
|
||||
// 判断库存是否足够
|
||||
private boolean checkStorageIsEnough(LeaseOutDetails record) {
|
||||
if (record.getManageType() == MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId() || record.getManageType() == MaTypeManageTypeEnum.SET_DEVICE.getTypeId()) {
|
||||
if (record.getManageType() == MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId()) {
|
||||
LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record);
|
||||
if (details == null) {
|
||||
return false;
|
||||
}
|
||||
} else if (record.getManageType() == MaTypeManageTypeEnum.CODE_DEVICE.getTypeId()) {
|
||||
if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) {
|
||||
String status = leaseOutDetailsMapper.getMachineStatus(record);
|
||||
String status = machineMapper.getMachineStatus(record);
|
||||
if (String.valueOf(MaMachineStatusEnum.IN_STORE.getStatus()).equals(status)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -193,34 +193,6 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
// }
|
||||
// }
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int updateTaskStatus(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
// 进行状态判断
|
||||
|
|
@ -233,10 +205,10 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
}
|
||||
String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId());
|
||||
if (i == leaseApplyDetailsList.size()) {
|
||||
leaseOutDetailsMapper.updateTaskStatus(taskId, 35);
|
||||
leaseOutDetailsMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus());
|
||||
res = 1;
|
||||
} else {
|
||||
leaseOutDetailsMapper.updateTaskStatus(taskId, 34);
|
||||
leaseOutDetailsMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
|
||||
res = 1;
|
||||
}
|
||||
return res;
|
||||
|
|
@ -252,10 +224,10 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
record.setOutNum(0L);
|
||||
}
|
||||
//判断(ma_type 设备规格表)中的库存够不够出库的
|
||||
Type maType = leaseOutDetailsMapper.selectByTypeId(record);
|
||||
Type maType = typeMapper.selectByTypeId(record);
|
||||
if (maType != null) {
|
||||
if ("0".equals(maType.getManageType())) {
|
||||
int count = leaseOutDetailsMapper.getCountOfCodeMachine(record);
|
||||
int count = typeMapper.getCountOfCodeMachine(record);
|
||||
if (BigDecimal.valueOf(count).compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -271,33 +243,19 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
private int insertRecords(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
// 首先更新领料任务详情表的领料数及状态(lease_apply_details)
|
||||
res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record);
|
||||
LeaseApplyDetails leaseApplyDetails = leaseOutDetailsMapper.getLeaseApplyDetails(record);
|
||||
res = leaseApplyDetailsMapper.updateLeaseApplyDetailsOutNum(record);
|
||||
LeaseApplyDetails leaseApplyDetails = leaseApplyDetailsMapper.getLeaseApplyDetails(record);
|
||||
if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) {
|
||||
leaseOutDetailsMapper.updateLeaseApplyDetails(record);
|
||||
leaseApplyDetailsMapper.updateLeaseApplyDetailsByLeaseOutRecord(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);
|
||||
}
|
||||
res = typeMapper.updateMaTypeStockNum(record);
|
||||
// 更新 (ma_machine 设备表)的状态
|
||||
leaseOutDetailsMapper.updateMaMachineStatus(record);
|
||||
machineMapper.updateMaMachineStatus(record);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
@ -314,7 +272,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
} else {
|
||||
String agreementId = leaseOutDetailsMapper.getAgreementId(taskId);
|
||||
String protocol = leaseOutDetailsMapper.getProtocol(agreementId);
|
||||
Type maType = leaseOutDetailsMapper.getMaType(record.getTypeId());
|
||||
Type maType = typeMapper.getMaType(record.getTypeId());
|
||||
if (StringUtils.isEmpty(protocol)) {
|
||||
maType.setFinalPrice(maType.getLeasePrice());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ package com.bonus.material.ma.mapper;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.material.lease.domain.LeaseOutDetails;
|
||||
import com.bonus.material.ma.domain.Machine;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.domain.vo.MachineVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 机具设备管理Mapper接口
|
||||
|
|
@ -68,4 +70,11 @@ public interface MachineMapper
|
|||
* @return
|
||||
*/
|
||||
List<Type> selectByTypeList(Type type);
|
||||
|
||||
String getMachineStatus(LeaseOutDetails record);
|
||||
|
||||
/**
|
||||
* 修改机具设备(ma_machine表)的状态为:在用
|
||||
*/
|
||||
int updateMaMachineStatus(@Param("record") LeaseOutDetails leaseOutDetails);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.material.ma.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.material.lease.domain.LeaseOutDetails;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.domain.vo.MaTypeConfigVo;
|
||||
import com.bonus.material.ma.domain.vo.MaTypeVo;
|
||||
|
|
@ -135,4 +137,17 @@ public interface TypeMapper {
|
|||
* @return
|
||||
*/
|
||||
List<Type> selectById(Long typeId);
|
||||
|
||||
/**
|
||||
* 减少 (ma_type 设备规格表)的库存数量
|
||||
*/
|
||||
int updateMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails);
|
||||
|
||||
Type selectByTypeId(@Param("record") LeaseOutDetails record);
|
||||
|
||||
Type getMaType(Long typeId);
|
||||
|
||||
int getCountOfCodeMachine(@Param("record") LeaseOutDetails record);
|
||||
|
||||
int getMachineByCt(LeaseOutDetails record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
lad.id, lad.parent_id, mt.type_id, mt.type_name, mt2.type_name as ma_type_name, mt.storage_num,
|
||||
mt.manage_type as manageType,
|
||||
(lad.pre_num - IF(lad.al_num IS NULL,'0',lad.al_num)) AS outNum,
|
||||
lad.pre_num, lad.audit_num, lad.al_num, lad.status, mt.unit_name,
|
||||
IFNULL(lad.pre_num,0) as preNum,
|
||||
IFNULL(lad.audit_num,0) as auditNum,
|
||||
IFNULL(lad.al_num,0) as alNum,
|
||||
lad.status, mt.unit_name,
|
||||
lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark, lad.company_id
|
||||
from
|
||||
lease_apply_details lad
|
||||
|
|
@ -155,4 +158,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from lease_apply_details
|
||||
where parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
<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="updateLeaseApplyDetailsByLeaseOutRecord">
|
||||
UPDATE
|
||||
lease_apply_details
|
||||
SET
|
||||
status = '2'
|
||||
WHERE
|
||||
parent_id = #{record.parentId} and type_id = #{record.typeId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
@ -119,12 +119,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</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.LeaseApplyDetails">
|
||||
SELECT id, parent_id as parentId, type_id as typeId, pre_num as preNum, al_num as alNum, `status`, remark
|
||||
FROM lease_apply_details
|
||||
|
|
@ -137,38 +131,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
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.storage_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 (1)
|
||||
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},
|
||||
|
|
@ -176,23 +138,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
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=",">
|
||||
|
|
@ -265,28 +210,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</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,
|
||||
|
|
@ -328,15 +251,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
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
|
||||
|
|
@ -348,38 +263,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
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>
|
||||
|
|
@ -287,4 +287,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{maId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getMachineStatus" resultType="java.lang.String">
|
||||
select ma_status
|
||||
from ma_machine
|
||||
where ma_id = #{maId}
|
||||
</select>
|
||||
|
||||
<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>
|
||||
</mapper>
|
||||
|
|
@ -643,4 +643,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
order by type_id
|
||||
</select>
|
||||
|
||||
<update id="updateMaTypeStockNum">
|
||||
UPDATE
|
||||
ma_type
|
||||
SET
|
||||
storage_num = storage_num - #{record.outNum} ,update_time = NOW()
|
||||
WHERE
|
||||
type_id = #{record.typeId}
|
||||
</update>
|
||||
|
||||
<select id="selectByTypeId" resultType="com.bonus.material.ma.domain.Type">
|
||||
select * from ma_type WHERE
|
||||
type_id = #{record.typeId}
|
||||
</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="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>
|
||||
|
||||
<select id="getMachineByCt" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
CASE mt.manage_type
|
||||
WHEN 0 THEN
|
||||
IFNULL(subquery0.num, 0)
|
||||
ELSE
|
||||
IFNULL(mt.storage_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 (1)
|
||||
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>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue