<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zr.mapper.PlanClassMapper">
<update id="updateStatusById" parameterType="com.zr.model.PlanClassVo">
<if test="status==0">
UPDATE planclass SET status = 1 WHERE id=#{id}
</if>
<if test="status==1">
UPDATE planclass SET status = 0 WHERE id=#{id}
</if>
</update>
<select id="queryCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(*) FROM planclass
<where>
<if test="code!=null and code!=''">
and code LIKE conat('%',#{code},'%')
</if>
<if test="name!=null and name!=''">
and name LIKE concat('%',#{name},'%')
</if>
<if test="status != 10">
and status=#{status}
</if>
</where>
</select>
<select id="queryAllUser" parameterType="java.util.Map" resultType="com.zr.model.PlanClassVo">
SELECT * FROM planclass
<where>
<if test="code!=null and code!=''">
and code LIKE conat('%',#{code},'%')
</if>
<if test="name!=null and name!=''">
and name LIKE concat('%',#{name},'%')
</if>
<if test="status != 10 ">
and status=#{status}
</if>
</where>
limit #{index},#{pageSize}
</select>
<!--
update user set name=#{name} where id=#{id};update user set name=#{name} where id=#{id};update user set name=#{name} where id=#{id}
-->
<!--
insert into user (id,name) values (1,2),(3,4),()-->
<!-- SELECT * from user where id IN (1,2,3,4)-->
<select id="queryUser" resultType="com.zr.test.pojo.User">
SELECT * from user
</select>
<select id="queryUserByIds" parameterType="java.util.List" resultType="com.zr.test.pojo.User">
SELECT * from user WHERE id IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!– select * from user where id in (1,2,3,)–>
<insert id="insertUserList" parameterType="java.util.List" >
INSERT into user (id,name) VALUES
<foreach collection="list" item="aa" open="(" separator="),(" close=")">
#{aa.id},#{aa.name}
</foreach>
</insert>
<!– INSERT into "user" (id,name) VALUES (1,小明),(2,小刚)–>
<delete id="delelteUserByIds" parameterType="java.util.List">
DELETE from user where id IN
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!– DELETE from "user" where id IN (1,2,3,)–>
<update id="updateUsers" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";">
UPDATE user SET name=#{item.name} where id = #{item.id}
</foreach>
</update>
<!– 根据多个用户名称和一个班级名称查询出相应的班级数据–>
<select id="queryClass" parameterType="com.zr.test.pojo.ClassVo" resultType="com.zr.test.pojo.ClassVo">
SELECT * FROM user_class uc LEFT JOIN user u ON uc.id= u.classId
WHERE uc.className=#{className}
and u.name in
<foreach collection="userList" item="item" open="(" separator="," close=")">
#{item.name}
</foreach>
</select>
<!-- UPDATE "user" SET name="小明" where id = 1;UPDATE "user" SET name="小刚" where id = 2-->
<select id="queryPlantByIdList" parameterType="java.util.List" resultType="com.zr.plant.pojo.PlantVo">
SELECT * from plant WHERE id IN
<foreach collection="list" item="item" open="(" separator="," close=")" >
#{item}
</foreach>
</select>
<select id="queryList" parameterType="com.zr.demo.pojo.DemoPlant" resultType="com.zr.plant.pojo.PlantVo">
SELECT * from plant WHERE 1=1
<if test="legalPlantCode!=null and legalPlantCode!=''">
AND p.legalPlantCode LIKE CONCAT('%',#{legalPlantCode},'%')
</if>
and id in
<foreach collection="ids" item="item" open="(" separator="," close=")" >
#{item}
</foreach>
and legalPersonCode in
<foreach collection="plantVoList" item="item" open="(" separator="," close=")" >
#{item.legalPersonCode}
</foreach>
</select>
<insert id="addList" parameterType="java.util.List">
INSERT into plant (legalPersonCode,legalPlantCode) VALUES
<foreach collection="list" item="item" open="(" separator="),(" close=")">
#{item.legalPersonCode}, #{item.legalPlantCode}
</foreach>
</insert>
<update id="updateList" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";">
update plant set legalPersonCode=#{item.legalPersonCode},legalPlantCode=#{item.legalPlantCode} where legalPlantCode =#{item.legalPlantCode}
</foreach>
</update>
<!--update plant set legalPersonCode=1111,legalPlantCode=222;update plant set legalPersonCode=333,legalPlantCode=444-->
<!-- INSERT into plant (legalPersonCode,legalPlantCode) VALUES (111,222),(333,4444)-->
<!-- SELECT * from plant id IN (1,2,3)-->
<select id="queryData" parameterType="com.zr.plant.pojo.PlantSelectVo"
resultType="com.zr.plant.pojo.PlantVo">
select p.*,l.legalPersonName from plant p LEFT JOIN legalPerson l on
p.legalPersonCode=l.legalPersonCode
where 1=1
<if test="legalPlantCode!=null and legalPlantCode!=''">
AND p.legalPlantCode LIKE CONCAT('%',#{legalPlantCode},'%')
</if>
<if test="legalPlantDec!=null and legalPlantDec!=''">
AND p.legalPlantDec LIKE CONCAT('%',#{legalPlantDec},'%')
</if>
<if test="legalPersonCode!=null and legalPersonCode!=''">
and p.legalPersonCode =#{legalPersonCode}
</if>
<if test="enabled!=null">
and p.enabled =#{enabled}
</if>
limit #{offset} , #{pageSize}
</select>
<select id="queryCount" parameterType="com.zr.plant.pojo.PlantSelectVo"
resultType="java.lang.Integer">
select count(p.id)
from plant p LEFT JOIN legalPerson l on
p.legalPersonCode=l.legalPersonCode
where 1=1
<if test="legalPlantCode!=null and legalPlantCode!=''">
AND p.legalPlantCode LIKE CONCAT('%',#{legalPlantCode},'%')
</if>
<if test="legalPlantDec!=null and legalPlantDec!=''">
AND p.legalPlantDec LIKE CONCAT('%',#{legalPlantDec},'%')
</if>
<if test="legalPersonCode!=null and legalPersonCode!=''">
and p.legalPersonCode =#{legalPersonCode}
</if>
<if test="enabled!=null">
and p.enabled =#{enabled}
</if>
</select>
<select id="queryUser" resultType="com.zr.User" >
SELECT id FROM user_info
</select>
<select id="queryPage" parameterType="com.zr.plant.pojo.PlantSelectVo"
resultType="com.zr.plant.pojo.PlantClass">
select le.id,le.remark legalPlantDec,le.code legalPlantCode,le.`status` enabled,le.legalPersonCode,ln.`name` legalPersonName
from legalpersonplant le left join legalperson ln on le.legalPersonCode = ln.code
where 1=1
<if test="legalPlantDec!=null and legalPlantDec!=''">
and le.remark =#{legalPlantDec}
</if>
<if test="legalPlantCode!=null and legalPlantCode!=''">
and le.code =#{legalPlantCode}
</if>
<if test="enabled!=null">
and le.status =#{enabled}
</if>
<if test="legalPersonCode!=null and legalPlantCode!=''">
and le.legalPersonCode =#{legalPersonCode}
</if>
limit #{offset} , #{pageSize}
</select>
<select id="queryCount" parameterType="com.zr.plant.pojo.PlantSelectVo"
resultType="java.lang.Integer">
select count(le.id)
FROM legalpersonplant le
where 1=1
<if test="legalPlantDec!=null and legalPlantDec!=''">
and le.remark =#{legalPlantDec}
</if>
<if test="legalPlantCode!=null and legalPlantCode!=''">
and le.code =#{legalPlantCode}
</if>
<if test="enabled!=null">
and le.status =#{enabled}
</if>
<if test="legalPersonCode!=null and legalPlantCode!=''">
and le.legalPersonCode =#{legalPersonCode}
</if>
</select>
<select id="queryUserAll" resultType="com.zr.demo.pojo.User">
SELECT * FROM USER
</select>
<select id="queryUserByIds" parameterType="java.util.List" resultType="com.zr.demo.pojo.User">
SELECT * from user WHERE id IN
<foreach collection="idList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<!--<!– 完成用户的批量新增 批量删除–>-->
<insert id="addPlanClassList" parameterType="java.util.List">
insert into planclass (nlegalPlantCodeclegalPlantDecmark,status) VALUES
<foreach collection="list" item="aaa" open="(" separator="),(" close=")">
#{aaa.name},#{legalPlantCodecode},#{legalPlantDecmark},#{aaa.status}
</foreach>
</insert>
<!--insert into user (id,name) values ()()()
update user set name=#{name},age=#{age};update user set name=#{name},age=#{age};-->
<!-- 批量修改-->
<update id="updateUserList" parameterType="com.zr.demo.pojo.User">
<foreach collection="userList" item="item" separator=";">
UPDATE user SET name=#{item.name},age=#{item.age},sex=#{item.sex} WHERE id =#{item.id}
</foreach>
</update>
<insert id="addPlanClassList" parameterType="java.util.List">
insert into planclass (nlegalPlantCodeclegalPlantDecmark,status) VALUES
<foreach collection="list" item="aaa" open="(" separator="),(" close=")">
#{aaa.name},#{legalPlantCodecode},#{legalPlantDecmark},#{aaa.status}
</foreach>
</insert>
<update id="updatePlanClassList" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";" >
UPDATE planclass SET name = #{item.nalegalPlantCodecode= #{ilegalPlantCodecode},status=#{item.status}
WHERE id = #{item.id}
</foreach>
</update>
<delete id="deletePlanClassByIdList" parameterType="java.util.List">
DELETE from planclass WHERE id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
<!-- <!– 分页查询计划大类数据–>-->
<select id="queryPage" parameterType="com.zr.plant.model.PlantSelectVo"
resultType="com.zr.plant.model.Plant">
select t.id,t.legalPlantCode,t.legalPlantDec,t.enabled,t.legalPersonCode,l.legalPersonName,t.createTime,t.createId,t.version
FROM plant t LEFT JOIN legalperson l ON t.legalPersonCode = l.legalPersonCode
where 1=1
<if test="legalPersonCode!=null and legalPersonCode!=''">
and t.legalPersonCode =#{legalPersonCode}
</if>
<if test="legalPlantCode!=null and legalPlantCode!=''">
and t.legalPlantCode =#{legalPlantCode}
</if>
<if test="legalPlantDec!=null and legalPlantDec!=''">
and t.legalPlantDec =#{legalPlantDec}
</if>
<if test="enabled!=null">
and t.enabled =#{enabled}
</if>
limit #{offset} , #{pageSize}
</select>
<!-- <!–分页查询总条数–>-->
<select id="queryCount" parameterType="com.zr.plant.model.PlantSelectVo"
resultType="java.lang.Integer">
select count(*)
FROM plant t where 1=1
<if test="legalPersonCode!=null and legalPersonCode!=''">
and t.legalPersonCode =#{legalPersonCode}
</if>
<if test="legalPlantCode!=null and legalPlantCode!=''">
and t.legalPlantCode =#{legalPlantCode}
</if>
<if test="legalPlantDec!=null and legalPlantDec!=''">
and t.legalPlantDec =#{legalPlantDec}
</if>
<if test="enabled!=null">
and t.enabled =#{enabled}
</if>
</select>
<select id="findPlanClassByNameList" parameterType="java.util.List" resultType="com.zr.planclass.moPlantClasslass">
SELECT * FROM planclass WHERE name IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<insert id="addPlanClassList" parameterType="java.util.List">
insert into planclass (nlegalPlantCodeclegalPlantDecmark,status) VALUES
<foreach collection="list" item="aaa" open="(" separator="),(" close=")">
#{aaa.name},#{legalPlantCodecode},#{legalPlantDecmark},#{aaa.status}
</foreach>
</insert>
<update id="updatePlanClassList" parameterType="java.util.List">
<foreach collection="list" item="item" separator=";" >
UPDATE planclass SET name = #{item.nalegalPlantCodecode= #{ilegalPlantCodecode},status=#{item.status}
WHERE id = #{item.id}
</foreach>
</update>
<delete id="deletePlanClassByIdList" parameterType="java.util.List">
DELETE from planclass WHERE id IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</delete>
<select id="queryPartnerData" parameterType="com.zr.inquiry.pojo.SupplierSelectVo"
resultType="com.zr.inquiry.pojo.SupplierVo">
select t.partnerName,t.partnerCode
FROM supplier t where 1=1
<if test="partnerCode!=null and partnerCode!=''">
and t.partnerCode =#{partnerCode}
</if>
<if test="partnerName!=null and partnerName!=''">
and t.partnerName =#{partnerName}
</if>
limit #{offset} , #{pageSize}
</select>
<!-- <!–询价单分页查询总条数–>-->
<select id="queryInquiryCount" parameterType="com.zr.inquiry.pojo.MaterialSelectVo"
resultType="java.lang.Integer">
select count(*)
FROM inquirytotal t
<if test="vendor!=null and vendor!=''">
LEFT JOIN inquirysupplierdetail su ON t.id = su.inquiryId
</if>
where 1=1
<if test="vendor!=null and vendor!=''">
and su.vendorCode =#{vendor}
</if>
<if test="requestForQuotationId!=null and requestForQuotationId!=''">
and t.requestForQuotationId =#{requestForQuotationId}
</if>
<if test="createStartTime!=null">
<![CDATA[ and t.createTime >=#{createStartTime} ]]>
</if>
<if test="createEndTime!=null">
<![CDATA[ and t.createTime <=#{createEndTime} ]]>
</if>
<if test="startTime!=null">
<![CDATA[ and t.startTime >=#{startTime} ]]>
</if>
<if test="endTime!=null">
<![CDATA[ and t.endTime <=#{endTime} ]]>
</if>
<if test="type!=null">
and t.type =#{type}
</if>
<if test="currencyCode!=null">
and t.currencyCode =#{currencyCode}
</if>
<if test="isTax!=null">
and t.isTax =#{isTax}
</if>
<if test="inquiryStatus!=null">
and t.inquiryStatus =#{inquiryStatus}
</if>
<if test="telegalPersonCodeonId != null">
anlegalPersonCodeonIdlegalPersonCodeonId}
</if>
</select>
<!-- <!–询价单分页查询数据–>-->
<select id="queryInquiryData" parameterType="com.zr.inquiry.pojo.InquiryTotalSelectVo"
resultType="com.zr.inquiry.pojo.InquiryTotalVo">
select DISTINCT t.id,t.requestForQuotationId,t.createTime,t.startTime,t.endTime,t.creatorName,t.type,t.currencyCode,t.isTax,t.inquiryStatus,le.legalPersonName
FROM inquirytotal t
LEFT JOIN inquirysupplierdetail su ON t.id = su.inquiryId
LEFT JOIN legalPerson le ONlegalPersonCodeonId = le.id
where 1=1
<if test="requestForQuotationId!=null and requestForQuotationId!=''">
and t.requestForQuotationId =#{requestForQuotationId}
</if>
<if test="createStartTime!=null">
<![CDATA[ and t.createTime >=#{createStartTime} ]]>
</if>
<if test="createEndTime!=null">
<![CDATA[ and t.createTime <=#{createEndTime} ]]>
</if>
<if test="startTime!=null">
<![CDATA[ and t.startTime >=#{startTime} ]]>
</if>
<if test="endTime!=null">
<![CDATA[ and t.endTime <=#{endTime} ]]>
</if>
<if test="type!=null">
and t.type =#{type}
</if>
<if test="currencyCode!=null">
and t.currencyCode =#{currencyCode}
</if>
<if test="isTax!=null">
and t.isTax =#{isTax}
</if>
<if test="inquiryStatus!=null">
and t.inquiryStatus =#{inquiryStatus}
</if>
<if test="telegalPersonCodeonId!=null">
anlegalPersonCodeonIdlegalPersonCodeonId}
</if>
<if test="vendor!=null and vendor!=''">
and su.vendorCode =#{vendor}
</if>
limit #{offset} , #{pageSize}
</select>
<!-- <!–分页查询总条数–>-->
<select id="queryPartnerCount" parameterType="com.zr.inquiry.pojo.SupplierSelectVo"
resultType="java.lang.Integer">
select count(*)
FROM supplier t where 1=1
<if test="partnerCode!=null and partnerCode!=''">
and t.partnerCode =#{partnerCode}
</if>
<if test="partnerName!=null and partnerName!=''">
and t.partnerName =#{partnerName}
</if>
</select>
<select id="querySpareByCodeList" parameterType="java.util.List" resultType="com.zr.inquiry.pojo.InquirySpareVo">
SELElegalPlantCodecode spareCoding,name spareName from spare whlegalPlantCodecode IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="querySupplierBySpareCodeList" parameterType="java.util.List" resultType="com.zr.inquiry.pojo.SpareSupplierVo">
SELECT * FROM supplier_spare where spareCode IN
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<insert id="insertTotal" parameterType="com.zr.inquiry.pojo.InquiryTotal" useGeneratedKeys="true" keyColumn="id" keyProperty="id" >
INSERT into inquirytotal (requestForQuotationId,createTime,startTime,endTime,creatorName,type,currencyCode,isTax,inquiryStalegalPersonCodeonId)
VALUES (#{requestForQuotationId},#{createTime},#{startTime},#{endTime},#{creatorName},#{type},#{currencyCode},#{isTax},#{inquiryStatuslegalPersonCodeonId})
</insert>
<insert id="insertSpareDetail">
INSERT INTO inquirysparedetail(
spareCoding,
spareName,
materialUnit,
inquiryQty,
currencyCode,
moq,
deliveryCycle,
inquiryId)
VALUES
<foreach collection="list" item="item" index="index" open="" close="" separator=",">
(
#{item.spareCoding},
#{item.spareName},
#{item.materialUnit},
#{item.inquiryQty},
#{item.currencyCode},
#{item.moq},
#{item.deliveryCycle},
#{item.inquiryId})
</foreach>
</insert>
<insert id="insertSupplierDetail">
INSERT INTO inquirysupplierdetail(
vendor,
vendorCode,
inquiryId)
VALUES
<foreach collection="list" item="item" index="index" open="" close="" separator=",">
(
#{item.vendor},
#{item.vendorCode},
#{item.inquiryId})
</foreach>
</insert>
</mapper>
mapper
package com.zr.planClass.mapper;
import com.zr.planClass.model.PlanClassSelectVo;
import com.zr.planClass.model.PlanClassVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface PlanClassMapper {
@Select("select count(id) from planclass where name = #{name}")
int queryByName( String name);
@Select("select * from planclass where name = #{name}")
List<PlanClassVo> queryByName2( String name);
@Select("select count(id) from planclass where code = #{code}")
int queryByCode( String code);
@Insert("insert into planclass (name,code,remark,status) values (#{name},#{code},#{remark},#{status})")
void addPlanClass(PlanClassVo planClassVo);
@Select("select * from planclass where id=#{id}")
PlanClassVo queryById(Integer id);
@Update("update planclass set name=#{name},status=#{status},updateName=#{updateName},version=#{version}+1 where id=#{id} and version=#{version}")
int updatePlanClass(PlanClassVo planClassVo);
@Update("update planclass set status=#{status},updateName=#{updateName} where id=#{id}")
void updatePlanClassStatus(PlanClassVo planClassVo);
List<PlanClassVo> queryPageData(PlanClassSelectVo planClassSelectVo);
int queryPageCount(PlanClassSelectVo planClassSelectVo);
List<PlanClassVo> queryExport(PlanClassSelectVo planClassSelectVo);
}
serviceImp
package com.zr.inquiry.service.impl;
import com.zr.enumvo.CurrencyCodeEnum;
import com.zr.enumvo.IsTaxEnum;
import com.zr.enumvo.TypeEnum;
import com.zr.inquiry.mapper.InquiryMapper;
import com.zr.inquiry.model.*;
import com.zr.inquiry.service.InquiryService;
import com.zr.util.ResultBuilderVo;
import com.zr.util.ResultVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class InquiryServiceImpl implements InquiryService {
@Autowired
private InquiryMapper inquiryMapper;
@Override
public ResultVo addInquiry(InquirytotalAddVo inquirytotalAddVo) {
//业务验证
ResultVo check = check(inquirytotalAddVo);
if (!check.getSuccess()){
return check;
}
Inquirytotal inquirytotal = new Inquirytotal();
BeanUtils.copyProperties(inquirytotalAddVo,inquirytotal);
//1.入库主表
inquiryMapper.insertyInquiryTotal(inquirytotal);
//2.入库备件明细表
// for ()
//3.入库供应商明细表
return null;
}
public ResultVo check(InquirytotalAddVo inquirytotalAddVo){
// 10.验证询价类型、询价币别、是否含税、询价开始日期是否在结束日期之前
ResultVo resultVo = checkEnum(inquirytotalAddVo);
if (!resultVo.getSuccess()){
return resultVo;
}
// 5.验证备件明细不能重复
// 6.验证供应商明细不能重复
ResultVo resultVo1 = checkRepeat(inquirytotalAddVo);
if (!resultVo1.getSuccess()){
return resultVo1;
}
// 7.验证备件是否都存在
// 8.验证供应商是否都存在
// 9.验证法人是否存在
ResultVo resultVo2 = checkCunzai(inquirytotalAddVo);
if (!resultVo2.getSuccess()){
return resultVo2;
}
// 1.验证每个备件必须要有可以生产他的供应商
// 1.根据多个备件查询备件供应商中间表,查询这些备件都被那些供应商生产
// 2.验证每个供应商一定有一个它可以生产的备件
ResultVo resultVo3 = checkHeFa(inquirytotalAddVo);
if (!resultVo3.getSuccess()){
return resultVo3;
}
//
return ResultBuilderVo.success();
}
public ResultVo checkHeFa(InquirytotalAddVo inquirytotalAddVo){
List<String> codeList = new ArrayList<>();
for (Inquirysparedetail inquirysparedetail: inquirytotalAddVo.getInquirysparedetailList()){
codeList.add(inquirysparedetail.getSpareCoding());
}
List<String> SuppliserCodeList = new ArrayList<>();
for (Inquirysupplierdetail inquirysupplierdetail: inquirytotalAddVo.getInquirysupplierdetailList()){
SuppliserCodeList.add(inquirysupplierdetail.getVendorCode());
}
//全部的中间表信息
List<SpareSupplierVo> spareSupplierVoList = inquiryMapper.querySpareSupplierBySpareCodeList(codeList);
//把每个备件能被生产的供应商找出来放到集合中。
for (String code:codeList){
//每个备件的供应商集合
List<String> SuppliserCodeList2 = new ArrayList<>();
for (SpareSupplierVo spareSupplierVo:spareSupplierVoList){
if (code.equals(spareSupplierVo.getSpareCoding())){
SuppliserCodeList2.add(spareSupplierVo.getVendorCode());
}
}
//disjoint判断是否存在交集,true代表没有交集,false代表存在交集。
if (Collections.disjoint(SuppliserCodeList2,SuppliserCodeList)){
return ResultBuilderVo.error("备件编码:"+code+"没有合法的供应商,它的合法供应商为:"+SuppliserCodeList2);
}
}
return ResultBuilderVo.success();
}
public ResultVo checkCunzai(InquirytotalAddVo inquirytotalAddVo){
List<String> codeList = new ArrayList<>();
for (Inquirysparedetail inquirysparedetail: inquirytotalAddVo.getInquirysparedetailList()){
codeList.add(inquirysparedetail.getSpareCoding());
}
List<String> inquirysparedetailList = inquiryMapper.queryByCodeList(codeList);
if (inquirysparedetailList.size()!=codeList.size()){
codeList.removeAll(inquirysparedetailList);
return ResultBuilderVo.error("存在不合法的备件,不合法的备件为:"+codeList);
}
return ResultBuilderVo.success();
}
public ResultVo checkRepeat(InquirytotalAddVo inquirytotalAddVo){
List<String> spareNameList = new ArrayList<>();
List<Inquirysparedetail> inquirysparedetailList = inquirytotalAddVo.getInquirysparedetailList();
for (Inquirysparedetail inquirysparedetail:inquirysparedetailList){
spareNameList.add(inquirysparedetail.getSpareCoding());
}
/* Set<String> setSpareName = new HashSet<>(spareNameList);
if (spareNameList.size()!=setSpareName.size()){
return ResultBuilderVo.error("存在重复的备件编码");
}*/
List<String> newSpareNameList = new ArrayList<>();
List<String> repeatSpareNameList = new ArrayList<>();
for (String code:spareNameList){
if (newSpareNameList.contains(code)){
repeatSpareNameList.add(code);
}
newSpareNameList.add(code);
}
if (repeatSpareNameList.size()>0){
return ResultBuilderVo.error("存在重复的备件编码,重复的备件编码为:"+repeatSpareNameList);
}
return ResultBuilderVo.success();
}
public ResultVo checkEnum(InquirytotalAddVo inquirytotalAddVo){
if (TypeEnum.getName(inquirytotalAddVo.getType())==null){
return ResultBuilderVo.error("询价类型不存在!");
}
if (CurrencyCodeEnum.getName(inquirytotalAddVo.getCurrencyCode())==null){
return ResultBuilderVo.error("询价币别不存在!");
}
if (IsTaxEnum.getName(inquirytotalAddVo.getIsTax())==null){
return ResultBuilderVo.error("是否含税不存在!");
}
int res= inquirytotalAddVo.getStartTime().compareTo(inquirytotalAddVo.getEndTime());
if(res>0){
return ResultBuilderVo.error("询价开始日期必须在询价结束日期之前");
}
return ResultBuilderVo.success();
}
}