数据接口开发

This commit is contained in:
haozq 2024-11-13 10:22:42 +08:00
parent 8c5c2da5ff
commit 0b419f8c5f
8 changed files with 22 additions and 18 deletions

View File

@ -107,7 +107,7 @@ public class PartApplyAppServiceImp {
if(num<1){
return ServerResponse.createErroe("配件申请失败");
}
int num2= mapper.insertDetails(list,dto);
int num2= mapper.insertDetails(list,dto);
if(num2==list.size()){
return ServerResponse.createSuccess("申请成功","申请成功");
}

View File

@ -60,4 +60,6 @@ public class PartInputDetails {
*/
private String partUnit;
private String remark;
}

View File

@ -2,7 +2,7 @@ package com.bonus.gzgqj.business.bases.mapper;
import com.bonus.gzgqj.business.bases.entity.PaTypeVo;
import com.bonus.gzgqj.business.bases.entity.VendVo;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;

View File

@ -3,7 +3,7 @@ package com.bonus.gzgqj.business.bases.mapper;
import com.bonus.gzgqj.business.app.entity.PartApplyAppVo;
import com.bonus.gzgqj.business.app.entity.PartApplyDetailAppVo;
import com.bonus.gzgqj.business.bases.entity.AuditRecord;
import org.omg.CORBA.INTERNAL;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;

View File

@ -2,10 +2,9 @@ package com.bonus.gzgqj.business.bases.mapper;
import com.bonus.gzgqj.business.bases.entity.PartInputDetails;
import com.bonus.gzgqj.business.bases.entity.PartInputVo;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
@ -34,7 +33,7 @@ public interface PartInputMapper {
* @param vo
* @param list
*/
int addDetails(@Param("param") PartInputVo vo,@Param("list") List<PartInputDetails> list);
int addDetails(@Param("param")PartInputVo vo,@Param("list") List<PartInputDetails> list);
/**
* 查询类型数量

View File

@ -92,7 +92,7 @@ public class PartInputServiceImpl implements PartInputService{
vo.setUpdater(userId.toString());
AtomicReference<String> isFlag= new AtomicReference<>("1");
final int[] inputNum = {0};
BigDecimal allPrice = new BigDecimal("0");
final BigDecimal[] allPrice = {new BigDecimal("0")};
list.forEach(detail->{
inputNum[0] = inputNum[0] +detail.getInputNum();
//单价
@ -104,11 +104,12 @@ public class PartInputServiceImpl implements PartInputService{
BigDecimal num = new BigDecimal(detail.getInputNum());
//总价
BigDecimal totalPrice = price.multiply(num);
System.err.println(totalPrice);
detail.setTotalPrice(totalPrice.toString());
allPrice.add(totalPrice);
allPrice[0] = allPrice[0].add(totalPrice);
});
vo.setAllPrice(allPrice.toString());
vo.setAllPrice(allPrice[0].toString());
vo.setInputNum(inputNum[0]);
vo.setIsFlag(isFlag.get());
int num=mapper.addInputData(vo);
@ -123,8 +124,9 @@ public class PartInputServiceImpl implements PartInputService{
//更新 库存数量-及平准单价
int typeNum=mapper.getPaTypeById(detail);
int nowNum= detail.getInputNum()+typeNum;
String pzPrice=mapper.getPzPrice(detail);
mapper.updateTypeNum(detail.getPartId(),nowNum,pzPrice);
// String pzPrice=mapper.getPzPrice(detail);
//最后入库就是最终价格
mapper.updateTypeNum(detail.getPartId(),nowNum,detail.getPartPrice());
});
return ServerResponse.createSuccess("入库成功");
}
@ -181,8 +183,9 @@ public class PartInputServiceImpl implements PartInputService{
}else{
list.forEach(detail->{
//更新 -及平准单价
String pzPrice=mapper.getPzPrice(detail);
mapper.updateTypeNum2(detail.getPartId(),pzPrice);
// String pzPrice=mapper.getPzPrice(detail);
mapper.updateTypeNum2(detail.getPartId(),detail.getPartPrice());
});
}
}

View File

@ -3,7 +3,7 @@
<mapper namespace="com.bonus.gzgqj.business.bases.mapper.PaTypeMapper" >
<!--新增类型-->
<insert id="addTypeData" useGeneratedKeys="true" keyProperty="id">
insert into pa_type(parent_id, name,remarks,unit,is_active,level)VALUES(#{parentId},#{name},#{remarks},#{unit},1,#{level})
insert into pa_type(parent_id, name,remarks,unit,is_active,level,price)VALUES(#{parentId},#{name},#{remarks},#{unit},1,#{level},0)
</insert>
<update id="updateTypeData">
update pa_type set name=#{name},remarks=#{remarks},unit=#{unit} where id=#{id}

View File

@ -11,11 +11,11 @@
<insert id="addDetails">
insert into t_part_put_details(
put_id,part_id,part_type,part_name,part_model,part_unit,input_num,part_price,
total_price,vender_id,vender_name) values
total_price,vender_id,vender_name,remark) values
<foreach collection="list" item="item" separator=",">
(#{param.id},#{item.partId},#{item.partType},#{item.partName},
#{item.partModel},#{item.partUnit},#{item.inputNum},#{item.partPrice},
#{item.totalPrice},#{item.vendId},#{item.vendName})
#{item.totalPrice},#{item.vendId},#{item.vendName},#{item.remark})
</foreach>
</insert>
@ -93,7 +93,7 @@
</select>
<select id="getPzPrice" resultType="java.lang.String">
select ROUND(IFNULL(AVG(part_price),0),2) price
from t_part_put_details
from t_part_put_details ppd
where ppd.part_id=#{partId}
</select>
</mapper>