cy
2023-11-06 d7f0b77a81c6c6f8895af082214edcbed29e3ab9
consum-base/src/main/java/com/consum/base/service/LGoodsUserRecordServiceImpl.java
@@ -2,15 +2,54 @@
import com.walker.jdbc.service.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
/**
 * @ClassName LGoodsUserRecordServiceImpl
 * @Date 2023/11/2
 * @Description
 * @Version 1.0
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class LGoodsUserRecordServiceImpl extends BaseServiceImpl {
    /**
     * 设置为非最新
     */
    private static String updSetNotLast = "update L_GOODS_USER_RECORD set LAST_RECORD = 0 where WH_GOODS_ID in(?) and LAST_RECORD=1";
    public int updSetNotLast(List<Long> outGoodsIds) {
        ArrayList<Object> params = new ArrayList<>();
        params.add(outGoodsIds);
        return this.update(updSetNotLast, params.toArray());
    }
    /**
     * 通过 调拨单ID 或者 分发记录表id 删除
     */
    private static String DEL_BY_TRANDS_AND_RECORDID = "delete from L_GOODS_USER_RECORD where 1=1";
    public int delByTrandsAndRecordId(Long transBusinessId, Long procureModelUserRecordId) {
        if (transBusinessId == null && procureModelUserRecordId == null) {
            return 0;
        }
        ArrayList<Object> params = new ArrayList<>();
        StringBuilder sql = new StringBuilder(DEL_BY_TRANDS_AND_RECORDID);
        if (transBusinessId != null) {
            sql.append(" and TRANS_BUSINESS_ID =?");
            params.add(transBusinessId);
        }
        if (procureModelUserRecordId != null) {
            sql.append(" and PROCURE_MODEL_USER_RECORD_ID =?");
            params.add(procureModelUserRecordId);
        }
        return update(sql.toString(), params.toArray());
    }
}