lxw
2023-02-09 348894f5921d9f78209c2320708a95cc8ca3d57b
产品锁定时有0120的需要也锁定
3个文件已修改
41 ■■■■■ 已修改文件
src/main/java/com/whyc/mapper/ProductMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductHistoryService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ProductMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/ProductMapper.java
@@ -1,6 +1,7 @@
package com.whyc.mapper;
import com.whyc.pojo.AttachLock;
import com.whyc.pojo.Material;
import com.whyc.pojo.Product;
import java.util.List;
@@ -14,4 +15,6 @@
    List<AttachLock> selectListMaterial(int productId);
    //根据产品id查询被锁定的产品丝印
    List<AttachLock> selectListProduct(int productId);
    //查询产品是否存在物料时钣金件的产品
    Material selectMaterial_0120(String parentCode, String customCode);
}
src/main/java/com/whyc/service/ProductHistoryService.java
@@ -8,6 +8,7 @@
import com.whyc.mapper.ProductBomMapper;
import com.whyc.mapper.ProductHistoryMapper;
import com.whyc.mapper.ProductMapper;
import com.whyc.pojo.Material;
import com.whyc.pojo.Product;
import com.whyc.pojo.ProductHistory;
import com.whyc.pojo.ProductLockLog;
@@ -135,6 +136,23 @@
            //设为不可用版本为-1
            uWrapper.set("version",-1);
            productMapper.update(null,uWrapper);
            //4.查询产品是否存在物料时钣金件的产品
            Material material_0120=productMapper.selectMaterial_0120(parentCode,customCode);
            //如果存在则锁定
            if(material_0120!=null){
                //先锁定历史
                UpdateWrapper wrapperHistory_0120=new UpdateWrapper();
                wrapperHistory_0120.eq("parent_code",parentCode);
                wrapperHistory_0120.set("enabled",0);
                mapper.update(null,wrapperHistory_0120);
                //再设置实时为-1
                UpdateWrapper wrapper_0120=new UpdateWrapper();
                wrapper_0120.eq("parent_code",parentCode);
                //设为不可用版本为-1
                wrapper_0120.set("version",-1);
                productMapper.update(null,wrapper_0120);
            }
            /*if(flag>0){
                //
                QueryWrapper qWrapper=new QueryWrapper();
src/main/resources/mapper/ProductMapper.xml
@@ -49,4 +49,24 @@
        and tb_product.id=#{productId}
        and tb_attach_lock.lock_flag=1
    </select>
    <select id="selectMaterial_0120" resultType="com.whyc.pojo.Material">
        select distinct tb_material.* from tb_product,tb_product_bom,tb_material
        <where>
            tb_product.id=tb_product_bom.product_id
            and tb_product_bom.material_id=tb_material.id
            and tb_material.sub_code like "%0120%"
            <if test="parentCode!=null">
                and parent_code like '%${parentCode}%'
            </if>
            <if test="customCode!=null">
                <if test="customCode==''">
                    and custom_code=#{customCode}
                </if>
                <if test="customCode!=''">
                    and custom_code  like '%${customCode}%'
                </if>
            </if>
       </where>
       limit 1
    </select>
</mapper>